Fix bug 2275
[osm/RO.git] / RO-VIM-openstack / osm_rovim_openstack / tests / test_vimconn_openstack.py
index be60c36..81a4274 100644 (file)
@@ -1127,6 +1127,11 @@ class TestSfcOperations(unittest.TestCase):
         self.assertEqual(result, "638f957c-82df-11e7-b7c8-132706021464")
 
 
+def check_if_assert_not_called(mocks: list):
+    for mocking in mocks:
+        mocking.assert_not_called()
+
+
 class Status:
     def __init__(self, s):
         self.status = s
@@ -2671,6 +2676,7 @@ class TestNewVmInstance(unittest.TestCase):
         """Prepare disks for VM instance successfully."""
         existing_vim_volumes = []
         created_items = {}
+        block_device_mapping = {}
         vm_av_zone = ["nova"]
 
         mock_root_volumes.return_value = root_vol_id
@@ -2679,7 +2685,12 @@ class TestNewVmInstance(unittest.TestCase):
         self.vimconn.cinder = CopyingMock()
 
         self.vimconn._prepare_disk_for_vminstance(
-            name, existing_vim_volumes, created_items, vm_av_zone, disk_list2
+            name,
+            existing_vim_volumes,
+            created_items,
+            vm_av_zone,
+            block_device_mapping,
+            disk_list2,
         )
         self.vimconn.cinder.volumes.set_bootable.assert_called_once_with(
             root_vol_id, True
@@ -2722,6 +2733,7 @@ class TestNewVmInstance(unittest.TestCase):
         existing_vim_volumes = []
         created_items = {}
         vm_av_zone = ["nova"]
+        block_device_mapping = {}
 
         mock_root_volumes.return_value = root_vol_id
         mock_created_vol_availability.return_value = 1700
@@ -2729,7 +2741,12 @@ class TestNewVmInstance(unittest.TestCase):
 
         with self.assertRaises(VimConnException) as err:
             self.vimconn._prepare_disk_for_vminstance(
-                name, existing_vim_volumes, created_items, vm_av_zone, disk_list2
+                name,
+                existing_vim_volumes,
+                created_items,
+                vm_av_zone,
+                block_device_mapping,
+                disk_list2,
             )
         self.assertEqual(
             str(err.exception), "Timeout creating volumes for instance basicvm"
@@ -2774,12 +2791,18 @@ class TestNewVmInstance(unittest.TestCase):
         """Disk list is empty."""
         existing_vim_volumes = []
         created_items = {}
+        block_device_mapping = {}
         vm_av_zone = ["nova"]
         mock_created_vol_availability.return_value = 2
         mock_existing_vol_availability.return_value = 3
 
         self.vimconn._prepare_disk_for_vminstance(
-            name, existing_vim_volumes, created_items, vm_av_zone, disk_list
+            name,
+            existing_vim_volumes,
+            created_items,
+            vm_av_zone,
+            block_device_mapping,
+            disk_list,
         )
         self.vimconn.cinder.volumes.set_bootable.assert_not_called()
         mock_created_vol_availability.assert_called_once_with(0, created_items)
@@ -2802,6 +2825,7 @@ class TestNewVmInstance(unittest.TestCase):
         existing_vim_volumes = []
         created_items = {}
         vm_av_zone = ["nova"]
+        block_device_mapping = {}
 
         mock_root_volumes.side_effect = Exception()
         mock_created_vol_availability.return_value = 10
@@ -2809,7 +2833,12 @@ class TestNewVmInstance(unittest.TestCase):
 
         with self.assertRaises(Exception):
             self.vimconn._prepare_disk_for_vminstance(
-                name, existing_vim_volumes, created_items, vm_av_zone, disk_list2
+                name,
+                existing_vim_volumes,
+                created_items,
+                vm_av_zone,
+                block_device_mapping,
+                disk_list2,
             )
         self.vimconn.cinder.volumes.set_bootable.assert_not_called()
         mock_created_vol_availability.assert_not_called()
@@ -2840,13 +2869,19 @@ class TestNewVmInstance(unittest.TestCase):
         existing_vim_volumes = []
         created_items = {}
         vm_av_zone = ["nova"]
+        block_device_mapping = {}
 
         mock_root_volumes.return_value = root_vol_id
         mock_non_root_volumes.side_effect = Exception
 
         with self.assertRaises(Exception):
             self.vimconn._prepare_disk_for_vminstance(
-                name, existing_vim_volumes, created_items, vm_av_zone, disk_list2
+                name,
+                existing_vim_volumes,
+                created_items,
+                vm_av_zone,
+                block_device_mapping,
+                disk_list2,
             )
         self.vimconn.cinder.volumes.set_bootable.assert_not_called()
         mock_created_vol_availability.assert_not_called()
@@ -4021,6 +4056,7 @@ class TestNewVmInstance(unittest.TestCase):
             existing_vim_volumes=[],
             created_items={},
             vm_av_zone="nova",
+            block_device_mapping={},
             disk_list=disk_list2,
         )
         self.vimconn.nova.servers.create.assert_called_once_with(
@@ -4033,7 +4069,7 @@ class TestNewVmInstance(unittest.TestCase):
             key_name="my_keypair",
             userdata="userdata",
             config_drive=True,
-            block_device_mapping=None,
+            block_device_mapping={},
             scheduler_hints={},
         )
         mock_time.assert_called_once()
@@ -4187,6 +4223,7 @@ class TestNewVmInstance(unittest.TestCase):
             existing_vim_volumes=[],
             created_items={},
             vm_av_zone="nova",
+            block_device_mapping={},
             disk_list=disk_list2,
         )
         self.vimconn.nova.servers.create.assert_called_once_with(
@@ -4199,7 +4236,7 @@ class TestNewVmInstance(unittest.TestCase):
             key_name="my_keypair",
             userdata="userdata",
             config_drive=True,
-            block_device_mapping=None,
+            block_device_mapping={},
             scheduler_hints={},
         )
         mock_time.assert_called_once()
