def test_recreate_connection_different_network(self, mock_session,
                                                   mock_fix_sp, mock_update,
                                                   mock_lli, mock_sh,
                                                   mock_list_net, mock_port):
        client = self.sync.neutron_client
        mock_port.return_value = [[{
            'network_id': '123',
            'mac_address': 'aa:11:cc:33:ee:44'
        }, {
            'vnic_type': 'baremetal',
            'profile': '1111'
        }]]
        fake_network = mech_test.FakeNetwork()
        mock_list_net.return_value = [fake_network]
        server_profile = copy.deepcopy(mech_test.FAKE_SERVER_PROFILE)
        client.port.server_profile_from_server_hardware.return_value = (
            server_profile)

        self.sync.recreate_connection()

        mock_fix_sp.assert_called_with(server_profile)
        mock_update.assert_called_with(
            '/rest/ethernet-networks/' + fake_network.oneview_network_id,
            server_profile,
            server_profile.get('connections')[0])
        self.assertFalse(self.sync.neutron_client.port.create.called)
Exemple #2
0
 def test_delete_outdated_flat_mapped_networks_clean(
         self, mock_session, mock_delete, mock_list_net,
         mock_oneview_client):
     network_unmapped = test_oneview_mech_driver.FakeNetwork()
     network_unmapped.manageable = False
     mock_list_net.return_value = [network_unmapped]
     common.delete_outdated_flat_mapped_networks(
         test_oneview_mech_driver.FLAT_NET_MAPPINGS)
     self.assertTrue(mock_delete.called)
    def test_synchronize_uplinkset_from_mapped_networks_no_segment(
            self, mock_session, mock_segment, mock_list_net):
        fake_network = mech_test.FakeNetwork()
        mock_list_net.return_value = [fake_network]
        mock_segment.return_value = None

        self.sync.synchronize_uplinkset_from_mapped_networks()

        self.assertFalse(
            self.sync.neutron_client.network.update_network_lig.called)
    def test_synchronize_uplinkset_from_mapped_networks(
            self, mock_session, mock_segment, mock_list_net):
        session = mock_session()
        fake_network = mech_test.FakeNetwork()
        mock_list_net.return_value = [fake_network]
        mock_segment.return_value = {
            'network_type': 'flat',
            'physical_network': 'physnet'
        }

        self.sync.synchronize_uplinkset_from_mapped_networks()

        self.sync.neutron_client.network.update_network_lig.assert_called_with(
            session, fake_network.oneview_network_id, 'flat', 'physnet')