Beispiel #1
0
 def _test_create_consumers(
     self, endpoints, method, expected, topics, listen):
     call_to_patch = 'neutron.common.rpc.create_connection'
     with mock.patch(call_to_patch) as create_connection:
         rpc.create_consumers(
             endpoints, method, topics, start_listening=listen)
         create_connection.assert_has_calls(expected)
Beispiel #2
0
 def _test_create_consumers(
     self, endpoints, method, expected, topics, listen):
     call_to_patch = 'neutron.common.rpc.Connection'
     with mock.patch(call_to_patch) as create_connection:
         rpc.create_consumers(
             endpoints, method, topics, start_listening=listen)
         create_connection.assert_has_calls(expected)
Beispiel #3
0
 def _test_create_consumers(self, endpoints, method, expected, topics,
                            listen):
     with mock.patch.object(n_rpc, 'Connection') as create_connection:
         rpc.create_consumers(endpoints,
                              method,
                              topics,
                              start_listening=listen)
         create_connection.assert_has_calls(expected)
Beispiel #4
0
    def test_create_consumers_with_node_name(self):
        endpoints = [mock.Mock()]
        expected = [
            mock.call(),
            mock.call().create_consumer("foo-topic-op", endpoints, fanout=True),
            mock.call().create_consumer("foo-topic-op.node1", endpoints, fanout=False),
            mock.call().consume_in_threads(),
        ]

        call_to_patch = "neutron.common.rpc.create_connection"
        with mock.patch(call_to_patch) as create_connection:
            rpc.create_consumers(endpoints, "foo", [("topic", "op", "node1")])
            create_connection.assert_has_calls(expected)
    def test_create_consumers(self):
        endpoints = [mock.Mock()]
        expected = [
            mock.call(new=True),
            mock.call().create_consumer('foo-topic-op', endpoints,
                                        fanout=True),
            mock.call().consume_in_threads()
        ]

        call_to_patch = 'neutron.common.rpc.create_connection'
        with mock.patch(call_to_patch) as create_connection:
            rpc.create_consumers(endpoints, 'foo', [('topic', 'op')])
            create_connection.assert_has_calls(expected)
Beispiel #6
0
    def test_create_consumers(self):
        dispatcher = mock.Mock()
        expected = [
            mock.call(new=True),
            mock.call().create_consumer('foo-topic-op', dispatcher,
                                        fanout=True),
            mock.call().consume_in_thread()
        ]

        call_to_patch = 'neutron.openstack.common.rpc.create_connection'
        with mock.patch(call_to_patch) as create_connection:
            rpc.create_consumers(dispatcher, 'foo', [('topic', 'op')])
            create_connection.assert_has_calls(expected)
Beispiel #7
0
    def test_create_consumers(self):
        endpoints = [mock.Mock()]
        expected = [
            mock.call(new=True),
            mock.call().create_consumer('foo-topic-op', endpoints,
                                        fanout=True),
            mock.call().consume_in_threads()
        ]

        call_to_patch = 'neutron.common.rpc.create_connection'
        with mock.patch(call_to_patch) as create_connection:
            rpc.create_consumers(endpoints, 'foo', [('topic', 'op')])
            create_connection.assert_has_calls(expected)
Beispiel #8
0
    def test_create_consumers_with_node_name(self):
        endpoints = [mock.Mock()]
        expected = [
            mock.call(),
            mock.call().create_consumer('foo-topic-op', endpoints,
                                        fanout=True),
            mock.call().create_consumer('foo-topic-op.node1', endpoints,
                                        fanout=False),
            mock.call().consume_in_threads()
        ]

        with mock.patch.object(n_rpc, 'Connection') as create_connection:
            rpc.create_consumers(endpoints, 'foo', [('topic', 'op', 'node1')])
            create_connection.assert_has_calls(expected)
Beispiel #9
0
    def test_create_consumers_with_node_name(self):
        endpoints = [mock.Mock()]
        expected = [
            mock.call(),
            mock.call().create_consumer('foo-topic-op', endpoints,
                                        fanout=True),
            mock.call().create_consumer('foo-topic-op.node1', endpoints,
                                        fanout=False),
            mock.call().consume_in_threads()
        ]

        with mock.patch.object(n_rpc, 'Connection') as create_connection:
            rpc.create_consumers(endpoints, 'foo', [('topic', 'op', 'node1')])
            create_connection.assert_has_calls(expected)