@@ -4281,6 +4318,7 @@ class TestNewVmInstance(unittest.TestCase):
             existing_vim_volumes=[],
             created_items={},
             vm_av_zone="nova",
+            block_device_mapping={},
             disk_list=disk_list2,
         )
         self.vimconn.nova.servers.create.assert_called_once_with(
@@ -4293,7 +4331,7 @@ class TestNewVmInstance(unittest.TestCase):
             key_name="my_keypair",
             userdata="userdata",
             config_drive=True,
-            block_device_mapping=None,
+            block_device_mapping={},
             scheduler_hints={"group": "38b73-e9cc-5a6a-t270-82cc4811bd4a"},
         )
         mock_time.assert_called_once()
@@ -4374,6 +4412,7 @@ class TestNewVmInstance(unittest.TestCase):
             existing_vim_volumes=[],
             created_items={},
             vm_av_zone="nova",
+            block_device_mapping={},
             disk_list=disk_list2,
         )
 
@@ -4387,7 +4426,7 @@ class TestNewVmInstance(unittest.TestCase):
             key_name="my_keypair",
             userdata="userdata",
             config_drive=True,
-            block_device_mapping=None,
+            block_device_mapping={},
             scheduler_hints={},
         )
         mock_time.assert_not_called()
@@ -4830,51 +4869,17 @@ class TestNewVmInstance(unittest.TestCase):
     def test_delete_ports_by_id_by_neutron(self):
         """neutron delete ports."""
         k_id = port_id
-        self.vimconn.neutron.list_ports.return_value = {
-            "ports": [{"id": port_id}, {"id": port2_id}]
-        }
-
         self.vimconn._delete_ports_by_id_wth_neutron(k_id)
-        self.vimconn.neutron.list_ports.assert_called_once()
         self.vimconn.neutron.delete_port.assert_called_once_with(k_id)
         self.vimconn.logger.error.assert_not_called()
 
-    def test_delete_ports_by_id_by_neutron_id_not_in_port_list(self):
-        """port id not in the port list."""
-        k_id = volume_id
-        self.vimconn.neutron.list_ports.return_value = {
-            "ports": [{"id": port_id}, {"id": port2_id}]
-        }
-
-        self.vimconn._delete_ports_by_id_wth_neutron(k_id)
-        self.vimconn.neutron.list_ports.assert_called_once()
-        self.vimconn.neutron.delete_port.assert_not_called()
-        self.vimconn.logger.error.assert_not_called()
-
-    def test_delete_ports_by_id_by_neutron_list_port_raise_exception(self):
-        """neutron list port raises exception."""
-        k_id = port_id
-        self.vimconn.neutron.list_ports.side_effect = nvExceptions.ClientException(
-            "Connection aborted."
-        )
-        self.vimconn._delete_ports_by_id_wth_neutron(k_id)
-        self.vimconn.neutron.list_ports.assert_called_once()
-        self.vimconn.neutron.delete_port.assert_not_called()
-        self.vimconn.logger.error.assert_called_once_with(
-            "Error deleting port: ClientException: Unknown Error (HTTP Connection aborted.)"
-        )
-
     def test_delete_ports_by_id_by_neutron_delete_port_raise_exception(self):
         """neutron delete port raises exception."""
         k_id = port_id
