Created
May 1, 2017 22:33
-
-
Save mriedem/013d1bcb9fd547a61adcccb99b9f0eae to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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