예제 #1
0
 def _setup_rpc(self):
     # RPC support
     self.service_topics = {
         svc_constants.CORE: topics.PLUGIN,
         svc_constants.L3_ROUTER_NAT: topics.L3PLUGIN
     }
     self.rpc_context = oslo_context.RequestContext('neutron',
                                                    'neutron',
                                                    is_admin=False)
     self.conn = n_rpc.create_connection(new=True)
     self.endpoints = [
         BridgeRpcCallbacks(),
         securitygroups_rpc.SecurityGroupServerRpcCallback(),
         dhcp_rpc.DhcpRpcCallback(),
         l3_rpc.L3RpcCallback(),
         agents_db.AgentExtRpcCallback(),
         metadata_rpc.MetadataRpcCallback()
     ]
     for svc_topic in self.service_topics.values():
         self.conn.create_consumer(svc_topic, self.endpoints, fanout=False)
     # Consume from all consumers in threads
     self.conn.consume_in_threads()
     self.notifier = AgentNotifierApi(topics.AGENT)
     self.agent_notifiers[q_const.AGENT_TYPE_DHCP] = (
         dhcp_rpc_agent_api.DhcpAgentNotifyAPI())
     self.agent_notifiers[q_const.AGENT_TYPE_L3] = (
         l3_rpc_agent_api.L3AgentNotifyAPI())
예제 #2
0
파일: nec_plugin.py 프로젝트: rodis/neutron
    def setup_rpc(self):
        self.service_topics = {
            svc_constants.CORE: topics.PLUGIN,
            svc_constants.L3_ROUTER_NAT: topics.L3PLUGIN
        }
        self.conn = n_rpc.create_connection(new=True)
        self.notifier = NECPluginV2AgentNotifierApi(topics.AGENT)
        self.agent_notifiers[const.AGENT_TYPE_DHCP] = (
            dhcp_rpc_agent_api.DhcpAgentNotifyAPI())
        self.agent_notifiers[const.AGENT_TYPE_L3] = (
            nec_router.L3AgentNotifyAPI())

        # NOTE: callback_sg is referred to from the sg unit test.
        self.callback_sg = securitygroups_rpc.SecurityGroupServerRpcCallback()
        self.endpoints = [
            NECPluginV2RPCCallbacks(self.safe_reference),
            dhcp_rpc.DhcpRpcCallback(),
            l3_rpc.L3RpcCallback(), self.callback_sg,
            agents_db.AgentExtRpcCallback(),
            metadata_rpc.MetadataRpcCallback()
        ]
        for svc_topic in self.service_topics.values():
            self.conn.create_consumer(svc_topic, self.endpoints, fanout=False)
        # Consume from all consumers in threads
        self.conn.consume_in_threads()
예제 #3
0
 def start_rpc_listeners(self):
     # RPC support
     self.topic = topics.L3PLUGIN
     self.conn = n_rpc.Connection()
     self.endpoints = [l3_rpc.L3RpcCallback()]
     self.conn.create_consumer(self.topic, self.endpoints, fanout=False)
     return self.conn.consume_in_threads()
예제 #4
0
    def test_ensure_host_set_on_ports_binds_correctly(self):
        network_id = self._create_network(self.core_plugin, self.admin_ctx)
        subnet = self._create_subnet(self.core_plugin, self.admin_ctx,
                                     network_id)
        interface_info = {'subnet_id': subnet['id']}

        router = self._create_router()
        self._bind_router(router['id'])
        self.plugin.add_router_interface(self.admin_ctx, router['id'],
                                         interface_info)
        port = self._get_first_interface(router['id'])
        self.assertEqual('', port[portbindings.HOST_ID])

        # Update the router object to include the first interface
        router = (self.plugin.list_active_sync_routers_on_active_l3_agent(
            self.admin_ctx, self.agent1['host'], [router['id']]))[0]

        # ensure_host_set_on_ports binds an unbound port
        callback = l3_rpc.L3RpcCallback()
        callback._l3plugin = self.plugin
        callback._ensure_host_set_on_ports(self.admin_ctx, self.agent1['host'],
                                           [router])
        port = self._get_first_interface(router['id'])
        self.assertEqual(self.agent1['host'], port[portbindings.HOST_ID])

        # ensure_host_set_on_ports does not rebind a bound port
        router = (self.plugin.list_active_sync_routers_on_active_l3_agent(
            self.admin_ctx, self.agent1['host'], [router['id']]))[0]
        callback._ensure_host_set_on_ports(self.admin_ctx, self.agent2['host'],
                                           [router])
        port = self._get_first_interface(router['id'])
        self.assertEqual(self.agent1['host'], port[portbindings.HOST_ID])
