diff options
author | Renuka Apte <renuka.apte@citrix.com> | 2012-05-29 11:54:35 -0700 |
---|---|---|
committer | Renuka Apte <renuka.apte@citrix.com> | 2012-06-15 09:49:42 -0700 |
commit | 152cf6f592a40b54cfb8b0132aee944e5533d54d (patch) | |
tree | 83a6e4bd94805237a245bebca94e6d68df2c198c | |
parent | e4b4d3472341a30fc394e5c7e05d2307991711da (diff) | |
download | nova-152cf6f592a40b54cfb8b0132aee944e5533d54d.tar.gz nova-152cf6f592a40b54cfb8b0132aee944e5533d54d.tar.xz nova-152cf6f592a40b54cfb8b0132aee944e5533d54d.zip |
xensm: Fix xensm volume driver after uuid changes
Fixes Bug 1013436
Minor fixes after uuid in volumes were changed from
integers.
The parameters passed to create_vdi have changed, so
modify the call from SM code accordingly
Change-Id: I3d61f0221b23bba9a9e218209d5293be8960e2e2
-rw-r--r-- | nova/virt/xenapi/vm_utils.py | 15 | ||||
-rw-r--r-- | nova/virt/xenapi/volumeops.py | 6 |
2 files changed, 15 insertions, 6 deletions
diff --git a/nova/virt/xenapi/vm_utils.py b/nova/virt/xenapi/vm_utils.py index 69478d34f..88d95ab7a 100644 --- a/nova/virt/xenapi/vm_utils.py +++ b/nova/virt/xenapi/vm_utils.py @@ -313,10 +313,18 @@ def destroy_vdi(session, vdi_ref): _('Unable to destroy VDI %s') % vdi_ref) -def create_vdi(session, sr_ref, instance, disk_type, virtual_size, +def create_vdi(session, sr_ref, info, disk_type, virtual_size, read_only=False): """Create a VDI record and returns its reference.""" - name_label = instance['name'] + # create_vdi may be called simply while creating a volume + # hence information about instance may or may not be present + otherconf = {} + if not isinstance(info, basestring): + name_label = info['display_name'] + otherconf = {'nova_instance_uuid': info['uuid'], + 'nova_disk_type': disk_type} + else: + name_label = info vdi_ref = session.call_xenapi("VDI.create", {'name_label': name_label, 'name_description': disk_type, @@ -326,8 +334,7 @@ def create_vdi(session, sr_ref, instance, disk_type, virtual_size, 'sharable': False, 'read_only': read_only, 'xenstore_data': {}, - 'other_config': {'nova_instance_uuid': instance['uuid'], - 'nova_disk_type': disk_type}, + 'other_config': otherconf, 'sm_config': {}, 'tags': []}) LOG.debug(_('Created VDI %(vdi_ref)s (%(name_label)s,' diff --git a/nova/virt/xenapi/volumeops.py b/nova/virt/xenapi/volumeops.py index bab0b4d2c..c90df787b 100644 --- a/nova/virt/xenapi/volumeops.py +++ b/nova/virt/xenapi/volumeops.py @@ -46,10 +46,12 @@ class VolumeOps(object): LOG.exception(exc) raise volume_utils.StorageError(_('Unable to get SR using uuid')) #Create VDI - label = 'vol-' + hex(volume['id'])[:-1] + label = 'vol-' + volume['id'] + desc = 'xensm volume for ' + volume['id'] # size presented to xenapi is in bytes, while euca api is in GB vdi_size = volume['size'] * 1024 * 1024 * 1024 - vdi_ref = vm_utils.create_vdi(self._session, sr_ref, label, + vdi_ref = vm_utils.create_vdi(self._session, + sr_ref, label, desc, vdi_size, False) vdi_rec = self._session.call_xenapi("VDI.get_record", vdi_ref) sm_vol_rec['vdi_uuid'] = vdi_rec['uuid'] |