<commit_before>#!/usr/bin/env python

# Copyright (c) 2015 Intracom S.A. Telecom Solutions. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v1.0 which accompanies this distribution,
# and is available at http://www.eclipse.org/legal/epl-v10.html

"""
With this module we create the master REST server
to manage the distributed topologies
"""

import bottle
import logging
import util.multinet_requests as m_util
import time

# We must define logging level separately because this module runs
# independently.
logging.basicConfig(level=logging.DEBUG)

WORKER_PORT_LIST = []
WORKER_IP_LIST = []

@bottle.route('/init', method='POST')
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))

    data = bottle.request.json
    logging.info(topo_conf)
    reqs = m_util.broadcast_cmd(WORKER_IP_LIST, WORKER_PORT_LIST, 'init',
                                data)

    stat, bod = m_util.aggregate_broadcast_response(reqs)
    return bottle.HTTPResponse(status=stat, body=bod)


@bottle.route('/start', method='POST')
def start():
    """
    Broadcast the POST request to the 'start' endpoint of the workers
    Aggregate the responses<commit_msg>fix bug after functional test<commit_after>#!/usr/bin/env python

# Copyright (c) 2015 Intracom S.A. Telecom Solutions. All rights reserved.
#
# This program and the accompanying materials are made available under the
# terms of the Eclipse Public License v1.0 which accompanies this distribution,
# and is available at http://www.eclipse.org/legal/epl-v10.html

"""
With this module we create the master REST server
to manage the distributed topologies
"""

import bottle
import logging
import util.multinet_requests as m_util
import time

# We must define logging level separately because this module runs
# independently.
logging.basicConfig(level=logging.DEBUG)

WORKER_PORT_LIST = []
WORKER_IP_LIST = []

@bottle.route('/init', method='POST')
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))

    data = bottle.request.json
    logging.info('[init] topology type: {0}'.format(data['topo_type']))
    reqs = m_util.broadcast_cmd(WORKER_IP_LIST, WORKER_PORT_LIST, 'init',
                                data)

    stat, bod = m_util.aggregate_broadcast_response(reqs)
    return bottle.HTTPResponse(status=stat, body=bod)


@bottle.route('/start', method='POST')
def start():
    """
    Broadcast the POST request to the 'start' endpoint of the workers
    Aggregate the responses
{'fraction_non_alphanumeric': 0.07885985748218527, 'fraction_numerical': 0.004513064133016627, 'mean_word_length': 3.6325632563256325, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2589793', 'n_tokens_mistral': 1216, 'n_tokens_neox': 1160, 'n_words': 464}