2018-05-14 23:24:19 +00:00
|
|
|
def set_iscsi_options(client, args):
|
|
|
|
params = {}
|
|
|
|
|
|
|
|
if args.auth_file:
|
|
|
|
params['auth_file'] = args.auth_file
|
|
|
|
if args.node_base:
|
|
|
|
params['node_base'] = args.node_base
|
|
|
|
if args.nop_timeout:
|
|
|
|
params['nop_timeout'] = args.nop_timeout
|
|
|
|
if args.nop_in_interval:
|
|
|
|
params['nop_in_interval'] = args.nop_in_interval
|
|
|
|
if args.no_discovery_auth:
|
|
|
|
params['no_discovery_auth'] = args.no_discovery_auth
|
|
|
|
if args.req_discovery_auth:
|
|
|
|
params['req_discovery_auth'] = args.req_discovery_auth
|
|
|
|
if args.req_discovery_auth_mutual:
|
|
|
|
params['req_discovery_auth_mutual'] = args.req_discovery_auth_mutual
|
|
|
|
if args.discovery_auth_group:
|
|
|
|
params['discovery_auth_group'] = args.discovery_auth_group
|
|
|
|
if args.max_sessions:
|
|
|
|
params['max_sessions'] = args.max_sessions
|
|
|
|
if args.max_connections_per_session:
|
|
|
|
params['max_connections_per_session'] = args.max_connections_per_session
|
|
|
|
if args.default_time2wait:
|
|
|
|
params['default_time2wait'] = args.default_time2wait
|
|
|
|
if args.default_time2retain:
|
|
|
|
params['default_time2retain'] = args.default_time2retain
|
|
|
|
if args.immediate_data:
|
|
|
|
params['immediate_data'] = args.immediate_data
|
|
|
|
if args.error_recovery_level:
|
|
|
|
params['error_recovery_level'] = args.error_recovery_level
|
|
|
|
if args.allow_duplicated_isid:
|
|
|
|
params['allow_duplicated_isid'] = args.allow_duplicated_isid
|
|
|
|
if args.min_connections_per_session:
|
|
|
|
params['min_connections_per_session'] = args.min_connections_per_session
|
|
|
|
return client.call('set_iscsi_options', params)
|
|
|
|
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
def get_portal_groups(client, args):
|
|
|
|
return client.call('get_portal_groups')
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
def get_initiator_groups(client, args):
|
|
|
|
return client.call('get_initiator_groups')
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
def get_target_nodes(client, args):
|
|
|
|
return client.call('get_target_nodes')
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
def construct_target_node(client, args):
|
2018-02-18 23:41:48 +00:00
|
|
|
luns = []
|
|
|
|
for u in args.bdev_name_id_pairs.strip().split(" "):
|
|
|
|
bdev_name, lun_id = u.split(":")
|
|
|
|
luns.append({"bdev_name": bdev_name, "lun_id": int(lun_id)})
|
2017-06-06 21:22:03 +00:00
|
|
|
|
2018-02-18 23:22:22 +00:00
|
|
|
pg_ig_maps = []
|
2017-06-06 21:22:03 +00:00
|
|
|
for u in args.pg_ig_mappings.strip().split(" "):
|
|
|
|
pg, ig = u.split(":")
|
2018-02-18 23:22:22 +00:00
|
|
|
pg_ig_maps.append({"pg_tag": int(pg), "ig_tag": int(ig)})
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
params = {
|
|
|
|
'name': args.name,
|
|
|
|
'alias_name': args.alias_name,
|
2018-02-18 23:22:22 +00:00
|
|
|
'pg_ig_maps': pg_ig_maps,
|
2018-02-18 23:41:48 +00:00
|
|
|
'luns': luns,
|
2017-06-06 21:22:03 +00:00
|
|
|
'queue_depth': args.queue_depth,
|
|
|
|
}
|
|
|
|
|
2018-02-21 17:51:16 +00:00
|
|
|
if args.chap_group:
|
|
|
|
params['chap_group'] = args.chap_group
|
|
|
|
if args.disable_chap:
|
|
|
|
params['disable_chap'] = args.disable_chap
|
|
|
|
if args.require_chap:
|
|
|
|
params['require_chap'] = args.require_chap
|
|
|
|
if args.mutual_chap:
|
|
|
|
params['mutual_chap'] = args.mutual_chap
|
2017-06-06 21:22:03 +00:00
|
|
|
if args.header_digest:
|
|
|
|
params['header_digest'] = args.header_digest
|
|
|
|
if args.data_digest:
|
|
|
|
params['data_digest'] = args.data_digest
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('construct_target_node', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
def target_node_add_lun(client, args):
|
2017-06-06 21:22:03 +00:00
|
|
|
params = {
|
|
|
|
'name': args.name,
|
|
|
|
'bdev_name': args.bdev_name,
|
|
|
|
}
|
|
|
|
if args.lun_id:
|
|
|
|
params['lun_id'] = args.lun_id
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('target_node_add_lun', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
def delete_pg_ig_maps(client, args):
|
2018-02-18 23:22:22 +00:00
|
|
|
pg_ig_maps = []
|
2017-06-06 21:22:03 +00:00
|
|
|
for u in args.pg_ig_mappings.strip().split(" "):
|
|
|
|
pg, ig = u.split(":")
|
2018-02-18 23:22:22 +00:00
|
|
|
pg_ig_maps.append({"pg_tag": int(pg), "ig_tag": int(ig)})
|
2017-06-06 21:22:03 +00:00
|
|
|
params = {
|
|
|
|
'name': args.name,
|
2018-02-18 23:22:22 +00:00
|
|
|
'pg_ig_maps': pg_ig_maps,
|
2017-06-06 21:22:03 +00:00
|
|
|
}
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('delete_pg_ig_maps', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
def add_pg_ig_maps(client, args):
|
2018-02-18 23:22:22 +00:00
|
|
|
pg_ig_maps = []
|
2017-06-06 21:22:03 +00:00
|
|
|
for u in args.pg_ig_mappings.strip().split(" "):
|
|
|
|
pg, ig = u.split(":")
|
2018-02-18 23:22:22 +00:00
|
|
|
pg_ig_maps.append({"pg_tag": int(pg), "ig_tag": int(ig)})
|
2017-06-06 21:22:03 +00:00
|
|
|
params = {
|
|
|
|
'name': args.name,
|
2018-02-18 23:22:22 +00:00
|
|
|
'pg_ig_maps': pg_ig_maps,
|
2017-06-06 21:22:03 +00:00
|
|
|
}
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('add_pg_ig_maps', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
def add_portal_group(client, args):
|
2017-06-06 21:22:03 +00:00
|
|
|
# parse out portal list host1:port1 host2:port2
|
|
|
|
portals = []
|
|
|
|
for p in args.portal_list:
|
|
|
|
ip, separator, port_cpumask = p.rpartition(':')
|
|
|
|
split_port_cpumask = port_cpumask.split('@')
|
|
|
|
if len(split_port_cpumask) == 1:
|
|
|
|
port = port_cpumask
|
|
|
|
portals.append({'host': ip, 'port': port})
|
|
|
|
else:
|
|
|
|
port = split_port_cpumask[0]
|
|
|
|
cpumask = split_port_cpumask[1]
|
|
|
|
portals.append({'host': ip, 'port': port, 'cpumask': cpumask})
|
|
|
|
|
|
|
|
params = {'tag': args.tag, 'portals': portals}
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('add_portal_group', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
def add_initiator_group(client, args):
|
2017-06-06 21:22:03 +00:00
|
|
|
initiators = []
|
|
|
|
netmasks = []
|
|
|
|
for i in args.initiator_list.strip().split(' '):
|
|
|
|
initiators.append(i)
|
|
|
|
for n in args.netmask_list.strip().split(' '):
|
|
|
|
netmasks.append(n)
|
|
|
|
|
|
|
|
params = {'tag': args.tag, 'initiators': initiators, 'netmasks': netmasks}
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('add_initiator_group', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
def add_initiators_to_initiator_group(client, args):
|
2018-02-06 23:22:00 +00:00
|
|
|
initiators = []
|
|
|
|
netmasks = []
|
|
|
|
if args.initiator_list:
|
|
|
|
for i in args.initiator_list.strip().split(' '):
|
|
|
|
initiators.append(i)
|
|
|
|
if args.netmask_list:
|
|
|
|
for n in args.netmask_list.strip().split(' '):
|
|
|
|
netmasks.append(n)
|
|
|
|
|
|
|
|
params = {'tag': args.tag, 'initiators': initiators, 'netmasks': netmasks}
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('add_initiators_to_initiator_group', params)
|
2018-02-06 23:22:00 +00:00
|
|
|
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
def delete_initiators_from_initiator_group(client, args):
|
2018-02-06 23:22:00 +00:00
|
|
|
initiators = []
|
|
|
|
netmasks = []
|
|
|
|
if args.initiator_list:
|
|
|
|
for i in args.initiator_list.strip().split(' '):
|
|
|
|
initiators.append(i)
|
|
|
|
if args.netmask_list:
|
|
|
|
for n in args.netmask_list.strip().split(' '):
|
|
|
|
netmasks.append(n)
|
|
|
|
|
|
|
|
params = {'tag': args.tag, 'initiators': initiators, 'netmasks': netmasks}
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('delete_initiators_from_initiator_group', params)
|
2018-02-06 23:22:00 +00:00
|
|
|
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
def delete_target_node(client, args):
|
2017-06-06 21:22:03 +00:00
|
|
|
params = {'name': args.target_node_name}
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('delete_target_node', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
def delete_portal_group(client, args):
|
2017-06-06 21:22:03 +00:00
|
|
|
params = {'tag': args.tag}
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('delete_portal_group', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
def delete_initiator_group(client, args):
|
2017-06-06 21:22:03 +00:00
|
|
|
params = {'tag': args.tag}
|
2018-03-27 21:31:52 +00:00
|
|
|
return client.call('delete_initiator_group', params)
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
def get_iscsi_connections(client, args):
|
|
|
|
return client.call('get_iscsi_connections')
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
def get_iscsi_global_params(client, args):
|
|
|
|
return client.call('get_iscsi_global_params')
|
2017-06-06 21:22:03 +00:00
|
|
|
|
|
|
|
|
2018-03-27 21:31:52 +00:00
|
|
|
def get_scsi_devices(client, args):
|
|
|
|
return client.call('get_scsi_devices')
|