Beispiel #10
0
    def _setup_rpc(self):
        self.agent_id = 'nic-switch-agent.%s' % socket.gethostname()
        LOG.info(_LI("RPC agent_id: %s"), self.agent_id)

        self.topic = topics.AGENT
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS)
        # RPC network init
        # Handle updates from service
        self.endpoints = [SriovNicSwitchRpcCallbacks(self.context, self,
                                                     self.sg_agent)]
        # Define the listening consumers for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.NETWORK, topics.DELETE],
                     [topics.NETWORK, topics.UPDATE],
                     [topics.SECURITY_GROUP, topics.UPDATE]]
        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic,
                                                     consumers,
                                                     start_listening=False)

        report_interval = cfg.CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)
    def setup_rpc(self):

        self.host = socket.gethostname()
        self.agent_id = 'nvsd-q-agent.%s' % self.host
        LOG.info(_LI("RPC agent_id: %s"), self.agent_id)

        self.topic = topics.AGENT
        self.context = n_context.get_admin_context_without_session()
        self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
        self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context,
                                                     self.sg_plugin_rpc)

        # RPC network init
        # Handle updates from service
        self.callback_oc = NVSDAgentRpcCallback(self.context,
                                                self, self.sg_agent)
        self.callback_sg = SecurityGroupAgentRpcCallback(self.context,
                                                         self.sg_agent)
        self.endpoints = [self.callback_oc, self.callback_sg]
        # Define the listening consumer for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.SECURITY_GROUP, topics.UPDATE]]
        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic,
                                                     consumers)
    def setup_rpc(self, physical_interfaces):
        if physical_interfaces:
            mac = utils.get_interface_mac(physical_interfaces[0])
        else:
            devices = ip_lib.IPWrapper().get_devices(True)
            if devices:
                mac = utils.get_interface_mac(devices[0].name)
            else:
                LOG.error(_LE("Unable to obtain MAC address for unique ID. " "Agent terminated!"))
                exit(1)

        self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
        self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
        self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context, self.sg_plugin_rpc, defer_refresh_firewall=True)

        self.agent_id = "%s%s" % ("lb", (mac.replace(":", "")))
        LOG.info(_LI("RPC agent_id: %s"), self.agent_id)

        self.topic = topics.AGENT
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS)
        # RPC network init
        # Handle updates from service
        self.endpoints = [LinuxBridgeRpcCallbacks(self.context, self, self.sg_agent)]
        # Define the listening consumers for the agent
        consumers = [
            [topics.PORT, topics.UPDATE],
            [topics.NETWORK, topics.DELETE],
            [topics.NETWORK, topics.UPDATE],
            [topics.SECURITY_GROUP, topics.UPDATE],
        ]

        if cfg.CONF.VXLAN.l2_population:
            consumers.append([topics.L2POPULATION, topics.UPDATE])
        self.connection = agent_rpc.create_consumers(self.endpoints, self.topic, consumers)
Beispiel #13
0
    def setup_rpc(self):
        self.plugin_rpc = OVSPluginApi(topics.PLUGIN)
        self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
        self.dvr_plugin_rpc = dvr_rpc.DVRServerRpcApi(topics.PLUGIN)
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS)

        # RPC network init
        self.context = context.get_admin_context_without_session()
        # Define the listening consumers for the agent
        consumers = [[constants.TUNNEL, topics.UPDATE],
                     [constants.TUNNEL, topics.DELETE],
                     [topics.SECURITY_GROUP, topics.UPDATE],
                     [topics.DVR, topics.UPDATE],
                     [topics.NETWORK, topics.UPDATE]]
        if self.l2_pop:
            consumers.append([topics.L2POPULATION, topics.UPDATE])
        self.connection = agent_rpc.create_consumers([self],
                                                     topics.AGENT,
                                                     consumers,
                                                     start_listening=False)

        # NOTE(rtheis): This will initialize all workers (API, RPC,
        # plugin service and OVN) with OVN IDL connections.
        trigger = ovsdb_monitor.OvnWorker
        self._nb_ovn, self._sb_ovn = impl_idl_ovn.get_ovn_idls(self, trigger)
Beispiel #14
0
    def setup_rpc(self):
        mac = self.int_br.get_local_port_mac()
        self.agent_id = "%s%s" % ("ovs", (mac.replace(":", "")))
        self.topic = topics.AGENT
        self.plugin_rpc = OVSPluginApi(topics.PLUGIN)
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)

        # RPC network init
        self.context = context.get_admin_context_without_session()
        # Handle updates from service
        self.dispatcher = self.create_rpc_dispatcher()
        # Define the listening consumers for the agent
        consumers = [
            [topics.PORT, topics.UPDATE],
            [topics.NETWORK, topics.DELETE],
            [constants.TUNNEL, topics.UPDATE],
            [topics.SECURITY_GROUP, topics.UPDATE],
        ]
        if self.l2_pop:
            consumers.append([topics.L2POPULATION, topics.UPDATE, cfg.CONF.host])
        self.connection = agent_rpc.create_consumers(self.dispatcher, self.topic, consumers)
        report_interval = cfg.CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(self._report_state)
            heartbeat.start(interval=report_interval)
 def _setup_rpc(self):
     self.topic = topics.AGENT
     self.plugin_rpc = RyuPluginApi(topics.PLUGIN)
     self.context = q_context.get_admin_context_without_session()
     self.endpoints = [self]
     consumers = [[topics.PORT, topics.UPDATE], [topics.SECURITY_GROUP, topics.UPDATE]]
     self.connection = agent_rpc.create_consumers(self.endpoints, self.topic, consumers)
