diff options
| author | Renuka Apte <renuka.apte@citrix.com> | 2012-02-14 16:23:06 -0800 |
|---|---|---|
| committer | Renuka Apte <renuka.apte@citrix.com> | 2012-02-21 15:35:37 -0800 |
| commit | 5a728f90d1ccf9a5264ef14648c7ec1fd35ee229 (patch) | |
| tree | 7d544b929fe0095e7782ff92f8a46fbc60127721 | |
| parent | adaf9049c8fb3652c0962909a3c835e1724d8a17 (diff) | |
xenapi: nova-volume support for multiple luns
Change-Id: I012fe76a8e2fb4ddd3c24c5fd43a9b2126d2773d
| -rw-r--r-- | nova/virt/xenapi/volume_utils.py | 11 | ||||
| -rw-r--r-- | nova/virt/xenapi/volumeops.py | 7 |
2 files changed, 16 insertions, 2 deletions
diff --git a/nova/virt/xenapi/volume_utils.py b/nova/virt/xenapi/volume_utils.py index eda77f183..e8124f7ef 100644 --- a/nova/virt/xenapi/volume_utils.py +++ b/nova/virt/xenapi/volume_utils.py @@ -235,13 +235,22 @@ class VolumeHelper(HelperBase): ' PBD %(pbd)s') % locals()) @classmethod - def introduce_vdi(cls, session, sr_ref, vdi_uuid=None): + def introduce_vdi(cls, session, sr_ref, vdi_uuid=None, target_lun=None): """Introduce VDI in the host""" try: session.call_xenapi("SR.scan", sr_ref) if vdi_uuid: LOG.debug("vdi_uuid: %s" % vdi_uuid) vdi_ref = session.call_xenapi("VDI.get_by_uuid", vdi_uuid) + elif target_lun: + vdi_refs = session.call_xenapi("SR.get_VDIs", sr_ref) + for curr_ref in vdi_refs: + curr_rec = session.call_xenapi("VDI.get_record", curr_ref) + if ('sm_config' in curr_rec and + 'LUNid' in curr_rec['sm_config'] and + curr_rec['sm_config']['LUNid'] == str(target_lun)): + vdi_ref = curr_ref + break else: vdi_ref = (session.call_xenapi("SR.get_VDIs", sr_ref))[0] except cls.XenAPI.Failure, exc: diff --git a/nova/virt/xenapi/volumeops.py b/nova/virt/xenapi/volumeops.py index 46606e2be..075ae705b 100644 --- a/nova/virt/xenapi/volumeops.py +++ b/nova/virt/xenapi/volumeops.py @@ -159,15 +159,20 @@ class VolumeOps(object): LOG.exception(exc) raise StorageError(_('Unable to introduce Storage Repository')) + vdi_uuid = None + target_lun = None if 'vdi_uuid' in data: vdi_uuid = data['vdi_uuid'] + elif 'target_lun' in data: + target_lun = data['target_lun'] else: vdi_uuid = None # Introduce VDI and attach VBD to VM try: vdi_ref = VolumeHelper.introduce_vdi(self._session, sr_ref, - vdi_uuid) + vdi_uuid, + target_lun) except StorageError, exc: LOG.exception(exc) self.forget_sr(uuid) |
