def init(): """ Broadcast the POST request to the 'init' endpoint of the workers Aggregate the responses Args: controller_ip_address (str): The IP address of the controller controller_of_port (int): The OpenFlow port of the controller switch_type (str): The type of soft switch to use for the emulation topo_type (str): The type of the topology we want to build topo_size (int): The size of the topology we want to build group_size (int): The number of switches in a gorup for gradual bootup group_delay (int): The delay between the bootup of each group hosts_per_switch (int): The number of hosts connected to each switch Returns: requests.models.Response: An HTTP Response with the aggregated status codes and bodies of the broadcasted requests """ logging.info('[ip list] {0}'.format(WORKER_IP_LIST)) topo_conf = bottle.request.json logging.info(topo_conf) reqs = m_util.broadcast_cmd(WORKER_IP_LIST, WORKER_PORT_LIST, 'init', topo_conf) stat, bod = m_util.aggregate_broadcast_response(reqs) return bottle.HTTPResponse(status=stat, body=bod)
def start(): """ Broadcast the POST request to the 'start' endpoint of the workers Aggregate the responses Returns: requests.models.Response: An HTTP Response with the aggregated status codes and bodies of the broadcasted requests """ reqs = m_util.broadcast_cmd(WORKER_IP_LIST, WORKER_PORT_LIST, 'start') stat, bod = m_util.aggregate_broadcast_response(reqs) return bottle.HTTPResponse(status=stat, body=bod)
def generate_traffic(): """ Broadcast the POST request to the 'generate_traffic' endpoint of the workers Aggregate the responses Returns: requests.models.Response: An HTTP Response with the aggregated status codes and bodies of the broadcasted requests """ data = bottle.request.json reqs = m_util.broadcast_cmd(WORKER_IP_LIST, WORKER_PORT_LIST, 'generate_traffic', data) stat, bod = m_util.aggregate_broadcast_response(reqs) return bottle.HTTPResponse(status=stat, body=bod)
def get_flows(): """ Broadcast the POST request to the 'get_flows' endpoint of the workers Aggregate the responses Returns: requests.models.Response: An HTTP Response with the aggregated status codes and bodies of the broadcasted requests """ t_start = time.time() reqs = m_util.broadcast_cmd(WORKER_IP_LIST, WORKER_PORT_LIST, 'get_flows') stat, bod = m_util.aggregate_broadcast_response(reqs) get_flow_latency = time.time() - t_start logging.info( '[get_flows] Flow latency interval on master: {0} [sec]'.format( get_flow_latency)) return bottle.HTTPResponse(status=stat, body=bod)
def get_flows(): """ Broadcast the POST request to the 'get_flows' endpoint of the workers Aggregate the responses Returns: requests.models.Response: An HTTP Response with the aggregated status codes and bodies of the broadcasted requests """ t_start = time.time() reqs = m_util.broadcast_cmd(WORKER_IP_LIST, WORKER_PORT_LIST, 'get_flows') stat, bod = m_util.aggregate_broadcast_response(reqs) get_flow_latency = time.time() - t_start logging.info('[get_flows] Flow latency interval on master: {0} [sec]'. format(get_flow_latency)) return bottle.HTTPResponse(status=stat, body=bod)