Beispiel #16
0
 def __init__(self, host, conf=None):
     self.state_rpc = agent_rpc.PluginReportStateAPI(
         n_topics.SVMDEVICE_DRIVER_TOPIC)
     self.agent_state = {
         'binary': 'neutron-servicevm-agent',
         'host': host,
         'topic': topics.SERVICEVM_AGENT,
         'configurations': {},
         'start_flag': True,
         'agent_type': constants.AGENT_TYPE_SERVICEVM
     }
     report_interval = cfg.CONF.AGENT.report_interval
     self.use_call = True
     self._initialize_rpc(host)
     self.topic = topics.SERVICEVM
     self.endpoints = [self]
     consumers = [[topics.SUBNET, topics.UPDATE],
                  [topics.SUBNET, topics.DELETE],
                  [topics.SUBNET, topics.CREATE]]
     self.connection = agent_rpc.create_consumers(self.endpoints,
                                                  self.topic, consumers)
     #self._agent_registration()
     super(ServiceVMAgentWithStateReport, self).__init__(host=host,
                                                         conf=conf)
     if report_interval:
         self.heartbeat = loopingcall.FixedIntervalLoopingCall(
             self._report_state)
         #self.heartbeat.start(interval=report_interval)
         self.heartbeat.start(interval=2)
    def setup_rpc(self):

        self.host = socket.gethostname()
        self.agent_id = 'nvsd-q-agent.%s' % self.host
        LOG.info(_LI("RPC agent_id: %s"), self.agent_id)

        self.topic = topics.AGENT
        self.context = n_context.get_admin_context_without_session()
        self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
        self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context,
                                                     self.sg_plugin_rpc,
                                                     self.root_helper)

        # RPC network init
        # Handle updates from service
        self.callback_oc = NVSDAgentRpcCallback(self.context, self,
                                                self.sg_agent)
        self.callback_sg = SecurityGroupAgentRpcCallback(
            self.context, self.sg_agent)
        self.endpoints = [self.callback_oc, self.callback_sg]
        # Define the listening consumer for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.SECURITY_GROUP, topics.UPDATE]]
        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic, consumers)
    def setup_rpc(self, physical_interfaces):
        if physical_interfaces:
            mac = utils.get_interface_mac(physical_interfaces[0])
        else:
            devices = ip_lib.IPWrapper(self.root_helper).get_devices(True)
            if devices:
                mac = utils.get_interface_mac(devices[0].name)
            else:
                LOG.error(_("Unable to obtain MAC address for unique ID. "
                          "Agent terminated!"))
                exit(1)
        self.agent_id = '%s%s' % ('lb', (mac.replace(":", "")))
        LOG.info(_("RPC agent_id: %s"), self.agent_id)

        self.topic = topics.AGENT
        self.plugin_rpc = LinuxBridgePluginApi(topics.PLUGIN)
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
        # RPC network init
        self.context = context.get_admin_context_without_session()
        # Handle updates from service
        self.callbacks = LinuxBridgeRpcCallbacks(self.context,
                                                 self)
        self.dispatcher = self.callbacks.create_rpc_dispatcher()
        # Define the listening consumers for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.NETWORK, topics.DELETE],
                     [topics.SECURITY_GROUP, topics.UPDATE]]
        self.connection = agent_rpc.create_consumers(self.dispatcher,
                                                     self.topic,
                                                     consumers)
        report_interval = cfg.CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)
Beispiel #19
0
    def setup_rpc(self):
        self.agent_id = 'dvs-agent-%s' % self.conf.host
        self.topic = topics.AGENT
        self.plugin_rpc = DVSPluginApi(topics.PLUGIN)
        self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)

        # RPC network init
        self.context = neutron.context.get_admin_context_without_session()

        # Handle updates from service
        self.endpoints = [self]

        # Define the listening consumers for the agent
        consumers = [[topics.PORT,
                      topics.CREATE], [topics.PORT, topics.UPDATE],
                     [topics.PORT, topics.DELETE],
                     [topics.NETWORK, topics.CREATE],
                     [topics.NETWORK, topics.UPDATE],
                     [topics.NETWORK, topics.DELETE],
                     [topics.SECURITY_GROUP, topics.UPDATE]]

        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic,
                                                     consumers,
                                                     start_listening=False)
Beispiel #20
0
    def setup_rpc(self):

        self.host = socket.gethostname()
        self.agent_id = 'nvsd-q-agent.%s' % self.host
        LOG.info(_("RPC agent_id: %s"), self.agent_id)

        self.topic = topics.AGENT
        self.context = n_context.get_admin_context_without_session()
        self.sg_agent = SecurityGroupAgentRpc(self.context,
                                              self.root_helper)

        # RPC network init
        # Handle updates from service
        self.callback_oc = NVSDAgentRpcCallback(self.context,
                                                self, self.sg_agent)
        self.callback_sg = SecurityGroupAgentRpcCallback(self.context,
                                                         self.sg_agent)
        self.dispatcher = dispatcher.RpcDispatcher([self.callback_oc,
                                                    self.callback_sg])
        # Define the listening consumer for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.SECURITY_GROUP, topics.UPDATE]]
        self.connection = agent_rpc.create_consumers(self.dispatcher,
                                                     self.topic,
                                                     consumers)
