]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Ignore stmf target must be offline exception
authorVictor Rodionov <vito.ordaz@gmail.com>
Thu, 1 Aug 2013 20:41:24 +0000 (00:41 +0400)
committerVictor Rodionov <vito.ordaz@gmail.com>
Wed, 7 Aug 2013 16:43:07 +0000 (20:43 +0400)
Patch to ignore

"NexentaJSONException: : Unable to add member to targetgroup:
    stmfadm: STMF target must be offline"

This error happens when targetgroup is already configured and busy.

fixed bug 1209305

Change-Id: I275dcf465934c99d30f85932fe72e8b1818ef870

cinder/volume/drivers/nexenta/volume.py

index fb1e94db0d448c9300fad245f0d5f737b181bed1..e9d7ce0d6534a08c512aaf6e34a37c19bb58e23d 100644 (file)
@@ -201,39 +201,41 @@ class NexentaDriver(driver.ISCSIDriver):  # pylint: disable=R0921
         target_name = self._get_target_name(volume['name'])
         target_group_name = self._get_target_group_name(volume['name'])
 
+        target_already_configured = False
         try:
             self.nms.iscsitarget.create_target({'target_name': target_name})
         except nexenta.NexentaException as exc:
-            if not ensure or 'already configured' not in exc.args[1]:
-                raise
+            if ensure and 'already configured' in exc.args[1]:
+                target_already_configured = True
+                LOG.info(_('Ignored target creation error "%s" while ensuring '
+                           'export'), exc)
             else:
-                LOG.info(_('Ignored target creation error "%s"'
-                           ' while ensuring export'), exc)
+                raise
         try:
             self.nms.stmf.create_targetgroup(target_group_name)
         except nexenta.NexentaException as exc:
-            if not ensure or 'already exists' not in exc.args[1]:
-                raise
-            else:
+            if ((ensure and 'already exists' in exc.args[1]) or
+                    (target_already_configured and
+                     'target must be offline' in exc.args[1])):
                 LOG.info(_('Ignored target group creation error "%s"'
                            ' while ensuring export'), exc)
+            else:
+                raise
         try:
             self.nms.stmf.add_targetgroup_member(target_group_name,
                                                  target_name)
         except nexenta.NexentaException as exc:
             if not ensure or 'already exists' not in exc.args[1]:
                 raise
-            else:
-                LOG.info(_('Ignored target group member addition error "%s"'
-                           ' while ensuring export'), exc)
+            LOG.info(_('Ignored target group member addition error "%s" while '
+                       'ensuring export'), exc)
         try:
             self.nms.scsidisk.create_lu(zvol_name, {})
         except nexenta.NexentaException as exc:
             if not ensure or 'in use' not in exc.args[1]:
                 raise
-            else:
-                LOG.info(_('Ignored LU creation error "%s"'
-                           ' while ensuring export'), exc)
+            LOG.info(_('Ignored LU creation error "%s"'
+                       ' while ensuring export'), exc)
         try:
             self.nms.scsidisk.add_lun_mapping_entry(zvol_name, {
                 'target_group': target_group_name,
@@ -241,9 +243,8 @@ class NexentaDriver(driver.ISCSIDriver):  # pylint: disable=R0921
         except nexenta.NexentaException as exc:
             if not ensure or 'view entry exists' not in exc.args[1]:
                 raise
-            else:
-                LOG.info(_('Ignored LUN mapping entry addition error "%s"'
-                           ' while ensuring export'), exc)
+            LOG.info(_('Ignored LUN mapping entry addition error "%s"'
+                       ' while ensuring export'), exc)
         return '%s:%s,1 %s 0' % (CONF.nexenta_host,
                                  CONF.nexenta_iscsi_target_portal_port,
                                  target_name)