コード例 #1
0
ファイル: nova.py プロジェクト: zainubwahid/neutron
    def __init__(self):
        auth = ks_loading.load_auth_from_conf_options(cfg.CONF, 'nova')

        session = ks_loading.load_session_from_conf_options(cfg.CONF,
                                                            'nova',
                                                            auth=auth)

        extensions = [
            ext for ext in nova_client.discover_extensions(NOVA_API_VERSION)
            if ext.name == "server_external_events"
        ]
        self.nclient = nova_client.Client(
            NOVA_API_VERSION,
            session=session,
            region_name=cfg.CONF.nova.region_name,
            endpoint_type=cfg.CONF.nova.endpoint_type,
            extensions=extensions)
        self.batch_notifier = batch_notifier.BatchNotifier(
            cfg.CONF.send_events_interval, self.send_events)

        # register callbacks for events pertaining resources affecting Nova
        callback_resources = (
            resources.FLOATING_IP,
            resources.PORT,
        )
        for resource in callback_resources:
            registry.subscribe(self._send_nova_notification, resource,
                               events.BEFORE_RESPONSE)
コード例 #2
0
ファイル: nova.py プロジェクト: dingboopt/neutron-x
    def __init__(self):
        # FIXME(jamielennox): A notifier is being created for each Controller
        # and each Notifier is handling it's own auth. That means that we are
        # authenticating the exact same thing len(controllers) times. This
        # should be an easy thing to optimize.
        # FIXME(kevinbenton): remove this comment and the one above once the
        # switch to pecan is complete since only one notifier is constructed
        # in the pecan notification hook.
        auth = ks_loading.load_auth_from_conf_options(cfg.CONF, 'nova')

        session = ks_loading.load_session_from_conf_options(cfg.CONF,
                                                            'nova',
                                                            auth=auth)

        extensions = [
            ext for ext in nova_client.discover_extensions(NOVA_API_VERSION)
            if ext.name == "server_external_events"
        ]
        self.nclient = nova_client.Client(
            NOVA_API_VERSION,
            session=session,
            region_name=cfg.CONF.nova.region_name,
            endpoint_type=cfg.CONF.nova.endpoint_type,
            extensions=extensions)
        self.batch_notifier = batch_notifier.BatchNotifier(
            cfg.CONF.send_events_interval, self.send_events)
コード例 #3
0
ファイル: ha.py プロジェクト: youaremylovemyy/neutron
 def __init__(self, host):
     self._init_ha_conf_path()
     super(AgentMixin, self).__init__(host)
     # BatchNotifier queue is needed to ensure that the HA router
     # state change sequence is under the proper order.
     self.state_change_notifier = batch_notifier.BatchNotifier(
         self._calculate_batch_duration(), self.notify_server)
     eventlet.spawn(self._start_keepalived_notifications_server)
コード例 #4
0
 def __init__(self):
     self._core_plugin = directory.get_plugin()
     # NOTE(bence romsics): The following bug and fix may be relevant here.
     # https://bugs.launchpad.net/nova/+bug/1697825
     # https://review.opendev.org/493536
     self._placement_client = place_client.PlacementAPIClient(cfg.CONF)
     self._agents = PlacementReporterAgents(self._core_plugin)
     self._batch_notifier = batch_notifier.BatchNotifier(
         cfg.CONF.send_events_interval, self._execute_deferred)
コード例 #5
0
 def __init__(self):
     auth = ks_loading.load_auth_from_conf_options(cfg.CONF, 'nova')
     self.session = ks_loading.load_session_from_conf_options(
         cfg.CONF,
         'nova',
         auth=auth)
     self.extensions = [
         ext for ext in nova_client.discover_extensions(NOVA_API_VERSION)
         if ext.name == "server_external_events"]
     self.batch_notifier = batch_notifier.BatchNotifier(
         cfg.CONF.send_events_interval, self.send_events)
