예제 #1
0
 def test_provision_local_vlan_vlan_fail(self):
     a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE, self.TUN_BRIDGE,
                                           '10.0.0.1', self.NET_MAPPING,
                                           'sudo', 2, ['gre'],
                                           self.VETH_MTU)
     a.provision_local_vlan(NET_UUID, p_const.TYPE_VLAN, 'net2', LS_ID)
     self._verify_mock_calls()
예제 #2
0
    def test_daemon_loop(self):
        reply2 = {
            'current': set(['tap0']),
            'added': set(['tap2']),
            'removed': set([])
        }

        reply3 = {
            'current': set(['tap2']),
            'added': set([]),
            'removed': set(['tap0'])
        }

        with contextlib.nested(
                mock.patch.object(log.ContextAdapter, 'exception'),
                mock.patch.object(ovs_neutron_agent.OVSNeutronAgent,
                                  'scan_ports'),
                mock.patch.object(
                    ovs_neutron_agent.OVSNeutronAgent,
                    'process_network_ports')) as (log_exception, scan_ports,
                                                  process_network_ports):
            log_exception.side_effect = Exception(
                'Fake exception to get out of the loop')
            scan_ports.side_effect = [reply2, reply3]
            process_network_ports.side_effect = [
                False,
                Exception('Fake exception to get out of the loop')
            ]

            q_agent = ovs_neutron_agent.OVSNeutronAgent(
                self.INT_BRIDGE, self.TUN_BRIDGE, '10.0.0.1', self.NET_MAPPING,
                'sudo', 2, ['gre'], self.VETH_MTU)

            # Hack to test loop
            # We start method and expect it will raise after 2nd loop
            # If something goes wrong, assert_has_calls below will catch it
            try:
                q_agent.daemon_loop()
            except Exception:
                pass

        # FIXME(salv-orlando): There should not be assertions on log messages
        log_exception.assert_called_once_with(
            "Error while processing VIF ports")
        scan_ports.assert_has_calls(
            [mock.call(set(), set()),
             mock.call(set(['tap0']), set())])
        process_network_ports.assert_has_calls([
            mock.call({
                'current': set(['tap0']),
                'removed': set([]),
                'added': set(['tap2'])
            }),
            mock.call({
                'current': set(['tap2']),
                'removed': set(['tap0']),
                'added': set([])
            })
        ])
        self._verify_mock_calls()
예제 #3
0
 def test_construct_with_arp_responder(self):
     ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE,
                                       self.TUN_BRIDGE,
                                       '10.0.0.1',
                                       self.NET_MAPPING,
                                       'sudo',
                                       2, ['gre'],
                                       self.VETH_MTU,
                                       l2_population=True,
                                       arp_responder=True)
     self.mock_tun_bridge_expected.insert(
         5,
         mock.call.add_flow(table=constants.PATCH_LV_TO_TUN,
                            priority=1,
                            proto="arp",
                            dl_dst="ff:ff:ff:ff:ff:ff",
                            actions="resubmit(,%s)" %
                            constants.ARP_RESPONDER))
     self.mock_tun_bridge_expected.insert(
         12,
         mock.call.add_flow(table=constants.ARP_RESPONDER,
                            priority=0,
                            actions="resubmit(,%s)" %
                            constants.FLOOD_TO_TUN))
     self._verify_mock_calls()
