Skip to content
This repository was archived by the owner on Jan 23, 2026. It is now read-only.

Commit d960297

Browse files
author
Michael Smith
committed
added ability to run REST API on different port and/or IP address
1 parent aa2c3f1 commit d960297

2 files changed

Lines changed: 19 additions & 7 deletions

File tree

applications/multisite/intersite.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ def complete_debug(self, text, line, begidx, endidx):
11861186
]
11871187
return completions
11881188

1189-
def parse_args():
1189+
def get_arg_parser():
11901190
parser = argparse.ArgumentParser(description='ACI Multisite Tool')
11911191
parser.add_argument('--config', default=None, help='Configuration file')
11921192
parser.add_argument('--maxlogfiles', type=int, default=10, help='Maximum number of log files (default is 10)')
@@ -1196,8 +1196,7 @@ def parse_args():
11961196
choices=['verbose', 'warnings', 'critical'],
11971197
const='critical',
11981198
help='Enable debug messages.')
1199-
args = parser.parse_args()
1200-
return args
1199+
return parser
12011200

12021201

12031202
def main():
@@ -1206,7 +1205,7 @@ def main():
12061205
12071206
:return: None
12081207
"""
1209-
execute_tool(parse_args())
1208+
execute_tool(get_arg_parser().parse_args())
12101209

12111210

12121211
def execute_tool(args, test_mode=False):

applications/multisite/intersite_rest_server.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,23 @@
11
from flask import Flask, request, abort, make_response, jsonify
2-
from intersite import execute_tool, parse_args
2+
from intersite import execute_tool, get_arg_parser
33
import json
44
from flask.ext.httpauth import HTTPBasicAuth
5+
6+
DEFAULT_PORT = '5000'
7+
DEFAULT_IPADDRESS = '127.0.0.1'
8+
59
auth = HTTPBasicAuth()
610

7-
collector = execute_tool(parse_args(), test_mode=True)
11+
parser = get_arg_parser()
12+
parser.add_argument('--ip',
13+
default=DEFAULT_IPADDRESS,
14+
help='IP address to listen on.')
15+
parser.add_argument('--port',
16+
default=DEFAULT_PORT,
17+
help='Port number to listen on.')
18+
19+
args = parser.parse_args()
20+
collector = execute_tool(args, test_mode=True)
821
app = Flask(__name__)
922

1023

@@ -38,4 +51,4 @@ def set_config():
3851
return json.dumps({'Status': 'OK'}, indent=4, separators=(',', ':'))
3952

4053
if __name__ == '__main__':
41-
app.run(debug=True)
54+
app.run(debug=True, host=args.ip, port=int(args.port))

0 commit comments

Comments
 (0)