def test_block_db_access(self, mock_db_IMPL, mock_LOG):
        cmd_common.block_db_access('unit-tests')

        self.assertEqual(api.IMPL, api.IMPL.foo)
        self.assertRaises(exception.DBNotAllowed, api.IMPL)
        self.assertEqual('unit-tests',
                         mock_LOG.error.call_args[0][1]['service_name'])
Beispiel #2
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "nova")

    # NOTE(stephenfin): Yes, this is silly, but the whole thing is being
    # removed and we want to make the diff in individual changes as small as
    # possible
    if True:
        LOG.error('Nova network is deprecated and not supported '
                  'except as required for CellsV1 deployments.')
        return 1

    objects.register_all()
    gmr_opts.set_defaults(CONF)

    gmr.TextGuruMeditation.setup_autorun(version, conf=CONF)

    cmd_common.block_db_access('nova-network')
    objects_base.NovaObject.indirection_api = conductor_rpcapi.ConductorAPI()

    LOG.warning('Nova network is deprecated and will be removed '
                'in the future')
    server = service.Service.create(binary='nova-network',
                                    topic=network_rpcapi.RPC_TOPIC,
                                    manager=CONF.network_manager)
    service.serve(server)
    service.wait()
Beispiel #3
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "nova")

    if not CONF.cells.enable:
        LOG.error(
            _LE('Nova network is deprecated and not supported '
                'except as required for CellsV1 deployments.'))
        return 1

    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    cmd_common.block_db_access('nova-network')
    objects_base.NovaObject.indirection_api = conductor_rpcapi.ConductorAPI()

    LOG.warning(
        _LW('Nova network is deprecated and will be removed '
            'in the future'))
    server = service.Service.create(binary='nova-network',
                                    topic=CONF.network_topic)
    service.serve(server)
    service.wait()
Beispiel #4
0
def main():
    """Parse environment and arguments and call the appropriate action."""
    config.parse_args(sys.argv,
                      default_config_files=jsonutils.loads(
                          os.environ['CONFIG_FILE']))

    logging.setup(CONF, "nova")
    global LOG
    LOG = logging.getLogger('nova.dhcpbridge')

    if CONF.action.name == 'old':
        # NOTE(sdague): old is the most frequent message sent, and
        # it's a noop. We should just exit immediately otherwise we
        # can stack up a bunch of requests in dnsmasq. A SIGHUP seems
        # to dump this list, so actions queued up get lost.
        return

    objects.register_all()

    if not CONF.conductor.use_local:
        cmd_common.block_db_access('nova-dhcpbridge')
        objects_base.NovaObject.indirection_api = \
            conductor_rpcapi.ConductorAPI()
    else:
        LOG.warning(
            _LW('Conductor local mode is deprecated and will '
                'be removed in a subsequent release'))

    if CONF.action.name in ['add', 'del']:
        LOG.debug(
            "Called '%(action)s' for mac '%(mac)s' with IP '%(ip)s'", {
                "action": CONF.action.name,
                "mac": CONF.action.mac,
                "ip": CONF.action.ip
            })
        CONF.action.func(CONF.action.mac, CONF.action.ip)
    else:
        try:
            network_id = int(os.environ.get('NETWORK_ID'))
        except TypeError:
            LOG.error(_LE("Environment variable 'NETWORK_ID' must be set."))
            return (1)

        print(init_leases(network_id))

    rpc.cleanup()
Beispiel #5
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, 'nova')
    priv_context.init(root_helper=shlex.split(utils.get_root_helper()))
    objects.register_all()
    gmr_opts.set_defaults(CONF)
    # Ensure os-vif objects are registered and plugins loaded
    os_vif.initialize()

    gmr.TextGuruMeditation.setup_autorun(version, conf=CONF)

    cmd_common.block_db_access('nova-compute')
    objects_base.NovaObject.indirection_api = conductor_rpcapi.ConductorAPI()
    objects.Service.enable_min_version_cache()
    server = service.Service.create(binary='nova-compute',
                                    topic=compute_rpcapi.RPC_TOPIC)
    service.serve(server)
    service.wait()
Beispiel #6
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, 'nova')
    priv_context.init(root_helper=shlex.split(utils.get_root_helper()))
    utils.monkey_patch()
    objects.register_all()
    # Ensure os-vif objects are registered and plugins loaded
    os_vif.initialize()

    gmr.TextGuruMeditation.setup_autorun(version)

    cmd_common.block_db_access('nova-compute')
    objects_base.NovaObject.indirection_api = conductor_rpcapi.ConductorAPI()

    server = service.Service.create(binary='nova-compute',
                                    topic=compute_rpcapi.RPC_TOPIC)
    service.serve(server)
    service.wait()
