self.verify_cmds(cmds)
def run_commands(self):
- tgtadm = self.driver.get_target_admin()
- tgtadm.set_execute(self.fake_execute)
- tgtadm.create_iscsi_target(self.target_name, self.tid,
- self.lun, self.path)
- tgtadm.show_target(self.tid, iqn=self.target_name)
- tgtadm.remove_iscsi_target(self.tid, self.lun, self.vol_id,
- self.vol_name)
+ target_helper = self.driver.get_target_helper()
+ target_helper.set_execute(self.fake_execute)
+ target_helper.create_iscsi_target(self.target_name, self.tid,
+ self.lun, self.path)
+ target_helper.show_target(self.tid, iqn=self.target_name)
+ target_helper.remove_iscsi_target(self.tid, self.lun, self.vol_id,
+ self.vol_name)
def test_target_admin(self):
self.clear_cmds()
"""
if CONF.iscsi_helper == 'lioadm':
- self.tgtadm.initialize_connection(volume, connector)
+ self.target_helper.initialize_connection(volume, connector)
iscsi_properties = self._get_iscsi_properties(volume)
return {
data['QoS_support'] = False
self._stats = data
- def get_target_admin(self):
+ def get_target_helper(self):
root_helper = utils.get_root_helper()
if CONF.iscsi_helper == 'iseradm':
return iscsi.ISERTgtAdm(root_helper, CONF.volumes_dir,
data['QoS_support'] = False
self._stats = data
- def get_target_admin(self):
+ def get_target_helper(self):
root_helper = utils.get_root_helper()
if CONF.iser_helper == 'fake':
VERSION = '1.0.0'
def __init__(self, *args, **kwargs):
- self.tgtadm = self.get_target_admin()
+ self.target_helper = self.get_target_helper()
super(BlockDeviceDriver, self).__init__(*args, **kwargs)
self.configuration.append_config_values(volume_opts)
def set_execute(self, execute):
super(BlockDeviceDriver, self).set_execute(execute)
- self.tgtadm.set_execute(execute)
+ self.target_helper.set_execute(execute)
def check_for_setup_error(self):
pass
# TODO(jdg): In the future move all of the dependent stuff into the
# corresponding target admin class
- if not isinstance(self.tgtadm, iscsi.TgtAdm):
+ if not isinstance(self.target_helper, iscsi.TgtAdm):
lun = 0
self._ensure_iscsi_targets(context, volume['host'])
iscsi_target = self.db.volume_allocate_iscsi_target(context,
chap_password)
# NOTE(jdg): For TgtAdm case iscsi_name is the ONLY param we need
# should clean this all up at some point in the future
- tid = self.tgtadm.create_iscsi_target(iscsi_name,
- iscsi_target,
- 0,
- volume_path,
- chap_auth)
+ tid = self.target_helper.create_iscsi_target(iscsi_name,
+ iscsi_target,
+ 0,
+ volume_path,
+ chap_auth)
model_update['provider_location'] = self._iscsi_location(
self.configuration.iscsi_ip_address, tid, iscsi_name, lun,
volume_path)
# TODO(jdg): In the future move all of the dependent stuff into the
# corresponding target admin class
- if isinstance(self.tgtadm, iscsi.LioAdm):
+ if isinstance(self.target_helper, iscsi.LioAdm):
try:
iscsi_target = self.db.volume_get_iscsi_target_num(
context,
LOG.info(_("Skipping remove_export. No iscsi_target "
"provisioned for volume: %s"), volume['id'])
return
- self.tgtadm.remove_iscsi_target(iscsi_target, 0, volume['id'],
- volume['name'])
+ self.target_helper.remove_iscsi_target(iscsi_target,
+ 0,
+ volume['id'],
+ volume['name'])
return
- elif not isinstance(self.tgtadm, iscsi.TgtAdm):
+ elif not isinstance(self.target_helper, iscsi.TgtAdm):
try:
iscsi_target = self.db.volume_get_iscsi_target_num(
context,
iqn = location[1]
# ietadm show will exit with an error
# this export has already been removed
- self.tgtadm.show_target(iscsi_target, iqn=iqn)
+ self.target_helper.show_target(iscsi_target, iqn=iqn)
except Exception:
LOG.info(_("Skipping remove_export. No iscsi_target "
"is presently exported for volume: %s"), volume['id'])
return
- self.tgtadm.remove_iscsi_target(iscsi_target, 0, volume['id'],
- volume['name'])
+ self.target_helper.remove_iscsi_target(iscsi_target, 0, volume['id'],
+ volume['name'])
def ensure_export(self, context, volume):
"""Synchronously recreates an export for a logical volume.
# TODO(jdg): In the future move all of the dependent stuff into the
# corresponding target admin class
- if isinstance(self.tgtadm, iscsi.LioAdm):
+ if isinstance(self.target_helper, iscsi.LioAdm):
try:
volume_info = self.db.volume_get(context, volume['id'])
(auth_method,
volume['name'])
volume_path = self.local_path(volume)
iscsi_target = 1
- self.tgtadm.create_iscsi_target(iscsi_name, iscsi_target,
- 0, volume_path, chap_auth,
- check_exit_code=False)
+ self.target_helper.create_iscsi_target(iscsi_name, iscsi_target,
+ 0, volume_path, chap_auth,
+ check_exit_code=False)
return
- if not isinstance(self.tgtadm, iscsi.TgtAdm):
+ if not isinstance(self.target_helper, iscsi.TgtAdm):
try:
iscsi_target = self.db.volume_get_iscsi_target_num(
context,
# NOTE(jdg): For TgtAdm case iscsi_name is the ONLY param we need
# should clean this all up at some point in the future
- self.tgtadm.create_iscsi_target(iscsi_name, iscsi_target,
- 0, volume_path, chap_auth,
- check_exit_code=False,
- old_name=old_name)
+ self.target_helper.create_iscsi_target(iscsi_name, iscsi_target,
+ 0, volume_path, chap_auth,
+ check_exit_code=False,
+ old_name=old_name)
def _iscsi_location(self, ip, target, iqn, lun=None, device=None):
return "%s:%s,%s %s %s %s" % (ip, self.configuration.iscsi_port,
# NOTE(jdg): tgtadm doesn't use the iscsi_targets table
# TODO(jdg): In the future move all of the dependent stuff into the
# corresponding target admin class
- if not isinstance(self.tgtadm, iscsi.TgtAdm):
+ if not isinstance(self.target_helper, iscsi.TgtAdm):
host_iscsi_targets = self.db.iscsi_target_count_by_host(context,
host)
if host_iscsi_targets >= self.configuration.iscsi_num_targets:
"""
def __init__(self, *args, **kwargs):
- self.tgtadm = self.get_target_admin()
+ self.target_helper = self.get_target_helper()
super(LVMISCSIDriver, self).__init__(*args, **kwargs)
self.backend_name =\
self.configuration.safe_get('volume_backend_name') or 'LVM_iSCSI'
def set_execute(self, execute):
super(LVMISCSIDriver, self).set_execute(execute)
- self.tgtadm.set_execute(execute)
+ self.target_helper.set_execute(execute)
- def _create_tgtadm_target(self, iscsi_name, iscsi_target,
- volume_path, chap_auth, lun=0,
- check_exit_code=False, old_name=None):
+ def _create_target(self, iscsi_name, iscsi_target,
+ volume_path, chap_auth, lun=0,
+ check_exit_code=False, old_name=None):
# NOTE(jdg): tgt driver has an issue where with a lot of activity
# (or sometimes just randomly) it will get *confused* and attempt
# to reuse a target ID, resulting in a target already exists error
try:
# NOTE(jdg): For TgtAdm case iscsi_name is all we need
# should clean this all up at some point in the future
- tid = self.tgtadm.create_iscsi_target(
+ tid = self.target_helper.create_iscsi_target(
iscsi_name,
iscsi_target,
0,
# TODO(jdg): In the future move all of the dependent stuff into the
# corresponding target admin class
- if isinstance(self.tgtadm, iscsi.LioAdm):
+ if isinstance(self.target_helper, iscsi.LioAdm):
try:
volume_info = self.db.volume_get(context, volume['id'])
(auth_method,
volume['name'])
iscsi_target = 1
- self._create_tgtadm_target(iscsi_name, iscsi_target,
- volume_path, chap_auth)
+ self._create_target(iscsi_name, iscsi_target,
+ volume_path, chap_auth)
return
- if not isinstance(self.tgtadm, iscsi.TgtAdm):
+ if not isinstance(self.target_helper, iscsi.TgtAdm):
try:
iscsi_target = self.db.volume_get_iscsi_target_num(
context,
# NOTE(jdg): For TgtAdm case iscsi_name is the ONLY param we need
# should clean this all up at some point in the future
- self._create_tgtadm_target(iscsi_name, iscsi_target,
- volume_path, chap_auth,
- lun=0,
- check_exit_code=False,
- old_name=old_name)
+ self._create_target(iscsi_name, iscsi_target,
+ volume_path, chap_auth,
+ lun=0,
+ check_exit_code=False,
+ old_name=old_name)
return
# NOTE(jdg): tgtadm doesn't use the iscsi_targets table
# TODO(jdg): In the future move all of the dependent stuff into the
# corresponding target admin class
- if not isinstance(self.tgtadm, iscsi.TgtAdm):
+ if not isinstance(self.target_helper, iscsi.TgtAdm):
host_iscsi_targets = self.db.iscsi_target_count_by_host(context,
host)
if host_iscsi_targets >= self.configuration.iscsi_num_targets:
# TODO(jdg): In the future move all of the dependent stuff into the
# corresponding target admin class
- if not isinstance(self.tgtadm, iscsi.TgtAdm):
+ if not isinstance(self.target_helper, iscsi.TgtAdm):
lun = 0
self._ensure_iscsi_targets(context, volume['host'])
iscsi_target = self.db.volume_allocate_iscsi_target(context,
chap_auth = self._iscsi_authentication('IncomingUser', chap_username,
chap_password)
- tid = self._create_tgtadm_target(iscsi_name, iscsi_target,
- volume_path, chap_auth)
+ tid = self._create_target(iscsi_name, iscsi_target,
+ volume_path, chap_auth)
model_update['provider_location'] = self._iscsi_location(
self.configuration.iscsi_ip_address, tid, iscsi_name, lun)
# TODO(jdg): In the future move all of the dependent stuff into the
# corresponding target admin class
- if isinstance(self.tgtadm, iscsi.LioAdm):
+ if isinstance(self.target_helper, iscsi.LioAdm):
try:
iscsi_target = self.db.volume_get_iscsi_target_num(
context,
"provisioned for volume: %s"), volume['id'])
return
- self.tgtadm.remove_iscsi_target(iscsi_target, 0, volume['id'],
- volume['name'])
+ self.target_helper.remove_iscsi_target(iscsi_target,
+ 0,
+ volume['id'],
+ volume['name'])
return
- elif not isinstance(self.tgtadm, iscsi.TgtAdm):
+ elif not isinstance(self.target_helper, iscsi.TgtAdm):
try:
iscsi_target = self.db.volume_get_iscsi_target_num(
context,
# ietadm show will exit with an error
# this export has already been removed
- self.tgtadm.show_target(iscsi_target, iqn=iqn)
+ self.target_helper.show_target(iscsi_target, iqn=iqn)
except Exception:
LOG.info(_("Skipping remove_export. No iscsi_target "
"is presently exported for volume: %s"), volume['id'])
return
- self.tgtadm.remove_iscsi_target(iscsi_target, 0, volume['name_id'],
- volume['name'])
+ self.target_helper.remove_iscsi_target(iscsi_target,
+ 0,
+ volume['name_id'],
+ volume['name'])
def migrate_volume(self, ctxt, volume, host, thin=False, mirror_count=0):
"""Optimize the migration if the destination is on the same server.
"""
def __init__(self, *args, **kwargs):
- self.tgtadm = self.get_target_admin()
+ self.target_helper = self.get_target_helper()
LVMVolumeDriver.__init__(self, *args, **kwargs)
self.backend_name =\
self.configuration.safe_get('volume_backend_name') or 'LVM_iSER'