예제 #4
0
    def test_provision_local_vlan_vlan(self):
        action_string = 'mod_vlan_vid:%s,normal' % LS_ID
        self.mock_map_tun_bridge_expected.append(
            mock.call.add_flow(priority=4,
                               in_port=self.MAP_TUN_OFPORT,
                               dl_vlan=LV_ID,
                               actions=action_string))

        action_string = 'mod_vlan_vid:%s,normal' % LS_ID
        self.mock_int_bridge_expected.append(
            mock.call.add_flow(priority=3,
                               in_port=self.INT_OFPORT,
                               dl_vlan=LV_ID,
                               actions=action_string))

        a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE, self.TUN_BRIDGE,
                                              '10.0.0.1', self.NET_MAPPING,
                                              'sudo', 2, ['gre'],
                                              self.VETH_MTU)
        a.available_local_vlans = set([LV_ID])
        a.phys_brs['net1'] = self.mock_map_tun_bridge
        a.phys_ofports['net1'] = self.MAP_TUN_OFPORT
        a.int_ofports['net1'] = self.INT_OFPORT
        a.provision_local_vlan(NET_UUID, p_const.TYPE_VLAN, 'net1', LS_ID)
        self._verify_mock_calls()
예제 #5
0
 def test_construct(self):
     ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE,
                                       self.TUN_BRIDGE,
                                       '10.0.0.1', self.NET_MAPPING,
                                       'sudo', 2, ['gre'],
                                       self.VETH_MTU)
     self._verify_mock_calls()
예제 #6
0
    def test_provision_local_vlan_flat(self):
        action_string = 'strip_vlan,normal'
        self.mock_map_tun_bridge.add_flow(priority=4,
                                          in_port=self.MAP_TUN_OFPORT,
                                          dl_vlan=LV_ID,
                                          actions=action_string)

        action_string = 'mod_vlan_vid:%s,normal' % LV_ID
        self.mock_int_bridge.add_flow(priority=3,
                                      in_port=self.INT_OFPORT,
                                      dl_vlan=65535,
                                      actions=action_string)

        self.mox.ReplayAll()

        a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE, self.TUN_BRIDGE,
                                              '10.0.0.1', self.NET_MAPPING,
                                              'sudo', 2, ['gre'],
                                              self.VETH_MTU)
        a.available_local_vlans = set([LV_ID])
        a.phys_brs['net1'] = self.mock_map_tun_bridge
        a.phys_ofports['net1'] = self.MAP_TUN_OFPORT
        a.int_ofports['net1'] = self.INT_OFPORT
        a.provision_local_vlan(NET_UUID, constants.TYPE_FLAT, 'net1', LS_ID)
        self.mox.VerifyAll()
예제 #7
0
    def test_provision_local_vlan(self):
        ofports = ','.join(TUN_OFPORTS[constants.TYPE_GRE].values())
        self.mock_tun_bridge_expected += [
            mock.call.mod_flow(table=constants.FLOOD_TO_TUN,
                               priority=1,
                               dl_vlan=LV_ID,
                               actions="strip_vlan,"
                               "set_tunnel:%s,output:%s" %
                               (LS_ID, ofports)),
            mock.call.add_flow(table=constants.TUN_TABLE['gre'],
                               priority=1,
                               tun_id=LS_ID,
                               actions="mod_vlan_vid:%s,resubmit(,%s)" %
                               (LV_ID, constants.LEARN_FROM_TUN)),
        ]

        a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE,
                                              self.TUN_BRIDGE,
                                              '10.0.0.1', self.NET_MAPPING,
                                              'sudo', 2, ['gre'],
                                              self.VETH_MTU)
        a.available_local_vlans = set([LV_ID])
        a.tun_br_ofports = TUN_OFPORTS
        a.provision_local_vlan(NET_UUID, constants.TYPE_GRE, None, LS_ID)
        self._verify_mock_calls()
