diff options
| author | John Griffith <john.griffith@solidfire.com> | 2012-05-04 11:31:56 -0600 |
|---|---|---|
| committer | John Griffith <john.griffith@solidfire.com> | 2012-05-10 13:36:32 -0600 |
| commit | dcad314fb9713104f0029311c43907e362ec6d49 (patch) | |
| tree | 4e6fffab1e7f064e94cee264192d05269ad1c0d4 /nova/api | |
| parent | d9ed81222048f589b6863aaf2a99983ba5a3094f (diff) | |
| download | nova-dcad314fb9713104f0029311c43907e362ec6d49.tar.gz nova-dcad314fb9713104f0029311c43907e362ec6d49.tar.xz nova-dcad314fb9713104f0029311c43907e362ec6d49.zip | |
Remove instance Foreign Key in volumes table, replace with instance_uuid
* Remove the instance relationship and instance_id FK
* Add instance_uuuid column to volumes table
* Passed unit tests and devstack tests
Change-Id: Id598f1f1d7915d1af6bf3dd75e5819dce08aaa0f
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/ec2utils.py | 4 | ||||
| -rw-r--r-- | nova/api/openstack/compute/contrib/volumes.py | 7 | ||||
| -rw-r--r-- | nova/api/openstack/volume/volumes.py | 12 |
3 files changed, 10 insertions, 13 deletions
diff --git a/nova/api/ec2/ec2utils.py b/nova/api/ec2/ec2utils.py index 9006da93e..ceb695a5e 100644 --- a/nova/api/ec2/ec2utils.py +++ b/nova/api/ec2/ec2utils.py @@ -197,6 +197,10 @@ def get_snapshot_uuid_from_int_id(context, int_id): return db.get_snapshot_uuid_by_ec2_id(context, int_id) +def ec2_instance_id_to_uuid(context, ec2_id): + int_id = ec2_id_to_id(ec2_id) + return db.instance_get(context, int_id)['uuid'] + _c2u = re.compile('(((?<=[a-z])[A-Z])|([A-Z](?![A-Z]|$)))') diff --git a/nova/api/openstack/compute/contrib/volumes.py b/nova/api/openstack/compute/contrib/volumes.py index 129b181c7..004a667b1 100644 --- a/nova/api/openstack/compute/contrib/volumes.py +++ b/nova/api/openstack/compute/contrib/volumes.py @@ -371,10 +371,9 @@ class VolumeAttachmentController(object): except exception.NotFound: raise exc.HTTPNotFound() - instance = vol['instance'] - if instance is None or str(instance['uuid']) != server_id: - LOG.debug("Instance not found (server_id=%(server_id)s)", - {'server_id': server_id}, instance=instance) + instance_uuid = vol['instance_uuid'] + if instance_uuid is None or instance_uuid != server_id: + LOG.debug(_("Instance %s is not attached."), instance_uuid) raise exc.HTTPNotFound() self.compute_api.detach_volume(context, diff --git a/nova/api/openstack/volume/volumes.py b/nova/api/openstack/volume/volumes.py index 7789bc1aa..5da007d13 100644 --- a/nova/api/openstack/volume/volumes.py +++ b/nova/api/openstack/volume/volumes.py @@ -48,15 +48,13 @@ def _translate_attachment_summary_view(_context, vol): """Maps keys for attachment summary view.""" d = {} - # TODO(bcwaldon): remove str cast once we use uuids - volume_id = str(vol['id']) + volume_id = vol['id'] # NOTE(justinsb): We use the volume id as the id of the attachment object d['id'] = volume_id d['volume_id'] = volume_id - if vol.get('instance'): - d['server_id'] = vol['instance']['uuid'] + d['server_id'] = vol['instance_uuid'] if vol.get('mountpoint'): d['device'] = vol['mountpoint'] @@ -77,8 +75,7 @@ def _translate_volume_summary_view(context, vol): """Maps keys for volumes summary view.""" d = {} - # TODO(bcwaldon): remove str cast once we use uuids - d['id'] = str(vol['id']) + d['id'] = vol['id'] d['status'] = vol['status'] d['size'] = vol['size'] d['availability_zone'] = vol['availability_zone'] @@ -99,9 +96,6 @@ def _translate_volume_summary_view(context, vol): d['volume_type'] = str(vol['volume_type_id']) d['snapshot_id'] = vol['snapshot_id'] - # TODO(bcwaldon): remove str cast once we use uuids - if d['snapshot_id'] is not None: - d['snapshot_id'] = str(d['snapshot_id']) LOG.audit(_("vol=%s"), vol, context=context) |