-        self.vimconn.neutron.list_ports.return_value = {
-            "ports": [{"id": port_id}, {"id": port2_id}]
-        }
         self.vimconn.neutron.delete_port.side_effect = nvExceptions.ClientException(
             "Connection aborted."
         )
         self.vimconn._delete_ports_by_id_wth_neutron(k_id)
-        self.vimconn.neutron.list_ports.assert_called_once()
         self.vimconn.neutron.delete_port.assert_called_once_with(k_id)
         self.vimconn.logger.error.assert_called_once_with(
             "Error deleting port: ClientException: Unknown Error (HTTP Connection aborted.)"
@@ -5445,6 +5450,67 @@ class TestNewVmInstance(unittest.TestCase):
         self.assertEqual(mock_sleep.call_count, 1800)
         mock_format_exception.assert_not_called()
 
+    @patch.object(vimconnector, "_reload_connection", new_callable=CopyingMock())
+    def test_get_monitoring_data(self, mock_reload_conection):
+        servers = ["server1", "server2"]
+        ports = {"ports": ["port1", "port2"]}
+        self.vimconn.nova.servers.list.return_value = servers
+        self.vimconn.neutron.list_ports.return_value = ports
+        result = self.vimconn.get_monitoring_data()
+        self.assertTupleEqual(result, (servers, ports))
+        mock_reload_conection.assert_called_once()
+        self.vimconn.nova.servers.list.assert_called_once_with(detailed=True)
+        self.vimconn.neutron.list_ports.assert_called_once()
+
+    @patch.object(vimconnector, "_reload_connection", new_callable=CopyingMock())
+    def test_get_monitoring_data_reload_connection_raises(self, mock_reload_conection):
+        mock_reload_conection.side_effect = VimConnNotFoundException(
+            "Connection object not found."
+        )
+        with self.assertRaises(VimConnException) as err:
+            result = self.vimconn.get_monitoring_data()
+            self.assertTupleEqual(result, None)
+        self.assertEqual(
+            str(err.exception.args[0]),
+            "Exception in monitoring while getting VMs and ports status: Connection object not found.",
+        )
+        mock_reload_conection.assert_called_once()
+        check_if_assert_not_called(
+            [self.vimconn.nova.servers.list, self.vimconn.neutron.list_ports]
+        )
+
+    @patch.object(vimconnector, "_reload_connection", new_callable=CopyingMock())
+    def test_get_monitoring_data_server_list_raises(self, mock_reload_conection):
+        self.vimconn.nova.servers.list.side_effect = VimConnConnectionException(
+            "Can not connect to Cloud API."
+        )
+        with self.assertRaises(VimConnException) as err:
+            result = self.vimconn.get_monitoring_data()
+            self.assertTupleEqual(result, None)
+        self.assertEqual(
+            str(err.exception.args[0]),
+            "Exception in monitoring while getting VMs and ports status: Can not connect to Cloud API.",
+        )
+        mock_reload_conection.assert_called_once()
+        self.vimconn.nova.servers.list.assert_called_once_with(detailed=True)
+        self.vimconn.neutron.list_ports.assert_not_called()
+
+    @patch.object(vimconnector, "_reload_connection", new_callable=CopyingMock())
+    def test_get_monitoring_data_list_ports_raises(self, mock_reload_conection):
+        self.vimconn.neutron.list_ports.side_effect = VimConnConnectionException(
+            "Can not connect to Cloud API."
+        )
+        with self.assertRaises(VimConnException) as err:
+            result = self.vimconn.get_monitoring_data()
+            self.assertTupleEqual(result, None)
+        self.assertEqual(
+            str(err.exception.args[0]),
+            "Exception in monitoring while getting VMs and ports status: Can not connect to Cloud API.",
+        )
+        mock_reload_conection.assert_called_once()
+        self.vimconn.nova.servers.list.assert_called_once_with(detailed=True)
+        self.vimconn.neutron.list_ports.assert_called_once()
+
 
 class TestNewFlavor(unittest.TestCase):
     @patch("logging.getLogger", autospec=True)
@@ -5469,11 +5535,7 @@ class TestNewFlavor(unittest.TestCase):
         self.new_flavor.id = "075d2482-5edb-43e3-91b3-234e65b6268a"
         self.vimconn.nova.flavors.create.return_value = self.new_flavor
 
-    @staticmethod
-    def check_if_assert_not_called(mocks: list):
-        for mocking in mocks:
-            mocking.assert_not_called()
-
+    @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
     @patch.object(
@@ -5490,6 +5552,7 @@ class TestNewFlavor(unittest.TestCase):
         mock_process_numa_paired_threads,
         mock_process_numa_vcpu,
         mock_process_numa_memory,
+        mock_process_vio_numa_nodes,
     ):
         """Process numa parameters, id, memory, vcpu exist, vim type is VIO,
         paired-threads, cores, threads do not exist in numa.
@@ -5501,8 +5564,6 @@ class TestNewFlavor(unittest.TestCase):
         extra_specs = {}
         expected_extra_specs = {
             "hw:numa_nodes": "2",
-            "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-            "vmware:latency_sensitivity_level": "high",
             "hw:cpu_sockets": "2",
         }
         self.vimconn.vim_type = "VIO"
@@ -5510,6 +5571,7 @@ class TestNewFlavor(unittest.TestCase):
 
         self.assertEqual(mock_process_numa_memory.call_count, 2)
         self.assertEqual(mock_process_numa_vcpu.call_count, 2)
+        mock_process_vio_numa_nodes.assert_called_once_with(2, {"hw:numa_nodes": "2"})
         _call_mock_process_numa_memory = mock_process_numa_memory.call_args_list
         self.assertEqual(
             _call_mock_process_numa_memory[0].args,
@@ -5518,8 +5580,6 @@ class TestNewFlavor(unittest.TestCase):
                 0,
                 {
                     "hw:numa_nodes": "2",
-                    "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-                    "vmware:latency_sensitivity_level": "high",
                 },
             ),
         )
@@ -5531,8 +5591,6 @@ class TestNewFlavor(unittest.TestCase):
                 {
                     "hw:cpu_sockets": "2",
                     "hw:numa_nodes": "2",
-                    "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-                    "vmware:latency_sensitivity_level": "high",
                 },
             ),
         )
@@ -5544,8 +5602,6 @@ class TestNewFlavor(unittest.TestCase):
                 0,
                 {
                     "hw:numa_nodes": "2",
-                    "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-                    "vmware:latency_sensitivity_level": "high",
                 },
             ),
         )
@@ -5557,13 +5613,11 @@ class TestNewFlavor(unittest.TestCase):
                 {
                     "hw:cpu_sockets": "2",
                     "hw:numa_nodes": "2",
-                    "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-                    "vmware:latency_sensitivity_level": "high",
                 },
             ),
         )
         self.assertDictEqual(extra_specs, expected_extra_specs)
-        self.check_if_assert_not_called(
+        check_if_assert_not_called(
             [
                 mock_process_numa_threads,
                 mock_process_numa_cores,
@@ -5571,6 +5625,7 @@ class TestNewFlavor(unittest.TestCase):
             ]
         )
 
+    @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
     @patch.object(
@@ -5587,6 +5642,7 @@ class TestNewFlavor(unittest.TestCase):
         mock_process_numa_paired_threads,
         mock_process_numa_vcpu,
         mock_process_numa_memory,
+        mock_process_vio_numa_nodes,
     ):
         """Process numa parameters, id, memory, vcpu exist, vim type is openstack,
         paired-threads, cores, threads do not exist in numa.
@@ -5640,7 +5696,7 @@ class TestNewFlavor(unittest.TestCase):
             ),
         )
         self.assertDictEqual(extra_specs, expected_extra_specs)
