Debian Codegraph @

neutron_lib/agent/topics.py

raw
1 # Copyright (c) 2012 OpenStack Foundation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 # http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12 # implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15
16 from neutron_lib.api.definitions import network
17 from neutron_lib.api.definitions import port
18 from neutron_lib.api.definitions import portbindings_extended
19 from neutron_lib.api.definitions import subnet
20
21
22 NETWORK = network.RESOURCE_NAME
23 SUBNET = subnet.RESOURCE_NAME
24 PORT = port.RESOURCE_NAME
25 PORT_BINDING = portbindings_extended.RESOURCE_NAME
26 SECURITY_GROUP = 'security_group'
27 L2POPULATION = 'l2population'
28 DVR = 'dvr'
29 RESOURCES = 'resources'
30
31 CREATE = 'create'
32 DELETE = 'delete'
33 UPDATE = 'update'
34 ACTIVATE = 'activate'
35 DEACTIVATE = 'deactivate'
36
37 AGENT = 'q-agent-notifier'
38 PLUGIN = 'q-plugin'
39 SERVER_RESOURCE_VERSIONS = 'q-server-resource-versions'
40 L3PLUGIN = 'q-l3-plugin'
41 REPORTS = 'q-reports-plugin'
42 DHCP = 'q-dhcp-notifer'
43 METERING_PLUGIN = 'q-metering-plugin'
44
45 L3_AGENT = 'l3_agent'
46 DHCP_AGENT = 'dhcp_agent'
47 METERING_AGENT = 'metering_agent'
48
49 RESOURCE_TOPIC_PATTERN = "neutron-vo-%(resource_type)s-%(version)s"
50
51
52 def get_topic_name(prefix, table, operation, host=None):
53 """Create a topic name.
54
55 The topic name needs to be synced between the agent and the
56 plugin. The plugin will send a fanout message to all of the
57 listening agents so that the agents in turn can perform their
58 updates accordingly.
59
60 :param prefix: Common prefix for the plugin/agent message queues.
61 :param table: The table in question (NETWORK, SUBNET, PORT).
62 :param operation: The operation that invokes notification (CREATE,
63 DELETE, UPDATE)
64 :param host: Add host to the topic
65 :returns: The topic name.
66 """
67 if host:
68 return f'{prefix}-{table}-{operation}.{host}'
69 return f'{prefix}-{table}-{operation}'