예제 #8
0
    def setUp(self):
        super(TestOvsNeutronAgent, self).setUp()
        self.addCleanup(cfg.CONF.reset)
        self.addCleanup(mock.patch.stopall)
        notifier_p = mock.patch(NOTIFIER)
        notifier_cls = notifier_p.start()
        self.notifier = mock.Mock()
        notifier_cls.return_value = self.notifier
        # Avoid rpc initialization for unit tests
        cfg.CONF.set_override('rpc_backend',
                              'neutron.openstack.common.rpc.impl_fake')
        cfg.CONF.set_override('report_interval', 0, 'AGENT')
        kwargs = ovs_neutron_agent.create_agent_config_map(cfg.CONF)

        with contextlib.nested(
            mock.patch('neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                       'OVSNeutronAgent.setup_integration_br',
                       return_value=mock.Mock()),
            mock.patch('neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                       'OVSNeutronAgent.setup_ancillary_bridges',
                       return_value=[]),
            mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
                       'get_local_port_mac',
                       return_value='00:00:00:00:00:01'),
            mock.patch('neutron.agent.linux.utils.get_interface_mac',
                       return_value='00:00:00:00:00:01')):
            self.agent = ovs_neutron_agent.OVSNeutronAgent(**kwargs)
            self.agent.tun_br = mock.Mock()
        self.agent.sg_agent = mock.Mock()
예제 #9
0
 def test_tunnel_update_self(self):
     a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE, self.TUN_BRIDGE,
                                           '10.0.0.1', self.NET_MAPPING,
                                           'sudo', 2, ['gre'],
                                           self.VETH_MTU)
     a.tunnel_update(mock.sentinel.ctx, tunnel_id='1', tunnel_ip='10.0.0.1')
     self._verify_mock_calls()
예제 #10
0
    def _test_ancillary_bridges(self, bridges, ancillary):
        device_ids = ancillary[:]

        def pullup_side_effect(self, *args):
            result = device_ids.pop(0)
            return result

        with contextlib.nested(
                mock.patch(
                    'neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                    'OVSNeutronAgent.setup_integration_br',
                    return_value=mock.Mock()),
                mock.patch('neutron.agent.linux.utils.get_interface_mac',
                           return_value='00:00:00:00:00:01'),
                mock.patch(
                    'neutron.agent.linux.ovs_lib.OVSBridge.'
                    'get_local_port_mac',
                    return_value='00:00:00:00:00:01'),
                mock.patch('neutron.agent.linux.ovs_lib.get_bridges',
                           return_value=bridges),
                mock.patch(
                    'neutron.agent.linux.ovs_lib.get_bridge_external_bridge_id',
                    side_effect=pullup_side_effect)):
            self.agent = ovs_neutron_agent.OVSNeutronAgent(**self.kwargs)
            self.assertEqual(len(ancillary), len(self.agent.ancillary_brs))
            if ancillary:
                bridges = [br.br_name for br in self.agent.ancillary_brs]
                for br in ancillary:
                    self.assertIn(br, bridges)
예제 #11
0
 def test_construct_without_arp_responder(self):
     ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE,
                                       self.TUN_BRIDGE,
                                       '10.0.0.1', self.NET_MAPPING,
                                       'sudo', 2, ['gre'],
                                       self.VETH_MTU, l2_population=False,
                                       arp_responder=True)
     self._verify_mock_calls()
예제 #12
0
 def testConstruct(self):
     self.mox.ReplayAll()
     ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE,
                                       self.TUN_BRIDGE,
                                       '10.0.0.1', self.NET_MAPPING,
                                       'sudo', 2, ['gre'],
                                       self.VETH_MTU)
     self.mox.VerifyAll()
예제 #13
0
 def test_provision_local_vlan_vlan_fail(self):
     self.mox.ReplayAll()
     a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE, self.TUN_BRIDGE,
                                           '10.0.0.1', self.NET_MAPPING,
                                           'sudo', 2, ['gre'],
                                           self.VETH_MTU)
     a.provision_local_vlan(NET_UUID, constants.TYPE_VLAN, 'net2', LS_ID)
     self.mox.VerifyAll()
예제 #14
0
 def test_tunnel_update_self(self):
     self.mox.ReplayAll()
     a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE, self.TUN_BRIDGE,
                                           '10.0.0.1', self.NET_MAPPING,
                                           'sudo', 2, ['gre'],
                                           self.VETH_MTU)
     a.tunnel_update(mox.MockAnything, tunnel_id='1', tunnel_ip='10.0.0.1')
     self.mox.VerifyAll()