예제 #5
0
    def _setup_rpc(self):

        self.endpoints = [l3_rpc.L3RpcCallback(),
                          agents_db.AgentExtRpcCallback(),
                          metadata_rpc.MetadataRpcCallback()]
        if cfg.CONF.df.use_centralized_ipv6_DHCP:
            self.endpoints.append(dhcp_rpc.DhcpRpcCallback())
예제 #6
0
 def setUp(self):
     super(TestL3RpcCallback, self).setUp()
     self.setup_coreplugin(test_db_base_plugin_v2.DB_PLUGIN_KLASS)
     self.plugin = directory.get_plugin()
     self.ctx = context.get_admin_context()
     cfg.CONF.set_override('ipv6_pd_enabled', True)
     self.callbacks = l3_rpc.L3RpcCallback()
     self.network = self._prepare_network()
예제 #7
0
 def setup_rpc(self):
     self.topic = topics.L3PLUGIN
     self.conn = n_rpc.create_connection(new=True)
     self.agent_notifiers.update(
         {q_const.AGENT_TYPE_L3: l3_rpc_agent_api.L3AgentNotifyAPI()})
     self.endpoints = [l3_rpc.L3RpcCallback()]
     self.conn.create_consumer(self.topic, self.endpoints, fanout=False)
     self.conn.consume_in_threads()
예제 #8
0
 def start_rpc_listeners(self):
     self.topic = topics.L3PLUGIN
     self.conn = n_rpc.Connection()
     self.agent_notifiers.update(
         {const.AGENT_TYPE_L3: l3_rpc_agent_api.L3AgentNotifyAPI()})
     self.endpoints = [l3_rpc.L3RpcCallback()]
     self.conn.create_consumer(self.topic, self.endpoints, fanout=False)
     return self.conn.consume_in_threads()
예제 #9
0
 def setUp(self):
     super(TestL3RpcCallback, self).setUp()
     self.setup_coreplugin(test_db_base_plugin_v2.DB_PLUGIN_KLASS)
     self.plugin = manager.NeutronManager.get_plugin()
     self.ctx = context.get_admin_context()
     cfg.CONF.set_override('default_ipv6_subnet_pool',
                           constants.IPV6_PD_POOL_ID)
     self.callbacks = l3_rpc.L3RpcCallback()
     self.network = self._prepare_network()
예제 #10
0
 def start_rpc_listeners(self):
     LOG.info('%s(): caller(): %s', log_utils.get_fname(1),
              log_utils.get_fname(2))
     # RPC support
     self.topic = topics.L3PLUGIN
     self.conn = n_rpc.Connection()
     self.endpoints = [l3_rpc.L3RpcCallback()]
     self.conn.create_consumer(self.topic, self.endpoints, fanout=False)
     return self.conn.consume_in_threads()
예제 #11
0
 def _setup_rpc(self):
     self.service_topics = {svc_constants.CORE: topics.PLUGIN,
                            svc_constants.L3_ROUTER_NAT: topics.L3PLUGIN}
     self.conn = n_rpc.create_connection(new=True)
     self.notifier = AgentNotifierApi(topics.AGENT)
     self.endpoints = [RyuRpcCallbacks(self.ofp_api_host),
                       securitygroups_rpc.SecurityGroupServerRpcCallback(),
                       dhcp_rpc.DhcpRpcCallback(),
                       l3_rpc.L3RpcCallback()]
     for svc_topic in self.service_topics.values():
         self.conn.create_consumer(svc_topic, self.endpoints, fanout=False)
     self.conn.consume_in_threads()
