Enable DHCP agent to work with plugin when L2 agents use DB polling

Fixes bug 1039393

By default the plugins will enable the RPC support. If and only if
the agent RPC is enabled will RPC notification messages be sent to the
agents

Change-Id: I4fb003a2b477e5e647c3ee408b449e71b3f5a883
This commit is contained in:
Gary Kotton 2012-08-21 03:07:39 -04:00
parent 6c7582e7a7
commit ab1b117f5b
2 changed files with 10 additions and 12 deletions

View File

@ -156,9 +156,8 @@ class LinuxBridgePluginV2(db_base_plugin_v2.QuantumDbPluginV2):
db.initialize()
self._parse_network_vlan_ranges()
db.sync_network_states(self.network_vlan_ranges)
self.rpc = cfg.CONF.AGENT.rpc
if self.rpc:
self._setup_rpc()
self.agent_rpc = cfg.CONF.AGENT.rpc
self._setup_rpc()
LOG.debug("Linux Bridge Plugin initialization complete")
def _setup_rpc(self):
@ -326,7 +325,7 @@ class LinuxBridgePluginV2(db_base_plugin_v2.QuantumDbPluginV2):
binding.vlan_id, self.network_vlan_ranges)
# the network_binding record is deleted via cascade from
# the network record, so explicit removal is not necessary
if self.rpc:
if self.agent_rpc:
self.notifier.network_delete(self.rpc_context, id)
def get_network(self, context, id, fields=None, verbose=None):
@ -344,11 +343,11 @@ class LinuxBridgePluginV2(db_base_plugin_v2.QuantumDbPluginV2):
return [self._fields(net, fields) for net in nets]
def update_port(self, context, id, port):
if self.rpc:
if self.agent_rpc:
original_port = super(LinuxBridgePluginV2, self).get_port(context,
id)
port = super(LinuxBridgePluginV2, self).update_port(context, id, port)
if self.rpc:
if self.agent_rpc:
if original_port['admin_state_up'] != port['admin_state_up']:
binding = db.get_network_binding(context.session,
port['network_id'])

View File

@ -197,9 +197,8 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
# update the vlan_id table based on current configuration
ovs_db_v2.update_vlan_id_pool()
self.rpc = cfg.CONF.AGENT.rpc
if cfg.CONF.AGENT.rpc:
self.setup_rpc()
self.agent_rpc = cfg.CONF.AGENT.rpc
self.setup_rpc()
def setup_rpc(self):
# RPC support
@ -335,7 +334,7 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
vlan_id = ovs_db_v2.get_vlan(id)
result = super(OVSQuantumPluginV2, self).delete_network(context, id)
ovs_db_v2.release_vlan_id(vlan_id)
if self.rpc:
if self.agent_rpc:
self.notifier.network_delete(self.context, id)
return result
@ -354,11 +353,11 @@ class OVSQuantumPluginV2(db_base_plugin_v2.QuantumDbPluginV2,
return [self._fields(net, fields) for net in nets]
def update_port(self, context, id, port):
if self.rpc:
if self.agent_pc:
original_port = super(OVSQuantumPluginV2, self).get_port(context,
id)
port = super(OVSQuantumPluginV2, self).update_port(context, id, port)
if self.rpc:
if self.agent_rpc:
if original_port['admin_state_up'] != port['admin_state_up']:
vlan_id = ovs_db_v2.get_vlan(port['network_id'])
self.notifier.port_update(self.context, port, vlan_id)