summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nova/virt/xenapi/vm_utils.py15
-rw-r--r--nova/virt/xenapi/volumeops.py6
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']