コード例 #6
0
ファイル: plugin.py プロジェクト: lhyzxj314/neutron
    def __init__(self):
        self.p_client, self.n_client = self._get_clients()
        self.batch_notifier = batch_notifier.BatchNotifier(
            cfg.CONF.send_events_interval, self._send_notifications)

        registry.subscribe(self._notify_subnet_created, resources.SUBNET,
                           events.AFTER_CREATE)
        registry.subscribe(self._notify_subnet_updated, resources.SUBNET,
                           events.AFTER_UPDATE)
        registry.subscribe(self._notify_subnet_deleted, resources.SUBNET,
                           events.AFTER_DELETE)
        registry.subscribe(self._notify_host_addition_to_aggregate,
                           resources.SEGMENT_HOST_MAPPING, events.AFTER_CREATE)
        registry.subscribe(self._notify_port_created_or_deleted,
                           resources.PORT, events.AFTER_CREATE)
        registry.subscribe(self._notify_port_updated, resources.PORT,
                           events.AFTER_UPDATE)
        registry.subscribe(self._notify_port_created_or_deleted,
                           resources.PORT, events.AFTER_DELETE)
コード例 #7
0
ファイル: nova.py プロジェクト: shivharis/neutron
    def __init__(self):
        auth = ks_loading.load_auth_from_conf_options(cfg.CONF, 'nova')

        session = ks_loading.load_session_from_conf_options(cfg.CONF,
                                                            'nova',
                                                            auth=auth)

        extensions = [
            ext for ext in nova_client.discover_extensions(NOVA_API_VERSION)
            if ext.name == "server_external_events"
        ]
        self.nclient = nova_client.Client(
            api_versions.APIVersion(NOVA_API_VERSION),
            session=session,
            region_name=cfg.CONF.nova.region_name,
            endpoint_type=cfg.CONF.nova.endpoint_type,
            extensions=extensions)
        self.batch_notifier = batch_notifier.BatchNotifier(
            cfg.CONF.send_events_interval, self.send_events)
コード例 #8
0
    def __init__(self):
        # FIXME(jamielennox): A notifier is being created for each Controller
        # and each Notifier is handling it's own auth. That means that we are
        # authenticating the exact same thing len(controllers) times. This
        # should be an easy thing to optimize.
        auth = ks_auth.load_from_conf_options(cfg.CONF, 'nova')
        endpoint_override = None

        if not auth:
            LOG.warning(
                _LW('Authenticating to nova using nova_admin_* options'
                    ' is deprecated. This should be done using'
                    ' an auth plugin, like password'))

            if cfg.CONF.nova_admin_tenant_id:
                endpoint_override = "%s/%s" % (cfg.CONF.nova_url,
                                               cfg.CONF.nova_admin_tenant_id)

            auth = DefaultAuthPlugin(
                auth_url=cfg.CONF.nova_admin_auth_url,
                username=cfg.CONF.nova_admin_username,
                password=cfg.CONF.nova_admin_password,
                tenant_id=cfg.CONF.nova_admin_tenant_id,
                tenant_name=cfg.CONF.nova_admin_tenant_name,
                endpoint_override=endpoint_override)

        session = ks_session.Session.load_from_conf_options(cfg.CONF,
                                                            'nova',
                                                            auth=auth)

        # NOTE(andreykurilin): novaclient.v1_1 was renamed to v2 and there is
        # no way to import the contrib module directly without referencing v2,
        # which would only work for novaclient >= 2.21.0.
        novaclient_cls = nova_client.get_client_class(NOVA_API_VERSION)
        server_external_events = importutils.import_module(
            novaclient_cls.__module__.replace(
                ".client", ".contrib.server_external_events"))

        self.nclient = novaclient_cls(session=session,
                                      region_name=cfg.CONF.nova.region_name,
                                      extensions=[server_external_events])
        self.batch_notifier = batch_notifier.BatchNotifier(
            cfg.CONF.send_events_interval, self.send_events)
