Commit 8fcc526b authored by Peter Chronz's avatar Peter Chronz
Browse files

Use argpase for the discovery master

parent f97d73ae
......@@ -9,12 +9,12 @@ sudo python -m unittest discover functional_tests
# Starting a slave agent
```
./startslave.py localhost actuator/tests/resources/slave-settings.yaml myself -v actuator -p 5672
./startslave.py localhost actuator/tests/resources/slave-settings.yaml myself -v actuator -p 5672 -u actuator -p 4ctu4t3!
```
# Starting the discovery master for testing
```
./start-discovery-master.py localhost 5672 actuator actuator 4ctu4te!
./start-discovery-master.py localhost --port 5672 -v actuator -u actuator -p 4ctu4t3!
```
# TODO
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import time
import sys
import argparse
from actuator.master import controller
from actuator.core.connection import ConnectionParameters
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('host', help='RabbitMQ host')
parser.add_argument('--port', help='RebbitMQ port', default=5672, type=int)
parser.add_argument(
'-v', '--vhost', help='RabbitMQ vhost to use', default='/')
parser.add_argument('-u', '--username', help='RabbitMQ user', default=None)
parser.add_argument(
'-p', '--password', help='RabbitMQ password', default=None)
args = parser.parse_args()
return args
if __name__ == '__main__':
host = sys.argv[1]
port = sys.argv[2]
port = int(float(port))
vhost = sys.argv[3]
username = sys.argv[4]
password = sys.argv[5]
connection_params = ConnectionParameters(username, password, host, port, vhost)
args = parse_args()
host = args.host
port = args.port
vhost = args.vhost
username = args.username
password = args.password
connection_params = ConnectionParameters(username, password, host, port,
vhost)
with controller.Controller(connection_params) as master:
print 'Discovery master online; printing discovered slaves...'
while True:
......
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
import logging
import argparse
......@@ -11,7 +10,7 @@ from actuator.core import settings
logger = logging.getLogger(__name__)
def make_parser():
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument('host', help='RabbitMQ hostname.')
parser.add_argument('--port', help='RabbitMQ port.', type=int, default=5672)
......@@ -25,7 +24,7 @@ def make_parser():
if __name__ == '__main__':
args = make_parser()
args = parse_args()
host = args.host
port = args.port
settings_path = args.settings_path
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment