Remove 'hardware.host_topology_and_format_from_host'

Since Id93a01fcaeaa6b95e49ded6b81249325126d012b, the 'numa_topology'
field of the 'nova.scheduler.host_manager.HostState' object will always
be a 'NUMATopology' object, meaning we don't need to call the
aforementioned function. With that call removed, we have no callers left
and can remove the function itself entirely.

Change-Id: I72cee470ac0bf380c9cd8d8f5c7d703e5374f65a
Signed-off-by: Stephen Finucane <sfinucan@redhat.com>
This commit is contained in:
Stephen Finucane 2019-07-18 18:22:05 +01:00
parent a44d84de62
commit 15799315a8
2 changed files with 2 additions and 34 deletions

View File

@ -29,8 +29,7 @@ class NUMATopologyFilter(filters.BaseHostFilter):
"""Check that the host_state provided satisfies any available
CPU policy requirements.
"""
host_topology, _ = hardware.host_topology_and_format_from_host(
host_state)
host_topology = host_state.numa_topology
# NOTE(stephenfin): There can be conflicts between the policy
# specified by the image and that specified by the instance, but this
# is not the place to resolve these. We do this during scheduling.
@ -72,8 +71,7 @@ class NUMATopologyFilter(filters.BaseHostFilter):
extra_specs = spec_obj.flavor.extra_specs
image_props = spec_obj.image.properties
requested_topology = spec_obj.numa_topology
host_topology, _fmt = hardware.host_topology_and_format_from_host(
host_state)
host_topology = host_state.numa_topology
pci_requests = spec_obj.pci_requests
network_metadata = None

View File

@ -2005,33 +2005,3 @@ def instance_topology_from_instance(instance):
emulator_threads_policy=emulator_threads_policy)
return instance_numa_topology
# TODO(ndipanov): Remove when all code paths are using objects
def host_topology_and_format_from_host(host):
"""Extract numa topology from myriad host representations.
Until the RPC version is bumped to 5.x, a host may be represented
as a dict, a db object, an actual ComputeNode object, or an
instance of HostState class. Identify the type received and return
either an instance of objects.NUMATopology if host's NUMA topology
is available, else None.
:returns: A two-tuple. The first element is either an instance of
objects.NUMATopology or None. The second element is a
boolean set to True if topology was in JSON format.
"""
was_json = False
try:
host_numa_topology = host.get('numa_topology')
except AttributeError:
host_numa_topology = host.numa_topology
if host_numa_topology is not None and isinstance(
host_numa_topology, six.string_types):
was_json = True
host_numa_topology = (objects.NUMATopology.obj_from_db_obj(
host_numa_topology))
return host_numa_topology, was_json