Beispiel #21
0
    def setup_rpc(self, physical_interfaces):
        if physical_interfaces:
            mac = utils.get_interface_mac(physical_interfaces[0])
        else:
            devices = ip_lib.IPWrapper(self.root_helper).get_devices(True)
            if devices:
                mac = utils.get_interface_mac(devices[0].name)
            else:
                LOG.error(
                    _("Unable to obtain MAC address for unique ID. "
                      "Agent terminated!"))
                exit(1)
        self.agent_id = '%s%s' % ('lb', (mac.replace(":", "")))
        LOG.info(_("RPC agent_id: %s"), self.agent_id)

        self.topic = topics.AGENT
        self.plugin_rpc = LinuxBridgePluginApi(topics.PLUGIN)
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
        # RPC network init
        self.context = context.get_admin_context_without_session()
        # Handle updates from service
        self.callbacks = LinuxBridgeRpcCallbacks(self.context, self)
        self.dispatcher = self.callbacks.create_rpc_dispatcher()
        # Define the listening consumers for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.NETWORK, topics.DELETE],
                     [topics.SECURITY_GROUP, topics.UPDATE]]
        self.connection = agent_rpc.create_consumers(self.dispatcher,
                                                     self.topic, consumers)
        report_interval = cfg.CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)
Beispiel #22
0
    def _setup_rpc(self):
        self.agent_id = 'vbox_%s' % platform.node()
        self.topic = topics.AGENT
        self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
        # RPC network init
        self.context = n_context.get_admin_context_without_session()
        # Handle updates from service
        self.endpoints = [self]
        # Define the listening consumers for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.NETWORK, topics.DELETE],
                     [topics.PORT, topics.DELETE],
                     [constants.TUNNEL, topics.UPDATE]]
        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic, consumers)
        self.sec_groups_agent = VBoxSecurityAgent(self.context,
                                                  self.plugin_rpc)

        report_interval = CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)

        self.agent_state = {
            'binary': 'neutron-vbox-agent',
            'host': cfg.CONF.host,
            'topic': n_const.L2_AGENT_TOPIC,
            'configurations': {
                'network_mappings': self._physical_network_mappings
            },
            'agent_type': n_const.AGENT_TYPE_VBOX,
            'start_flag': True
        }
    def setup_rpc(self):
        self.host = socket.gethostname()
        self.agent_id = 'nec-q-agent.%s' % self.host
        LOG.info(_LI("RPC agent_id: %s"), self.agent_id)

        self.topic = topics.AGENT
        self.context = q_context.get_admin_context_without_session()

        self.plugin_rpc = NECPluginApi(topics.PLUGIN)
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
        self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
        self.sg_agent = sg_rpc.SecurityGroupAgentRpc(self.context,
                                                     self.sg_plugin_rpc)

        # RPC network init
        # Handle updates from service
        self.callback_nec = NECAgentRpcCallback(self.context, self,
                                                self.sg_agent)
        self.callback_sg = SecurityGroupAgentRpcCallback(
            self.context, self.sg_agent)
        self.endpoints = [self.callback_nec, self.callback_sg]
        # Define the listening consumer for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.SECURITY_GROUP, topics.UPDATE]]
        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic, consumers)

        report_interval = config.CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)
Beispiel #24
0
    def setup_rpc(self):
        # print("cfarquhar: in setup_rpc")
        self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
        self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
        self.sg_agent = agent_sg_rpc.SecurityGroupAgentRpc(
            self.context, self.sg_plugin_rpc, defer_refresh_firewall=True)
        # LOG.info("cfarquhar: vars(plugin_rpc): {}".format(vars(self.plugin_rpc)))
        # LOG.info("cfarquhar: vars(sg_plugin_rpc): {}".format(vars(self.sg_plugin_rpc)))
        # LOG.info("cfarquhar: vars(sg_agent.plugin_rpc): {}".format(vars(self.sg_agent.plugin_rpc)))

        self.agent_id = self.mgr.get_agent_id()
        LOG.info("RPC agent_id: %s", self.agent_id)

        self.topic = topics.AGENT
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS)
        # RPC network init
        # Handle updates from service
        self.rpc_callbacks = self.mgr.get_rpc_callbacks(
            self.context, self, self.sg_agent)
        self.endpoints = [self.rpc_callbacks]
        self._validate_rpc_endpoints()
        # Define the listening consumers for the agent
        consumers = self.mgr.get_rpc_consumers()
        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic,
                                                     consumers,
                                                     start_listening=False)
    def setup_rpc(self, physical_interfaces):
        if physical_interfaces:
            mac = utils.get_interface_mac(physical_interfaces[0])
        else:
            devices = ip_lib.IPWrapper().get_devices(True)
            if devices:
                mac = utils.get_interface_mac(devices[0].name)
            else:
                LOG.error(_LE("Unable to obtain MAC address for unique ID. "
                              "Agent terminated!"))
                exit(1)
        self.agent_id = '%s%s' % ('lb', (mac.replace(":", "")))
        LOG.info(_LI("RPC agent_id: %s"), self.agent_id)

        self.topic = topics.AGENT
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
        # RPC network init
        # Handle updates from service
        self.endpoints = [LinuxBridgeRpcCallbacks(self.context, self,
                                                  self.sg_agent)]
        # Define the listening consumers for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.NETWORK, topics.DELETE],
                     [topics.SECURITY_GROUP, topics.UPDATE]]
        if cfg.CONF.VXLAN.l2_population:
            consumers.append([topics.L2POPULATION,
                              topics.UPDATE, cfg.CONF.host])
        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic,
                                                     consumers)
        report_interval = cfg.CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)
