Feature 10960 Performance optimizations for the polling of VM status in RO
[osm/RO.git] / RO-VIM-openstack / osm_rovim_openstack / tests / test_vimconn_openstack.py
index a351d53..47450c9 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
@@ -5801,7 +5806,6 @@ class TestNewVmInstance(unittest.TestCase):
         self.assertDictEqual(result, created_items)
 
     def test_update_block_device_mapping_empty_volume(self):
-        """"""
         volume = ""
         block_device_mapping = {}
         base_disk_index = 100
@@ -5816,7 +5820,6 @@ class TestNewVmInstance(unittest.TestCase):
         self.assertEqual(created_items, {})
 
     def test_update_block_device_mapping_invalid_volume(self):
-        """"""
         volume = "Volume-A"
         block_device_mapping = {}
         base_disk_index = 100
@@ -5833,7 +5836,6 @@ class TestNewVmInstance(unittest.TestCase):
         self.assertEqual(created_items, {})
 
     def test_update_block_device_mapping(self):
-        """"""
         volume = MagicMock(autospec=True)
         volume.id = volume_id
         block_device_mapping = {}
@@ -5851,7 +5853,6 @@ class TestNewVmInstance(unittest.TestCase):
         )
 
     def test_update_block_device_mapping_with_keep_flag(self):
-        """"""
         volume = MagicMock(autospec=True)
         volume.id = volume_id
         block_device_mapping = {}
@@ -5916,6 +5917,67 @@ class TestNewVmInstance(unittest.TestCase):
         with self.assertRaises(AttributeError):
             self.vimconn._extract_items_wth_keep_flag_from_created_items(created_items)
 
+    @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)
@@ -5940,11 +6002,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(
@@ -5961,6 +6019,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.
@@ -5972,8 +6031,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"
@@ -5981,6 +6038,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,
@@ -5989,8 +6047,6 @@ class TestNewFlavor(unittest.TestCase):
                 0,
                 {
                     "hw:numa_nodes": "2",
-                    "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-                    "vmware:latency_sensitivity_level": "high",
                 },
             ),
         )
@@ -6002,8 +6058,6 @@ class TestNewFlavor(unittest.TestCase):
                 {
                     "hw:cpu_sockets": "2",
                     "hw:numa_nodes": "2",
-                    "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-                    "vmware:latency_sensitivity_level": "high",
                 },
             ),
         )
@@ -6015,8 +6069,6 @@ class TestNewFlavor(unittest.TestCase):
                 0,
                 {
                     "hw:numa_nodes": "2",
-                    "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-                    "vmware:latency_sensitivity_level": "high",
                 },
             ),
         )
@@ -6028,13 +6080,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,
@@ -6042,6 +6092,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(
@@ -6058,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,
     ):
         """Process numa parameters, id, memory, vcpu exist, vim type is openstack,
         paired-threads, cores, threads do not exist in numa.
@@ -6111,7 +6163,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,
@@ -6119,6 +6171,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(
@@ -6135,6 +6188,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.
@@ -6151,9 +6205,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)
@@ -6176,6 +6228,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(
@@ -6192,6 +6245,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.
@@ -6200,8 +6254,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",
@@ -6209,15 +6261,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,
             (
@@ -6226,8 +6279,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",
                 },
             ),
         )
@@ -6239,13 +6290,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(
@@ -6262,6 +6312,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.
@@ -6278,7 +6329,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)
@@ -6295,6 +6346,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(
@@ -6311,6 +6363,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.
@@ -6321,18 +6374,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,
@@ -6341,8 +6393,6 @@ class TestNewFlavor(unittest.TestCase):
                 {
                     "hw:cpu_sockets": "2",
                     "hw:numa_nodes": "2",
-                    "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
-                    "vmware:latency_sensitivity_level": "high",
                 },
             ),
         )
@@ -6353,13 +6403,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(
@@ -6376,6 +6425,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.
@@ -6387,15 +6437,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,
@@ -6403,6 +6451,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(
@@ -6412,13 +6461,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(
@@ -6435,6 +6483,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.
@@ -6453,12 +6502,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)
@@ -6472,6 +6522,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(
@@ -6488,18 +6539,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,
@@ -6508,8 +6556,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(
@@ -6526,6 +6576,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 = []
@@ -6535,13 +6586,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)
@@ -7171,7 +7223,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, {})
@@ -7283,9 +7335,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(
@@ -7316,7 +7366,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]
         )
 
@@ -7352,7 +7402,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,
@@ -7390,7 +7440,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,
@@ -7429,7 +7479,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,
@@ -7479,9 +7529,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(
@@ -7523,7 +7571,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,
@@ -7571,7 +7619,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
@@ -7760,6 +7808,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()