예제 #15
0
    def test_daemon_loop(self):
        reply2 = {
            'current': set(['tap0']),
            'added': set([]),
            'removed': set([])
        }

        reply3 = {
            'current': set(['tap2']),
            'added': set([]),
            'removed': set([])
        }

        self.mox.StubOutWithMock(log.ContextAdapter, 'exception')
        log.ContextAdapter.exception(_("Error in agent event loop")).AndRaise(
            Exception('Fake exception to get out of the loop'))

        self.mox.StubOutWithMock(ovs_neutron_agent.OVSNeutronAgent,
                                 'update_ports')
        ovs_neutron_agent.OVSNeutronAgent.update_ports(set()).AndReturn(reply2)
        ovs_neutron_agent.OVSNeutronAgent.update_ports(set(
            ['tap0'])).AndReturn(reply3)
        self.mox.StubOutWithMock(ovs_neutron_agent.OVSNeutronAgent,
                                 'process_network_ports')
        ovs_neutron_agent.OVSNeutronAgent.process_network_ports({
            'current':
            set(['tap0']),
            'removed':
            set([]),
            'added':
            set([])
        }).AndReturn(False)
        ovs_neutron_agent.OVSNeutronAgent.process_network_ports({
            'current':
            set(['tap0']),
            'removed':
            set([]),
            'added':
            set([])
        }).AndRaise(Exception('Fake exception to get out of the loop'))
        self.mox.ReplayAll()
        q_agent = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE,
                                                    self.TUN_BRIDGE,
                                                    '10.0.0.1',
                                                    self.NET_MAPPING, 'sudo',
                                                    2, ['gre'], self.VETH_MTU)

        # Hack to test loop
        # We start method and expect it will raise after 2nd loop
        # If something goes wrong, mox.VerifyAll() will catch it
        try:
            q_agent.daemon_loop()
        except Exception:
            pass

        self.mox.VerifyAll()
예제 #16
0
 def test_construct_vxlan(self):
     self.mox.StubOutWithMock(ovs_lib, 'get_installed_ovs_klm_version')
     ovs_lib.get_installed_ovs_klm_version().AndReturn("1.10")
     self.mox.StubOutWithMock(ovs_lib, 'get_installed_ovs_usr_version')
     ovs_lib.get_installed_ovs_usr_version('sudo').AndReturn("1.10")
     self.mox.ReplayAll()
     ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE, self.TUN_BRIDGE,
                                       '10.0.0.1', self.NET_MAPPING, 'sudo',
                                       2, ['vxlan'], self.VETH_MTU)
     self.mox.VerifyAll()
예제 #17
0
 def _build_agent(self, **kwargs):
     kwargs.setdefault('integ_br', self.INT_BRIDGE)
     kwargs.setdefault('tun_br', self.TUN_BRIDGE)
     kwargs.setdefault('local_ip', '10.0.0.1')
     kwargs.setdefault('bridge_mappings', self.NET_MAPPING)
     kwargs.setdefault('polling_interval', 2)
     kwargs.setdefault('tunnel_types', ['gre'])
     kwargs.setdefault('veth_mtu', self.VETH_MTU)
     kwargs.setdefault('use_veth_interconnection',
                       self.USE_VETH_INTERCONNECTION)
     return ovs_neutron_agent.OVSNeutronAgent(**kwargs)
예제 #18
0
    def test_port_unbound(self):
        with mock.patch.object(ovs_neutron_agent.OVSNeutronAgent,
                               'reclaim_local_vlan') as reclaim_local_vlan:
            a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE,
                                                  self.TUN_BRIDGE, '10.0.0.1',
                                                  self.NET_MAPPING, 'sudo', 2,
                                                  ['gre'], self.VETH_MTU)
            a.local_vlan_map[NET_UUID] = LVM
            a.port_unbound(VIF_ID, NET_UUID)

        reclaim_local_vlan.assert_called_once_with(NET_UUID)
        self._verify_mock_calls()
