'ietadm --op new --tid=%(tid)s --lun=%(lun)s '
'--params Path=%(path)s,Type=fileio',
'ietadm --op show --tid=%(tid)s',
- 'ietadm --op delete --tid=%(tid)s',
- 'ietadm --op delete --tid=%(tid)s --lun=%(lun)s'])
+ 'ietadm --op delete --tid=%(tid)s --lun=%(lun)s',
+ 'ietadm --op delete --tid=%(tid)s'])
LOG.exception(msg, **kwargs)
self._rollback()
+
+
+def ensure_tree(path):
+ """Create a directory (and any ancestor directories required)
+
+ :param path: Directory to create
+ """
+ try:
+ os.makedirs(path)
+ except OSError as exc:
+ if exc.errno == errno.EEXIST:
+ if not os.path.isdir(path):
+ raise
+ else:
+ raise
# Note(jdg) tid and lun aren't used by TgtAdm but remain for
# compatibility
- if not os.path.exists(FLAGS.volumes_dir):
- os.makedirs(FLAGS.volumes_dir)
+ utils.ensure_tree(FLAGS.volumes_dir)
vol_id = name.split(':')[1]
volume_conf = """
def remove_iscsi_target(self, tid, lun, vol_id, **kwargs):
LOG.info(_('Removing volume: %s') % vol_id)
- self._delete_target(tid, **kwargs)
self._delete_logicalunit(tid, lun, **kwargs)
+ self._delete_target(tid, **kwargs)
def _new_target(self, name, tid, **kwargs):
self._run('--op', 'new',