-        self.check_if_assert_not_called(
+        check_if_assert_not_called(
             [
                 mock_process_numa_threads,
                 mock_process_numa_cores,
@@ -5648,6 +5704,7 @@ class TestNewFlavor(unittest.TestCase):
             ]
         )
 
+    @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
     @patch.object(
@@ -5664,6 +5721,7 @@ class TestNewFlavor(unittest.TestCase):
         mock_process_numa_paired_threads,
         mock_process_numa_vcpu,
         mock_process_numa_memory,
+        mock_process_vio_numa_nodes,
     ):
         """Process numa parameters, id, paired-threads exist, vim type is openstack.
         vcpus calculation according to paired-threads in numa, there is extra_spec.
@@ -5680,9 +5738,7 @@ class TestNewFlavor(unittest.TestCase):
         mock_process_numa_paired_threads.side_effect = [6, 6]
         self.vimconn._process_numa_parameters_of_flavor(numas, extra_specs)
 
-        self.check_if_assert_not_called(
-            [mock_process_numa_threads, mock_process_numa_cores]
-        )
+        check_if_assert_not_called([mock_process_numa_threads, mock_process_numa_cores])
         self.assertEqual(mock_process_numa_memory.call_count, 2)
         self.assertEqual(mock_process_numa_vcpu.call_count, 2)
         self.assertEqual(mock_process_numa_paired_threads.call_count, 2)
@@ -5705,6 +5761,7 @@ class TestNewFlavor(unittest.TestCase):
         )
         self.assertDictEqual(extra_specs, expected_extra_specs)
 
+    @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
     @patch.object(
@@ -5721,6 +5778,7 @@ class TestNewFlavor(unittest.TestCase):
         mock_process_numa_paired_threads,
         mock_process_numa_vcpu,
         mock_process_numa_memory,
+        mock_process_vio_numa_nodes,
     ):
         """Process numa parameters, id, paired-threads exist, vim type is VIO.
         vcpus calculation according to paired-threads in numa, there is extra_spec.
@@ -5729,8 +5787,6 @@ class TestNewFlavor(unittest.TestCase):
         extra_specs = {"some-key": "some-value"}
         expected_extra_specs = {
             "hw:numa_nodes": "2",
-            "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-            "vmware:latency_sensitivity_level": "high",
             "hw:cpu_sockets": "2",
             "hw:cpu_threads": "8",
             "some-key": "some-value",
@@ -5738,15 +5794,16 @@ class TestNewFlavor(unittest.TestCase):
         self.vimconn.vim_type = "VIO"
         mock_process_numa_paired_threads.side_effect = [4, 4]
         self.vimconn._process_numa_parameters_of_flavor(numas, extra_specs)
-        self.check_if_assert_not_called(
-            [mock_process_numa_threads, mock_process_numa_cores]
-        )
+        check_if_assert_not_called([mock_process_numa_threads, mock_process_numa_cores])
         self.assertEqual(mock_process_numa_paired_threads.call_count, 2)
         self.assertEqual(mock_process_numa_memory.call_count, 2)
         self.assertEqual(mock_process_numa_vcpu.call_count, 2)
         _call_mock_process_numa_paired_threads = (
             mock_process_numa_paired_threads.call_args_list
         )
+        mock_process_vio_numa_nodes.assert_called_once_with(
+            2, {"some-key": "some-value", "hw:numa_nodes": "2"}
+        )
         self.assertEqual(
             _call_mock_process_numa_paired_threads[0].args,
             (
@@ -5755,8 +5812,6 @@ class TestNewFlavor(unittest.TestCase):
                     "hw:cpu_sockets": "2",
                     "hw:numa_nodes": "2",
                     "some-key": "some-value",
-                    "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-                    "vmware:latency_sensitivity_level": "high",
                 },
             ),
         )
@@ -5768,13 +5823,12 @@ class TestNewFlavor(unittest.TestCase):
                     "hw:cpu_sockets": "2",
                     "hw:numa_nodes": "2",
                     "some-key": "some-value",
-                    "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-                    "vmware:latency_sensitivity_level": "high",
                 },
             ),
         )
         self.assertDictEqual(extra_specs, expected_extra_specs)
 