예제 #19
0
    def test_port_bound(self):
        self.mock_int_bridge.set_db_attribute('Port', VIF_PORT.port_name,
                                              'tag', str(LVM.vlan))
        self.mock_int_bridge.delete_flows(in_port=VIF_PORT.ofport)

        self.mox.ReplayAll()
        a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE, self.TUN_BRIDGE,
                                              '10.0.0.1', self.NET_MAPPING,
                                              'sudo', 2, ['gre'],
                                              self.VETH_MTU)
        a.local_vlan_map[NET_UUID] = LVM
        a.port_bound(VIF_PORT, NET_UUID, 'gre', None, LS_ID)
        self.mox.VerifyAll()
예제 #20
0
 def test_tunnel_update(self):
     self.mock_tun_bridge.add_tunnel_port('gre-1', '10.0.10.1', '10.0.0.1',
                                          'gre', 4789)
     self.mox.ReplayAll()
     a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE, self.TUN_BRIDGE,
                                           '10.0.0.1', self.NET_MAPPING,
                                           'sudo', 2, ['gre'],
                                           self.VETH_MTU)
     a.tunnel_update(mox.MockAnything,
                     tunnel_id='1',
                     tunnel_ip='10.0.10.1',
                     tunnel_type=constants.TYPE_GRE)
     self.mox.VerifyAll()
예제 #21
0
 def test_construct_vxlan(self):
     with mock.patch.object(ovs_lib, 'get_installed_ovs_klm_version',
                            return_value="1.10") as klm_ver:
         with mock.patch.object(ovs_lib, 'get_installed_ovs_usr_version',
                                return_value="1.10") as usr_ver:
             ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE,
                                               self.TUN_BRIDGE,
                                               '10.0.0.1', self.NET_MAPPING,
                                               'sudo', 2, ['vxlan'],
                                               self.VETH_MTU)
     klm_ver.assert_called_once_with()
     usr_ver.assert_called_once_with('sudo')
     self._verify_mock_calls()
예제 #22
0
    def setUp(self):
        super(TestOvsNeutronAgent, self).setUp()
        notifier_p = mock.patch(NOTIFIER)
        notifier_cls = notifier_p.start()
        self.notifier = mock.Mock()
        notifier_cls.return_value = self.notifier
        cfg.CONF.set_default('firewall_driver',
                             'neutron.agent.firewall.NoopFirewallDriver',
                             group='SECURITYGROUP')
        # Avoid rpc initialization for unit tests
        cfg.CONF.set_override('rpc_backend',
                              'neutron.openstack.common.rpc.impl_fake')
        kwargs = ovs_neutron_agent.create_agent_config_map(cfg.CONF)

        class MockFixedIntervalLoopingCall(object):
            def __init__(self, f):
                self.f = f

            def start(self, interval=0):
                self.f()

        with contextlib.nested(
                mock.patch(
                    'neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                    'OVSNeutronAgent.setup_integration_br',
                    return_value=mock.Mock()),
                mock.patch(
                    'neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                    'OVSNeutronAgent.setup_ancillary_bridges',
                    return_value=[]),
                mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
                           'create'),
                mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
                           'set_secure_mode'),
                mock.patch(
                    'neutron.agent.linux.ovs_lib.OVSBridge.'
                    'get_local_port_mac',
                    return_value='00:00:00:00:00:01'),
                mock.patch('neutron.agent.linux.utils.get_interface_mac',
                           return_value='00:00:00:00:00:01'),
                mock.patch(
                    'neutron.openstack.common.loopingcall.'
                    'FixedIntervalLoopingCall',
                    new=MockFixedIntervalLoopingCall),
                mock.patch(
                    'neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                    'OVSNeutronAgent._check_arp_responder_support',
                    return_value=True)):
            self.agent = ovs_neutron_agent.OVSNeutronAgent(**kwargs)
            self.agent.tun_br = mock.Mock()
        self.agent.sg_agent = mock.Mock()