Beispiel #26
0
    def _setup_rpc(self):
        self.topic = topics.AGENT
        self.endpoints = [HyperVSecurityCallbackMixin(self)]
        consumers = [[topics.SECURITY_GROUP, topics.UPDATE]]

        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic, consumers)
Beispiel #27
0
    def setup_rpc(self, physical_interfaces):
        if physical_interfaces:
            mac = utils.get_interface_mac(physical_interfaces[0])
        else:
            devices = ip_lib.IPWrapper().get_devices(True)
            if devices:
                mac = utils.get_interface_mac(devices[0].name)
            else:
                LOG.error(
                    _LE("Unable to obtain MAC address for unique ID. "
                        "Agent terminated!"))
                exit(1)
        self.agent_id = '%s%s' % ('lb', (mac.replace(":", "")))
        LOG.info(_LI("RPC agent_id: %s"), self.agent_id)

        self.topic = topics.AGENT
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS)
        # RPC network init
        # Handle updates from service
        self.endpoints = [
            LinuxBridgeRpcCallbacks(self.context, self, self.sg_agent)
        ]
        # Define the listening consumers for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.NETWORK, topics.DELETE],
                     [topics.SECURITY_GROUP, topics.UPDATE]]
        if cfg.CONF.VXLAN.l2_population:
            consumers.append([topics.L2POPULATION, topics.UPDATE])
        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic, consumers)
        report_interval = cfg.CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)
Beispiel #28
0
    def _setup_rpc(self):
        self.agent_id = 'mlnx-agent.%s' % socket.gethostname()
        LOG.info(_("RPC agent_id: %s"), self.agent_id)

        self.topic = topics.AGENT
        self.plugin_rpc = MlnxEswitchPluginApi(topics.PLUGIN)
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
        # RPC network init
        self.context = context.get_admin_context_without_session()
        # Handle updates from service
        self.callbacks = MlnxEswitchRpcCallbacks(self.context,
                                                 self)
        self.dispatcher = self.callbacks.create_rpc_dispatcher()
        # Define the listening consumers for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.NETWORK, topics.DELETE],
                     [topics.SECURITY_GROUP, topics.UPDATE]]
        self.connection = agent_rpc.create_consumers(self.dispatcher,
                                                     self.topic,
                                                     consumers)

        report_interval = cfg.CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.LoopingCall(self._report_state)
            heartbeat.start(interval=report_interval)
    def setup_rpc(self, host):
        self.agent_id = 'servicechain_agent_%s' % platform.node()
        self.plugin_rpc = ServiceChainPluginApi(
            sc_constants.SERVICECHAIN_TOPIC, host)

        self.topic = sc_constants.SERVICECHAIN_AGENT_TOPIC

        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)

        self.context = context.get_admin_context_without_session()
        self.dispatcher = [self]
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.NETWORK, topics.DELETE],
                     ['port_flows', 'add', cfg.CONF.host],
                     ['port_flows', 'delete', cfg.CONF.host],
                     ['port_type', 'set', cfg.CONF.host],
                     ['port_type', 'clear', cfg.CONF.host]]

        self.connection = agent_rpc.create_consumers(self.dispatcher,
                                                     self.topic, consumers)
        report_interval = cfg.CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)
Beispiel #30
0
 def __init__(self, host, conf=None):
     self.state_rpc = agent_rpc.PluginReportStateAPI(n_topics.SVMDEVICE_DRIVER_TOPIC)
     self.agent_state = {
         'binary': 'neutron-servicevm-agent',
         'host': host,
         'topic': topics.SERVICEVM_AGENT,
         'configurations': {},
         'start_flag': True,
         'agent_type': constants.AGENT_TYPE_SERVICEVM}
     report_interval = cfg.CONF.AGENT.report_interval
     self.use_call = True
     self._initialize_rpc(host)
     self.topic = topics.SERVICEVM
     self.endpoints = [self]
     consumers = [[topics.SUBNET, topics.UPDATE],
                  [topics.SUBNET, topics.DELETE],
                  [topics.SUBNET, topics.CREATE]]
     self.connection = agent_rpc.create_consumers(self.endpoints,
                                                  self.topic,
                                                  consumers)
     #self._agent_registration()
     super(ServiceVMAgentWithStateReport, self).__init__(host=host,
                                                        conf=conf)
     if report_interval:
         self.heartbeat = loopingcall.FixedIntervalLoopingCall(
             self._report_state)
         #self.heartbeat.start(interval=report_interval)
         self.heartbeat.start(interval=2)
Beispiel #31
0
    def _setup_rpc(self):
        self.agent_id = 'hyperv_%s' % platform.node()
        self.topic = topics.AGENT
        self.plugin_rpc = HyperVPluginApi(topics.PLUGIN)

        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)

        # RPC network init
        self.context = context.get_admin_context_without_session()
        # Handle updates from service
        self.endpoints = [self]
        # Define the listening consumers for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.NETWORK, topics.DELETE],
                     [topics.PORT, topics.DELETE],
                     [constants.TUNNEL, topics.UPDATE]]
        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic,
                                                     consumers)

        self.sec_groups_agent = HyperVSecurityAgent(
            self.context, self.plugin_rpc)
        report_interval = CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)
 def _set_l2_rpc_consumers(self):
     self.endpoints = [L2populationRpcCallback(self)]
     # Define the listening consumers for the agent
     consumers = [[topics.L2POPULATION, topics.UPDATE, self.conf.host]]
     self.connection = agent_rpc.create_consumers(self.endpoints,
                                                  topics.AGENT,
                                                  consumers)
