Beispiel #1
0
    def test_get_neutron_network_invalid_property(self):
        def fake_call_method(module, method, *args, **kwargs):
            if method == 'get_dynamic_property':
                raise error_util.InvalidPropertyException()

        with contextlib.nested(
            mock.patch.object(vm_util, 'get_host_ref'),
            mock.patch.object(self.session, '_call_method',
                              fake_call_method),
            mock.patch.object(network_util, 'get_network_with_the_name')
        ) as (_get_host, _call_method, _get_name):
            vif.get_neutron_network(self.session, 'network_name',
                                    'cluster', 'vif')
    def test_get_neutron_network_invalid_property(self):
        def fake_call_method(module, method, *args, **kwargs):
            if method == 'get_object_property':
                raise vexc.InvalidPropertyException()

        with contextlib.nested(
            mock.patch.object(vm_util, 'get_host_ref'),
            mock.patch.object(self.session, '_call_method',
                              fake_call_method),
            mock.patch.object(network_util, 'get_network_with_the_name')
        ) as (_get_host, _call_method, _get_name):
            vif.get_neutron_network(self.session, 'network_name',
                                    'cluster', self.vif)
Beispiel #3
0
 def test_get_neutron_network(self):
     self.mox.StubOutWithMock(vm_util, 'get_host_ref')
     self.mox.StubOutWithMock(self.session, '_call_method')
     self.mox.StubOutWithMock(vif, '_get_network_ref_from_opaque')
     vm_util.get_host_ref(self.session, self.cluster).AndReturn('fake-host')
     opaque = fake.DataObject()
     opaque.HostOpaqueNetworkInfo = ['fake-network-info']
     self.session._call_method(
         vim_util, "get_dynamic_property", 'fake-host', 'HostSystem',
         'config.network.opaqueNetwork').AndReturn(opaque)
     vif._get_network_ref_from_opaque(
         opaque.HostOpaqueNetworkInfo, CONF.vmware.integration_bridge,
         self.vif['network']['id']).AndReturn('fake-network-ref')
     self.mox.ReplayAll()
     network_ref = vif.get_neutron_network(self.session,
                                           self.vif['network']['id'],
                                           self.cluster, self.vif)
     self.assertEqual(network_ref, 'fake-network-ref')
Beispiel #4
0
 def test_get_neutron_network(self):
     self.mox.StubOutWithMock(vm_util, 'get_host_ref')
     self.mox.StubOutWithMock(self.session, '_call_method')
     self.mox.StubOutWithMock(vif, '_get_network_ref_from_opaque')
     vm_util.get_host_ref(self.session,
             self.cluster).AndReturn('fake-host')
     opaque = fake.DataObject()
     opaque.HostOpaqueNetworkInfo = ['fake-network-info']
     self.session._call_method(vutil, "get_object_property",
              'fake-host', 'config.network.opaqueNetwork').AndReturn(opaque)
     vif._get_network_ref_from_opaque(opaque.HostOpaqueNetworkInfo,
             CONF.vmware.integration_bridge,
             self.vif['network']['id']).AndReturn('fake-network-ref')
     self.mox.ReplayAll()
     network_ref = vif.get_neutron_network(self.session,
                                           self.vif['network']['id'],
                                           self.cluster,
                                           self.vif)
     self.assertEqual(network_ref, 'fake-network-ref')
Beispiel #5
0
 def test_get_network_ref_neutron(self):
     self.mox.StubOutWithMock(vif, 'get_neutron_network')
     vif.get_neutron_network(self.session, 'fa0', self.cluster, self.vif)
     self.mox.ReplayAll()
     vif.get_network_ref(self.session, self.cluster, self.vif, True)
Beispiel #6
0
 def test_get_network_ref_neutron(self):
     self.mox.StubOutWithMock(vif, "get_neutron_network")
     vif.get_neutron_network(self.session, "fa0", self.cluster, self.vif)
     self.mox.ReplayAll()
     vif.get_network_ref(self.session, self.cluster, self.vif, True)