예제 #12
0
    def test_router_auto_scheduling(self):
        router = self._create_router()
        agents = self.l3_plugin.list_l3_agents_hosting_router(
            self.context, router['id'])
        # router is not scheduled yet
        self.assertEqual([], agents['agents'])

        l3_rpc_handler = l3_rpc.L3RpcCallback()
        # router should be auto scheduled once l3 agent requests router ids
        l3_rpc_handler.get_router_ids(self.context, self.l3_agent['host'])
        agents = self.l3_plugin.list_l3_agents_hosting_router(
            self.context, router['id'])
        self.assertEqual(1, len(agents['agents']))
        self.assertEqual(self.l3_agent['id'], agents['agents'][0]['id'])
예제 #13
0
 def setup_rpc(self):
     # RPC support
     self.topic = topics.L3PLUGIN
     self.conn = n_rpc.create_connection()
     self.agent_notifiers[bc.constants.AGENT_TYPE_L3] = (
         l3_rpc_agent_api.L3AgentNotifyAPI())
     self.agent_notifiers[cisco_constants.AGENT_TYPE_L3_CFG] = (
         l3_router_rpc_cfg_agent_api.L3RouterCfgAgentNotifyAPI(self))
     self.endpoints = [l3_rpc.L3RpcCallback(),
                       l3cfg_rpc.L3RouterCfgRpcCallback(self)]
     self.conn.create_consumer(self.topic, self.endpoints,
                               fanout=False)
     # Consume from all consumers in threads
     self.conn.consume_in_threads()
예제 #14
0
 def _setup_rpc(self):
     # RPC support
     self.service_topics = {svc_constants.CORE: topics.PLUGIN,
                            svc_constants.L3_ROUTER_NAT: topics.L3PLUGIN}
     self.conn = n_rpc.create_connection(new=True)
     self.notifier = agent_notifier_api.AgentNotifierApi(
         topics.AGENT)
     self.endpoints = [rpc_callbacks.HyperVRpcCallbacks(self.notifier),
                       dhcp_rpc.DhcpRpcCallback(),
                       l3_rpc.L3RpcCallback(),
                       agents_db.AgentExtRpcCallback()]
     for svc_topic in self.service_topics.values():
         self.conn.create_consumer(svc_topic, self.endpoints, fanout=False)
     # Consume from all consumers in threads
     self.conn.consume_in_threads()
예제 #15
0
 def test_router_auto_schedule_with_l3agent_and_openflow(self):
     with contextlib.nested(
             self.router(),
             self.router(arg_list=('provider', ),
                         provider='openflow')) as (r1, r2):
         l3_rpc_cb = l3_rpc.L3RpcCallback()
         self._register_agent_states()
         ret_a = l3_rpc_cb.sync_routers(self.adminContext, host=L3_HOSTA)
         ret_b = l3_rpc_cb.sync_routers(self.adminContext, host=L3_HOSTB)
         l3_agents = self._list_l3_agents_hosting_router(r1['router']['id'])
         self.assertEqual(1, len(ret_a))
         self.assertFalse(len(ret_b))
         self.assertIn(r1['router']['id'], [r['id'] for r in ret_a])
         self.assertNotIn(r2['router']['id'], [r['id'] for r in ret_a])
     self.assertEqual(1, len(l3_agents['agents']))
     self.assertEqual(L3_HOSTA, l3_agents['agents'][0]['host'])
예제 #16
0
    def setup_dhcpmeta_access(self):
        # Ok, so we're going to add L3 here too with the DHCP
        self.conn = n_rpc.create_connection(new=True)
        self.conn.create_consumer(
            topics.PLUGIN,
            [dhcp_rpc.DhcpRpcCallback(),
             agents_db.AgentExtRpcCallback()],
            fanout=False)

        self.conn.create_consumer(topics.L3PLUGIN, [l3_rpc.L3RpcCallback()],
                                  fanout=False)

        # Consume from all consumers in a thread
        self.conn.consume_in_threads()

        self.handle_network_dhcp_access_delegate = noop
        self.handle_port_dhcp_access_delegate = noop
        self.handle_port_metadata_access_delegate = noop
        self.handle_metadata_access_delegate = noop
