JovianDSS: fix code style and naming

Code style and product name changes for Open-E JovinDSS driver

Change-Id: Ia7415dc727000256bdd67ee2fb588f692ebc5aa2
Implements: blueprint joviandss-code-style-fix
This commit is contained in:
andrei.perepiolkin 2021-08-30 05:56:07 -04:00 committed by Andrei
parent fff0ee68a8
commit 8930fbac3c
5 changed files with 177 additions and 169 deletions

View File

@ -36,7 +36,7 @@ LOG = logging.getLogger(__name__)
@interface.volumedriver @interface.volumedriver
class JovianISCSIDriver(driver.ISCSIDriver): class JovianISCSIDriver(driver.ISCSIDriver):
"""Executes volume driver commands on Open-E JovianDSS V7. """Executes volume driver commands on Open-E JovianDSS.
Version history: Version history:
@ -52,7 +52,7 @@ class JovianISCSIDriver(driver.ISCSIDriver):
VERSION = "1.0.1" VERSION = "1.0.1"
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(JovianISCSIDriver, self).__init__(*args, **kwargs) super().__init__(*args, **kwargs)
self._stats = None self._stats = None
self.jovian_iscsi_target_portal_port = "3260" self.jovian_iscsi_target_portal_port = "3260"
@ -70,7 +70,7 @@ class JovianISCSIDriver(driver.ISCSIDriver):
backend_name = None backend_name = None
if self.configuration: if self.configuration:
backend_name = self.configuration.get('volume_backend_name', backend_name = self.configuration.get('volume_backend_name',
'JovianDSS') 'Open-EJovianDSS')
if not backend_name: if not backend_name:
backend_name = self.__class__.__name__ backend_name = self.__class__.__name__
return backend_name return backend_name
@ -150,11 +150,11 @@ class JovianISCSIDriver(driver.ISCSIDriver):
sparse=self.jovian_sparse, sparse=self.jovian_sparse,
block_size=self.block_size) block_size=self.block_size)
except jexc.JDSSException as ex: except jexc.JDSSException as jerr:
LOG.error("Create volume error. Because %(err)s", LOG.error("Create volume error. Because %(err)s",
{"err": ex}) {"err": jerr})
raise exception.VolumeBackendAPIException( raise exception.VolumeBackendAPIException(
_('Failed to create volume %s.') % volume.id) _('Failed to create volume %s.') % volume.id) from jerr
ret = {} ret = {}
if provider_auth is not None: if provider_auth is not None:
ret['provider_auth'] = provider_auth ret['provider_auth'] = provider_auth
@ -171,10 +171,10 @@ class JovianISCSIDriver(driver.ISCSIDriver):
rename = {'name': jcom.hidden(vname)} rename = {'name': jcom.hidden(vname)}
try: try:
self.ra.modify_lun(vname, rename) self.ra.modify_lun(vname, rename)
except jexc.JDSSException as err: except jexc.JDSSException as jerr:
msg = _('Failure in hidding {object}, err: {error},' emsg = _('Failure in hiding %(object)s, err: %(error)s,'
' object have to be removed manually') ' object has to be removed manually') % {'object': vname,
emsg = msg.format(object=vname, error=err) 'error': jerr}
LOG.warning(emsg) LOG.warning(emsg)
raise exception.VolumeBackendAPIException(emsg) raise exception.VolumeBackendAPIException(emsg)
@ -185,8 +185,8 @@ class JovianISCSIDriver(driver.ISCSIDriver):
if snap['clones'] == '': if snap['clones'] == '':
try: try:
self.ra.delete_snapshot(vname, snap['name']) self.ra.delete_snapshot(vname, snap['name'])
except jexc.JDSSException as err: except jexc.JDSSException as jerr:
args = {'obj': jcom.idname(vname), 'err': err} args = {'obj': jcom.idname(vname), 'err': jerr}
msg = (_("Unable to clean garbage for " msg = (_("Unable to clean garbage for "
"%(obj)s: %(err)s") % args) "%(obj)s: %(err)s") % args)
raise exception.VolumeBackendAPIException(msg) raise exception.VolumeBackendAPIException(msg)
@ -220,16 +220,16 @@ class JovianISCSIDriver(driver.ISCSIDriver):
psnap = [] psnap = []
try: try:
psnap = self.ra.get_snapshots(vsnap[1]) psnap = self.ra.get_snapshots(vsnap[1])
except jexc.JDSSException: except jexc.JDSSException as jerr:
msg = (_('Failure in acquiring snapshot for %s.') % vsnap[1]) msg = (_('Failure in acquiring snapshot for %s.') % vsnap[1])
raise exception.VolumeBackendAPIException(msg) raise exception.VolumeBackendAPIException(msg) from jerr
try: try:
psnap = self._clean_garbage_snapshots(vsnap[1], psnap) psnap = self._clean_garbage_snapshots(vsnap[1], psnap)
except exception.VolumeBackendAPIException as err: except exception.VolumeBackendAPIException as err:
msg = (_('Failure in cleaning garbage snapshots %s' msg = (_('Failure in cleaning garbage snapshots %s'
' for volume %s, %s') % psnap, vsnap[1], err) ' for volume %s, %s') % psnap, vsnap[1], err)
raise exception.VolumeBackendAPIException(msg) raise exception.VolumeBackendAPIException(msg) from err
if len(psnap) > 0: if len(psnap) > 0:
deletable = False deletable = False
self._hide_object(vsnap[1]) self._hide_object(vsnap[1])
@ -240,9 +240,9 @@ class JovianISCSIDriver(driver.ISCSIDriver):
recursively_children=True, recursively_children=True,
recursively_dependents=True, recursively_dependents=True,
force_umount=True) force_umount=True)
except jexc.JDSSException as err: except jexc.JDSSException as jerr:
LOG.warning('Failure during deletion of physical ' LOG.warning('Failure during deletion of physical '
'snapshot %s, err: %s', vsnap[0], err) 'snapshot %s, err: %s', vsnap[0], jerr)
msg = (_('Failure during deletion of virtual snapshot ' msg = (_('Failure during deletion of virtual snapshot '
'%s') % vsnap[1]) '%s') % vsnap[1])
raise exception.VolumeBackendAPIException(msg) raise exception.VolumeBackendAPIException(msg)
@ -269,8 +269,8 @@ class JovianISCSIDriver(driver.ISCSIDriver):
LOG.debug('volume %s dne, it was already ' LOG.debug('volume %s dne, it was already '
'deleted', vname) 'deleted', vname)
return return
except jexc.JDSSException as err: except jexc.JDSSException as jerr:
raise exception.VolumeBackendAPIException(err) raise exception.VolumeBackendAPIException(jerr)
snapshots = self._clean_garbage_snapshots(vname, snapshots) snapshots = self._clean_garbage_snapshots(vname, snapshots)
@ -295,8 +295,8 @@ class JovianISCSIDriver(driver.ISCSIDriver):
LOG.debug('volume %s does not exist, it was already ' LOG.debug('volume %s does not exist, it was already '
'deleted.', vname) 'deleted.', vname)
return return
except jexc.JDSSException as err: except jexc.JDSSException as jerr:
raise exception.VolumeBackendAPIException(err) raise exception.VolumeBackendAPIException(jerr)
if vol['is_clone']: if vol['is_clone']:
self._delete_back_recursively(jcom.origin_volume(vol['origin']), self._delete_back_recursively(jcom.origin_volume(vol['origin']),
@ -304,13 +304,13 @@ class JovianISCSIDriver(driver.ISCSIDriver):
else: else:
try: try:
self.ra.delete_lun(vname, force_umount=True) self.ra.delete_lun(vname, force_umount=True)
except jexc.JDSSRESTException as err: except jexc.JDSSRESTException as jerr:
LOG.debug( LOG.debug(
"Unable to delete physical volume %(volume)s " "Unable to delete physical volume %(volume)s "
"with error %(err)s.", { "with error %(err)s.", {
"volume": vname, "volume": vname,
"err": err}) "err": jerr})
raise exception.VolumeIsBusy(err) raise exception.VolumeIsBusy(jerr)
def _delete_back_recursively(self, opvname, opsname): def _delete_back_recursively(self, opvname, opsname):
"""Deletes snapshot by removing its oldest removable parent """Deletes snapshot by removing its oldest removable parent
@ -320,8 +320,8 @@ class JovianISCSIDriver(driver.ISCSIDriver):
source snapshot if such exists, or deletes it source snapshot if such exists, or deletes it
If it is not hidden, trigers delete for snapshot If it is not hidden, trigers delete for snapshot
:param ovname: origin phisical volume name :param opvname: origin physical volume name
:param osname: origin phisical snapshot name :param opsname: origin physical snapshot name
""" """
if jcom.is_hidden(opvname): if jcom.is_hidden(opvname):
@ -334,8 +334,8 @@ class JovianISCSIDriver(driver.ISCSIDriver):
' physical volume %s, volume do not exist', ' physical volume %s, volume do not exist',
opvname) opvname)
return return
except jexc.JDSSException as err: except jexc.JDSSException as jerr:
raise exception.VolumeBackendAPIException(err) raise exception.VolumeBackendAPIException(jerr)
snaps = self._clean_garbage_snapshots(opvname, snaps) snaps = self._clean_garbage_snapshots(opvname, snaps)
@ -348,8 +348,8 @@ class JovianISCSIDriver(driver.ISCSIDriver):
recursively_children=True, recursively_children=True,
recursively_dependents=True, recursively_dependents=True,
force_umount=True) force_umount=True)
except jexc.JDSSException as err: except jexc.JDSSException as jerr:
raise exception.VolumeBackendAPIException(err) raise exception.VolumeBackendAPIException(jerr)
else: else:
vol = None vol = None
try: try:
@ -359,8 +359,8 @@ class JovianISCSIDriver(driver.ISCSIDriver):
LOG.debug('volume %s does not exist, it was already ' LOG.debug('volume %s does not exist, it was already '
'deleted.', opvname) 'deleted.', opvname)
return return
except jexc.JDSSException as err: except jexc.JDSSException as jerr:
raise exception.VolumeBackendAPIException(err) raise exception.VolumeBackendAPIException(jerr)
if vol['is_clone']: if vol['is_clone']:
self._delete_back_recursively( self._delete_back_recursively(
@ -376,8 +376,8 @@ class JovianISCSIDriver(driver.ISCSIDriver):
LOG.debug('volume %s does not exist, it was already ' LOG.debug('volume %s does not exist, it was already '
'deleted.', opvname) 'deleted.', opvname)
return return
except jexc.JDSSException as err: except jexc.JDSSException as jerr:
raise exception.VolumeBackendAPIException(err) raise exception.VolumeBackendAPIException(jerr)
else: else:
# Resource is active # Resource is active
try: try:
@ -386,8 +386,8 @@ class JovianISCSIDriver(driver.ISCSIDriver):
recursively_children=True, recursively_children=True,
recursively_dependents=True, recursively_dependents=True,
force_umount=True) force_umount=True)
except jexc.JDSSException as err: except jexc.JDSSException as jerr:
raise exception.VolumeBackendAPIException(err) raise exception.VolumeBackendAPIException(jerr) from jerr
def extend_volume(self, volume, new_size): def extend_volume(self, volume, new_size):
"""Extend an existing volume. """Extend an existing volume.
@ -400,9 +400,9 @@ class JovianISCSIDriver(driver.ISCSIDriver):
try: try:
self.ra.extend_lun(jcom.vname(volume.id), self.ra.extend_lun(jcom.vname(volume.id),
new_size * o_units.Gi) new_size * o_units.Gi)
except jexc.JDSSException: except jexc.JDSSException as jerr:
raise exception.VolumeBackendAPIException( raise exception.VolumeBackendAPIException(
(_('Failed to extend volume %s.'), volume.id)) (_('Failed to extend volume %s.'), volume.id)) from jerr
def revert_to_snapshot(self, context, volume, snapshot): def revert_to_snapshot(self, context, volume, snapshot):
"""Revert volume to snapshot. """Revert volume to snapshot.
@ -421,10 +421,10 @@ class JovianISCSIDriver(driver.ISCSIDriver):
vsize = None vsize = None
try: try:
vsize = self.ra.get_lun(vname).get('volsize') vsize = self.ra.get_lun(vname).get('volsize')
except jexc.JDSSResourceNotFoundException: except jexc.JDSSResourceNotFoundException as jerr:
raise exception.VolumeNotFound(volume_id=volume.id) raise exception.VolumeNotFound(volume_id=volume.id) from jerr
except jexc.JDSSException as err: except jexc.JDSSException as jerr:
raise exception.VolumeBackendAPIException(err) raise exception.VolumeBackendAPIException(jerr) from jerr
if vsize is None: if vsize is None:
raise exception.VolumeDriverException( raise exception.VolumeDriverException(
@ -432,17 +432,17 @@ class JovianISCSIDriver(driver.ISCSIDriver):
try: try:
self.ra.rollback_volume_to_snapshot(vname, sname) self.ra.rollback_volume_to_snapshot(vname, sname)
except jexc.JDSSException as err: except jexc.JDSSException as jerr:
raise exception.VolumeBackendAPIException(err.message) raise exception.VolumeBackendAPIException(jerr.message) from jerr
try: try:
rvsize = self.ra.get_lun(vname).get('volsize') rvsize = self.ra.get_lun(vname).get('volsize')
if rvsize != vsize: if rvsize != vsize:
self.ra.extend_lun(vname, vsize) self.ra.extend_lun(vname, vsize)
except jexc.JDSSResourceNotFoundException: except jexc.JDSSResourceNotFoundException as jerr:
raise exception.VolumeNotFound(volume_id=volume.id) raise exception.VolumeNotFound(volume_id=volume.id) from jerr
except jexc.JDSSException as err: except jexc.JDSSException as jerr:
raise exception.VolumeBackendAPIException(err) raise exception.VolumeBackendAPIException(jerr) from jerr
def _clone_object(self, oname, coname): def _clone_object(self, oname, coname):
"""Creates a clone of specified object """Creates a clone of specified object
@ -459,20 +459,22 @@ class JovianISCSIDriver(driver.ISCSIDriver):
except jexc.JDSSSnapshotExistsException: except jexc.JDSSSnapshotExistsException:
try: try:
self.ra.delete_snapshot(oname, coname) self.ra.delete_snapshot(oname, coname)
except jexc.JDSSSnapshotIsBusyException: except jexc.JDSSSnapshotIsBusyException as jerrisbusy:
raise exception.Duplicate() raise exception.Duplicate() from jerrisbusy
except jexc.JDSSException: except jexc.JDSSException as jerr:
raise exception.VolumeBackendAPIException( raise exception.VolumeBackendAPIException(
(_("Unable to create volume %s.") % coname)) (_("Unable to create volume %s.") % coname)) from jerr
except jexc.JDSSResourceNotFoundException: except jexc.JDSSResourceNotFoundException as jerrnotfound:
if jcom.is_volume(oname): if jcom.is_volume(oname):
raise exception.VolumeNotFound(volume_id=jcom.idname(oname)) raise exception.VolumeNotFound(
raise exception.SnapshotNotFound(snapshot_id=jcom.idname(oname)) volume_id=jcom.idname(oname)) from jerrnotfound
raise exception.SnapshotNotFound(
snapshot_id=jcom.idname(oname)) from jerrnotfound
except jexc.JDSSException as err: except jexc.JDSSException as jerr:
args = {'snapshot': coname, args = {'snapshot': coname,
'object': oname, 'object': oname,
'err': err} 'err': jerr}
msg = (_('Failed to create tmp snapshot %(snapshot)s ' msg = (_('Failed to create tmp snapshot %(snapshot)s '
'for object %(object)s: %(err)s') % args) 'for object %(object)s: %(err)s') % args)
raise exception.VolumeBackendAPIException(msg) raise exception.VolumeBackendAPIException(msg)
@ -483,25 +485,25 @@ class JovianISCSIDriver(driver.ISCSIDriver):
coname, coname,
oname, oname,
sparse=self.jovian_sparse) sparse=self.jovian_sparse)
except jexc.JDSSResourceExistsException: except jexc.JDSSResourceExistsException as jerr:
raise exception.Duplicate() raise exception.Duplicate() from jerr
except jexc.JDSSException as err: except jexc.JDSSException as jerr:
try: try:
self.ra.delete_snapshot(oname, self.ra.delete_snapshot(oname,
coname, coname,
recursively_children=True, recursively_children=True,
recursively_dependents=True, recursively_dependents=True,
force_umount=True) force_umount=True)
except jexc.JDSSException as terr: except jexc.JDSSException as jerrd:
LOG.warning("Because of %s phisical snapshot %s of volume" LOG.warning("Because of %s physical snapshot %s of volume"
" %s have to be removed manually", " %s have to be removed manually",
terr, jerrd,
coname, coname,
oname) oname)
raise exception.VolumeBackendAPIException( raise exception.VolumeBackendAPIException(
_("Unable to create volume {vol} because of {err}.").format( _("Unable to create volume %(vol)s because of %(err)s.") % {
vol=coname, err=err)) 'vol': coname, 'err': jerr}) from jerr
def create_cloned_volume(self, volume, src_vref): def create_cloned_volume(self, volume, src_vref):
"""Create a clone of the specified volume. """Create a clone of the specified volume.
@ -523,12 +525,12 @@ class JovianISCSIDriver(driver.ISCSIDriver):
try: try:
clone_size = int(self.ra.get_lun(cvname)['volsize']) clone_size = int(self.ra.get_lun(cvname)['volsize'])
except jexc.JDSSException: except jexc.JDSSException as jerr:
self._delete_back_recursively(vname, cvname) self._delete_back_recursively(vname, cvname)
raise exception.VolumeBackendAPIException( raise exception.VolumeBackendAPIException(
_("Fail in cloning volume {vol} to {clone}.").format( _("Fail in cloning volume %(vol)s to %(clone)s.") % {
vol=src_vref.id, clone=volume.id)) 'vol': src_vref.id, 'clone': volume.id}) from jerr
try: try:
if int(clone_size) < o_units.Gi * int(volume.size): if int(clone_size) < o_units.Gi * int(volume.size):
@ -540,8 +542,8 @@ class JovianISCSIDriver(driver.ISCSIDriver):
try: try:
self._delete_back_recursively(cvname, cvname) self._delete_back_recursively(cvname, cvname)
except exception.VolumeBackendAPIException as err: except exception.VolumeBackendAPIException as err:
LOG.warning("Because of %s phisical snapshot %s of volume" LOG.warning("Because of %s physical snapshot %s of volume"
" %s have to be removed manualy", " %s have to be removed manually",
err, err,
cvname, cvname,
vname) vname)
@ -579,12 +581,12 @@ class JovianISCSIDriver(driver.ISCSIDriver):
try: try:
clone_size = int(self.ra.get_lun(cvname)['volsize']) clone_size = int(self.ra.get_lun(cvname)['volsize'])
except jexc.JDSSException: except jexc.JDSSException as jerr:
self._delete_back_recursively(sname, cvname) self._delete_back_recursively(sname, cvname)
raise exception.VolumeBackendAPIException( raise exception.VolumeBackendAPIException(
_("Fail in cloning snapshot {snap} to {clone}.").format( _("Fail in cloning snapshot %(snap)s to %(clone)s.") % {
snap=snapshot.id, clone=volume.id)) 'snap': snapshot.id, 'clone': volume.id}) from jerr
try: try:
if clone_size < o_units.Gi * int(volume.size): if clone_size < o_units.Gi * int(volume.size):
@ -594,11 +596,11 @@ class JovianISCSIDriver(driver.ISCSIDriver):
# before failing # before failing
try: try:
self._delete_back_recursively(cvname, cvname) self._delete_back_recursively(cvname, cvname)
except exception.VolumeBackendAPIException as ierr: except exception.VolumeBackendAPIException as err:
msg = ("Hidden snapshot %s of volume %s " msg = ("Hidden snapshot %s of volume %s "
"have to be removed manualy, " "have to be removed manualy, "
"as automatic removal failed: %s") "as automatic removal failed: %s")
LOG.warning(msg, cvname, sname, ierr) LOG.warning(msg, cvname, sname, err)
raise raise
provider_location = self._get_provider_location(volume.id) provider_location = self._get_provider_location(volume.id)
@ -650,8 +652,8 @@ class JovianISCSIDriver(driver.ISCSIDriver):
LOG.debug('physical volume %s dne, it was already ' LOG.debug('physical volume %s dne, it was already '
'deleted.', sname) 'deleted.', sname)
return return
except jexc.JDSSException as err: except jexc.JDSSException as jerr:
raise exception.VolumeBackendAPIException(err) raise exception.VolumeBackendAPIException(jerr)
snapshots = self._clean_garbage_snapshots(sname, snapshots) snapshots = self._clean_garbage_snapshots(sname, snapshots)
@ -675,16 +677,15 @@ class JovianISCSIDriver(driver.ISCSIDriver):
symbolgroups=(string.ascii_lowercase + symbolgroups=(string.ascii_lowercase +
string.ascii_uppercase + string.digits)) string.ascii_uppercase + string.digits))
return 'CHAP {user} {passwd}'.format( return 'CHAP %(user)s %(passwd)s' % {
user=chap_user, passwd=chap_password) 'user': chap_user, 'passwd': chap_password}
def _get_provider_location(self, volume_name): def _get_provider_location(self, volume_name):
"""Return volume iscsiadm-formatted provider location string.""" """Return volume iscsiadm-formatted provider location string."""
return '{host}:{port},1 {name} 0'.format( return '%(host)s:%(port)s,1 %(name)s 0' % {
host=self.ra.get_active_host(), 'host': self.ra.get_active_host(),
port=self.jovian_iscsi_target_portal_port, 'port': self.jovian_iscsi_target_portal_port,
name=self._get_target_name(volume_name) 'name': self._get_target_name(volume_name)}
)
def create_export(self, _ctx, volume, connector): def create_export(self, _ctx, volume, connector):
"""Create new export for zvol. """Create new export for zvol.
@ -765,13 +766,13 @@ class JovianISCSIDriver(driver.ISCSIDriver):
self.ra.create_target(target_name, self.ra.create_target(target_name,
use_chap=use_chap) use_chap=use_chap)
except jexc.JDSSResourceExistsException: except jexc.JDSSResourceExistsException as jerrex:
raise exception.Duplicate() raise exception.Duplicate() from jerrex
except jexc.JDSSException as ex: except jexc.JDSSException as jerr:
msg = (_('Unable to create target %(target)s ' msg = (_('Unable to create target %(target)s '
'because of %(error)s.') % {'target': target_name, 'because of %(error)s.') % {'target': target_name,
'error': ex}) 'error': jerr})
raise exception.VolumeBackendAPIException(msg) raise exception.VolumeBackendAPIException(msg)
def _attach_target_volume(self, target_name, vname): def _attach_target_volume(self, target_name, vname):
@ -784,11 +785,11 @@ class JovianISCSIDriver(driver.ISCSIDriver):
""" """
try: try:
self.ra.attach_target_vol(target_name, vname) self.ra.attach_target_vol(target_name, vname)
except jexc.JDSSException as ex: except jexc.JDSSException as jerr:
msg = ('Unable to attach volume to target {target} ' msg = ('Unable to attach volume to target {target} '
'because of {error}.') 'because of {error}.')
emsg = msg.format(target=target_name, error=ex) emsg = msg.format(target=target_name, error=jerr)
LOG.debug(msg, {"target": target_name, "error": ex}) LOG.debug(msg, {"target": target_name, "error": jerr})
try: try:
self.ra.delete_target(target_name) self.ra.delete_target(target_name)
except jexc.JDSSException: except jexc.JDSSException:
@ -806,7 +807,7 @@ class JovianISCSIDriver(driver.ISCSIDriver):
try: try:
self.ra.create_target_user(target_name, cred) self.ra.create_target_user(target_name, cred)
except jexc.JDSSException as ex: except jexc.JDSSException as jerr:
try: try:
self.ra.delete_target(target_name) self.ra.delete_target(target_name)
except jexc.JDSSException: except jexc.JDSSException:
@ -817,7 +818,7 @@ class JovianISCSIDriver(driver.ISCSIDriver):
'because of %(error)s.') % { 'because of %(error)s.') % {
'target': target_name, 'target': target_name,
'user': cred['name'], 'user': cred['name'],
'error': ex}) 'error': jerr})
LOG.debug(err_msg) LOG.debug(err_msg)
@ -865,7 +866,7 @@ class JovianISCSIDriver(driver.ISCSIDriver):
auth = volume.provider_auth auth = volume.provider_auth
if not auth: if not auth:
msg = _("volume {} is missing provider_auth").format(volume.id) msg = _("volume %s is missing provider_auth") % volume.id
raise exception.VolumeDriverException(msg) raise exception.VolumeDriverException(msg)
(__, auth_username, auth_secret) = auth.split() (__, auth_username, auth_secret) = auth.split()
@ -894,9 +895,9 @@ class JovianISCSIDriver(driver.ISCSIDriver):
user['name']) user['name'])
self._set_target_credentials(target_name, chap_cred) self._set_target_credentials(target_name, chap_cred)
except jexc.JDSSException as err: except jexc.JDSSException as jerr:
self.ra.delete_target(target_name) self.ra.delete_target(target_name)
raise exception.VolumeBackendAPIException(err) raise exception.VolumeBackendAPIException(jerr)
def _remove_target_volume(self, volume): def _remove_target_volume(self, volume):
"""_remove_target_volume """_remove_target_volume
@ -911,33 +912,33 @@ class JovianISCSIDriver(driver.ISCSIDriver):
try: try:
self.ra.detach_target_vol(target_name, jcom.vname(volume.id)) self.ra.detach_target_vol(target_name, jcom.vname(volume.id))
except jexc.JDSSResourceNotFoundException as ex: except jexc.JDSSResourceNotFoundException as jerrrnf:
LOG.debug('failed to remove resource %(t)s because of %(err)s', { LOG.debug('failed to remove resource %(t)s because of %(err)s', {
't': target_name, 't': target_name,
'err': ex.args[0]}) 'err': jerrrnf.args[0]})
except jexc.JDSSException as ex: except jexc.JDSSException as jerr:
LOG.debug('failed to Terminate_connection for target %(targ)s' LOG.debug('failed to Terminate_connection for target %(targ)s '
'because of: %(err)s', { 'because of: %(err)s', {
'targ': target_name, 'targ': target_name,
'err': ex.args[0]}) 'err': jerr.args[0]})
raise exception.VolumeBackendAPIException(ex) raise exception.VolumeBackendAPIException(jerr)
LOG.debug("delete target: %s", target_name) LOG.debug("delete target: %s", target_name)
try: try:
self.ra.delete_target(target_name) self.ra.delete_target(target_name)
except jexc.JDSSResourceNotFoundException as ex: except jexc.JDSSResourceNotFoundException as jerrrnf:
LOG.debug('failed to remove resource %(target)s because ' LOG.debug('failed to remove resource %(target)s because '
'of %(err)s', {'target': target_name, 'of %(err)s', {'target': target_name,
'err': ex.args[0]}) 'err': jerrrnf.args[0]})
except jexc.JDSSException as ex: except jexc.JDSSException as jerr:
LOG.debug('Failed to Terminate_connection for target %(targ)s' LOG.debug('Failed to Terminate_connection for target %(targ)s '
'because of: %(err)s', { 'because of: %(err)s ', {
'targ': target_name, 'targ': target_name,
'err': ex.args[0]}) 'err': jerr.args[0]})
raise exception.VolumeBackendAPIException(ex) raise exception.VolumeBackendAPIException(jerr)
def _get_iscsi_properties(self, volume, connector): def _get_iscsi_properties(self, volume, connector):
"""Return dict according to cinder/driver.py implementation. """Return dict according to cinder/driver.py implementation.

