pass
-def create(backing_device, name, userid, password):
+def create(backing_device, name, userid, password, initiator_iqns=None):
try:
rtsroot = rtslib.root.RTSRoot()
except rtslib.utils.RTSLibError:
acl_new.chap_userid = userid
acl_new.chap_password = password
- tpg_new.enable = 1
-
m = rtslib.MappedLUN(acl_new, lun_new.lun, lun_new.lun)
+ if initiator_iqns:
+ initiator_iqns = initiator_iqns.strip(' ')
+ for i in initiator_iqns.split(','):
+ acl_new = rtslib.NodeACL(tpg_new, i, mode='create')
+ acl_new.chap_userid = userid
+ acl_new.chap_password = password
+
+ m = rtslib.MappedLUN(acl_new, lun_new.lun, lun_new.lun)
+
+ tpg_new.enable = 1
+
try:
rtslib.NetworkPortal(tpg_new, '0.0.0.0', 3260, mode='any')
except rtslib.utils.RTSLibError:
def usage():
print "Usage:"
- print sys.argv[0], "create [device] [name] [userid] [password]"
+ print sys.argv[0], \
+ "create [device] [name] [userid] [password]", \
+ "<initiator_iqn,iqn2,iqn3,...>"
print sys.argv[0], "get-targets"
print sys.argv[0], "delete [iqn]"
print sys.argv[0], "verify"
if len(argv) < 6:
usage()
+ if len(argv) > 7:
+ usage()
+
backing_device = argv[2]
name = argv[3]
userid = argv[4]
password = argv[5]
+ initiator_iqns = None
+
+ if len(argv) > 6:
+ initiator_iqns = argv[6]
- create(backing_device, name, userid, password)
+ create(backing_device, name, userid, password, initiator_iqns)
elif argv[1] == 'get-targets':
get_targets()
'directory'),
cfg.StrOpt('iet_conf',
default='/etc/iet/ietd.conf',
- help='IET configuration file'), ]
+ help='IET configuration file'),
+ cfg.StrOpt('lio_initiator_iqns',
+ default='',
+ help=('Comma-separatd list of initiator IQNs '
+ 'allowed to connect to the '
+ 'iSCSI target. (From Nova compute nodes.)'
+ )
+ )
+ ]
FLAGS = flags.FLAGS
FLAGS.register_opts(iscsi_helper_opt)
if chap_auth != None:
(chap_auth_userid, chap_auth_password) = chap_auth.split(' ')[1:]
+ extra_args = []
+ if FLAGS.lio_initiator_iqns:
+ extra_args.append(FLAGS.lio_initiator_iqns)
+
try:
- self._execute('cinder-rtstool',
- 'create',
- path,
- name,
- chap_auth_userid,
- chap_auth_password,
- run_as_root=True)
+ command_args = ['cinder-rtstool',
+ 'create',
+ path,
+ name,
+ chap_auth_userid,
+ chap_auth_password]
+ if extra_args != []:
+ command_args += extra_args
+ self._execute(*command_args, run_as_root=True)
except exception.ProcessExecutionError as e:
LOG.error(_("Failed to create iscsi target for volume "
"id:%(vol_id)s.") % locals())