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/api | |
| parent | c2a8d0f1e2e9a25465100128bae4f60b532d16f5 (diff) | |
| parent | 56042d3a60bb76108b21261c3a4dbd8f67d6549c (diff) | |
| download | nova-a62e0f3e10cae4938ca2fec047268064cab3bff2.tar.gz nova-a62e0f3e10cae4938ca2fec047268064cab3bff2.tar.xz nova-a62e0f3e10cae4938ca2fec047268064cab3bff2.zip | |
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/api')
| -rw-r--r-- | nova/api/openstack/ips.py | 19 | ||||
| -rw-r--r-- | nova/api/openstack/views/servers.py | 3 |
2 files changed, 11 insertions, 11 deletions
diff --git a/nova/api/openstack/ips.py b/nova/api/openstack/ips.py index abea71830..71646b6d3 100644 --- a/nova/api/openstack/ips.py +++ b/nova/api/openstack/ips.py @@ -32,25 +32,24 @@ class Controller(object): self.compute_api = nova.compute.API() self.builder = nova.api.openstack.views.addresses.ViewBuilderV10() - def index(self, req, server_id): + def _get_instance(self, req, server_id): try: - instance = self.compute_api.get(req.environ['nova.context'], id) + instance = self.compute_api.get( + req.environ['nova.context'], server_id) except nova.exception.NotFound: return faults.Fault(exc.HTTPNotFound()) + return instance + + def index(self, req, server_id): + instance = self._get_instance(req, server_id) return {'addresses': self.builder.build(instance)} def public(self, req, server_id): - try: - instance = self.compute_api.get(req.environ['nova.context'], id) - except nova.exception.NotFound: - return faults.Fault(exc.HTTPNotFound()) + instance = self._get_instance(req, server_id) return {'public': self.builder.build_public_parts(instance)} def private(self, req, server_id): - try: - instance = self.compute_api.get(req.environ['nova.context'], id) - except nova.exception.NotFound: - return faults.Fault(exc.HTTPNotFound()) + instance = self._get_instance(req, server_id) return {'private': self.builder.build_private_parts(instance)} def show(self, req, server_id, id): diff --git a/nova/api/openstack/views/servers.py b/nova/api/openstack/views/servers.py index 245d0e3fa..cbfa5aae7 100644 --- a/nova/api/openstack/views/servers.py +++ b/nova/api/openstack/views/servers.py @@ -75,7 +75,7 @@ class ViewBuilder(object): } inst_dict = { - 'id': int(inst['id']), + 'id': inst['id'], 'name': inst['display_name'], 'addresses': self.addresses_builder.build(inst), 'status': power_mapping[inst.get('state')]} @@ -99,6 +99,7 @@ class ViewBuilder(object): self._build_image(inst_dict, inst) self._build_flavor(inst_dict, inst) + inst_dict['uuid'] = inst['uuid'] return dict(server=inst_dict) def _build_image(self, response, inst): |
