コード例 #1
0
ファイル: test_l2_app.py プロジェクト: QiuMike/dragonflow
    def test_multicast_local_port(self):
        fake_local_port1 = test_app_base.make_fake_local_port(
            macs=['00:0b:0c:0d:0e:0f'],
            ips=['10.0.0.11'],
            lswitch='fake_local_switch1')
        self.controller.update(fake_local_port1)
        self.app.mod_flow.assert_any_call(
            inst=mock.ANY,
            command=self.app.ofproto.OFPFC_ADD,
            table_id=const.INGRESS_DESTINATION_PORT_LOOKUP_TABLE,
            priority=const.PRIORITY_HIGH,
            match=mock.ANY)
        self.app.mod_flow.reset_mock()

        fake_local_port2 = test_app_base.make_fake_local_port(
            lswitch='fake_local_switch1',
            macs=['1a:0b:0c:0d:0e:0f'],
            ips=['10.0.0.12'],
            ofport=2)
        self.controller.update(fake_local_port2)
        self.app.mod_flow.assert_any_call(
            inst=mock.ANY,
            command=self.app.ofproto.OFPFC_MODIFY,
            table_id=const.INGRESS_DESTINATION_PORT_LOOKUP_TABLE,
            priority=const.PRIORITY_HIGH,
            match=mock.ANY)
        self.app.mod_flow.reset_mock()
コード例 #2
0
 def test_port_admin_state_create(self):
     port = test_app_base.make_fake_local_port(id='id1', enabled=False)
     port.emit_created()
     _M[l2.EVENT_BIND_LOCAL].assert_not_called()
     port2 = test_app_base.make_fake_local_port(id='id1', enabled=True)
     port2.emit_created()
     _M[l2.EVENT_BIND_LOCAL].assert_called_once_with(port2)
コード例 #3
0
 def test_add_remove_local_port(self):
     fake_local_vlan_port1 = test_app_base.make_fake_local_port(
             network_type='vlan',
             name='fake_local_vlan_port1',
             unique_key=3,
             ofport=2,
             lswitch='fake_vlan_switch1',
             local_network_id=1)
     self.logical_networks.add_local_port(
             port_id=fake_local_vlan_port1.id,
             network_id=1,
             network_type='vlan')
     net_1_vlan_ports = self.logical_networks.get_local_port_count(
             network_id=1,
             network_type='vlan')
     self.assertEqual(1, net_1_vlan_ports)
     fake_local_vlan_port2 = test_app_base.make_fake_local_port(
             network_type='vlan',
             name='fake_local_vlan_port2',
             unique_key=4,
             ofport=3,
             lswitch='fake_vlan_switch1',
             local_network_id=1)
     self.logical_networks.add_local_port(
             port_id=fake_local_vlan_port2.id,
             network_id=1,
             network_type='vlan')
     net_1_vlan_ports = self.logical_networks.get_local_port_count(
             network_id=1,
             network_type='vlan')
     self.assertEqual(2, net_1_vlan_ports)
     net_2_gre_ports = self.logical_networks.get_local_port_count(
             network_id=2,
             network_type='gre')
     self.assertEqual(0, net_2_gre_ports)
     fake_local_gre_port1 = test_app_base.make_fake_local_port(
             network_type='gre',
             lswitch='fake_gre_switch1',
             name='fake_local_gre_port1',
             unique_key=5,
             ofport=4,
             local_network_id=2)
     self.logical_networks.add_local_port(
             port_id=fake_local_gre_port1.id,
             network_id=2,
             network_type='gre')
     net_2_gre_ports = self.logical_networks.get_local_port_count(
             network_id=2,
             network_type='gre')
     self.assertEqual(1, net_2_gre_ports)
     self.logical_networks.remove_local_port(
             port_id=fake_local_gre_port1.id,
             network_id=2,
             network_type='gre')
     net_2_gre_ports = self.logical_networks.get_local_port_count(
             network_id=2,
             network_type='gre')
     self.assertEqual(0, net_2_gre_ports)
コード例 #4
0
    def test_port_admin_state_update(self):
        old_port = test_app_base.make_fake_local_port(id='id1', enabled=False)
        old_port.emit_created()

        _M[l2.EVENT_BIND_LOCAL].reset_mock()
        new_port = test_app_base.make_fake_local_port(id='id1', enabled=True)
        new_port.emit_updated(old_port)
        _M[l2.EVENT_BIND_LOCAL].assert_called_once_with(new_port)

        _M[l2.EVENT_BIND_LOCAL].reset_mock()
        old_port.emit_updated(new_port)
        _M[l2.EVENT_BIND_LOCAL].assert_not_called()
コード例 #5
0
 def test_update_bind_local(self):
     old_port = test_app_base.make_fake_port(id='id1')
     new_port = test_app_base.make_fake_local_port(id='id1')
     old_port.emit_created()
     new_port.emit_updated(old_port)
     _M[l2.EVENT_BIND_LOCAL].assert_called_once_with(new_port)
     _M[l2.EVENT_LOCAL_UPDATED].assert_not_called()
コード例 #6
0
ファイル: test_dhcp_app.py プロジェクト: lihiwish/dragonflow
    def _build_dhcp_test_fake_lport(self, dhcp_params=None):
        fake_loprt = test_app_base.make_fake_local_port(
            lswitch=test_app_base.fake_logic_switch1,
            subnets=test_app_base.fake_lswitch_default_subnets,
            ips=('10.0.0.1', ),
            dhcp_params=dhcp_params)

        return fake_loprt
コード例 #7
0
ファイル: test_dhcp_app.py プロジェクト: snapiri/dragonflow
    def _create_dhcp_port(self):
        fake_dhcp_port = test_app_base.make_fake_local_port(
            lswitch=test_app_base.fake_logic_switch1,
            subnets=test_app_base.fake_lswitch_default_subnets,
            ips=('10.0.0.2', ),
            macs=("11:22:33:44:55:66", ),
            device_owner=n_const.DEVICE_OWNER_DHCP)

        return fake_dhcp_port
コード例 #8
0
ファイル: test_sg_app.py プロジェクト: snapiri/dragonflow
 def _get_another_local_lport(self):
     fake_local_port = test_app_base.make_fake_local_port(
         id='fake_port2',
         topic='fake_tenant1',
         name='',
         unique_key=5,
         version=2,
         ips=[
             netaddr.IPAddress('10.0.0.10'),
             netaddr.IPAddress('2222:2222::2')
         ],
         subnets=['fake_subnet1'],
         macs=[netaddr.EUI('fa:16:3e:8c:2e:12')],
         lswitch='fake_switch1',
         security_groups=['fake_security_group_id1'],
         allowed_address_pairs=[],
         port_security_enabled=True,
         device_owner='compute:None',
         device_id='fake_device_id',
         # 'binding_profile': {},
         # 'binding_vnic_type': 'normal',
     )
     return fake_local_port
コード例 #9
0
 def test_update_local_port(self):
     port = test_app_base.make_fake_local_port()
     port.emit_created()
     port.emit_updated(port)
     _M[l2.EVENT_LOCAL_UPDATED].assert_called_once_with(port, port)
コード例 #10
0
 def test_local_port_deleted(self):
     port = test_app_base.make_fake_local_port()
     port.emit_created()
     port.emit_deleted()
     _M[l2.EVENT_UNBIND_LOCAL].assert_called_once_with(port)