コード例 #9
0
ファイル: nova.py プロジェクト: smartcloud-openstack/neutron
    def __init__(self):
        # FIXME(jamielennox): A notifier is being created for each Controller
        # and each Notifier is handling it's own auth. That means that we are
        # authenticating the exact same thing len(controllers) times. This
        # should be an easy thing to optimize.
        auth = ks_auth.load_from_conf_options(cfg.CONF, 'nova')
        endpoint_override = None

        if not auth:
            LOG.warning(
                _LW('Authenticating to nova using nova_admin_* options'
                    ' is deprecated. This should be done using'
                    ' an auth plugin, like password'))

            if cfg.CONF.nova_admin_tenant_id:
                endpoint_override = "%s/%s" % (cfg.CONF.nova_url,
                                               cfg.CONF.nova_admin_tenant_id)

            auth = DefaultAuthPlugin(
                auth_url=cfg.CONF.nova_admin_auth_url,
                username=cfg.CONF.nova_admin_username,
                password=cfg.CONF.nova_admin_password,
                tenant_id=cfg.CONF.nova_admin_tenant_id,
                tenant_name=cfg.CONF.nova_admin_tenant_name,
                endpoint_override=endpoint_override)

        session = ks_session.Session.load_from_conf_options(cfg.CONF,
                                                            'nova',
                                                            auth=auth)

        extensions = [
            ext for ext in nova_client.discover_extensions(NOVA_API_VERSION)
            if ext.name == "server_external_events"
        ]
        self.nclient = nova_client.Client(
            NOVA_API_VERSION,
            session=session,
            region_name=cfg.CONF.nova.region_name,
            extensions=extensions)
        self.batch_notifier = batch_notifier.BatchNotifier(
            cfg.CONF.send_events_interval, self.send_events)
コード例 #10
0
ファイル: nova.py プロジェクト: mrwukang/neutron
    def __init__(self):
        # FIXME(jamielennox): A notifier is being created for each Controller
        # and each Notifier is handling it's own auth. That means that we are
        # authenticating the exact same thing len(controllers) times. This
        # should be an easy thing to optimize.
        auth = ks_loading.load_auth_from_conf_options(cfg.CONF, 'nova')

        session = ks_loading.load_session_from_conf_options(cfg.CONF,
                                                            'nova',
                                                            auth=auth)

        extensions = [
            ext for ext in nova_client.discover_extensions(NOVA_API_VERSION)
            if ext.name == "server_external_events"
        ]
        self.nclient = nova_client.Client(
            NOVA_API_VERSION,
            session=session,
            region_name=cfg.CONF.nova.region_name,
            extensions=extensions)
        self.batch_notifier = batch_notifier.BatchNotifier(
            cfg.CONF.send_events_interval, self.send_events)
コード例 #11
0
ファイル: plugin.py プロジェクト: ychen2u/stx-neutron
 def __init__(self):
     self.p_client, self.n_client = self._get_clients()
     self.batch_notifier = batch_notifier.BatchNotifier(
         cfg.CONF.send_events_interval, self._send_notifications)
コード例 #12
0
 def __init__(self, host):
     self._init_ha_conf_path()
     super(AgentMixin, self).__init__(host)
     self.state_change_notifier = batch_notifier.BatchNotifier(
         self._calculate_batch_duration(), self.notify_server)
     eventlet.spawn(self._start_keepalived_notifications_server)
コード例 #13
0
 def __init__(self):
     self.batch_notifier = batch_notifier.BatchNotifier(
         cfg.CONF.send_events_interval, self.send_events)
     self.irclient = self._get_ironic_client()
コード例 #14
0
 def setUp(self):
     super(TestBatchNotifier, self).setUp()
     self.notifier = batch_notifier.BatchNotifier(0.1, lambda x: x)
     self.spawn_n = mock.patch('eventlet.spawn_n').start()
コード例 #15
0
 def setUp(self):
     super(TestBatchNotifier, self).setUp()
     self._received_events = eventlet.Queue()
     self.notifier = batch_notifier.BatchNotifier(2, self._queue_events)
     self.spawn_n_p = mock.patch.object(eventlet, 'spawn_n')