def new_vif(vif_dict=None, version=4):
    vif = dict(id=1,
               address='aa:aa:aa:aa:aa:aa',
               type='bridge',
               network=new_network(version=version))
    vif_dict = vif_dict or {}
    vif.update(vif_dict)
    return model.VIF(**vif)
Beispiel #2
0
 def setUp(self):
     super(TestUpdateInstanceCache, self).setUp()
     self.context = context.get_admin_context()
     self.instance = objects.Instance(uuid=FAKE_UUID)
     vifs = [network_model.VIF(id='super_vif')]
     self.nw_info = network_model.NetworkInfo(vifs)
     self.nw_json = fields.NetworkModel.to_primitive(self, 'network_info',
                                                     self.nw_info)
Beispiel #3
0
    def setUp(self):
        super(VMwareVifTestCase, self).setUp()
        self.flags(vlan_interface='vmnet0', group='vmware')
        network = network_model.Network(id=0,
                                        bridge='fa0',
                                        label='fake',
                                        vlan=3,
                                        bridge_interface='eth0',
                                        injected=True)

        self.vif = network_model.NetworkInfo([
            network_model.VIF(id=None,
                              address='DE:AD:BE:EF:00:00',
                              network=network,
                              type=None,
                              devname=None,
                              ovs_interfaceid=None,
                              rxtx_cap=3)
        ])[0]
        self.session = fake.FakeSession()
        self.cluster = None
Beispiel #4
0
    def current():
        subnet_4 = network_model.Subnet(
            cidr=fake_ip,
            dns=[network_model.IP(fake_ip),
                 network_model.IP(fake_ip)],
            gateway=network_model.IP(fake_ip),
            ips=[network_model.IP(fake_ip),
                 network_model.IP(fake_ip)],
            routes=None,
            dhcp_server=fake_ip)
        subnet_6 = network_model.Subnet(cidr=fake_ip,
                                        gateway=network_model.IP(fake_ip),
                                        ips=[
                                            network_model.IP(fake_ip),
                                            network_model.IP(fake_ip),
                                            network_model.IP(fake_ip)
                                        ],
                                        routes=None,
                                        version=6)
        subnets = [subnet_4]
        if ipv6:
            subnets.append(subnet_6)
        network = network_model.Network(id=None,
                                        bridge=fake,
                                        label=None,
                                        subnets=subnets,
                                        vlan=fake_vlan,
                                        bridge_interface=fake_bridge_interface,
                                        injected=False)
        vif = network_model.VIF(id='vif-xxx-yyy-zzz',
                                address=fake,
                                network=network,
                                type=network_model.VIF_TYPE_BRIDGE,
                                devname=None,
                                ovs_interfaceid=None)

        return vif
Beispiel #5
0
 def test_get_network_ref_bridge(self):
     self.mox.StubOutWithMock(vif, 'ensure_vlan_bridge')
     vif.ensure_vlan_bridge(self.session,
                            self.vif,
                            cluster=self.cluster,
                            create_vlan=True)
     self.mox.ReplayAll()
     network = network_model.Network(id=0,
                                     bridge='fa0',
                                     label='fake',
                                     vlan=3,
                                     bridge_interface='eth0',
                                     injected=True,
                                     should_create_vlan=True)
     self.vif = network_model.NetworkInfo([
         network_model.VIF(id=None,
                           address='DE:AD:BE:EF:00:00',
                           network=network,
                           type=None,
                           devname=None,
                           ovs_interfaceid=None,
                           rxtx_cap=3)
     ])[0]
     vif.get_network_ref(self.session, self.cluster, self.vif, False)
Beispiel #6
0
    def test_vif_not_equal(self):
        vif1 = model.VIF(id=1)
        vif2 = model.VIF(id=2)
        self.assertNotEqual(vif1, vif2)

        vif1 = model.VIF(address='00:00:00:00:00:11')
        vif2 = model.VIF(address='00:00:00:00:00:22')
        self.assertNotEqual(vif1, vif2)

        vif1 = model.VIF(network='net1')
        vif2 = model.VIF(network='net2')
        self.assertNotEqual(vif1, vif2)

        vif1 = model.VIF(type='ovs')
        vif2 = model.VIF(type='linuxbridge')
        self.assertNotEqual(vif1, vif2)

        vif1 = model.VIF(devname='ovs1234')
        vif2 = model.VIF(devname='linuxbridge1234')
        self.assertNotEqual(vif1, vif2)

        vif1 = model.VIF(qbh_params=1)
        vif2 = model.VIF(qbh_params=None)
        self.assertNotEqual(vif1, vif2)

        vif1 = model.VIF(qbg_params=1)
        vif2 = model.VIF(qbg_params=None)
        self.assertNotEqual(vif1, vif2)

        vif1 = model.VIF(active=True)
        vif2 = model.VIF(active=False)
        self.assertNotEqual(vif1, vif2)

        vif1 = model.VIF(vnic_type=model.VNIC_TYPE_NORMAL)
        vif2 = model.VIF(vnic_type=model.VNIC_TYPE_DIRECT)
        self.assertNotEqual(vif1, vif2)

        vif1 = model.VIF(profile={'pci_slot': '0000:0a:00.1'})
        vif2 = model.VIF(profile={'pci_slot': '0000:0a:00.2'})
        self.assertNotEqual(vif1, vif2)

        vif1 = model.VIF(preserve_on_delete=True)
        vif2 = model.VIF(preserve_on_delete=False)
        self.assertNotEqual(vif1, vif2)
Beispiel #7
0
 def test_vif_equal(self):
     vif1 = model.VIF()
     vif2 = model.VIF()
     self.assertEqual(vif1, vif2)
Beispiel #8
0
 def test_stringify(self):
     networkinfo = network_model.NetworkInfo()
     networkinfo.append(network_model.VIF(id=123))
     networkinfo.append(network_model.VIF(id=456))
     self.assertEqual('NetworkModel(123,456)',
                      self.field.stringify(networkinfo))