Merge "objects: remove cpu_topology from __init__ of InstanceNUMATopology"

This commit is contained in:
Jenkins 2017-05-17 12:53:40 +00:00 committed by Gerrit Code Review
commit 01b1357e30
3 changed files with 8 additions and 7 deletions

View File

@ -66,9 +66,6 @@ class InstanceNUMACell(base.NovaObject,
if 'pagesize' not in kwargs:
self.pagesize = None
self.obj_reset_changes(['pagesize'])
if 'cpu_topology' not in kwargs:
self.cpu_topology = None
self.obj_reset_changes(['cpu_topology'])
if 'cpu_pinning' not in kwargs:
self.cpu_pinning = None
self.obj_reset_changes(['cpu_pinning_raw'])
@ -110,7 +107,7 @@ class InstanceNUMACell(base.NovaObject,
cpu_list = sorted(list(self.cpuset))
threads = 0
if self.cpu_topology:
if ('cpu_topology' in self) and self.cpu_topology:
threads = self.cpu_topology.threads
if threads == 1:
threads = 0

View File

@ -1840,10 +1840,12 @@ class HelperMethodsTestCase(test.NoDBTestCase):
cells=[
objects.InstanceNUMACell(
id=0, cpuset=set([0, 1]), memory=256, pagesize=2048,
cpu_pinning={0: 0, 1: 1}),
cpu_pinning={0: 0, 1: 1},
cpu_topology=None),
objects.InstanceNUMACell(
id=1, cpuset=set([2]), memory=256, pagesize=2048,
cpu_pinning={2: 3}),
cpu_pinning={2: 3},
cpu_topology=None),
])
self.context = context.RequestContext('fake-user',
'fake-project')

View File

@ -571,7 +571,8 @@ def _get_desirable_cpu_topologies(flavor, image_meta, allow_threads=True,
if numa_topology:
min_requested_threads = None
cell_topologies = [cell.cpu_topology for cell in numa_topology.cells
if cell.cpu_topology]
if ('cpu_topology' in cell
and cell.cpu_topology)]
if cell_topologies:
min_requested_threads = min(
topo.threads for topo in cell_topologies)
@ -1693,6 +1694,7 @@ def instance_topology_from_instance(instance):
cpuset=set(cell['cpuset']),
memory=cell['memory'],
pagesize=cell.get('pagesize'),
cpu_topology=cell.get('cpu_topology'),
cpu_pinning=cell.get('cpu_pinning_raw'),
cpu_policy=cell.get('cpu_policy'),
cpu_thread_policy=cell.get('cpu_thread_policy'),