+    @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
     @patch.object(
@@ -5791,6 +5845,7 @@ class TestNewFlavor(unittest.TestCase):
         mock_process_numa_paired_threads,
         mock_process_numa_vcpu,
         mock_process_numa_memory,
+        mock_process_vio_numa_nodes,
     ):
         """Process numa parameters, id, cores exist, vim type is openstack.
         vcpus calculation according to cores in numa.
@@ -5807,7 +5862,7 @@ class TestNewFlavor(unittest.TestCase):
         mock_process_numa_cores.side_effect = [1, 2]
         self.vimconn._process_numa_parameters_of_flavor(numas, extra_specs)
 
-        self.check_if_assert_not_called(
+        check_if_assert_not_called(
             [mock_process_numa_threads, mock_process_numa_paired_threads]
         )
         self.assertEqual(mock_process_numa_cores.call_count, 2)
@@ -5824,6 +5879,7 @@ class TestNewFlavor(unittest.TestCase):
         )
         self.assertDictEqual(extra_specs, expected_extra_specs)
 
+    @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
     @patch.object(
@@ -5840,6 +5896,7 @@ class TestNewFlavor(unittest.TestCase):
         mock_process_numa_paired_threads,
         mock_process_numa_vcpu,
         mock_process_numa_memory,
+        mock_process_vio_numa_nodes,
     ):
         """Process numa parameters, id, cores exist, vim type is VIO.
         vcpus calculation according to cores in numa.
