def test_get_neutron_network_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_neutron_network('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_neutron_network_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_neutron_network('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_neutron_network_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_neutron_network('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_neutron_network_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_neutron_network('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_neutron_network_dvs_provider(self, mock_network_name): fake_network_obj = {'type': 'DistributedVirtualPortgroup', 'dvpg': 'fake-key', 'dvsw': 'fake-props'} mock_network_name.side_effect = [None, 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_neutron_network('fake-session', 'fake-cluster', vif_info) calls = [mock.call('fake-session', 'fa0', 'fake-cluster'), mock.call('fake-session', 'fake', 'fake-cluster')] mock_network_name.assert_has_calls(calls) self.assertEqual(fake_network_obj, network_ref)
def test_get_neutron_network_dvs_vif_details(self, mock_network_name): fake_network_obj = { 'type': 'DistributedVirtualPortgroup', 'dvpg': 'pg1', '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, details={ 'dvs_port_key': 'key1', 'dvs_port_group_name': 'pg1' }, address='DE:AD:BE:EF:00:00', network=self._network) ])[0] network_ref = vif._get_neutron_network('fake-session', 'fake-cluster', vif_info) mock_network_name.assert_called_once_with('fake-session', 'pg1', 'fake-cluster') self.assertEqual(fake_network_obj, network_ref)