예제 #1
0
 def test_get_network_ref_flat_dhcp(self):
     self.mox.StubOutWithMock(vif, 'ensure_vlan_bridge')
     vif.ensure_vlan_bridge(self.session,
                            self.vif,
                            cluster=self.cluster,
                            create_vlan=False)
     self.mox.ReplayAll()
     vif.get_network_ref(self.session, self.cluster, self.vif, False)
예제 #2
0
파일: test_vif.py 프로젝트: hsluoyz/patron
 def test_ensure_vlan_bridge_with_network(self):
     self.mox.StubOutWithMock(network_util, 'get_network_with_the_name')
     self.mox.StubOutWithMock(network_util,
         'get_vswitch_for_vlan_interface')
     self.mox.StubOutWithMock(network_util,
         'check_if_vlan_interface_exists')
     self.mox.StubOutWithMock(network_util, 'create_port_group')
     vm_network = {'name': 'VM Network', 'type': 'Network'}
     network_util.get_network_with_the_name(self.session, 'fa0',
         self.cluster).AndReturn(vm_network)
     self.mox.ReplayAll()
     vif.ensure_vlan_bridge(self.session, self.vif, create_vlan=False)
예제 #3
0
 def test_ensure_vlan_bridge_with_network(self):
     self.mox.StubOutWithMock(network_util, 'get_network_with_the_name')
     self.mox.StubOutWithMock(network_util,
                              'get_vswitch_for_vlan_interface')
     self.mox.StubOutWithMock(network_util,
                              'check_if_vlan_interface_exists')
     self.mox.StubOutWithMock(network_util, 'create_port_group')
     vm_network = {'name': 'VM Network', 'type': 'Network'}
     network_util.get_network_with_the_name(
         self.session, 'fa0', self.cluster).AndReturn(vm_network)
     self.mox.ReplayAll()
     vif.ensure_vlan_bridge(self.session, self.vif, create_vlan=False)
예제 #4
0
파일: test_vif.py 프로젝트: hsluoyz/patron
    def test_ensure_vlan_bridge_without_vlan(self):
        self.mox.StubOutWithMock(network_util, 'get_network_with_the_name')
        self.mox.StubOutWithMock(network_util,
            'get_vswitch_for_vlan_interface')
        self.mox.StubOutWithMock(network_util,
            'check_if_vlan_interface_exists')
        self.mox.StubOutWithMock(network_util, 'create_port_group')

        network_util.get_network_with_the_name(self.session, 'fa0',
            self.cluster).AndReturn(None)
        network_util.get_vswitch_for_vlan_interface(self.session, 'vmnet0',
            self.cluster).AndReturn('vmnet0')
        network_util.check_if_vlan_interface_exists(self.session, 'vmnet0',
        self.cluster).AndReturn(True)
        network_util.create_port_group(self.session, 'fa0', 'vmnet0', 0,
            self.cluster)
        network_util.get_network_with_the_name(self.session, 'fa0', None)
        self.mox.ReplayAll()
        vif.ensure_vlan_bridge(self.session, self.vif, create_vlan=False)
예제 #5
0
    def test_ensure_vlan_bridge_without_vlan(self):
        self.mox.StubOutWithMock(network_util, 'get_network_with_the_name')
        self.mox.StubOutWithMock(network_util,
                                 'get_vswitch_for_vlan_interface')
        self.mox.StubOutWithMock(network_util,
                                 'check_if_vlan_interface_exists')
        self.mox.StubOutWithMock(network_util, 'create_port_group')

        network_util.get_network_with_the_name(self.session, 'fa0',
                                               self.cluster).AndReturn(None)
        network_util.get_vswitch_for_vlan_interface(
            self.session, 'vmnet0', self.cluster).AndReturn('vmnet0')
        network_util.check_if_vlan_interface_exists(
            self.session, 'vmnet0', self.cluster).AndReturn(True)
        network_util.create_port_group(self.session, 'fa0', 'vmnet0', 0,
                                       self.cluster)
        network_util.get_network_with_the_name(self.session, 'fa0', None)
        self.mox.ReplayAll()
        vif.ensure_vlan_bridge(self.session, self.vif, create_vlan=False)
예제 #6
0
파일: test_vif.py 프로젝트: hsluoyz/patron
 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)
예제 #7
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)
예제 #8
0
파일: test_vif.py 프로젝트: hsluoyz/patron
    def test_ensure_vlan_bridge_with_existing_dvs(self):
        network_ref = {'dvpg': 'dvportgroup-2062',
                       'type': 'DistributedVirtualPortgroup'}
        self.mox.StubOutWithMock(network_util, 'get_network_with_the_name')
        self.mox.StubOutWithMock(network_util,
            'get_vswitch_for_vlan_interface')
        self.mox.StubOutWithMock(network_util,
            'check_if_vlan_interface_exists')
        self.mox.StubOutWithMock(network_util, 'create_port_group')

        network_util.get_network_with_the_name(self.session, 'fa0',
            self.cluster).AndReturn(network_ref)
        self.mox.ReplayAll()
        ref = vif.ensure_vlan_bridge(self.session,
                                     self.vif,
                                     create_vlan=False)
        self.assertThat(ref, matchers.DictMatches(network_ref))
예제 #9
0
    def test_ensure_vlan_bridge_with_existing_dvs(self):
        network_ref = {
            'dvpg': 'dvportgroup-2062',
            'type': 'DistributedVirtualPortgroup'
        }
        self.mox.StubOutWithMock(network_util, 'get_network_with_the_name')
        self.mox.StubOutWithMock(network_util,
                                 'get_vswitch_for_vlan_interface')
        self.mox.StubOutWithMock(network_util,
                                 'check_if_vlan_interface_exists')
        self.mox.StubOutWithMock(network_util, 'create_port_group')

        network_util.get_network_with_the_name(
            self.session, 'fa0', self.cluster).AndReturn(network_ref)
        self.mox.ReplayAll()
        ref = vif.ensure_vlan_bridge(self.session, self.vif, create_vlan=False)
        self.assertThat(ref, matchers.DictMatches(network_ref))
예제 #10
0
파일: test_vif.py 프로젝트: hsluoyz/patron
 def test_get_network_ref_flat_dhcp(self):
     self.mox.StubOutWithMock(vif, 'ensure_vlan_bridge')
     vif.ensure_vlan_bridge(self.session, self.vif, cluster=self.cluster,
                            create_vlan=False)
     self.mox.ReplayAll()
     vif.get_network_ref(self.session, self.cluster, self.vif, False)