Exemple #1
0
def create_consumers(endpoints, prefix, topic_details, start_listening=True):
    """Create agent RPC consumers.

    :param endpoints: The list of endpoints to process the incoming messages.
    :param prefix: Common prefix for the plugin/agent message queues.
    :param topic_details: A list of topics. Each topic has a name, an
                          operation, and an optional host param keying the
                          subscription to topic.host for plugin calls.
    :param start_listening: if True, it starts the processing loop

    :returns: A common Connection.
    """

    connection = n_rpc.Connection()
    for details in topic_details:
        topic, operation, node_name = itertools.islice(
            itertools.chain(details, [None]), 3)

        topic_name = topics.get_topic_name(prefix, topic, operation)
        connection.create_consumer(topic_name, endpoints, fanout=True)
        if node_name:
            node_topic_name = '%s.%s' % (topic_name, node_name)
            connection.create_consumer(node_topic_name,
                                       endpoints,
                                       fanout=False)
    if start_listening:
        connection.consume_in_threads()
    return connection
Exemple #2
0
 def __init__(self, topic=topics.AGENT):
     self.topic = topic
     self.topic_l2pop_update = topics.get_topic_name(topic,
                                                     topics.L2POPULATION,
                                                     topics.UPDATE)
     target = oslo_messaging.Target(topic=topic, version='1.0')
     self.client = n_rpc.get_client(target)
Exemple #3
0
    def __init__(self, topic):
        self.topic = topic
        self.topic_network_delete = topics.get_topic_name(topic,
                                                          topics.NETWORK,
                                                          topics.DELETE)
        self.topic_port_update = topics.get_topic_name(topic,
                                                       topics.PORT,
                                                       topics.UPDATE)
        self.topic_port_delete = topics.get_topic_name(topic,
                                                       topics.PORT,
                                                       topics.DELETE)
        self.topic_network_update = topics.get_topic_name(topic,
                                                          topics.NETWORK,
                                                          topics.UPDATE)

        target = oslo_messaging.Target(topic=topic, version='1.0')
        self.client = n_rpc.get_client(target)
Exemple #4
0
 def ask_agent_to_delete_flow_rules(self, context, flow_rule):
     LOG.debug('Ask agent on the specific host to delete flows ')
     LOG.debug('flow_rule: %s', flow_rule)
     host = flow_rule.get('host')
     cctxt = self.client.prepare(
         topic=topics.get_topic_name(
             self.topic, sfc_topics.PORTFLOW, topics.DELETE),
         server=host)
     cctxt.cast(context, 'delete_flow_rules', flowrule_entries=flow_rule)
 def test_enhanced_sg_provider_updated(self):
     rpcapi = ovsvapp_rpc.OVSvAppAgentNotifyAPI(topics.AGENT)
     self._test_rpc_api(rpcapi,
                        topics.get_topic_name(topics.AGENT,
                                              self.sg_topic,
                                              topics.UPDATE),
                        'enhanced_sg_provider_updated', rpc_method='cast',
                        fanout=True,
                        network_id=FAKE_NETWORK_ID)
 def security_groups_rule_updated(self, context, security_groups):
     sg_topic = ovsvapp_const.OVSVAPP + '_' + topics.SECURITY_GROUP
     cctxt = self.client.prepare(
         topic=topics.get_topic_name(self.topic,
                                     sg_topic,
                                     topics.UPDATE),
         fanout=True)
     cctxt.cast(context, 'security_groups_rule_updated',
                security_groups=security_groups)
Exemple #7
0
 def test_port_delete(self):
     rpcapi = plugin_rpc.AgentNotifierApi(topics.AGENT)
     self._test_rpc_api(
         rpcapi,
         topics.get_topic_name(topics.AGENT,
                               topics.PORT,
                               topics.DELETE),
         'port_delete', rpc_method='cast',
         fanout=True, port_id='fake_port')
 def enhanced_sg_provider_updated(self, context, network_id):
     sg_topic = ovsvapp_const.OVSVAPP + '_' + topics.SECURITY_GROUP
     cctxt = self.client.prepare(
         topic=topics.get_topic_name(self.topic,
                                     sg_topic,
                                     topics.UPDATE),
         fanout=True)
     cctxt.cast(context, 'enhanced_sg_provider_updated',
                network_id=network_id)
Exemple #9
0
 def test_delete_network(self):
     rpcapi = plugin_rpc.AgentNotifierApi(topics.AGENT)
     self._test_rpc_api(
             rpcapi,
             topics.get_topic_name(topics.AGENT,
                                   topics.NETWORK,
                                   topics.DELETE),
             'network_delete', rpc_method='cast',
             fanout=True, network_id='fake_request_spec')
 def security_groups_provider_updated(self, context,
                                      devices_to_update=None):
     sg_topic = ovsvapp_const.OVSVAPP + '_' + topics.SECURITY_GROUP
     cctxt = self.client.prepare(
         topic=topics.get_topic_name(self.topic,
                                     sg_topic,
                                     topics.UPDATE),
         fanout=True)
     cctxt.cast(context, 'security_groups_provider_updated',
                devices_to_update=devices_to_update)
