Merge "objects: Add 'InstanceNUMATopology.cpu_pinning' property"
This commit is contained in:
commit
0012fdfdc3
|
@ -12,6 +12,8 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import itertools
|
||||
|
||||
from oslo_serialization import jsonutils
|
||||
from oslo_utils import versionutils
|
||||
|
||||
|
@ -217,6 +219,13 @@ class InstanceNUMATopology(base.NovaObject,
|
|||
InstanceNUMACell._from_dict(cell_dict)
|
||||
for cell_dict in data_dict.get('cells', [])])
|
||||
|
||||
@property
|
||||
def cpu_pinning(self):
|
||||
"""Return a set of all host CPUs this NUMATopology is pinned to."""
|
||||
return set(itertools.chain.from_iterable([
|
||||
cell.cpu_pinning.values() for cell in self.cells
|
||||
if cell.cpu_pinning]))
|
||||
|
||||
@property
|
||||
def cpu_pinning_requested(self):
|
||||
return all(cell.cpu_pinning_requested for cell in self.cells)
|
||||
|
|
|
@ -137,6 +137,19 @@ class _TestInstanceNUMATopology(object):
|
|||
inst_cell.cpu_policy = fields.CPUAllocationPolicy.DEDICATED
|
||||
self.assertTrue(inst_cell.cpu_pinning_requested)
|
||||
|
||||
def test_cpu_pinning(self):
|
||||
topo_obj = get_fake_obj_numa_topology(self.context)
|
||||
|
||||
self.assertEqual(set(), topo_obj.cpu_pinning)
|
||||
|
||||
topo_obj.cells[0].pin_vcpus((1, 10), (2, 11))
|
||||
|
||||
self.assertEqual(set([10, 11]), topo_obj.cpu_pinning)
|
||||
|
||||
topo_obj.cells[1].pin_vcpus((3, 0), (4, 1))
|
||||
|
||||
self.assertEqual(set([0, 1, 10, 11]), topo_obj.cpu_pinning)
|
||||
|
||||
def test_cpu_pinning_requested(self):
|
||||
fake_topo_obj = copy.deepcopy(fake_obj_numa_topology)
|
||||
self.assertFalse(fake_topo_obj.cpu_pinning_requested)
|
||||
|
|
Loading…
Reference in New Issue