예제 #23
0
    def test_port_unbound(self):
        self.mox.StubOutWithMock(ovs_neutron_agent.OVSNeutronAgent,
                                 'reclaim_local_vlan')
        ovs_neutron_agent.OVSNeutronAgent.reclaim_local_vlan(NET_UUID)

        self.mox.ReplayAll()

        a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE, self.TUN_BRIDGE,
                                              '10.0.0.1', self.NET_MAPPING,
                                              'sudo', 2, ['gre'],
                                              self.VETH_MTU)
        a.local_vlan_map[NET_UUID] = LVM
        a.port_unbound(VIF_ID, NET_UUID)
        self.mox.VerifyAll()
예제 #24
0
    def testReclaimLocalVlan(self):
        self.mock_tun_bridge.delete_flows(tun_id=LVM.segmentation_id)

        self.mock_tun_bridge.delete_flows(dl_vlan=LVM.vlan)

        self.mox.ReplayAll()
        a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE, self.TUN_BRIDGE,
                                              '10.0.0.1', self.NET_MAPPING,
                                              'sudo', 2, ['gre'],
                                              self.VETH_MTU)
        a.available_local_vlans = set()
        a.local_vlan_map[NET_UUID] = LVM
        a.reclaim_local_vlan(NET_UUID, LVM)
        self.assertTrue(LVM.vlan in a.available_local_vlans)
        self.mox.VerifyAll()
예제 #25
0
    def test_port_bound(self):
        self.mock_int_bridge_expected += [
            mock.call.db_get_val('Port', VIF_PORT.port_name, 'tag'),
            mock.call.set_db_attribute('Port', VIF_PORT.port_name, 'tag',
                                       str(LVM.vlan)),
            mock.call.delete_flows(in_port=VIF_PORT.ofport)
        ]

        a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE, self.TUN_BRIDGE,
                                              '10.0.0.1', self.NET_MAPPING,
                                              'sudo', 2, ['gre'],
                                              self.VETH_MTU)
        a.local_vlan_map[NET_UUID] = LVM
        a.port_bound(VIF_PORT, NET_UUID, 'gre', None, LS_ID)
        self._verify_mock_calls()
예제 #26
0
    def test_reclaim_local_vlan(self):
        self.mock_tun_bridge.delete_flows(table=constants.TUN_TABLE['gre'],
                                          tun_id=LS_ID)
        self.mock_tun_bridge.delete_flows(dl_vlan=LVM.vlan)

        self.mox.ReplayAll()
        a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE, self.TUN_BRIDGE,
                                              '10.0.0.1', self.NET_MAPPING,
                                              'sudo', 2, ['gre'],
                                              self.VETH_MTU)
        a.available_local_vlans = set()
        a.local_vlan_map[NET_UUID] = LVM
        a.reclaim_local_vlan(NET_UUID)
        self.assertIn(LVM.vlan, a.available_local_vlans)
        self.mox.VerifyAll()
