Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mriedem/013d1bcb9fd547a61adcccb99b9f0eae to your computer and use it in GitHub Desktop.
Save mriedem/013d1bcb9fd547a61adcccb99b9f0eae to your computer and use it in GitHub Desktop.
diff --git a/nova/compute/api.py b/nova/compute/api.py
index a357df4..9bf19ea 100644
--- a/nova/compute/api.py
+++ b/nova/compute/api.py
@@ -4510,16 +4510,25 @@ class HostAPI(base.Base):
state=state)
def compute_node_get(self, context, compute_id):
- """Return compute node entry for particular integer ID."""
+ """Return compute node entry for particular integer ID or UUID."""
load_cells()
# NOTE(danms): Unfortunately this API exposes database identifiers
# which means we really can't do something efficient here
+ is_uuid = uuidutils.is_uuid_like(compute_id)
for cell in CELLS:
if cell.uuid == objects.CellMapping.CELL0_UUID:
continue
with nova_context.target_cell(context, cell):
try:
+ if is_uuid:
+ # NOTE(mriedem): We wouldn't have to loop over cells if
+ # we stored the ComputeNode.uuid in the HostMapping but
+ # we don't have that. It could be added but would
+ # require an online data migration to update existing
+ # host mappings.
+ return objects.ComputeNode.get_by_uuid(context,
+ compute_id)
return objects.ComputeNode.get_by_id(context,
int(compute_id))
except exception.ComputeHostNotFound:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment