From 74ad499748a74faf21f8f3fce0402bbb1a65262c Mon Sep 17 00:00:00 2001 From: wangzz Date: Thu, 20 Apr 2017 12:26:51 +0900 Subject: [PATCH 1/2] add the terminate_connection in iSCSIDriver add the terminate_connection in iSCSIDriver for checking if the last volume is removed. If so, delete the initiator group which mapped with the volume --- xtremio.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/xtremio.py b/xtremio.py index 9c2efef..e084c91 100644 --- a/xtremio.py +++ b/xtremio.py @@ -925,6 +925,19 @@ def _get_iscsi_properties(self, lunmap): 'target_luns': [lunmap['lun']] * len(portals)} return properties + def terminate_connection(self, volume, connector, **kwargs): + (super(XtremIOISCSIDriver, self) + .terminate_connection(volume, connector, **kwargs)) + num_vols = (self.client + .num_of_mapped_volumes(self._get_ig_name(connector))) + if num_vols > 0: + return + else: + igName = self._get_ig_name(connector) + # delete the initiator group + self.client.req('initiator-groups', 'DELETE', name=igName, ver='v2') + LOG.debug('Deleted initiator group: %s', igName) + def _get_initiator_names(self, connector): return [connector['initiator']] From 858437ee340635f47e511c9e837848809d5b6622 Mon Sep 17 00:00:00 2001 From: wangzz Date: Thu, 20 Apr 2017 22:18:06 +0900 Subject: [PATCH 2/2] just need to return the id and status if return the whole snapshot the snapshot.name will not be able to be saved and cinder db will not be updated correctly. Only id and status need to be returned --- xtremio.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xtremio.py b/xtremio.py index e084c91..26dedc1 100644 --- a/xtremio.py +++ b/xtremio.py @@ -746,12 +746,12 @@ def create_cgsnapshot(self, context, cgsnapshot, snapshots): snapshots = objects.SnapshotList().get_all_for_cgsnapshot( context, cgsnapshot['id']) + snap_model_update = [] for snapshot in snapshots: - snapshot.status = 'available' - + snap_model_update.append({'id': snapshot.id, 'status': 'available'}) model_update = {'status': 'available'} - return model_update, snapshots + return model_update, snap_model_update def delete_cgsnapshot(self, context, cgsnapshot, snapshots): """Deletes a cgsnapshot."""