예제 #27
0
    def setUp(self):
        super(TestOvsDvrNeutronAgent, self).setUp()
        notifier_p = mock.patch(NOTIFIER)
        notifier_cls = notifier_p.start()
        self.notifier = mock.Mock()
        notifier_cls.return_value = self.notifier
        cfg.CONF.set_default('firewall_driver',
                             'neutron.agent.firewall.NoopFirewallDriver',
                             group='SECURITYGROUP')
        kwargs = ovs_neutron_agent.create_agent_config_map(cfg.CONF)

        class MockFixedIntervalLoopingCall(object):
            def __init__(self, f):
                self.f = f

            def start(self, interval=0):
                self.f()

        with contextlib.nested(
                mock.patch(
                    'neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                    'OVSNeutronAgent.setup_integration_br',
                    return_value=mock.Mock()),
                mock.patch(
                    'neutron.plugins.openvswitch.agent.ovs_neutron_agent.'
                    'OVSNeutronAgent.setup_ancillary_bridges',
                    return_value=[]),
                mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
                           'create'),
                mock.patch('neutron.agent.linux.ovs_lib.OVSBridge.'
                           'set_secure_mode'),
                mock.patch(
                    'neutron.agent.linux.ovs_lib.OVSBridge.'
                    'get_local_port_mac',
                    return_value='00:00:00:00:00:01'),
                mock.patch('neutron.agent.linux.utils.get_interface_mac',
                           return_value='00:00:00:00:00:01'),
                mock.patch('neutron.agent.linux.ovs_lib.BaseOVS.get_bridges'),
                mock.patch(
                    'neutron.openstack.common.loopingcall.'
                    'FixedIntervalLoopingCall',
                    new=MockFixedIntervalLoopingCall)):
            self.agent = ovs_neutron_agent.OVSNeutronAgent(**kwargs)
            # set back to true because initial report state will succeed due
            # to mocked out RPC calls
            self.agent.use_call = True
            self.agent.tun_br = mock.Mock()
        self.agent.sg_agent = mock.Mock()
예제 #28
0
    def testPortDead(self):
        self.mock_int_bridge.set_db_attribute(
            'Port', VIF_PORT.port_name, 'tag', ovs_neutron_agent.DEAD_VLAN_TAG)

        self.mock_int_bridge.add_flow(priority=2, in_port=VIF_PORT.ofport,
                                      actions='drop')

        self.mox.ReplayAll()
        a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE,
                                              self.TUN_BRIDGE,
                                              '10.0.0.1', self.NET_MAPPING,
                                              'sudo', 2, ['gre'],
                                              self.VETH_MTU)
        a.available_local_vlans = set([LV_ID])
        a.local_vlan_map[NET_UUID] = LVM
        a.port_dead(VIF_PORT)
        self.mox.VerifyAll()
예제 #29
0
    def test_port_dead(self):
        self.mock_int_bridge_expected += [
            mock.call.db_get_val('Port', VIF_PORT.port_name, 'tag'),
            mock.call.set_db_attribute('Port', VIF_PORT.port_name, 'tag',
                                       ovs_neutron_agent.DEAD_VLAN_TAG),
            mock.call.add_flow(priority=2,
                               in_port=VIF_PORT.ofport,
                               actions='drop')
        ]

        a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE, self.TUN_BRIDGE,
                                              '10.0.0.1', self.NET_MAPPING,
                                              'sudo', 2, ['gre'],
                                              self.VETH_MTU)
        a.available_local_vlans = set([LV_ID])
        a.local_vlan_map[NET_UUID] = LVM
        a.port_dead(VIF_PORT)
        self._verify_mock_calls()
예제 #30
0
    def test_tunnel_update(self):
        tunnel_port = '9999'
        self.mock_tun_bridge.add_tunnel_port.return_value = tunnel_port
        self.mock_tun_bridge_expected += [
            mock.call.add_tunnel_port('gre-1', '10.0.10.1', '10.0.0.1',
                                      'gre', 4789),
            mock.call.add_flow(priority=1, in_port=tunnel_port,
                               actions='resubmit(,2)')
        ]

        a = ovs_neutron_agent.OVSNeutronAgent(self.INT_BRIDGE,
                                              self.TUN_BRIDGE,
                                              '10.0.0.1', self.NET_MAPPING,
                                              'sudo', 2, ['gre'],
                                              self.VETH_MTU)
        a.tunnel_update(
            mock.sentinel.ctx, tunnel_id='1', tunnel_ip='10.0.10.1',
            tunnel_type=constants.TYPE_GRE)
        self._verify_mock_calls()