View File

@ -84,13 +84,13 @@ def is_hidden(name):
def origin_snapshot(origin_str): def origin_snapshot(origin_str):
"""Extracts original phisical snapshot name from origin record""" """Extracts original physical snapshot name from origin record"""
return origin_str.split("@")[1] return origin_str.split("@")[1]
def origin_volume(origin_str): def origin_volume(origin_str):
"""Extracts original phisical volume name from origin record""" """Extracts original physical volume name from origin record"""
return origin_str.split("@")[0].split("/")[1] return origin_str.split("@")[0].split("/")[1]

View File

@ -14,7 +14,7 @@
# under the License. # under the License.
"""REST cmd interoperation class for JovianDSS driver.""" """REST cmd interoperation class for Open-E JovianDSS driver."""
import re import re
from oslo_log import log as logging from oslo_log import log as logging
@ -39,19 +39,19 @@ class JovianRESTAPI(object):
re.compile(r'^Zfs resource: .* not found in this collection\.$')) re.compile(r'^Zfs resource: .* not found in this collection\.$'))
def _general_error(self, url, resp): def _general_error(self, url, resp):
reason = "Request {} failure".format(url) reason = "Request %s failure" % url
if 'error' in resp: if 'error' in resp:
eclass = resp.get('class', 'Unknown') eclass = resp.get('class', 'Unknown')
code = resp.get('code', 'Unknown') code = resp.get('code', 'Unknown')
msg = resp.get('message', 'Unknown') msg = resp.get('message', 'Unknown')
reason = _("Request to {url} failed with code: {code} " reason = _("Request to %(url)s failed with code: %(code)s "
"of type:{eclass} reason:{message}") "of type:%(eclass)s reason:%(message)s")
reason = reason.format(eclass=eclass, reason = (reason % {'url': url,
code=code, 'code': code,
message=msg, 'eclass': eclass,
url=url) 'message': msg})
raise jexc.JDSSException(reason=reason) raise jexc.JDSSException(reason=reason)
def get_active_host(self): def get_active_host(self):
@ -140,9 +140,9 @@ class JovianRESTAPI(object):
if resp["error"] is not None: if resp["error"] is not None:
if resp["error"]["errno"] == str(5): if resp["error"]["errno"] == str(5):
raise jexc.JDSSRESTException( msg = _('Failed to create volume %s.' %
'Failed to create volume. {}.'.format( resp['error']['message'])
resp['error']['message'])) raise jexc.JDSSRESTException(msg)
raise jexc.JDSSRESTException('Failed to create volume.') raise jexc.JDSSRESTException('Failed to create volume.')
@ -293,7 +293,7 @@ class JovianRESTAPI(object):
"property_value":"<value of a property>"} "property_value":"<value of a property>"}
""" """
req = '/volumes/{}/properties'.format(volume_name) req = '/volumes/%s/properties' % volume_name
resp = self.rproxy.pool_request('PUT', req, json_data=prop) resp = self.rproxy.pool_request('PUT', req, json_data=prop)
@ -469,7 +469,7 @@ class JovianRESTAPI(object):
} }
:return: :return:
""" """
req = '/san/iscsi/targets/' + target_name + "/incoming-users" req = "/san/iscsi/targets/%s/incoming-users" % target_name
LOG.debug("add credentails to target %s", target_name) LOG.debug("add credentails to target %s", target_name)
@ -491,7 +491,7 @@ class JovianRESTAPI(object):
:param target_name: :param target_name:
""" """
req = '/san/iscsi/targets/' + target_name + "/incoming-users" req = "/san/iscsi/targets/%s/incoming-users" % target_name
LOG.debug("get chap cred for target %s", target_name) LOG.debug("get chap cred for target %s", target_name)
@ -514,8 +514,9 @@ class JovianRESTAPI(object):
:param target_name: target name :param target_name: target name
:param user_name: user name :param user_name: user name
""" """
req = '/san/iscsi/targets/{0}/incoming-users/{1}'.format( req = '/san/iscsi/targets/%(target)s/incoming-users/%(user)s' % {
target_name, user_name) 'target': target_name,
'user': user_name}
LOG.debug("remove credentails from target %s", target_name) LOG.debug("remove credentails from target %s", target_name)
@ -538,7 +539,9 @@ class JovianRESTAPI(object):
:param lun_name: :param lun_name:
:return: Bool :return: Bool
""" """
req = '/san/iscsi/targets/' + target_name + "/luns/" + lun_name req = '/san/iscsi/targets/%(tar)s/luns/%(lun)s' % {
'tar': target_name,
'lun': lun_name}
LOG.debug("check if volume %(vol)s is associated with %(tar)s", LOG.debug("check if volume %(vol)s is associated with %(tar)s",
{'vol': lun_name, {'vol': lun_name,
@ -567,7 +570,7 @@ class JovianRESTAPI(object):
:param lun_name: :param lun_name:
:return: :return:
""" """
req = '/san/iscsi/targets/{}/luns'.format(target_name) req = '/san/iscsi/targets/%s/luns' % target_name
jbody = {"name": lun_name, "lun": lun_id} jbody = {"name": lun_name, "lun": lun_id}
LOG.debug("atach volume %(vol)s to target %(tar)s", LOG.debug("atach volume %(vol)s to target %(tar)s",
@ -596,7 +599,9 @@ class JovianRESTAPI(object):
:param lun_name: :param lun_name:
:return: :return:
""" """
req = '/san/iscsi/targets/' + target_name + "/luns/" + lun_name req = '/san/iscsi/targets/%(tar)s/luns/%(lun)s' % {
'tar': target_name,
'lun': lun_name}
LOG.debug("detach volume %(vol)s from target %(tar)s", LOG.debug("detach volume %(vol)s from target %(tar)s",
{'vol': lun_name, {'vol': lun_name,
@ -621,7 +626,7 @@ class JovianRESTAPI(object):
:param snapshot_name: snapshot name :param snapshot_name: snapshot name
:return: :return:
""" """
req = '/volumes/' + volume_name + '/snapshots' req = '/volumes/%s/snapshots' % volume_name
jbody = { jbody = {
'snapshot_name': snapshot_name 'snapshot_name': snapshot_name
@ -655,7 +660,7 @@ class JovianRESTAPI(object):
:param original_vol_name: sample copy :param original_vol_name: sample copy
:return: :return:
""" """
req = '/volumes/' + original_vol_name + '/clone' req = '/volumes/%s/clone' % original_vol_name
jbody = { jbody = {
'name': volume_name, 'name': volume_name,
@ -682,8 +687,8 @@ class JovianRESTAPI(object):
volume=volume_name) volume=volume_name)
if resp["error"]["errno"] == 1: if resp["error"]["errno"] == 1:
raise jexc.JDSSResourceNotFoundException( raise jexc.JDSSResourceNotFoundException(
res="{vol}@{snap}".format(vol=original_vol_name, res="%(vol)s@%(snap)s" % {'vol': original_vol_name,
snap=snapshot_name)) 'snap': snapshot_name})
self._general_error(req, resp) self._general_error(req, resp)
@ -695,9 +700,9 @@ class JovianRESTAPI(object):
:param snapshot_name: snapshot of a volume above :param snapshot_name: snapshot of a volume above
:return: :return:
""" """
req = ('/volumes/{vol}/snapshots/' req = ('/volumes/%(vol)s/snapshots/'
'{snap}/rollback').format(vol=volume_name, '%(snap)s/rollback') % {'vol': volume_name,
snap=snapshot_name) 'snap': snapshot_name}
LOG.debug("rollback volume %(vol)s to snapshot %(snap)s", LOG.debug("rollback volume %(vol)s to snapshot %(snap)s",
{'vol': volume_name, {'vol': volume_name,
@ -712,8 +717,8 @@ class JovianRESTAPI(object):
if resp["error"]: if resp["error"]:
if resp["error"]["errno"] == 1: if resp["error"]["errno"] == 1:
raise jexc.JDSSResourceNotFoundException( raise jexc.JDSSResourceNotFoundException(
res="{vol}@{snap}".format(vol=volume_name, res="%(vol)s@%(snap)s" % {'vol': volume_name,
snap=snapshot_name)) 'snap': snapshot_name})
self._general_error(req, resp) self._general_error(req, resp)
@ -740,8 +745,9 @@ class JovianRESTAPI(object):
:return: :return:
""" """
req = '/volumes/' + volume_name + '/snapshots/' + snapshot_name req = '/volumes/%(vol)s/snapshots/%(snap)s' % {
'vol': volume_name,
'snap': snapshot_name}
LOG.debug("delete snapshot %(snap)s of volume %(vol)s", LOG.debug("delete snapshot %(snap)s of volume %(vol)s",
{'snap': snapshot_name, {'snap': snapshot_name,
'vol': volume_name}) 'vol': volume_name})
@ -805,7 +811,7 @@ class JovianRESTAPI(object):
"error": null "error": null
} }
""" """
req = '/volumes/' + volume_name + '/snapshots' req = '/volumes/%s/snapshots' % volume_name
LOG.debug("get snapshots for volume %s ", volume_name) LOG.debug("get snapshots for volume %s ", volume_name)

View File

@ -107,8 +107,8 @@ class JovianRESTProxy(object):
out = None out = None
for i in range(len(self.hosts)): for i in range(len(self.hosts)):
try: try:
addr = "{base}{req}".format(base=self._get_base_url(), addr = "%(base)s%(req)s" % {'base': self._get_base_url(),
req=req) 'req': req}
LOG.debug("Sending %(t)s to %(addr)s", LOG.debug("Sending %(t)s to %(addr)s",
{'t': request_method, 'addr': addr}) {'t': request_method, 'addr': addr})
r = None r = None

View File

@ -2,8 +2,8 @@
Open-E JovianDSS iSCSI driver Open-E JovianDSS iSCSI driver
============================= =============================
The ``JovianISCSIDriver`` allows usage of Open-E Jovian Data Storage The ``JovianISCSIDriver`` allows usage of Open-E JovianDSS
Solution to be used as Block Storage in OpenStack deployments. Data Storage Solution to be used as Block Storage in OpenStack deployments.
Supported operations Supported operations
~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~
@ -24,18 +24,19 @@ Configuring
Edit with your favourite editor Cinder config file. It can be found at Edit with your favourite editor Cinder config file. It can be found at
/etc/cinder/cinder.conf /etc/cinder/cinder.conf
Add the field enabled\_backends with value jdss-0: Add the field enabled\_backends with value open-e-jdss-0:
:: ::
enabled_backends = jdss-0 enabled_backends = open-e-jdss-0
Provide settings to JovianDSS driver by adding 'jdss-0' description: Provide settings to Open-E JovianDSS driver by adding 'open-e-jdss-0'
description:
:: ::
[jdss-0] [open-e-jdss-0]
backend_name = jdss-0 backend_name = Open-EJovianDSS
chap_password_len = 14 chap_password_len = 14
driver_use_ssl = True driver_use_ssl = True
driver_ssl_cert_verify = True driver_ssl_cert_verify = True
@ -58,20 +59,20 @@ Provide settings to JovianDSS driver by adding 'jdss-0' description:
- Default value - Default value
- Description - Description
* - ``backend_name`` * - ``backend_name``
- JovianDSS-iSCSI - Open-EJovianDSS
- Name of the back end - Name of the back end
* - ``chap_password_len`` * - ``chap_password_len``
- 12 - 12
- Length of the unique generated CHAP password. - Length of the unique generated CHAP password.
* - ``driver_use_ssl`` * - ``driver_use_ssl``
- True - True
- Use SSL to send requests to JovianDSS[1] - Use SSL to send requests to Open-E JovianDSS[1]
* - ``driver_ssl_cert_verify`` * - ``driver_ssl_cert_verify``
- True - True
- Verify authenticity of JovianDSS[1] certificate - Verify authenticity of Open-E JovianDSS[1] certificate
* - ``driver_ssl_cert_path`` * - ``driver_ssl_cert_path``
- None - None
- Path to the JovianDSS[1] certificate for verification - Path to the Open-E JovianDSS[1] certificate for verification
* - ``iscsi_target_prefix`` * - ``iscsi_target_prefix``
- iqn.2016-04.com.open-e:01:cinder- - iqn.2016-04.com.open-e:01:cinder-
- Prefix that will be used to form target name for volume - Prefix that will be used to form target name for volume
@ -92,21 +93,21 @@ Provide settings to JovianDSS driver by adding 'jdss-0' description:
- Location of the driver source code - Location of the driver source code
* - ``san_hosts`` * - ``san_hosts``
- -
- Comma separated list of IP address of the JovianDSS - Comma separated list of IP address of the Open-E JovianDSS
* - ``san_login`` * - ``san_login``
- admin - admin
- Must be set according to the settings in [1] - Must be set according to the settings in [1]
* - ``san_password`` * - ``san_password``
- admin - admin
- Jovian password [1], **should be changed** for security purposes - Open-E Jovian DSS password [1], **should be changed**
* - ``san_thin_provision`` * - ``san_thin_provision``
- False - False
- Using thin provisioning for new volumes - Using thin provisioning for new volumes
1. JovianDSS Web interface/System Settings/REST Access 1. Open-E JovianDSS Web interface/System Settings/REST Access
2. Pool can be created by going to JovianDSS Web interface/Storage 2. Pool can be created by going to Open-E JovianDSS Web interface/Storage
.. _interface/Storage: .. _interface/Storage:
@ -116,18 +117,18 @@ Provide settings to JovianDSS driver by adding 'jdss-0' description:
Multiple Pools Multiple Pools
~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~
In order to add another JovianDSS Pool, create a copy of In order to add another Open-E JovianDSS Pool, create a copy of
JovianDSS config in cinder.conf file. Open-E JovianDSS config in cinder.conf file.
For instance if you want to add ``Pool-1`` located on the same host as For instance if you want to add ``Pool-1`` located on the same host as
``Pool-0``. You extend ``cinder.conf`` file like: ``Pool-0``. You extend ``cinder.conf`` file like:
:: ::
enabled_backends = jdss-0, jdss-1 enabled_backends = open-e-jdss-0, open-e-jdss-1
[jdss-0] [open-e-jdss-0]
backend_name = jdss-0 backend_name = open-e-jdss-0
chap_password_len = 14 chap_password_len = 14
driver_use_ssl = True driver_use_ssl = True
driver_ssl_cert_verify = False driver_ssl_cert_verify = False
@ -142,8 +143,8 @@ For instance if you want to add ``Pool-1`` located on the same host as
san_password = admin san_password = admin
san_thin_provision = True san_thin_provision = True
[jdss-1] [open-e-jdss-1]
backend_name = jdss-1 backend_name = open-e-jdss-1
chap_password_len = 14 chap_password_len = 14
driver_use_ssl = True driver_use_ssl = True
driver_ssl_cert_verify = False driver_ssl_cert_verify = False
@ -162,7 +163,7 @@ For instance if you want to add ``Pool-1`` located on the same host as
HA Cluster HA Cluster
~~~~~~~~~~ ~~~~~~~~~~
To utilize High Availability feature of JovianDSS: To utilize High Availability feature of Open-E JovianDSS:
1. `Guide`_ on configuring Pool to high availability cluster 1. `Guide`_ on configuring Pool to high availability cluster
@ -175,8 +176,8 @@ and 192.168.31.100 the configuration file will look like:
:: ::
[jdss-2] [open-e-jdss-2]
backend_name = jdss-2 backend_name = open-e-jdss-2
chap_password_len = 14 chap_password_len = 14
driver_use_ssl = True driver_use_ssl = True
driver_ssl_cert_verify = False driver_ssl_cert_verify = False