LOG.error(msg)
ret = errno.EFAULT
- if ret == 0:
- ret, event_uuid = self._get_event_uuid(output)
-
if ret == errno.EAGAIN:
- status = self._wait_event(
- self.dpl.get_vdev_status,
- self._conver_uuid2hex(volumeid), event_uuid)
- if status['state'] == 'error':
+ ret, event_uuid = self._get_event_uuid(output)
+ if len(event_uuid):
+ ret = 0
+ status = self._wait_event(
+ self.dpl.get_vdev_status,
+ self._conver_uuid2hex(volumeid), event_uuid)
+ if status['state'] == 'error':
+ ret = errno.EFAULT
+ msg = _('Flexvisor failed to assign volume %(id)s: '
+ '%(status)s.') % {'id': volumeid,
+ 'status': status}
+ LOG.error(msg)
+ raise exception.VolumeBackendAPIException(data=msg)
+ else:
ret = errno.EFAULT
- msg = _('Flexvisor failed to assign volume %(id)s: '
- '%(status)s.') % {'id': volumeid,
- 'status': status}
+ msg = _('Flexvisor failed to assign volume %(id)s due to '
+ 'unable to query status by event '
+ 'id.') % {'id': volumeid}
LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg)
- else:
- ret = 0
elif ret != 0:
msg = _('Flexvisor assign volume failed:%(id)s:'
'%(status)s.') % {'id': volumeid, 'status': ret}
targetwwpns, initiatorwwpns)
if ret == errno.EAGAIN:
ret, event_uuid = self._get_event_uuid(output)
- if ret == 0:
+ if ret == 0 and len(event_uuid):
status = self._wait_event(
self.dpl.get_vdev_status, volumeid, event_uuid)
if status['state'] == 'error':
+ ret = errno.EFAULT
msg = _('Flexvisor failed to unassign volume %(id)s:'
' %(status)s.') % {'id': volumeid,
'status': status}
LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg)
- else:
- ret = 0
else:
msg = _('Flexvisor failed to unassign volume (get event) '
'%(id)s.') % {'id': volumeid}
ret, output = self.dpl.assign_vdev(self._conver_uuid2hex(
volume['id']), connector['initiator'].lower(), volume['id'],
'%s:%d' % (dpl_server, dpl_iscsi_port), 0)
- if ret == 0:
- ret, event_uuid = self._get_event_uuid(output)
if ret == errno.EAGAIN:
- status = self._wait_event(
- self.dpl.get_vdev_status, self._conver_uuid2hex(
- volume['id']), event_uuid)
- if status['state'] == 'error':
+ ret, event_uuid = self._get_event_uuid(output)
+ if len(event_uuid):
+ ret = 0
+ status = self._wait_event(
+ self.dpl.get_vdev_status, self._conver_uuid2hex(
+ volume['id']), event_uuid)
+ if status['state'] == 'error':
+ ret = errno.EFAULT
+ msg = _('Flexvisor failed to assign volume %(id)s: '
+ '%(status)s.') % {'id': volume['id'],
+ 'status': status}
+ LOG.error(msg)
+ raise exception.VolumeBackendAPIException(data=msg)
+ else:
ret = errno.EFAULT
- msg = _('Flexvisor failed to assign volume %(id)s: '
- '%(status)s.') % {'id': volume['id'],
- 'status': status}
+ msg = _('Flexvisor failed to assign volume %(id)s due to '
+ 'unable to query status by event '
+ 'id.') % {'id': volume['id']}
LOG.error(msg)
raise exception.VolumeBackendAPIException(data=msg)
elif ret != 0:
return None
def _get_event_uuid(self, output):
+ ret = 0
event_uuid = ""
- if type(output) is not dict:
- return -1, event_uuid
- if output.get("metadata") and output["metadata"]:
+ if type(output) is dict and \
+ output.get("metadata") and output["metadata"]:
if output["metadata"].get("event_uuid") and \
output["metadata"]["event_uuid"]:
event_uuid = output["metadata"]["event_uuid"]
- return 0, event_uuid
- return -1, event_uuid
+ else:
+ ret = errno.EINVAL
+ else:
+ ret = errno.EINVAL
+ return ret, event_uuid
def _wait_event(self, callFun, objuuid, eventid=None):
nRetry = 30