@@ -5850,18 +5907,17 @@ class TestNewFlavor(unittest.TestCase):
             "hw:cpu_cores": "3",
             "hw:cpu_sockets": "2",
             "hw:numa_nodes": "2",
-            "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-            "vmware:latency_sensitivity_level": "high",
         }
         self.vimconn.vim_type = "VIO"
         mock_process_numa_cores.side_effect = [1, 2]
         self.vimconn._process_numa_parameters_of_flavor(numas, extra_specs)
-        self.check_if_assert_not_called(
+        check_if_assert_not_called(
             [mock_process_numa_threads, mock_process_numa_paired_threads]
         )
         self.assertEqual(mock_process_numa_memory.call_count, 2)
         self.assertEqual(mock_process_numa_vcpu.call_count, 2)
         self.assertEqual(mock_process_numa_cores.call_count, 2)
+        mock_process_vio_numa_nodes.assert_called_once_with(2, {"hw:numa_nodes": "2"})
         _call_mock_process_numa_cores = mock_process_numa_cores.call_args_list
         self.assertEqual(
             _call_mock_process_numa_cores[0].args,
@@ -5870,8 +5926,6 @@ class TestNewFlavor(unittest.TestCase):
                 {
                     "hw:cpu_sockets": "2",
                     "hw:numa_nodes": "2",
-                    "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-                    "vmware:latency_sensitivity_level": "high",
                 },
             ),
         )
@@ -5882,13 +5936,12 @@ class TestNewFlavor(unittest.TestCase):
                 {
                     "hw:cpu_sockets": "2",
                     "hw:numa_nodes": "2",
-                    "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-                    "vmware:latency_sensitivity_level": "high",
                 },
             ),
         )
         self.assertDictEqual(extra_specs, expected_extra_specs)
 
+    @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
     @patch.object(
@@ -5905,6 +5958,7 @@ class TestNewFlavor(unittest.TestCase):
         mock_process_numa_paired_threads,
         mock_process_numa_vcpu,
         mock_process_numa_memory,
+        mock_process_vio_numa_nodes,
     ):
         """Process numa parameters, memory, vcpu, thread exist, vim type is VIO,
         vcpus calculation according threads in numa, there are not numa ids.
@@ -5916,15 +5970,13 @@ class TestNewFlavor(unittest.TestCase):
         extra_specs = {}
         expected_extra_specs = {
             "hw:numa_nodes": "2",
-            "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-            "vmware:latency_sensitivity_level": "high",
             "hw:cpu_sockets": "2",
             "hw:cpu_threads": "3",
         }
         self.vimconn.vim_type = "VIO"
         mock_process_numa_threads.return_value = 3
         self.vimconn._process_numa_parameters_of_flavor(numas, extra_specs)
-        self.check_if_assert_not_called(
+        check_if_assert_not_called(
             [
                 mock_process_numa_memory,
                 mock_process_numa_vcpu,
@@ -5932,6 +5984,7 @@ class TestNewFlavor(unittest.TestCase):
                 mock_process_numa_paired_threads,
             ]
         )
+        mock_process_vio_numa_nodes.assert_called_once_with(2, {"hw:numa_nodes": "2"})
         self.assertEqual(mock_process_numa_threads.call_count, 1)
         _call_mock_process_numa_threads = mock_process_numa_threads.call_args_list
         self.assertEqual(
@@ -5941,13 +5994,12 @@ class TestNewFlavor(unittest.TestCase):
                 {
                     "hw:cpu_sockets": "2",
                     "hw:numa_nodes": "2",
-                    "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-                    "vmware:latency_sensitivity_level": "high",
                 },
             ),
         )
         self.assertDictEqual(extra_specs, expected_extra_specs)
 
+    @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
     @patch.object(
@@ -5964,6 +6016,7 @@ class TestNewFlavor(unittest.TestCase):
         mock_process_numa_paired_threads,
         mock_process_numa_vcpu,
         mock_process_numa_memory,
+        mock_process_vio_numa_nodes,
     ):
         """Process numa parameters, memory, vcpu, thread exist, vim type is openstack,
         vcpus calculation according threads in numa, there are not numa ids.
@@ -5982,12 +6035,13 @@ class TestNewFlavor(unittest.TestCase):
         mock_process_numa_threads.return_value = 3
         self.vimconn._process_numa_parameters_of_flavor(numas, extra_specs)
 