예제 #17
0
 def _setup_rpc(self):
     self.conn = n_rpc.create_connection(new=True)
     self.endpoints = [
         dhcp_rpc.DhcpRpcCallback(),
         l3_rpc.L3RpcCallback(),
         agents_db.AgentExtRpcCallback(),
         metadata_rpc.MetadataRpcCallback()
     ]
     self.agent_notifiers[const.AGENT_TYPE_L3] = (
         l3_rpc_agent_api.L3AgentNotifyAPI())
     self.agent_notifiers[const.AGENT_TYPE_DHCP] = (
         dhcp_rpc_agent_api.DhcpAgentNotifyAPI())
     self.network_scheduler = importutils.import_object(
         cfg.CONF.network_scheduler_driver)
     self.supported_extension_aliases.extend(
         ['agent', 'dhcp_agent_scheduler'])
     self.conn.create_consumer(topics.PLUGIN, self.endpoints, fanout=False)
     self.conn.create_consumer(topics.L3PLUGIN,
                               self.endpoints,
                               fanout=False)
     self.conn.consume_in_threads()
예제 #18
0
파일: plugin.py 프로젝트: dlq84/neutron
    def setup_rpc(self):
        # RPC support
        self.service_topics = {
            svc_constants.CORE: topics.PLUGIN,
            svc_constants.L3_ROUTER_NAT: topics.L3PLUGIN
        }
        self.conn = n_rpc.create_connection(new=True)
        self.notifier = NVSDPluginV2AgentNotifierApi(topics.AGENT)
        self.agent_notifiers[q_const.AGENT_TYPE_DHCP] = (
            dhcp_rpc_agent_api.DhcpAgentNotifyAPI())
        self.agent_notifiers[q_const.AGENT_TYPE_L3] = (
            l3_rpc_agent_api.L3AgentNotifyAPI())
        self.endpoints = [
            securitygroups_rpc.SecurityGroupServerRpcCallback(),
            dhcp_rpc.DhcpRpcCallback(),
            l3_rpc.L3RpcCallback(),
            agents_db.AgentExtRpcCallback()
        ]
        for svc_topic in self.service_topics.values():
            self.conn.create_consumer(svc_topic, self.endpoints, fanout=False)

        # Consume from all consumers in threads
        self.conn.consume_in_threads()
예제 #19
0
bind = session.get_bind()
s = time.time()
floating_ips = [{'port_id': '0083ad87-9c9b-4711-8242-f4e8fbcf6a70'}, {'port_id': '0283cc9a-1330-4f44-9b96-f49692995038'}, {'port_id': '03936f53-5788-431b-bbdf-fcaca18c7da5'}]
sql = '''
    SELECT 
        ports.id AS port_id, ports.device_id AS device_id, ports.device_owner AS device_owner, 
        ml2_port_bindings.host AS host
    FROM ports 
    LEFT OUTER JOIN ml2_port_bindings ON ports.id = ml2_port_bindings.port_id 
    WHERE id in("%s")
''' % '", "'.join([fip['port_id'] for fip in floating_ips])
cur = bind.execute(sql)
res = cur.fetchall()
print res
print 'total time: %s' % (time.time() - s)
"""

# '''
l3_rpc_callback = l3_rpc.L3RpcCallback()

s = time.time()
# routers = l3_rpc_callback.l3plugin.get_sync_data(context, ['e2321c88-b4b0-4c20-aba3-c041160bbad2'], True)
routers = l3_rpc_callback.sync_routers(context, host='node3')
# pp(routers)
print 'total time: %s' % (time.time() - s)
# '''

#
# run it like this:
# python /home/chao/query.py --config-file /home/chao/neutron.conf --config-file /home/chao/plugin.ini --log-file /home/chao/server.log