Exemple #11
0
 def test_tunnel_delete(self):
     rpcapi = plugin_rpc.AgentNotifierApi(topics.AGENT)
     self._test_rpc_api(
             rpcapi,
             topics.get_topic_name(topics.AGENT,
                                   type_tunnel.TUNNEL,
                                   topics.DELETE),
             'tunnel_delete', rpc_method='cast',
             fanout=True,
             tunnel_ip='fake_ip', tunnel_type='gre')
 def test_device_update(self):
     rpcapi = ovsvapp_rpc.OVSvAppAgentNotifyAPI(topics.AGENT)
     self._test_rpc_api(rpcapi,
                        topics.get_topic_name(topics.AGENT,
                                              self.cluster_device_topic,
                                              topics.UPDATE),
                        'device_update', rpc_method='cast',
                        fanout=True,
                        device_data='fake_device_data',
                        cluster_id=FAKE_CLUSTER_ID)
 def test_device_delete(self):
     rpcapi = ovsvapp_rpc.OVSvAppAgentNotifyAPI(topics.AGENT)
     self._test_rpc_api(rpcapi,
                        topics.get_topic_name(topics.AGENT,
                                              self.cluster_device_topic,
                                              topics.DELETE),
                        'device_delete', rpc_method='cast',
                        fanout=True,
                        network_info='fake_network_info',
                        host=FAKE_HOST,
                        cluster_id=FAKE_CLUSTER_ID)
Exemple #14
0
 def test_port_update(self):
     rpcapi = plugin_rpc.AgentNotifierApi(topics.AGENT)
     self._test_rpc_api(
             rpcapi,
             topics.get_topic_name(topics.AGENT,
                                   topics.PORT,
                                   topics.UPDATE),
             'port_update', rpc_method='cast',
             fanout=True, port='fake_port',
             network_type='fake_network_type',
             segmentation_id='fake_segmentation_id',
             physical_network='fake_physical_network')
 def test_device_create(self):
     rpcapi = ovsvapp_rpc.OVSvAppAgentNotifyAPI(topics.AGENT)
     self._test_rpc_api(rpcapi,
                        topics.get_topic_name(topics.AGENT,
                                              self.cluster_device_topic,
                                              topics.CREATE),
                        'device_create', rpc_method='cast',
                        fanout=True,
                        device='fake_device',
                        ports='fake_ports',
                        sg_rules='fake_sg_rules',
                        cluster_id=FAKE_CLUSTER_ID)
Exemple #16
0
 def _get_security_group_topic(self, host=None):
     return topics.get_topic_name(topics.AGENT, dvs_const.DVS,
                                  topics.UPDATE, host)
Exemple #17
0
 def _get_tunnel_update_topic(self):
     return topics.get_topic_name(self.topic,
                                  TUNNEL,
                                  topics.UPDATE)
Exemple #18
0
 def _get_tunnel_delete_topic(self):
     return topics.get_topic_name(self.topic,
                                  TUNNEL,
                                  topics.DELETE)
Exemple #19
0
 def _get_tunnel_update_topic(self):
     return topics.get_topic_name(self.topic,
                                  TUNNEL,
                                  topics.UPDATE)
 def _get_security_group_topic(self):
     return topics.get_topic_name(self.topic,
                                  topics.SECURITY_GROUP,
                                  topics.UPDATE)
Exemple #21
0
 def _get_tunnel_delete_topic(self):
     return topics.get_topic_name(self.topic, TUNNEL, topics.DELETE)
Exemple #22
0
 def _get_security_group_topic(self):
     return topics.get_topic_name(self.topic, topics.SECURITY_GROUP,
                                  topics.UPDATE)
 def _get_device_topic(self, action, cluster_id):
     cluster_device_topic = ovsvapp_utils.get_cluster_based_topic(
         cluster_id, ovsvapp_const.DEVICE)
     return topics.get_topic_name(self.topic,
                                  cluster_device_topic,
                                  action)
Exemple #24
0
 def _get_dvr_update_topic(self):
     return topics.get_topic_name(self.topic, topics.DVR, topics.UPDATE)
Exemple #25
0
 def _get_dvr_update_topic(self):
     return topics.get_topic_name(self.topic,
                                  topics.DVR,
                                  topics.UPDATE)
 def _get_security_group_topic(self, host=None):
     return topics.get_topic_name(topics.AGENT,
                                  dvs_const.DVS,
                                  topics.UPDATE, host)