Beispiel #33
0
    def setup_rpc(self):
        """Registers the RPC consumers for the plugin."""
        self.agent_id = 'sea-agent-%s' % cfg.CONF.host
        self.topic = topics.AGENT
        self.plugin_rpc = PVMPluginApi(topics.PLUGIN)
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)

        self.context = ctx.get_admin_context_without_session()

        # Defines what will be listening for incoming events from the
        # controller.
        self.endpoints = [PVMRpcCallbacks(self)]

        # Define the listening consumers for the agent.  ML2 only supports
        # these two update types.
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.NETWORK, topics.DELETE]]

        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic, consumers)

        # Report interval is for the agent health check.
        report_interval = cfg.CONF.AGENT.report_interval
        if report_interval:
            hb = loopingcall.FixedIntervalLoopingCall(self._report_state)
            hb.start(interval=report_interval)
Beispiel #34
0
    def _setup_rpc(self):
        self.topic = topics.AGENT
        self.dispatcher = self._create_rpc_dispatcher()
        consumers = [[topics.SECURITY_GROUP, topics.UPDATE]]

        self.connection = agent_rpc.create_consumers(self.dispatcher,
                                                     self.topic, consumers)
    def setup_rpc(self, host):
        self.agent_id = 'servicechain_agent_%s' % platform.node()
        self.plugin_rpc = ServiceChainPluginApi(sc_constants.SERVICECHAIN_TOPIC, host) 


        self.topic = sc_constants.SERVICECHAIN_AGENT_TOPIC
   
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)

        self.context = context.get_admin_context_without_session()
        self.dispatcher = [self]
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.NETWORK, topics.DELETE],
                     ['port_flows','add',cfg.CONF.host],
                     ['port_flows','delete',cfg.CONF.host],
                     ['port_type','set',cfg.CONF.host],
                     ['port_type','clear',cfg.CONF.host]]
        
        
        self.connection = agent_rpc.create_consumers(self.dispatcher,
                                                     self.topic,
                                                     consumers)
        report_interval = cfg.CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)
Beispiel #36
0
    def _setup_rpc(self):
        self.agent_id = 'nic-switch-agent.%s' % socket.gethostname()
        LOG.info("RPC agent_id: %s", self.agent_id)
        self.topic = topics.AGENT
        self.failed_report_state = False
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS)
        # RPC network init
        # Handle updates from service
        self.endpoints = [SriovNicSwitchRpcCallbacks(self.context, self,
                                                     self.sg_agent)]
        # Define the listening consumers for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.NETWORK, topics.UPDATE],
                     [topics.SECURITY_GROUP, topics.UPDATE],
                     [topics.PORT_BINDING, topics.DEACTIVATE],
                     [topics.PORT_BINDING, topics.ACTIVATE]]
        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic,
                                                     consumers,
                                                     start_listening=False)

        report_interval = cfg.CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)
    def setup_rpc(self):
        self.host = socket.gethostname()
        self.agent_id = 'nec-q-agent.%s' % self.host
        LOG.info(_("RPC agent_id: %s"), self.agent_id)

        self.topic = topics.AGENT
        self.context = q_context.get_admin_context_without_session()

        self.plugin_rpc = NECPluginApi(topics.PLUGIN)
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
        self.sg_agent = SecurityGroupAgentRpc(self.context)

        # RPC network init
        # Handle updates from service
        self.callback_nec = NECAgentRpcCallback(self.context,
                                                self, self.sg_agent)
        self.callback_sg = SecurityGroupAgentRpcCallback(self.context,
                                                         self.sg_agent)
        self.endpoints = [self.callback_nec, self.callback_sg]
        # Define the listening consumer for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.SECURITY_GROUP, topics.UPDATE]]
        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic,
                                                     consumers)

        report_interval = config.CONF.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)
    def _setup_rpc(self):
        self.topic = topics.AGENT
        self.dispatcher = self._create_rpc_dispatcher()
        consumers = [[topics.SECURITY_GROUP, topics.UPDATE]]

        self.connection = agent_rpc.create_consumers(self.dispatcher,
                                                     self.topic,
                                                     consumers)
 def __init__(self):
     self.connection = agent_rpc.create_consumers(
         [self],
         topics.AGENT,
         [topics.L2POPULATION, topics.UPDATE],
         start_listening=False
     )
     self.connection.consume_in_threads()
