bin/handlers/init_topos
#!/usr/bin/env python
"""Initialize the Mininet topologies
Command line handler to build the distributed topologies
"""
import json
import util.multinet_requests as m_util
import argparse
import logging
logging.getLogger().setLevel(logging.DEBUG)
def master_init_main():
"""Main
Send a POST request to the master 'init' endpoint,
validate the response code and print the responses
Usage:
bin/handlers/init_topos --json-config <path-to-json-conf>
Example:
bin/handlers/init_topos --json-config config/runtime_config.json
Command Line Arguments:
json-config (str): Path to the JSON configuration file to be used
"""
args = m_util.parse_arguments()
conf = m_util.parse_json_conf(args.json_config)
data = {'topo':conf['topo'], 'is_serial':args.is_serial}
res = m_util.master_cmd(conf['master_ip'],
conf['master_port'],
'init',
data)
m_util.handle_post_request(res, exit_on_fail=True)
if __name__ == '__main__':
master_init_main()