diff options
| author | Rick Harris <rick.harris@rackspace.com> | 2011-06-20 16:17:35 +0000 |
|---|---|---|
| committer | Tarmac <> | 2011-06-20 16:17:35 +0000 |
| commit | a62e0f3e10cae4938ca2fec047268064cab3bff2 (patch) | |
| tree | 33ed9c6245fa6bc7f154707e86e2e516781d4b09 /nova/compute | |
| parent | c2a8d0f1e2e9a25465100128bae4f60b532d16f5 (diff) | |
| parent | 56042d3a60bb76108b21261c3a4dbd8f67d6549c (diff) | |
This patch adds support for working with instances by UUID in addition to integer IDs.
The Zone Scheduler routing mechanics were changed slightly so that when an UUID is passed in, it checks to see whether the item is available locally.
If it isn't it re-routes to a child zone.
If it is available locally, it substitutes the UUID with the integer ID and calls the wrapped function. This is the 'trick' allows us to not change any of the virt-layer code-- everything still uses integer IDs locally.
Diffstat (limited to 'nova/compute')
| -rw-r--r-- | nova/compute/api.py | 11 | ||||
| -rw-r--r-- | nova/compute/manager.py | 1 |
2 files changed, 9 insertions, 3 deletions
diff --git a/nova/compute/api.py b/nova/compute/api.py index b81aecb70..e6cffb6b3 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -579,8 +579,15 @@ class API(base.Base): def get(self, context, instance_id): """Get a single instance with the given instance_id.""" - rv = self.db.instance_get(context, instance_id) - return dict(rv.iteritems()) + # NOTE(sirp): id used to be exclusively integer IDs; now we're + # accepting both UUIDs and integer IDs. The handling of this + # is done in db/sqlalchemy/api/instance_get + if utils.is_uuid_like(instance_id): + uuid = instance_id + instance = self.db.instance_get_by_uuid(context, uuid) + else: + instance = self.db.instance_get(context, instance_id) + return dict(instance.iteritems()) @scheduler_api.reroute_compute("get") def routing_get(self, context, instance_id): diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 8ab744855..a7ec021b8 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -783,7 +783,6 @@ class ComputeManager(manager.SchedulerDependentManager): def get_diagnostics(self, context, instance_id): """Retrieve diagnostics for an instance on this host.""" instance_ref = self.db.instance_get(context, instance_id) - if instance_ref["state"] == power_state.RUNNING: LOG.audit(_("instance %s: retrieving diagnostics"), instance_id, context=context) |