Beispiel #40
0
    def _setup_rpc(self):
        self.topic = topics.AGENT
        self.endpoints = [HyperVSecurityCallbackMixin(self)]
        consumers = [[topics.SECURITY_GROUP, topics.UPDATE]]

        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic,
                                                     consumers)
    def _setup_rpc(self):

        # LBaaS Callbacks API
        self.plugin_rpc = agent_api.LbaasAgentApi(
            plugin_driver.TOPIC_PROCESS_ON_HOST,
            self.context,
            self.agent_host
        )
        self.driver.plugin_rpc = self.plugin_rpc

        # Agent state Callbacks API
        self.state_rpc = agent_rpc.PluginReportStateAPI(
            plugin_driver.TOPIC_PROCESS_ON_HOST)
        report_interval = self.conf.AGENT.report_interval
        if report_interval:
            heartbeat = loopingcall.FixedIntervalLoopingCall(
                self._report_state)
            heartbeat.start(interval=report_interval)

        if not self.conf.f5_global_routed_mode:
            # Core plugin Callbacks API
            self.driver.tunnel_rpc = agent_api.CoreAgentApi(topics.PLUGIN)

            # L2 Populate plugin Callbacks API
            if self.conf.l2_population:
                self.driver.l2pop_rpc = agent_api.L2PopulationApi()

            # Besides LBaaS Plugin calls... what else to consume

            # tunnel updates to support vxlan and gre endpoint
            # NOTE:  the driver can decide to handle endpoint
            # membership based on the rpc notification or through
            # other means (i.e. as part of a service definition)
            consumers = [[constants.TUNNEL, topics.UPDATE]]
            # L2 populate fdb calls
            # NOTE:  the driver can decide to handle fdb updates
            # or use some other mechanism (i.e. flooding) to
            # learn about port updates.
            if self.conf.l2_population:
                consumers.append([topics.L2POPULATION,
                                  topics.UPDATE, cfg.CONF.host])

            agent_rpc.create_consumers(dispatcher.RpcDispatcher([self]),
                           plugin_driver.TOPIC_LOADBALANCER_AGENT,
                           consumers)
Beispiel #42
0
 def _setup_rpc(self):
     self.context = context.get_admin_context_without_session()
     # Set GBP rpc API
     self.of_rpc = rpc.GBPServerRpcApi(rpc.TOPIC_OPFLEX)
     self.topic = topics.AGENT
     self.endpoints = [self]
     consumers = [[rpc.TOPIC_OPFLEX, rpc.ENDPOINT, topics.UPDATE]]
     self.connection = agent_rpc.create_consumers(
         self.endpoints, self.topic, consumers, start_listening=True)
Beispiel #43
0
 def _setup_rpc(self):
     self.topic = topics.AGENT
     self.plugin_rpc = PluginApi(topics.PLUGIN)
     self.context = q_context.get_admin_context_without_session()
     self.endpoints = [self]
     consumers = [[topics.PORT, topics.UPDATE],
                  [topics.SECURITY_GROUP, topics.UPDATE]]
     self.connection = agent_rpc.create_consumers(self.endpoints,
                                                  self.topic, consumers)
Beispiel #44
0
 def _setup_rpc(self):
     self.topic = topics.AGENT
     self.plugin_rpc = RyuPluginApi(topics.PLUGIN)
     self.context = q_context.get_admin_context_without_session()
     self.dispatcher = self._create_rpc_dispatcher()
     consumers = [[topics.PORT, topics.UPDATE],
                  [topics.SECURITY_GROUP, topics.UPDATE]]
     self.connection = agent_rpc.create_consumers(self.dispatcher,
                                                  self.topic, consumers)
Beispiel #45
0
 def _setup_rpc(self):
     self.topic = topics.AGENT
     self.plugin_rpc = PluginApi(topics.PLUGIN)
     self.context = q_context.get_admin_context_without_session()
     self.dispatcher = dispatcher.RpcDispatcher([self])
     consumers = [[topics.PORT, topics.UPDATE],
                  [topics.SECURITY_GROUP, topics.UPDATE]]
     self.connection = agent_rpc.create_consumers(self.dispatcher,
                                                  self.topic,
                                                  consumers)
    def _setup_sg_rpc(self):
        # RPC network init
        # Handle updates from service
        self.endpoints = [self]
        # Define the listening consumers for the agent
        consumers = [[topics.SECURITY_GROUP, topics.UPDATE, self.conf.host],
                     [topics.PORT, topics.UPDATE, self.conf.host]]

        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     topics.AGENT, consumers)
    def _setup_sg_rpc(self):
        # RPC network init
        # Handle updates from service
        self.endpoints = [self]
        # Define the listening consumers for the agent
        consumers = [[topics.SECURITY_GROUP, topics.UPDATE, self.conf.host],
                     [topics.PORT, topics.UPDATE, self.conf.host]]

        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     topics.AGENT,
                                                     consumers)
Beispiel #48
0
    def _sfc_setup_rpc(self):
        self.sfc_plugin_rpc = SfcPluginApi(sfc_topics.SFC_PLUGIN,
                                           cfg.CONF.host)

        self.topic = sfc_topics.SFC_AGENT
        self.endpoints = [self]
        consumers = [[sfc_topics.PORTFLOW, topics.UPDATE],
                     [sfc_topics.PORTFLOW, topics.DELETE]]

        # subscribe sfc plugin message
        self.connection = agent_rpc.create_consumers(self.endpoints,
                                                     self.topic, consumers)
