Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from common import TableGenerator
TableGenerator(output, ['pool_name', 'registration_status',
'free', 'used',
'vpool_set',
'tagged_varrays',
'storage_tiers']).printTable()
else:
from common import TableGenerator
TableGenerator(output, ['pool_name',
'registration_status',
'free', 'used']).printTable()
except SOSError as e:
if(e.err_code == SOSError.NOT_FOUND_ERR):
raise SOSError(SOSError.NOT_FOUND_ERR,
"Storagepool list failed: "
+ e.err_text)
else:
raise e
if (common.is_uri(name)):
return name
(pname, label) = common.get_parent_child_from_xpath(name)
if(not pname):
raise SOSError(SOSError.NOT_FOUND_ERR,
"Project name not specified")
proj = Project(self.__ipAddr, self.__port)
puri = proj.project_query(pname)
puri = puri.strip()
uris = self.search_fileshares(puri)
for uri in uris:
fileshare = self.show_by_uri(uri)
if (fileshare and fileshare['name'] == label):
return fileshare['id']
raise SOSError(SOSError.NOT_FOUND_ERR,
"Filesystem " + label + ": not found")
def objectcos_add(self, name, description ):
objcoslst = self.objectcos_list()
for cs in objcoslst:
if(cs['name'] == name):
raise SOSError(SOSError.ENTRY_ALREADY_EXISTS_ERR,
"Objectcos create failed: object cos with same name already exists")
parms = dict()
if (name):
parms['name'] = name
if (description):
parms['description'] = description
body = None
if (parms):
body = json.dumps(parms)
(s, h) = common.service_json_request(self.__ipAddr, common.OBJCTRL_PORT , "POST",
self.URI_OBJ_COS.format('object') , body)
def vpool_delete(args):
obj = VirtualPool(args.ip, args.port)
try:
obj.vpool_delete(args.name, args.type)
# return "VPOOL " + 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, "VPOOL " + args.name +
" ("+ args.type + ") " + ": Delete failed\n" + e.err_text)
else:
raise e
def objectcos_query(self, name):
if (common.is_uri(name)):
return name
objcoslst = self.objectcos_list()
for cs in objcoslst:
cos_res = self.objectcos_show_by_uri(cs['id'])
if (cos_res['name'] == name):
return cos_res['id']
raise SOSError(SOSError.NOT_FOUND_ERR,
"Object Cos query failed: object cos with name "+name+" not found")
def snapshot_create(args):
if not args.sync and args.synctimeout !=0:
raise SOSError(SOSError.CMD_LINE_ERR,"error: Cannot use synctimeout without Sync ")
obj = Snapshot(args.ip, args.port)
try:
(storageresType, storageresTypename) = obj.get_storageAttributes(
args.filesystem, args.volume, args.consistencygroup)
if(storageresType == Snapshot.FILE and args.inactive is True):
raise SOSError(
SOSError.CMD_LINE_ERR,
"-inactive option is used for block type only")
if(args.consistencygroup and args.type):
raise SOSError(
SOSError.CMD_LINE_ERR,
' Parameter -type is not applicable ' +
'for consistency group snapshot')
resourceUri = obj.storageResource_query(
storageresType,
args.filesystem,
def computevpool_query(self, name):
'''
Returns the UID of the computesystem specified by the name
'''
computevpools = self.computevpool_list()
for computevpool in computevpools:
if (computevpool['name'] == name):
return computevpool['id']
raise SOSError(SOSError.NOT_FOUND_ERR,
"computevpool " + name + ": not found")
return
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
'''contrlparms = storpool['controller_params']
for item in contrlparms:
if(item['name'] == 'NativeId'):
compval = item['value']'''
if(poolName == compval):
found = True
res = self.storagepool_register(systemuri, pooluri)
else:
res = self.storagepool_register(systemuri, pooluri)
# Print error if named pool is not found
if (not (found)):
raise SOSError(SOSError.NOT_FOUND_ERR,
"Storagepool with name " +poolName+" not found\n")
return name
(tenant_name, project_name) = common.get_parent_child_from_xpath(name)
from tenant import Tenant
tenant_obj = Tenant(self.__ipAddr, self.__port)
try:
tenant_uri = tenant_obj.tenant_query(tenant_name)
projects = self.project_list(tenant_uri)
if(projects and len(projects) > 0):
for project in projects:
if (project):
project_detail = self.project_show_by_uri(project['id'])
if(project_detail and project_detail['name'] == project_name):
return project_detail['id']
raise SOSError(SOSError.NOT_FOUND_ERR, 'Project: ' + project_name + ' not found')
except SOSError as e:
raise e