Ejemplo n.º 1
0
def main():
    """Starts the web server."""
    parser = argparse.ArgumentParser(
        description='Cluster-Insight data collector')
    parser.add_argument('-d',
                        '--debug',
                        action='store_true',
                        help='enable debug mode')
    parser.add_argument('--host',
                        action='store',
                        type=str,
                        default='0.0.0.0',
                        help='hostname to listen on [default=all interfaces]')
    parser.add_argument(
        '-p',
        '--port',
        action='store',
        type=int,
        default=constants.DATA_COLLECTOR_PORT,
        help='data collector port number [default=%(default)d]')
    args = parser.parse_args()

    g_state = global_state.GlobalState()
    g_state.init_caches_and_synchronization()
    app.context_graph_global_state = g_state

    app.run(host=args.host, port=args.port, debug=args.debug)
Ejemplo n.º 2
0
 def setUp(self):
   os.environ['KUBERNETES_SERVICE_HOST'] = 'localhost'
   os.environ['KUBERNETES_SERVICE_PORT'] = '443'
   gs = global_state.GlobalState()
   gs.init_caches_and_synchronization()
   collector.app.context_graph_global_state = gs
   collector.app.testing = True
   self.app = collector.app.test_client()
Ejemplo n.º 3
0
 def setUp(self):
     gs = global_state.GlobalState()
     gs.init_caches_and_synchronization()
     gs.set_testing(True)
     gs.set_logger(collector.app.logger)
     gs.set_num_workers(1)  # execute worker tasks sequentially
     collector.app.context_graph_global_state = gs
     self.app = collector.app.test_client()
    def setUp(self):
        self._mox = mox.Mox()
        self._modem_conf = modem_configuration.ModemConfiguration()
        self._task_loop = self._mox.CreateMock(task_loop.TaskLoop)
        self._transceiver = self._mox.CreateMock(at_transceiver.ATTransceiver)

        self._machine = network_identity_machine.NetworkIdentityMachine(
            global_state.GlobalState(), self._transceiver, self._modem_conf)

        # Mock out the task_loop
        self._machine._task_loop = self._task_loop
Ejemplo n.º 5
0
    def __init__(self,
                 replaced_modem = None,
                 state_machines = None,
                 modem_at_port_dev_name = None):
        """
        @param replaced_modem: Name of the modem being emulated. If left None,
                the base modem will be emulated. A list of valid modems can be
                found in the module modem_configuration

        @param state_machines: Objects of subtypes of StateMachine that override
                any state machine defined in the configuration files for the
                same well-known-name.

        @param modem_at_port_dev_name: The full path to the primary AT port of
                the physical modem. This is needed only if we're running in a
                mode where we pass on modemmanager commands to the modem. This
                should be a string of the form '/dev/XXX'

        """
        self._logger = logging.getLogger(__name__)

        if not state_machines:
            state_machines = []
        if modem_at_port_dev_name and (
                type(modem_at_port_dev_name) is not str or
                modem_at_port_dev_name[0:5] != '/dev/'):
            raise wme.WardModemSetupException(
                    'Modem device name must be of the form "/dev/XXX", '
                    'where XXX is the udev device.')

        # The modem that wardmodem is intended to replace.
        self._replaced_modem = replaced_modem

        # Pseudo net interface exported to shill.
        self._net_interface = net_interface.PseudoNetInterface()

        # The internal task loop object. Readable through a property.
        self._task_loop = task_loop.TaskLoop()

        # The global state object shared by all state machines.
        self._state = global_state.GlobalState()

        # The configuration object for the replaced modem.
        self._modem_conf = modem_configuration.ModemConfiguration(
                replaced_modem)

        self._create_transceiver(modem_at_port_dev_name)
        self._setup_state_machines(state_machines)

        self._started = False
Ejemplo n.º 6
0
def main():
    parser = argparse.ArgumentParser(
        description='Cluster-Insight data collector')
    parser.add_argument('-d',
                        '--debug',
                        action='store_true',
                        help='enable debug mode')
    parser.add_argument('-p',
                        '--port',
                        action='store',
                        type=int,
                        default=constants.DATA_COLLECTOR_PORT,
                        help=('data collector port number [default=%d]' %
                              constants.DATA_COLLECTOR_PORT))
    parser.add_argument('--docker_port',
                        action='store',
                        type=int,
                        default=constants.DOCKER_PORT,
                        help=('Docker port number [default=%d]' %
                              constants.DOCKER_PORT))
    parser.add_argument(
        '-w',
        '--workers',
        action='store',
        type=int,
        default=0,
        help=('number of concurrent workers. A zero or a '
              'negative value denotes an automatic calculation '
              'of this number. [default=0]'))
    args = parser.parse_args()

    app.logger.setLevel(logging.DEBUG if args.debug else logging.INFO)
    g_state = global_state.GlobalState()
    g_state.init_caches_and_synchronization()
    g_state.set_logger(app.logger)
    g_state.set_docker_port(args.docker_port)
    g_state.set_num_workers(args.workers)
    app.context_graph_global_state = g_state

    app.run(host='0.0.0.0', port=args.port, debug=args.debug)
    def setUp(self):
        self._mox = mox.Mox()

        # Prepare modem configuration to suit our needs.
        self._modem_conf = modem_configuration.ModemConfiguration()
        self._modem_conf.base_wm_request_response_map = {
            'AT1': 'AT1RESPONSE',
            'AT2': ('AT2OK', 'AT2ERROR'),
            'AT3': 'AT3RESPONSE'
        }
        self._modem_conf.plugin_wm_request_response_map = {
            'AT3': 'AT3RESPONSE_OVERRIDEN',
            'AT4': 'AT4RESPONSE',
            'AT5': ['AT5RESPONSE1', 'AT5RESPONSE2']
        }

        self._task_loop = self._mox.CreateMock(task_loop.TaskLoop)
        self._transceiver = self._mox.CreateMock(at_transceiver.ATTransceiver)
        self._machine = request_response.RequestResponse(
            global_state.GlobalState(), self._transceiver, self._modem_conf)

        # Mock out the task_loop
        self._machine._task_loop = self._task_loop
Ejemplo n.º 8
0
 def setUp(self):
     self._state = global_state.GlobalState()
     self._state.init_caches_and_synchronization()