Rename '_numa_get_constraints_XXX' functions
These don't actually return constraints but topologies. Rename and group them together. Change-Id: Id9627839c38798704dbffac3b52dfd4c4046b598
This commit is contained in:
@@ -1183,7 +1183,25 @@ def _get_cpu_thread_policy_constraints(flavor, image_meta):
|
|||||||
return policy
|
return policy
|
||||||
|
|
||||||
|
|
||||||
def _numa_get_constraints_manual(nodes, flavor, cpu_list, mem_list):
|
def _get_numa_topology_auto(nodes, flavor):
|
||||||
|
if ((flavor.vcpus % nodes) > 0 or
|
||||||
|
(flavor.memory_mb % nodes) > 0):
|
||||||
|
raise exception.ImageNUMATopologyAsymmetric()
|
||||||
|
|
||||||
|
cells = []
|
||||||
|
for node in range(nodes):
|
||||||
|
ncpus = int(flavor.vcpus / nodes)
|
||||||
|
mem = int(flavor.memory_mb / nodes)
|
||||||
|
start = node * ncpus
|
||||||
|
cpuset = set(range(start, start + ncpus))
|
||||||
|
|
||||||
|
cells.append(objects.InstanceNUMACell(
|
||||||
|
id=node, cpuset=cpuset, memory=mem))
|
||||||
|
|
||||||
|
return objects.InstanceNUMATopology(cells=cells)
|
||||||
|
|
||||||
|
|
||||||
|
def _get_numa_topology_manual(nodes, flavor, cpu_list, mem_list):
|
||||||
cells = []
|
cells = []
|
||||||
totalmem = 0
|
totalmem = 0
|
||||||
|
|
||||||
@@ -1248,24 +1266,6 @@ def vcpus_realtime_topology(flavor, image):
|
|||||||
return vcpus_rt
|
return vcpus_rt
|
||||||
|
|
||||||
|
|
||||||
def _numa_get_constraints_auto(nodes, flavor):
|
|
||||||
if ((flavor.vcpus % nodes) > 0 or
|
|
||||||
(flavor.memory_mb % nodes) > 0):
|
|
||||||
raise exception.ImageNUMATopologyAsymmetric()
|
|
||||||
|
|
||||||
cells = []
|
|
||||||
for node in range(nodes):
|
|
||||||
ncpus = int(flavor.vcpus / nodes)
|
|
||||||
mem = int(flavor.memory_mb / nodes)
|
|
||||||
start = node * ncpus
|
|
||||||
cpuset = set(range(start, start + ncpus))
|
|
||||||
|
|
||||||
cells.append(objects.InstanceNUMACell(
|
|
||||||
id=node, cpuset=cpuset, memory=mem))
|
|
||||||
|
|
||||||
return objects.InstanceNUMATopology(cells=cells)
|
|
||||||
|
|
||||||
|
|
||||||
def get_emulator_threads_constraint(flavor, image_meta):
|
def get_emulator_threads_constraint(flavor, image_meta):
|
||||||
"""Determines the emulator threads policy"""
|
"""Determines the emulator threads policy"""
|
||||||
emu_threads_policy = flavor.get('extra_specs', {}).get(
|
emu_threads_policy = flavor.get('extra_specs', {}).get(
|
||||||
@@ -1379,10 +1379,10 @@ def numa_get_constraints(flavor, image_meta):
|
|||||||
raise exception.ImageNUMATopologyIncomplete()
|
raise exception.ImageNUMATopologyIncomplete()
|
||||||
|
|
||||||
if cpu_list is None:
|
if cpu_list is None:
|
||||||
numa_topology = _numa_get_constraints_auto(
|
numa_topology = _get_numa_topology_auto(
|
||||||
nodes, flavor)
|
nodes, flavor)
|
||||||
else:
|
else:
|
||||||
numa_topology = _numa_get_constraints_manual(
|
numa_topology = _get_numa_topology_manual(
|
||||||
nodes, flavor, cpu_list, mem_list)
|
nodes, flavor, cpu_list, mem_list)
|
||||||
|
|
||||||
# We currently support same pagesize for all cells.
|
# We currently support same pagesize for all cells.
|
||||||
|
|||||||
Reference in New Issue
Block a user