import errno
-import six
from cinder import exception
-from cinder.i18n import _, _LI, _LE
+from cinder.i18n import _, _LE, _LI
from cinder.openstack.common import log as logging
from cinder.volume import driver
from cinder.volume.drivers.prophetstor import dplcommon
if fcInfo['type'] == 'fc':
fcInfos[fcUuid] = fcInfo
except Exception as e:
- msg = _LE("Failed to get fiber channel info from storage due "
- "to %(stat)s") % {'stat': six.text_type(e)}
- LOG.error(msg)
+ LOG.error(_LE("Failed to get fiber channel info from storage "
+ "due to %(stat)s"), {'stat': e})
return fcInfos
def _get_targets(self):
targetI['targetAddr'] = targetInfo[2]
targetInfos[str(targetInfo[0])] = targetI
except Exception as e:
- msg = _LE("Failed to get fiber channel target from storage server"
- " due to %(stat)s") % {'stat': six.text_type(e)}
targetInfos = {}
- LOG.error(msg)
+ LOG.error(_LE("Failed to get fiber channel target from "
+ "storage server due to %(stat)s"),
+ {'stat': e})
return targetInfos
def _get_targetwpns(self, volumeid, initiatorWwpns):
targetWwpns = fc_info.get('target_identifier', '')
lstargetWwpns.append(targetWwpns)
except Exception as e:
- msg = _LE("Failed to get target wwpns from storage due "
- "to %(stat)s") % {'stat': six.text_type(e)}
- LOG.error(msg)
+ LOG.error(_LE("Failed to get target wwpns from storage due "
+ "to %(stat)s"), {'stat': e})
lstargetWwpns = []
return lstargetWwpns
self._conver_uuid2hex(volumeid), targetwwpns,
initiatorwwpns, volumename)
except Exception:
- msg = _LE('Volume %(volumeid)s failed to send assign command, '
- 'ret: %(status)s output: %(output)s') % \
- {'volumeid': volumeid, 'status': ret, 'output': output}
- LOG.error(msg)
+ LOG.error(_LE('Volume %(volumeid)s failed to send assign command, '
+ 'ret: %(status)s output: %(output)s'),
+ {'volumeid': volumeid, 'status': ret, 'output': output})
ret = errno.EFAULT
if ret == errno.EAGAIN:
'%(status)s.') % {'id': volumeid, 'status': ret}
raise exception.VolumeBackendAPIException(data=msg)
else:
- msg = _LI('Flexvisor succeed to unassign volume '
- '%(id)s.') % {'id': volumeid}
- LOG.info(msg)
+ LOG.info(_LI('Flexvisor succeeded to unassign volume %(id)s.'),
+ {'id': volumeid})
return ret
ret = 0
targetIdentifier = []
szwwpns = []
- msg = _LI('initialize_connection volume: %(volume)s, connector:'
- ' %(connector)s') % {"volume": volume,
- "connector": connector}
- LOG.info(msg)
+ LOG.info(_LI('initialize_connection volume: %(volume)s, connector:'
+ ' %(connector)s'),
+ {"volume": volume, "connector": connector})
# Get Storage Fiber channel controller
dc_fc = self._get_fc_channel()
{}).get('targetAddr', '')
lsTargetWwpn.append(targetWwpn)
# Use wwpns to assign volume.
- msg = _LI('Prefer use target wwpn %(wwpn)s') % {'wwpn': lsTargetWwpn}
- LOG.info(msg)
+ LOG.info(_LI('Prefer use target wwpn %(wwpn)s'),
+ {'wwpn': lsTargetWwpn})
# Start to create export in all FC target node.
assignedTarget = []
for pTarget in lsTargetWwpn:
else:
assignedTarget.append(pTarget)
except Exception as e:
- msg = _LE('Failed to export fiber channel target '
- 'due to %s') % (six.text_type(e))
- LOG.error(msg)
+ LOG.error(_LE('Failed to export fiber channel target '
+ 'due to %s'), e)
ret = errno.EFAULT
break
if ret == 0:
properties['target_lun'] = int(nLun)
properties['volume_id'] = volume['id']
properties['initiator_target_map'] = init_targ_map
- msg = _LI('%(volume)s assign type fibre_channel, properties '
- '%(properties)s') % {'volume': volume['id'],
- 'properties': properties}
- LOG.info(msg)
+ LOG.info(_LI('%(volume)s assign type fibre_channel, properties '
+ '%(properties)s'),
+ {'volume': volume['id'], 'properties': properties})
else:
msg = _('Invalid connection initialization response of '
'volume %(name)s') % {'name': volume['name']}
raise exception.VolumeBackendAPIException(data=msg)
- msg = _LI('Connect initialization info: '
- '{driver_volume_type: fibre_channel, '
- 'data: %(properties)s') % {'properties': properties}
- LOG.info(msg)
+ LOG.info(_LI('Connect initialization info: '
+ '{driver_volume_type: fibre_channel, '
+ 'data: %(properties)s'), {'properties': properties})
return {'driver_volume_type': 'fibre_channel',
'data': properties}
szwwpns = []
ret = 0
info = {'driver_volume_type': 'fibre_channel', 'data': {}}
- msg = _LI('terminate_connection volume: %(volume)s, '
- 'connector: %(con)s') % {'volume': volume, 'con': connector}
- LOG.info(msg)
+ LOG.info(_LI('terminate_connection volume: %(volume)s, '
+ 'connector: %(con)s'),
+ {'volume': volume, 'con': connector})
# Query targetwwpns.
# Get all target list of volume.
for dwwpn in connector['wwpns']:
try:
payload = json.dumps(params, ensure_ascii=False)
payload.encode('utf-8')
- except Exception:
- LOG.error(_LE('JSON encode params error: %s.'),
- six.text_type(params))
+ except Exception as e:
+ LOG.error(_LE('JSON encode params %(param)s error:'
+ ' %(status)s.'), {'param': params, 'status': e})
retcode = errno.EINVAL
for i in range(CONNECTION_RETRY):
try:
break
except IOError as ioerr:
LOG.error(_LE('Connect to Flexvisor error: %s.'),
- six.text_type(ioerr))
+ ioerr)
retcode = errno.ENOTCONN
except Exception as e:
LOG.error(_LE('Connect to Flexvisor failed: %s.'),
- six.text_type(e))
+ e)
retcode = errno.EFAULT
retry = CONNECTION_RETRY
continue
except Exception as e:
LOG.error(_LE('Failed to send request: %s.'),
- six.text_type(e))
+ e)
retcode = errno.EFAULT
break
continue
except Exception as e:
LOG.error(_LE('Failed to get response: %s.'),
- six.text_type(e.message))
+ e)
retcode = errno.EFAULT
break
retcode = errno.ENODATA
elif retcode == 0 and response.status not in expected_status:
LOG.error(_LE('%(method)s %(url)s unexpected response status: '
- '%(response)s (expects: %(expects)s).')
- % {'method': method,
- 'url': url,
- 'response': httplib.responses[response.status],
- 'expects': expected_status})
+ '%(response)s (expects: %(expects)s).'),
+ {'method': method,
+ 'url': url,
+ 'response': httplib.responses[response.status],
+ 'expects': expected_status})
if response.status == httplib.UNAUTHORIZED:
raise exception.NotAuthorized
retcode = errno.EACCES
data = json.loads(data)
except (TypeError, ValueError) as e:
LOG.error(_LE('Call to json.loads() raised an exception: %s.'),
- six.text_type(e))
+ e)
retcode = errno.ENOEXEC
except Exception as e:
LOG.error(_LE('Read response raised an exception: %s.'),
- six.text_type(e))
+ e)
retcode = errno.ENOEXEC
elif retcode == 0 and \
response.status in [httplib.OK, httplib.CREATED] and \
data = json.loads(data)
except (TypeError, ValueError) as e:
LOG.error(_LE('Call to json.loads() raised an exception: %s.'),
- six.text_type(e))
+ e)
retcode = errno.ENOEXEC
except Exception as e:
LOG.error(_LE('Read response raised an exception: %s.'),
- six.text_type(e))
+ e)
retcode = errno.ENOEXEC
if connection:
class DPLCOMMONDriver(driver.VolumeDriver):
"""class of dpl storage adapter."""
- VERSION = '2.0.1'
+ VERSION = '2.0.2'
def __init__(self, *args, **kwargs):
super(DPLCOMMONDriver, self).__init__(*args, **kwargs)
continue
except Exception as e:
- msg = _('Flexvisor failed to get event %(volume)s'
- '(%(status)s).') % {'volume': eventid,
- 'status': six.text_type(e)}
- LOG.error(msg)
+ LOG.error(_LE('Flexvisor failed to get event %(volume)s '
+ '(%(status)s).'),
+ {'volume': eventid, 'status': e})
raise loopingcall.LoopingCallDone(retvalue=False)
status['state'] = 'error'
fExit = True
'cgid': cgId}
raise exception.VolumeBackendAPIException(data=msg)
else:
- msg = _LI('Flexvisor succeeded to add volume %(id)s to '
- 'group %(cgid)s.') % {'id': volume['id'],
- 'cgid': cgId}
- LOG.info(msg)
+ LOG.info(_LI('Flexvisor succeeded to add volume %(id)s to '
+ 'group %(cgid)s.'),
+ {'id': volume['id'], 'cgid': cgId})
def _get_snapshotid_of_vgsnapshot(self, vgID, vgsnapshotID, volumeID):
snapshotID = None
def create_consistencygroup(self, context, group):
"""Creates a consistencygroup."""
- msg = _LI('Start to create consistency group: %(group_name)s '
- 'id: %(id)s') % {'group_name': group['name'],
- 'id': group['id']}
- LOG.info(msg)
+ LOG.info(_LI('Start to create consistency group: %(group_name)s '
+ 'id: %(id)s'),
+ {'group_name': group['name'], 'id': group['id']})
model_update = {'status': 'available'}
try:
ret, output = self.dpl.create_vg(
context, group['id'])
model_update = {}
model_update['status'] = group['status']
- LOG.info(_LI('Start to delete consistency group: %(cg_name)s')
- % {'cg_name': group['id']})
+ LOG.info(_LI('Start to delete consistency group: %(cg_name)s'),
+ {'cg_name': group['id']})
try:
self.dpl.delete_vg(self._conver_uuid2hex(group['id']))
except Exception as e:
model_update = {}
LOG.info(_LI('Start to create cgsnapshot for consistency group'
- ': %(group_name)s') %
- {'group_name': cgId})
+ ': %(group_name)s'), {'group_name': cgId})
try:
self.dpl.create_vdev_snapshot(self._conver_uuid2hex(cgId),
model_update = {}
model_update['status'] = cgsnapshot['status']
LOG.info(_LI('Delete cgsnapshot %(snap_name)s for consistency group: '
- '%(group_name)s') % {'snap_name': cgsnapshot['id'],
- 'group_name': cgsnapshot['consistencygroup_id']})
+ '%(group_name)s'),
+ {'snap_name': cgsnapshot['id'],
+ 'group_name': cgsnapshot['consistencygroup_id']})
try:
self.dpl.delete_vdev_snapshot(self._conver_uuid2hex(cgId),
raise exception.VolumeBackendAPIException(
data=msg)
else:
- msg = _LI('Flexvisor succeed to create volume '
- '%(id)s.') % {'id': volume['id']}
- LOG.info(msg)
+ LOG.info(_LI('Flexvisor succeeded to create volume %(id)s.'),
+ {'id': volume['id']})
if volume.get('consistencygroup_id', None):
try:
raise exception.VolumeBackendAPIException(
data=msg)
else:
- msg = _LI('Flexvisor succeed to create volume %(id)s '
- 'from snapshot.') % {'id': volume['id']}
- LOG.info(msg)
+ LOG.info(_LI('Flexvisor succeeded to create volume %(id)s '
+ 'from snapshot.'), {'id': volume['id']})
if volume.get('consistencygroup_id', None):
try:
raise exception.VolumeBackendAPIException(
data=msg)
else:
- msg = _LI('Flexvisor succeed to create volume %(id)s '
- 'from snapshot.') % {'id': volume['id']}
- LOG.info(msg)
+ LOG.info(_LI('Flexvisor succeeded to create volume %(id)s '
+ 'from snapshot.'), {'id': volume['id']})
def create_cloned_volume(self, volume, src_vref):
"""Creates a clone of the specified volume."""
raise exception.VolumeBackendAPIException(
data=msg)
else:
- msg = _LI('Flexvisor succeed to clone '
- 'volume %(id)s.') % {'id': volume['id']}
- LOG.info(msg)
+ LOG.info(_LI('Flexvisor succeeded to clone volume %(id)s.'),
+ {'id': volume['id']})
if volume.get('consistencygroup_id', None):
try:
self._conver_uuid2hex(volume['id']),
self._conver_uuid2hex(volume['consistencygroup_id']))
if ret:
- msg = _LW('Flexvisor failed to delete volume %(id)s from'
- ' the group %(vgid)s.') % {
- 'id': volume['id'],
- 'vgid': volume['consistencygroup_id']}
+ LOG.warning(_LW('Flexvisor failed to delete volume '
+ '%(id)s from the group %(vgid)s.'),
+ {'id': volume['id'],
+ 'vgid': volume['consistencygroup_id']})
except Exception as e:
- msg = _LW('Flexvisor failed to delete volume %(id)s from '
- 'group %(vgid)s due to %(status)s.') % {
- 'id': volume['id'],
- 'vgid': volume['consistencygroup_id'],
- 'status': six.text_type(e)}
+ LOG.warning(_LW('Flexvisor failed to delete volume %(id)s '
+ 'from group %(vgid)s due to %(status)s.'),
+ {'id': volume['id'],
+ 'vgid': volume['consistencygroup_id'],
+ 'status': e})
if ret:
ret = 0
- LOG.warning(msg)
ret, output = self.dpl.delete_vdev(self._conver_uuid2hex(volume['id']))
if ret == errno.EAGAIN:
raise exception.VolumeBackendAPIException(data=msg)
elif ret == errno.ENODATA:
ret = 0
- msg = _LI('Flexvisor volume %(id)s does not '
- 'exist.') % {'id': volume['id']}
- LOG.info(msg)
+ LOG.info(_LI('Flexvisor volume %(id)s does not '
+ 'exist.'), {'id': volume['id']})
elif ret != 0:
msg = _('Flexvisor failed to delete volume %(id)s: '
'%(status)s.') % {'id': volume['id'], 'status': ret}
raise exception.VolumeBackendAPIException(
data=msg)
else:
- msg = _LI('Flexvisor succeed to extend volume'
- ' %(id)s.') % {'id': volume['id']}
- LOG.info(msg)
+ LOG.info(_LI('Flexvisor succeeded to extend volume'
+ ' %(id)s.'), {'id': volume['id']})
def create_snapshot(self, snapshot):
"""Creates a snapshot."""
'get event) %(id)s.') % {'id': snapshot['id']}
raise exception.VolumeBackendAPIException(data=msg)
elif ret == errno.ENODATA:
- msg = _LI('Flexvisor snapshot %(id)s not existed.') % \
- {'id': snapshot['id']}
- LOG.info(msg)
+ LOG.info(_LI('Flexvisor snapshot %(id)s not existed.'),
+ {'id': snapshot['id']})
elif ret != 0:
msg = _('Flexvisor failed to delete snapshot %(id)s: '
'%(status)s.') % {'id': snapshot['id'], 'status': ret}
raise exception.VolumeBackendAPIException(data=msg)
else:
- msg = _LI('Flexvisor succeed to delete '
- 'snapshot %(id)s.') % {'id': snapshot['id']}
- LOG.info(msg)
+ LOG.info(_LI('Flexvisor succeeded to delete snapshot %(id)s.'),
+ {'id': snapshot['id']})
def get_volume_stats(self, refresh=False):
"""Get volume stats.
for poolUuid, poolName in output.get('children', []):
qpools.append(poolUuid)
else:
- msg = _LE("Flexvisor failed to get pool list."
- "(Error: %d)") % (ret)
- LOG.error(msg)
+ LOG.error(_LE("Flexvisor failed to get pool list."
+ "(Error: %d)"), ret)
except Exception as e:
- msg = _LE("Flexvisor failed to get pool list due to "
- "%s.") % (six.text_type(e))
- LOG.error(msg)
+ LOG.error(_LE("Flexvisor failed to get pool list due to "
+ "%s."), e)
# Query pool detail information
for poolid in qpools:
pool['reserved_percentage'] = 0
pools.append(pool)
else:
- msg = _LW("Failed to query pool %(id)s status "
- "%(ret)d.") % {'id': poolid,
- 'ret': ret}
- LOG.warning(msg)
+ LOG.warning(_LW("Failed to query pool %(id)s status "
+ "%(ret)d."), {'id': poolid, 'ret': ret})
continue
return pools
data['pools'] = pools
self._stats = data
except Exception as e:
- msg = _LE('Failed to get server info due to '
- '%(state)s.') % {'state': six.text_type(e)}
- LOG.error(msg)
+ LOG.error(_LE('Failed to get server info due to '
+ '%(state)s.'), {'state': e})
return self._stats
def do_setup(self, context):
ret = 0
output = status.get('output', {})
else:
- LOG.error(_LE('Flexvisor failed to get pool info '
- '(failed to get event)%s.') % (poolid))
+ LOG.error(_LE('Flexvisor failed to get pool %(id)s info.'),
+ {'id': poolid})
raise exception.VolumeBackendAPIException(
data="failed to get event")
elif ret != 0:
'%(status)s.') % {'id': poolid, 'status': ret}
raise exception.VolumeBackendAPIException(data=msg)
else:
- msg = _('Flexvisor succeed to get pool info.')
- LOG.debug(msg)
+ LOG.debug('Flexvisor succeeded to get pool info.')
return ret, output