Beispiel #49
0
    def init_host(self):
        LOG.info(_LI("APIC service agent starting ..."))
        self.state = {
            'binary': BINARY_APIC_SERVICE_AGENT,
            'host': self.host,
            'topic': self.topic,
            'configurations': {},
            'start_flag': True,
            'agent_type': TYPE_APIC_SERVICE_AGENT,
        }

        self.dispatcher = [self, agents_db.AgentExtRpcCallback()]
        self.connection = agent_rpc.create_consumers(
            self.dispatcher, self.topic, [], start_listening=False)
        self.connection.consume_in_threads()
Beispiel #50
0
    def init_host(self):
        LOG.info(_LI("APIC service agent starting ..."))
        self.state = {
            'binary': BINARY_APIC_SERVICE_AGENT,
            'host': self.host,
            'topic': self.topic,
            'configurations': {},
            'start_flag': True,
            'agent_type': TYPE_APIC_SERVICE_AGENT,
        }

        self.dispatcher = [self, agents_db.AgentExtRpcCallback()]
        self.connection = agent_rpc.create_consumers(self.dispatcher,
                                                     self.topic, [],
                                                     start_listening=False)
        self.connection.consume_in_threads()
 def _setup_rpc(self):
     self.topic = topics.AGENT
     self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
     self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
     self.context = q_context.get_admin_context_without_session()
     self.endpoints = [self]
     consumers = [[topics.PORT, topics.UPDATE],
                  [topics.SECURITY_GROUP, topics.UPDATE]]
     self.connection = agent_rpc.create_consumers(self.endpoints,
                                                  self.topic, consumers)
     self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
     report_interval = cfg.CONF.AGENT.report_interval
     if report_interval:
         heartbeat = loopingcall.FixedIntervalLoopingCall(
             self._report_state)
         heartbeat.start(interval=report_interval)
Beispiel #52
0
    def _setup_rpc(self):
        self.agent_id = 'hyperv_%s' % platform.node()
        self.topic = topics.AGENT
        self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)

        # RPC network init
        self.context = context.get_admin_context_without_session()
        # Handle updates from service
        self.dispatcher = self._create_rpc_dispatcher()
        # Define the listening consumers for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.NETWORK, topics.DELETE],
                     [topics.PORT, topics.DELETE],
                     [constants.TUNNEL, topics.UPDATE]]
        self.connection = agent_rpc.create_consumers(self.dispatcher,
                                                     self.topic, consumers)
Beispiel #53
0
    def _sfc_setup_rpc(self):
        self.sfc_plugin_rpc = SfcPluginApi(
            sfc_topics.SFC_PLUGIN, cfg.CONF.host)

        self.topic = sfc_topics.SFC_AGENT
        self.endpoints = [self]
        consumers = [
            [sfc_topics.PORTFLOW, topics.UPDATE],
            [sfc_topics.PORTFLOW, topics.DELETE]
        ]

        # subscribe sfc plugin message
        self.connection = agent_rpc.create_consumers(
            self.endpoints,
            self.topic,
            consumers)
    def setup_rpc(self):
        self.agent_id = "dvs-agent-%s" % cfg.CONF.host
        self.topic = topics.AGENT
        self.plugin_rpc = DVSPluginApi(topics.PLUGIN)
        self.state_rpc = agent_rpc.PluginReportStateAPI(topics.REPORTS)

        # Handle updates from service
        self.endpoints = [self]
        # Define the listening consumers for the agent
        consumers = [
            [topics.PORT, topics.UPDATE],
            [topics.PORT, topics.DELETE],
            [topics.NETWORK, topics.DELETE],
            [topics.SECURITY_GROUP, topics.UPDATE],
            [dvs_const.DVS, topics.UPDATE],
        ]
        self.connection = agent_rpc.create_consumers(self.endpoints, self.topic, consumers, start_listening=False)
 def _setup_rpc(self):
     self.topic = topics.AGENT
     self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)
     self.sg_plugin_rpc = sg_rpc.SecurityGroupServerRpcApi(topics.PLUGIN)
     self.context = q_context.get_admin_context_without_session()
     self.endpoints = [self]
     consumers = [[topics.PORT, topics.UPDATE],
                  [topics.SECURITY_GROUP, topics.UPDATE]]
     self.connection = agent_rpc.create_consumers(self.endpoints,
                                                  self.topic,
                                                  consumers)
     self.state_rpc = agent_rpc.PluginReportStateAPI(topics.PLUGIN)
     report_interval = cfg.CONF.AGENT.report_interval
     if report_interval:
         heartbeat = loopingcall.FixedIntervalLoopingCall(
             self._report_state)
         heartbeat.start(interval=report_interval)
Beispiel #56
0
    def _setup_rpc(self):
        self.agent_id = 'hyperv_%s' % platform.node()
        self.topic = topics.AGENT
        self.plugin_rpc = agent_rpc.PluginApi(topics.PLUGIN)

        # RPC network init
        self.context = context.get_admin_context_without_session()
        # Handle updates from service
        self.dispatcher = self._create_rpc_dispatcher()
        # Define the listening consumers for the agent
        consumers = [[topics.PORT, topics.UPDATE],
                     [topics.NETWORK, topics.DELETE],
                     [topics.PORT, topics.DELETE],
                     [constants.TUNNEL, topics.UPDATE]]
        self.connection = agent_rpc.create_consumers(self.dispatcher,
                                                     self.topic,
                                                     consumers)