Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def list_user_group(args):
obj = Authentication(args.ip, args.port)
try:
uris = obj.list_user_group()
output = []
for uri in uris:
if(obj.show_user_group_by_uri(uri['id'])):
output.append(
obj.show_user_group_by_uri(uri['id']))
if(len(output) > 0):
if(args.verbose):
return common.format_json_object(output)
else:
from common import TableGenerator
TableGenerator(output, ['name', 'domain', 'attributes']).printTable()
except SOSError as e:
if(e.err_code == SOSError.NOT_FOUND_ERR):
raise SOSError(SOSError.NOT_FOUND_ERR,
"User Group list failed: " + e.err_text)
else:
raise e
def volume_mirror_protect_show(args):
obj = Volume(args.ip, args.port)
try:
if(not args.tenant):
args.tenant=""
res = obj.mirror_protection_show(args.tenant + "/" + args.project + "/" + args.name,
args.mirrorvol)
return common.format_json_object(res)
except SOSError as e:
raise e
def san_fabrics_list(args):
obj = SanFabrics(args.ip, args.port)
try:
uris = obj.san_fabrics_list(args.name)
output = []
for uri in uris:
param = {'fabricname': uri}
output.append(param)
if(len(output) > 0):
if(args.verbose):
return common.format_json_object(output)
elif(args.long):
TableGenerator(
output,
['fabricname']).printTable()
else:
TableGenerator(output, ['fabricname']).printTable()
except SOSError as e:
common.format_err_msg_and_raise(
"list",
"sanfabrics",
e.err_text,
e.err_code)
def meter_get_status(args):
obj = Meter(args.ip, args.port)
try:
time_frame = common.get_formatted_time_string(args.year,
args.month, args.day,
args.hour, args.minute)
res = obj.get_stats(args.format, time_frame)
if (args.format == "json"):
return common.format_json_object(res)
return res
except ValueError as e:
raise SOSError(SOSError.CMD_LINE_ERR, "error: " + str(e))
except SOSError as e:
if (e.err_code == SOSError.SOS_FAILURE_ERR):
raise SOSError(SOSError.SOS_FAILURE_ERR,
"Unable to get requested usage statistics")
else:
raise e
def ps_list(args):
obj = ProtectionSystem(args.ip, args.port)
try:
output = []
uris = obj.ps_list()
if(len(uris) > 0):
for item in obj.ps_list_by_hrefs(uris):
output.append(item)
if(args.verbose == True):
return common.format_json_object(output)
if(len(output) > 0):
if(args.long == True):
from common import TableGenerator
TableGenerator(output, ['name', 'system_type',
'ip_address',
'port_number',
'installation_id',
'job_discovery_status']).printTable()
else:
from common import TableGenerator
TableGenerator(output, ['name', 'system_type',
'ip_address',
'port_number']).printTable()
except SOSError as e:
def get_diagnostics(args):
obj = Monitoring(args.ip, Monitoring.DEFAULT_SYSMGR_PORT)
try:
return common.format_json_object(obj.get_diagnostics(args.node, args.verbose))
except SOSError as e:
common.format_err_msg_and_raise("get", "diagnostics", e.err_text, e.err_code)
def login_failed_ip_list(args):
obj = LoginFailedIP(args.ip, args.port)
try:
res = obj.login_failed_ip_list()
return common.format_json_object(res)
except SOSError as e:
if(e.err_code == SOSError.NOT_FOUND_ERR):
raise SOSError(SOSError.NOT_FOUND_ERR,
"login-failed-ip list failed: " + e.err_text)
else:
raise e
def get_project_acl(args):
obj = Project(args.ip, args.port)
try:
if(not args.tenant):
args.tenant=""
res = obj.get_acl(args.tenant + "/" + args.name)
if(res):
return common.format_json_object(res)
except SOSError as e:
raise e
def cluster_ipreconfig(args):
obj = Monitoring(args.ip, Monitoring.DEFAULT_SYSMGR_PORT)
try:
return common.format_json_object(obj.cluster_ipreconfig(args))
except SOSError as e:
common.format_err_msg_and_raise(
"cluster",
"ipreconfig",
e.err_text,
e.err_code)
def ps_connectivity(args):
obj = ProtectionSystem(args.ip, args.port)
try:
res = obj.ps_connectivity(args.name)
return common.format_json_object(res)
# return "Protection system " + args.name + " of type " + args.type + ":
# Deleted"
except SOSError as e:
if (e.err_code == SOSError.SOS_FAILURE_ERR):
raise SOSError(SOSError.SOS_FAILURE_ERR,
"Protection system " +
": connectivity failed\n" +
e.err_text)
else:
common.format_err_msg_and_raise("connectivity",
"protectionsystem",
e.err_text, e.err_code)