# 1.1 Support Security Group RPC
target = messaging.Target(version='1.1')
- def __init__(self, context, agent):
+ def __init__(self, context, agent, sg_agent):
super(LinuxBridgeRpcCallbacks, self).__init__()
self.context = context
self.agent = agent
- self.sg_agent = agent
+ self.sg_agent = sg_agent
def network_delete(self, context, **kwargs):
LOG.debug("network_delete received")
pass
-class LinuxBridgeNeutronAgentRPC(sg_rpc.SecurityGroupAgentRpcMixin):
+class LinuxBridgeSecurityGroupAgent(sg_rpc.SecurityGroupAgentRpcMixin):
+ def __init__(self, context, plugin_rpc, root_helper):
+ self.context = context
+ self.plugin_rpc = plugin_rpc
+ self.root_helper = root_helper
+ self.init_firewall()
+
+
+class LinuxBridgeNeutronAgentRPC(object):
def __init__(self, interface_mappings, polling_interval,
root_helper):
# stores received port_updates for processing by the main loop
self.updated_devices = set()
+ self.context = context.get_admin_context_without_session()
+ self.plugin_rpc = LinuxBridgePluginApi(topics.PLUGIN)
+ self.sg_agent = LinuxBridgeSecurityGroupAgent(self.context,
+ self.plugin_rpc, self.root_helper)
self.setup_rpc(interface_mappings.values())
- self.init_firewall()
def _report_state(self):
try:
LOG.info(_LI("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.endpoints = [LinuxBridgeRpcCallbacks(self.context, self)]
+ 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],
resync_a = False
resync_b = False
- self.prepare_devices_filter(device_info.get('added'))
+ self.sg_agent.prepare_devices_filter(device_info.get('added'))
if device_info.get('updated'):
- self.refresh_firewall()
+ self.sg_agent.refresh_firewall()
# Updated devices are processed the same as new ones, as their
# admin_state_up may have changed. The set union prevents duplicating
def treat_devices_removed(self, devices):
resync = False
- self.remove_devices_filter(devices)
+ self.sg_agent.remove_devices_filter(devices)
for device in devices:
LOG.info(_LI("Attachment %s removed"), device)
details = None
devices = [DEVICE_1]
with contextlib.nested(
mock.patch.object(agent.plugin_rpc, "update_device_down"),
- mock.patch.object(agent, "remove_devices_filter")
+ mock.patch.object(agent.sg_agent, "remove_devices_filter")
) as (fn_udd, fn_rdf):
fn_udd.return_value = {'device': DEVICE_1,
'exists': True}
devices = [DEVICE_1]
with contextlib.nested(
mock.patch.object(agent.plugin_rpc, "update_device_down"),
- mock.patch.object(agent, "remove_devices_filter")
+ mock.patch.object(agent.sg_agent, "remove_devices_filter")
) as (fn_udd, fn_rdf):
fn_udd.return_value = {'device': DEVICE_1,
'exists': False}
devices = [DEVICE_1]
with contextlib.nested(
mock.patch.object(agent.plugin_rpc, "update_device_down"),
- mock.patch.object(agent, "remove_devices_filter")
+ mock.patch.object(agent.sg_agent, "remove_devices_filter")
) as (fn_udd, fn_rdf):
fn_udd.side_effect = Exception()
with mock.patch.object(linuxbridge_neutron_agent.LOG,
'added': set(['tap3', 'tap4']),
'updated': set(['tap2', 'tap3']),
'removed': set(['tap1'])}
- agent.prepare_devices_filter = mock.Mock()
- agent.refresh_firewall = mock.Mock()
+ agent.sg_agent.prepare_devices_filter = mock.Mock()
+ agent.sg_agent.refresh_firewall = mock.Mock()
agent.treat_devices_added_updated = mock.Mock(return_value=False)
agent.treat_devices_removed = mock.Mock(return_value=False)
agent.process_network_devices(device_info)
- agent.prepare_devices_filter.assert_called_with(set(['tap3', 'tap4']))
- self.assertTrue(agent.refresh_firewall.called)
+ agent.sg_agent.prepare_devices_filter.assert_called_with(
+ set(['tap3', 'tap4']))
+ self.assertTrue(agent.sg_agent.refresh_firewall.called)
agent.treat_devices_added_updated.assert_called_with(set(['tap2',
'tap3',
'tap4']))
self.lb_rpc = linuxbridge_neutron_agent.LinuxBridgeRpcCallbacks(
object(),
- FakeLBAgent()
+ FakeLBAgent(),
+ object()
)
self.root_helper = cfg.CONF.AGENT.root_helper