# by creating the entry in the persist file
# and then doing an update to get the target
# created.
- self.update_iscsi_target(name)
+ (out, err) = self._execute('tgt-admin', '--update', name,
+ run_as_root=True)
+ LOG.debug("StdOut from tgt-admin --update: %s", out)
+ LOG.debug("StdErr from tgt-admin --update: %s", err)
# Grab targets list for debug
# Consider adding a check for lun 0 and 1 for tgtadm
'target',
run_as_root=True)
LOG.debug("Targets after update: %s" % out)
- except (putils.ProcessExecutionError,
- exception.ISCSITargetUpdateFailed) as e:
+ except putils.ProcessExecutionError as e:
LOG.warning(_("Failed to create iscsi target for volume "
"id:%(vol_id)s: %(e)s")
% {'vol_id': vol_id, 'e': str(e)})
return tid
- def update_iscsi_target(self, name):
-
- LOG.info(_('Updating iscsi target: %s') % name)
-
- try:
- (out, err) = self._execute('tgt-admin', '--update', name,
- run_as_root=True)
- except putils.ProcessExecutionError as e:
- LOG.error(_("Failed to update iscsi target %(name)s: %(e)s") %
- {'name': name, 'e': str(e)})
- LOG.error("StdOut from tgt-admin --update: %s", e.stdout)
- LOG.error("StdErr from tgt-admin --update: %s", e.stderr)
- raise exception.ISCSITargetUpdateFailed(name=name)
-
def remove_iscsi_target(self, tid, lun, vol_id, vol_name, **kwargs):
LOG.info(_('Removing iscsi_target for: %s') % vol_id)
vol_uuid_file = vol_name
self.tid += 1
return self.tid
- def update_iscsi_target(self, name):
- return
-
class LioAdm(TargetAdmin):
"""iSCSI target administration for LIO using python-rtslib."""
def _iscsi_authentication(self, chap, name, password):
return "%s %s %s" % (chap, name, password)
- def initialize_connection(self, volume, connector):
- """Initializes the connection and returns connection info.
-
- This function overrides the base class implementation so that the iSCSI
- target can be updated. This is necessary in the event that a user
- extended the volume before attachement.
- """
-
- # update the iSCSI target
- iscsi_name = "%s%s" % (self.configuration.iscsi_target_prefix,
- volume['name'])
- try:
- self.tgtadm.update_iscsi_target(iscsi_name)
- except brick_exception.ISCSITargetUpdateFailed as e:
- msg = (_('Failed to initialize iscsi '
- 'connection for target: %s.') % iscsi_name)
- LOG.error(msg)
- raise exception.VolumeBackendAPIException(data=msg)
-
- # continue with the base class behaviour
- return driver.ISCSIDriver.initialize_connection(self,
- volume,
- connector)
-
class LVMISERDriver(LVMISCSIDriver, driver.ISERDriver):
"""Executes commands relating to ISER volumes.