Beispiel #7
0
def main():
    """Parse environment and arguments and call the appropriate action."""
    config.parse_args(sys.argv,
        default_config_files=jsonutils.loads(os.environ['CONFIG_FILE']))

    logging.setup(CONF, "nova")
    global LOG
    LOG = logging.getLogger('nova.dhcpbridge')

    if CONF.action.name == 'old':
        # NOTE(sdague): old is the most frequent message sent, and
        # it's a noop. We should just exit immediately otherwise we
        # can stack up a bunch of requests in dnsmasq. A SIGHUP seems
        # to dump this list, so actions queued up get lost.
        return

    objects.register_all()

    if not CONF.conductor.use_local:
        cmd_common.block_db_access('nova-dhcpbridge')
        objects_base.NovaObject.indirection_api = \
            conductor_rpcapi.ConductorAPI()
    else:
        LOG.warning(_LW('Conductor local mode is deprecated and will '
                        'be removed in a subsequent release'))

    if CONF.action.name in ['add', 'del']:
        LOG.debug("Called '%(action)s' for mac '%(mac)s' with IP '%(ip)s'",
                  {"action": CONF.action.name,
                   "mac": CONF.action.mac,
                   "ip": CONF.action.ip})
        CONF.action.func(CONF.action.mac, CONF.action.ip)
    else:
        try:
            network_id = int(os.environ.get('NETWORK_ID'))
        except TypeError:
            LOG.error(_LE("Environment variable 'NETWORK_ID' must be set."))
            return(1)

        print(init_leases(network_id))

    rpc.cleanup()
Beispiel #8
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "nova")
    priv_context.init(root_helper=shlex.split(utils.get_root_helper()))
    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    if not CONF.conductor.use_local:
        cmd_common.block_db_access("nova-compute")
        objects_base.NovaObject.indirection_api = conductor_rpcapi.ConductorAPI()
    else:
        LOG.warning(_LW("Conductor local mode is deprecated and will " "be removed in a subsequent release"))

    server = service.Service.create(
        binary="nova-compute", topic=CONF.compute_topic, db_allowed=CONF.conductor.use_local
    )
    service.serve(server)
    service.wait()
Beispiel #9
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "nova")
    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    if not CONF.conductor.use_local:
        cmd_common.block_db_access('nova-network')
        objects_base.NovaObject.indirection_api = \
            conductor_rpcapi.ConductorAPI()
    else:
        LOG.warning(_LW('Conductor local mode is deprecated and will '
                        'be removed in a subsequent release'))

    LOG.warning(_LW('Nova network is deprecated and will be removed '
                    'in the future'))
    server = service.Service.create(binary='nova-network',
                                    topic=CONF.network_topic,
                                    db_allowed=CONF.conductor.use_local)
    service.serve(server)
    service.wait()
Beispiel #10
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, "nova")

    if not CONF.cells.enable:
        LOG.error(_LE('Nova network is deprecated and not supported '
                      'except as required for CellsV1 deployments.'))
        return 1

    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    cmd_common.block_db_access('nova-network')
    objects_base.NovaObject.indirection_api = conductor_rpcapi.ConductorAPI()

    LOG.warning(_LW('Nova network is deprecated and will be removed '
                    'in the future'))
    server = service.Service.create(binary='nova-network',
                                    topic=CONF.network_topic)
    service.serve(server)
    service.wait()
Beispiel #11
0
def main():
    config.parse_args(sys.argv)
    logging.setup(CONF, 'nova')
    priv_context.init(root_helper=shlex.split(utils.get_root_helper()))
    utils.monkey_patch()
    objects.register_all()

    gmr.TextGuruMeditation.setup_autorun(version)

    if not CONF.conductor.use_local:
        cmd_common.block_db_access('nova-compute')
        objects_base.NovaObject.indirection_api = \
            conductor_rpcapi.ConductorAPI()
    else:
        LOG.warning(
            _LW('Conductor local mode is deprecated and will '
                'be removed in a subsequent release'))

    server = service.Service.create(binary='nova-compute',
                                    topic=CONF.compute_topic,
                                    db_allowed=CONF.conductor.use_local)
    service.serve(server)
    service.wait()