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)
def test_get_network_ref_dvs_with_dvs_pg_id(self, mock_network_name): fake_network_obj = { 'type': 'DistributedVirtualPortgroup', 'dvpg': 'fake-key', 'dvsw': 'fake-props' } mock_network_name.side_effect = [fake_network_obj] vif_details = {'dvs_id': 'fake-props', 'pg_id': 'fake-key'} vif_info = network_model.NetworkInfo([ network_model.VIF(type=network_model.VIF_TYPE_DVS, address='DE:AD:BE:EF:00:00', network=self._network, details=vif_details) ])[0] network_ref = vif.get_network_ref('fake-session', 'fake-cluster', vif_info) fake_network_ref = { 'type': 'DistributedVirtualPortgroup', 'dvpg': 'fake-key', 'dvsw': 'fake-props' } self.assertEqual(network_ref, fake_network_ref) calls = [] mock_network_name.assert_has_calls(calls) self.assertEqual(fake_network_obj, network_ref)
def test_get_network_ref_bridge(self, mock_ensure_vlan_bridge): 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) mock_ensure_vlan_bridge.assert_called_once_with( self.session, self.vif, cluster=self.cluster, create_vlan=True)
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)
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)
def test_get_network_ref_ovs(self, mock_check): vif_info = network_model.NetworkInfo([ network_model.VIF(type=network_model.VIF_TYPE_OVS, address='DE:AD:BE:EF:00:00', network=self._network) ])[0] network_ref = vif.get_network_ref('fake-session', 'fake-cluster', vif_info) expected_ref = { 'type': 'OpaqueNetwork', 'network-id': 0, 'network-type': 'nsx.LogicalSwitch', 'use-external-id': True } self.assertEqual(expected_ref, network_ref) mock_check.assert_called_once_with('fake-session')
def test_get_network_ref_ovs_integration_bridge(self, mock_check): self.flags(integration_bridge='fake-bridge-id', group='vmware') vif_info = network_model.NetworkInfo([ network_model.VIF(type=network_model.VIF_TYPE_OVS, address='DE:AD:BE:EF:00:00', network=self._network) ])[0] network_ref = vif.get_network_ref('fake-session', 'fake-cluster', vif_info) expected_ref = { 'type': 'OpaqueNetwork', 'network-id': 'fake-bridge-id', 'network-type': 'opaque', 'use-external-id': False } self.assertEqual(expected_ref, network_ref) mock_check.assert_called_once_with('fake-session')
def test_get_network_ref_dvs(self, mock_network_name): fake_network_obj = { 'type': 'DistributedVirtualPortgroup', 'dvpg': 'fake-key', 'dvsw': 'fake-props' } mock_network_name.return_value = fake_network_obj vif_info = network_model.NetworkInfo([ network_model.VIF(type=network_model.VIF_TYPE_DVS, address='DE:AD:BE:EF:00:00', network=self._network) ])[0] network_ref = vif.get_network_ref('fake-session', 'fake-cluster', vif_info) mock_network_name.assert_called_once_with('fake-session', 'fa0', 'fake-cluster') self.assertEqual(fake_network_obj, network_ref)
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)
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)
def test_get_network_ref_flat_dhcp(self, mock_ensure_vlan_bridge): vif.get_network_ref(self.session, self.cluster, self.vif, False) mock_ensure_vlan_bridge.assert_called_once_with(self.session, self.vif, cluster=self.cluster, create_vlan=False)
def test_get_network_ref_flat_dhcp(self, mock_ensure_vlan_bridge): vif.get_network_ref(self.session, self.cluster, self.vif, False) mock_ensure_vlan_bridge.assert_called_once_with( self.session, self.vif, cluster=self.cluster, create_vlan=False)