intracom-telecom-sdn/multinet

View on GitHub
bin/handlers/get_flows

Summary

Maintainability
Test Coverage
#!/usr/bin/env python
"""Get the number of flows for each worker of multinet
Command line handler to get the number of flows from each worker of the multinet
topology
"""

import util.multinet_requests as m_util


def get_flows_main():
    """Main
    Send a POST request to the master 'get_flows' endpoint,
    validate the response code and print the responses

    Usage:
      bin/handler/get_flows --json-config <path-to-json-conf>

    Example:
      bin/handler/get_flows --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 = {'is_serial':args.is_serial}
    res = m_util.master_cmd(conf['master_ip'],
                            conf['master_port'],
                            'get_flows', data)

    m_util.handle_post_request(res, exit_on_fail=False)

if __name__ == '__main__':
    get_flows_main()