diff --git a/hooks/neutron_ovs_context.py b/hooks/neutron_ovs_context.py index 74ff9355..bcefc5ff 100644 --- a/hooks/neutron_ovs_context.py +++ b/hooks/neutron_ovs_context.py @@ -278,9 +278,12 @@ def parse_cpu_list(cpulist): cores = [] ranges = cpulist.split(',') for cpu_range in ranges: - cpu_min_max = cpu_range.split('-') - cores += range(int(cpu_min_max[0]), - int(cpu_min_max[1]) + 1) + if "-" in cpu_range: + cpu_min_max = cpu_range.split('-') + cores += range(int(cpu_min_max[0]), + int(cpu_min_max[1]) + 1) + else: + cores.append(int(cpu_range)) return cores diff --git a/unit_tests/test_neutron_ovs_context.py b/unit_tests/test_neutron_ovs_context.py index 98ee1fd8..1fe1c93a 100644 --- a/unit_tests/test_neutron_ovs_context.py +++ b/unit_tests/test_neutron_ovs_context.py @@ -495,6 +495,7 @@ class MockPCIDevice(object): TEST_CPULIST_1 = "0-3" TEST_CPULIST_2 = "0-7,16-23" +TEST_CPULIST_3 = "0,4,8,12,16,20,24" DPDK_DATA_PORTS = ( "br-phynet3:fe:16:41:df:23:fe " "br-phynet1:fe:16:41:df:23:fd " @@ -518,6 +519,8 @@ class TestDPDKUtils(CharmTestCase): self.assertEqual(context.parse_cpu_list(TEST_CPULIST_2), [0, 1, 2, 3, 4, 5, 6, 7, 16, 17, 18, 19, 20, 21, 22, 23]) + self.assertEqual(context.parse_cpu_list(TEST_CPULIST_3), + [0, 4, 8, 12, 16, 20, 24]) @patch.object(context, 'parse_cpu_list', wraps=context.parse_cpu_list) def test_numa_node_cores(self, _parse_cpu_list):