-        self.check_if_assert_not_called(
+        check_if_assert_not_called(
             [
                 mock_process_numa_memory,
                 mock_process_numa_vcpu,
                 mock_process_numa_cores,
                 mock_process_numa_paired_threads,
+                mock_process_vio_numa_nodes,
             ]
         )
         self.assertEqual(mock_process_numa_threads.call_count, 1)
@@ -6001,6 +6055,7 @@ class TestNewFlavor(unittest.TestCase):
         )
         self.assertDictEqual(extra_specs, expected_extra_specs)
 
+    @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
     @patch.object(
@@ -6017,18 +6072,15 @@ class TestNewFlavor(unittest.TestCase):
         mock_process_numa_paired_threads,
         mock_process_numa_vcpu,
         mock_process_numa_memory,
+        mock_process_vio_numa_nodes,
     ):
         """Numa list is empty, vim type is VIO."""
         numas = []
         extra_specs = {}
-        expected_extra_specs = {
-            "hw:numa_nodes": "0",
-            "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-            "vmware:latency_sensitivity_level": "high",
-        }
+        expected_extra_specs = {"hw:numa_nodes": "0"}
         self.vimconn.vim_type = "VIO"
         self.vimconn._process_numa_parameters_of_flavor(numas, extra_specs)
-        self.check_if_assert_not_called(
+        check_if_assert_not_called(
             [
                 mock_process_numa_memory,
                 mock_process_numa_vcpu,
@@ -6037,8 +6089,10 @@ class TestNewFlavor(unittest.TestCase):
                 mock_process_numa_threads,
             ]
         )
+        mock_process_vio_numa_nodes.assert_called_once_with(0, {"hw:numa_nodes": "0"})
         self.assertDictEqual(extra_specs, expected_extra_specs)
 
+    @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
     @patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
     @patch.object(
@@ -6055,6 +6109,7 @@ class TestNewFlavor(unittest.TestCase):
         mock_process_numa_paired_threads,
         mock_process_numa_vcpu,
         mock_process_numa_memory,
+        mock_process_vio_numa_nodes,
     ):
         """Numa list is empty, vim type is openstack."""
         numas = []
@@ -6064,13 +6119,14 @@ class TestNewFlavor(unittest.TestCase):
         mock_process_numa_threads.return_value = None
         self.vimconn._process_numa_parameters_of_flavor(numas, extra_specs)
 
-        self.check_if_assert_not_called(
+        check_if_assert_not_called(
             [
                 mock_process_numa_memory,
                 mock_process_numa_vcpu,
                 mock_process_numa_cores,
                 mock_process_numa_paired_threads,
                 mock_process_numa_threads,
+                mock_process_vio_numa_nodes,
             ]
         )
         self.assertDictEqual(extra_specs, expected_extra_specs)
@@ -6700,7 +6756,7 @@ class TestNewFlavor(unittest.TestCase):
         extended = {}
         extra_specs = {}
         self.vimconn._process_extended_config_of_flavor(extended, extra_specs)
-        self.check_if_assert_not_called(
+        check_if_assert_not_called(
             [mock_process_resource_quota, mock_process_numa_parameters_of_flavor]
         )
         self.assertEqual(extra_specs, {})
@@ -6812,9 +6868,7 @@ class TestNewFlavor(unittest.TestCase):
         self.vimconn.nova.flavors.create.assert_called_once_with(
             name=name1, ram=3, vcpus=vcpus, disk=50, ephemeral=0, swap=0, is_public=True
         )
-        self.check_if_assert_not_called(
-            [self.new_flavor.set_keys, mock_format_exception]
-        )
+        check_if_assert_not_called([self.new_flavor.set_keys, mock_format_exception])
 
     @patch.object(vimconnector, "_get_flavor_details", new_callable=CopyingMock())
     @patch.object(
@@ -6845,7 +6899,7 @@ class TestNewFlavor(unittest.TestCase):
         self.vimconn.nova.flavors.create.assert_called_once_with(
             name=name1, ram=3, vcpus=8, disk=50, ephemeral=0, swap=0, is_public=True
         )
-        self.check_if_assert_not_called(
+        check_if_assert_not_called(
             [mock_change_flavor_name, mock_format_exception, self.new_flavor.set_keys]
         )
 
@@ -6881,7 +6935,7 @@ class TestNewFlavor(unittest.TestCase):
         self.vimconn.nova.flavors.create.assert_called_once_with(
             name=name1, ram=3, vcpus=8, disk=50, ephemeral=0, swap=0, is_public=True
         )
-        self.check_if_assert_not_called(
+        check_if_assert_not_called(
             [
                 self.new_flavor.set_keys,
                 mock_extended_config_of_flavor,
@@ -6919,7 +6973,7 @@ class TestNewFlavor(unittest.TestCase):
         self.assertEqual(
             str(call_mock_format_exception[0][0]), str(ClientException(error_msg))
         )
-        self.check_if_assert_not_called(
+        check_if_assert_not_called(
             [
                 mock_change_flavor_name,
                 mock_get_flavor_details,
@@ -6958,7 +7012,7 @@ class TestNewFlavor(unittest.TestCase):
         self.assertEqual(
             str(call_mock_format_exception[0][0]), str(KeyError(error_msg))
         )
-        self.check_if_assert_not_called(
+        check_if_assert_not_called(
             [
                 mock_reload_connection,
                 mock_change_flavor_name,
@@ -7008,9 +7062,7 @@ class TestNewFlavor(unittest.TestCase):
             swap=0,
             is_public=True,
         )
-        self.check_if_assert_not_called(
-            [self.new_flavor.set_keys, mock_format_exception]
-        )
+        check_if_assert_not_called([self.new_flavor.set_keys, mock_format_exception])
 
     @patch.object(vimconnector, "_get_flavor_details", new_callable=CopyingMock())
     @patch.object(
@@ -7052,7 +7104,7 @@ class TestNewFlavor(unittest.TestCase):
             swap=0,
             is_public=True,
         )
-        self.check_if_assert_not_called(
+        check_if_assert_not_called(
             [
                 self.new_flavor.set_keys,
                 mock_extended_config_of_flavor,
@@ -7100,7 +7152,7 @@ class TestNewFlavor(unittest.TestCase):
         self.assertEqual(mock_get_flavor_details.call_count, 3)
         self.assertEqual(self.vimconn.nova.flavors.create.call_count, 3)
         self.assertEqual(mock_reload_connection.call_count, 3)
-        self.check_if_assert_not_called(
+        check_if_assert_not_called(
             [mock_change_flavor_name, mock_extended_config_of_flavor]
         )
         _call_mock_format_exception = mock_format_exception.call_args
@@ -7289,6 +7341,51 @@ class TestNewFlavor(unittest.TestCase):
         )
         self.assertEqual(mock_format_exception.call_count, 1)
 
+    def test_process_process_vio_numa_nodes_without_numa_with_extra_spec(self):
+        numa_nodes = 0
+        extra_specs = {"hw:numa_nodes": "0"}
+        expected_extra_spec = {
+            "vmware:latency_sensitivity_level": "high",
+            "hw:numa_nodes": "0",
+        }
+        self.vimconn.process_vio_numa_nodes(numa_nodes, extra_specs)
+        self.assertDictEqual(extra_specs, expected_extra_spec)
+
+    def test_process_process_vio_numa_nodes_list_type_numa_nodes_empty_extra_spec(self):
+        numa_nodes = [7, 9, 4]
+        extra_specs = {}
+        expected_extra_spec = {
+            "vmware:latency_sensitivity_level": "high",
+        }
+        self.vimconn.process_vio_numa_nodes(numa_nodes, extra_specs)
+        self.assertDictEqual(extra_specs, expected_extra_spec)
+
+    def test_process_process_vio_numa_nodes_with_numa_with_extra_spec(self):
+        numa_nodes = 5
+        extra_specs = {"hw:numa_nodes": "5"}
+        expected_extra_spec = {
+            "vmware:latency_sensitivity_level": "high",
+            "hw:numa_nodes": "5",
+        }
+        self.vimconn.process_vio_numa_nodes(numa_nodes, extra_specs)
+        self.assertDictEqual(extra_specs, expected_extra_spec)
+
+    def test_process_process_vio_numa_nodes_none_numa_nodes(self):
+        numa_nodes = None
+        extra_specs = {"hw:numa_nodes": "None"}
+        expected_extra_spec = {
+            "vmware:latency_sensitivity_level": "high",
+            "hw:numa_nodes": "None",
+        }
+        self.vimconn.process_vio_numa_nodes(numa_nodes, extra_specs)
+        self.assertDictEqual(extra_specs, expected_extra_spec)
+
+    def test_process_process_vio_numa_nodes_invalid_type_extra_specs(self):
+        numa_nodes = 5
+        extra_specs = []
+        with self.assertRaises(TypeError):
+            self.vimconn.process_vio_numa_nodes(numa_nodes, extra_specs)
+
 
 if __name__ == "__main__":
     unittest.main()