def key_write(self, key, filepath, keypool, tenant, apitype, uid, secret, type): ''' write a key parameters: key: key keypool: keypool tenant: tenant name value: value apitype: api to be used uid: user id secret: secret Returns: JSON payload response ''' if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) if (apitype == 's3'): s3_key_write(namespace, keypool, key, filepath, uid, secret) elif (apitype == 'swift'): swift_object_write(namespace, keypool, key, filepath, uid, secret) elif (apitype == 'atmos'): atmos_object_write(namespace, keypool, key, filepath, uid, secret, type) else: raise SOSError(SOSError.VALUE_ERR, "Wrong API type " + apitype + " specified")
def key_list_versions(self, keypool, key, tenant, apitype, uid, secret): ''' Returns versions of the key` Parameters: key: label of the key keypool: label of the keypool project: project name tenant: tenant name apitype: api to be used uid: user id secret: secret Returns: JSON payload of key list ''' if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) if(apitype == 's3'): s3_key_list_versions(namespace, keypool, key, uid, secret ) elif ( (apitype =='swift') or (apitype=='atmos')) : raise SOSError(SOSError.NOT_FOUND_ERR, "Versioning not available with API type " + apitype) else: raise SOSError(SOSError.VALUE_ERR, "Wroing API type " + apitype + " specified")
def key_delete(self, key, keypool, tenant, apitype, version, uid, secret): ''' Makes a REST API call to delete a key by its name Parameters: key: label of the key keypool: label of the keypool project: project name tenant: tenant name apitype: api to be used uid: user id secret: secret Returns: JSON payload of key list ''' if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) if (apitype == 's3'): s3_key_delete(namespace, keypool, key, version, uid, secret) elif (apitype == 'swift'): swift_object_delete(namespace, keypool, key, version, uid, secret) elif (apitype == 'atmos'): atmos_object_delete(namespace, keypool, key, uid, secret) else: raise SOSError(SOSError.VALUE_ERR, "Wrong API type " + apitype + " specified")
def keypool_update( self, keypool, tenant, versioning, apitype, uid, secret): ''' update keypool versioning parameters: keypool: label of the keypool project: project name tenant: tenant name uid: user id secret: secret key Returns: JSON payload response ''' if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) try: if(apitype == 's3'): return s3_bucket_update( namespace, keypool, versioning, uid, secretkey) else: raise SOSError(SOSError.VALUE_ERR, "Wrong API type " + apitype + " specified") except SOSError as e: raise e
def key_list_versions(self, keypool, key, tenant, apitype, uid, secret): ''' Returns versions of the key` Parameters: key: label of the key keypool: label of the keypool project: project name tenant: tenant name apitype: api to be used uid: user id secret: secret Returns: JSON payload of key list ''' if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) if (apitype == 's3'): s3_key_list_versions(namespace, keypool, key, uid, secret) elif ((apitype == 'swift') or (apitype == 'atmos')): raise SOSError( SOSError.NOT_FOUND_ERR, "Versioning not available with API type " + apitype) else: raise SOSError(SOSError.VALUE_ERR, "Wroing API type " + apitype + " specified")
def key_delete(self, key, keypool, tenant, apitype, version, uid, secret): ''' Makes a REST API call to delete a key by its name Parameters: key: label of the key keypool: label of the keypool project: project name tenant: tenant name apitype: api to be used uid: user id secret: secret Returns: JSON payload of key list ''' if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) if(apitype == 's3'): s3_key_delete(namespace, keypool, key, version, uid, secret ) elif(apitype == 'swift'): swift_object_delete(namespace, keypool, key, version, uid, secret ) elif(apitype == 'atmos'): atmos_object_delete(namespace, keypool, key, uid, secret ) else: raise SOSError(SOSError.VALUE_ERR, "Wrong API type " + apitype + " specified")
def keypool_show(self, keypool, tenant, uid, secret): ''' show keypool parameters: keypool: label of the keypool tenant: tenant name uid: user id secret: secret key Returns: JSON payload response ''' #uri = self.keypool_query(label) if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) try: if(apitype == 's3'): return s3_bucket_show(namespace, keypool, uid, secretkey) elif(apitype == 'swift'): return swift_container_show(namespace, keypool, uid, secretkey) elif(apitype == 'atmos'): return atmos_subtenant_show(namespace, keypool, uid, secretkey) else: raise SOSError(SOSError.VALUE_ERR, "Wrong API type " + apitype + " specified") except SOSError as e: raise e
def keypool_delete(self, keypool, tenant, uid, secret): '''Makes a REST API call to delete a keypool by its name, project and tenant ''' if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) try: if(apitype == 's3'): return s3_bucket_delete(namespace, keypool, uid, secretkey) elif(apitype == 'swift'): return swift_container_delete(namespace, keypool, uid, secretkey) elif(apitype == 'atmos'): return atmos_subtenant_delete(namespace, keypool, uid, secretkey) else: raise SOSError(SOSError.VALUE_ERR, "Wrong API type " + apitype + " specified") except SOSError as e: raise e
def keypool_show(self, keypool, tenant, uid, secret): ''' show keypool parameters: keypool: label of the keypool tenant: tenant name uid: user id secret: secret key Returns: JSON payload response ''' #uri = self.keypool_query(label) if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) try: if (apitype == 's3'): return s3_bucket_show(namespace, keypool, uid, secretkey) elif (apitype == 'swift'): return swift_container_show(namespace, keypool, uid, secretkey) elif (apitype == 'atmos'): return atmos_subtenant_show(namespace, keypool, uid, secretkey) else: raise SOSError(SOSError.VALUE_ERR, "Wrong API type " + apitype + " specified") except SOSError as e: raise e
def keypool_update(self, keypool, tenant, versioning, apitype, uid, secret): ''' update keypool versioning parameters: keypool: label of the keypool project: project name tenant: tenant name uid: user id secret: secret key Returns: JSON payload response ''' if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) try: if (apitype == 's3'): return s3_bucket_update(namespace, keypool, versioning, uid, secretkey) else: raise SOSError(SOSError.VALUE_ERR, "Wrong API type " + apitype + " specified") except SOSError as e: raise e
def keypool_create(self, keypool, projectname, tenant, vpoolname, apitype, uid, secret): ''' creates a keypool parameters: keypool: label of the keypool project: project name tenant: tenant name vpool: vpool name apitype: api type(s3, swift or atmos) uid: user id secret: secret key Returns: JSON payload response ''' errorcontext = 0 if ((projectname) and (not common.is_uri(projectname))): from project import Project obj = Project(self.__ipAddr, self.__port) projectlst = obj.project_list(tenant) project_uri = None for projiter in projectlst: if (projiter['name'] == projectname): project_uri = projiter['id'] if (not project_uri): raise SOSError(SOSError.VALUE_ERR, "Porject " + projectname + ": not found") if ((vpoolname) and (not common.is_uri(vpoolname))): from virtualpool import VirtualPool obj = VirtualPool(self.__ipAddr, self.__port) vpool = obj.vpool_show(vpoolname, 'object') vpool_uri = vpool['id'] if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) try: if (apitype == 's3'): return s3_bucket_create(namespace, keypool, project_uri, vpool_uri, uid, secretkey) elif (apitype == 'swift'): return swift_container_create(namespace, keypool, project_uri, vpool_uri, uid, secretkey) elif (apitype == 'atmos'): return atmos_subtenant_create(namespace, tenant, keypool, project_uri, vpool_uri, uid, secretkey) else: raise SOSError(SOSError.VALUE_ERR, "Wrong API type " + apitype + " specified") except SOSError as e: raise e
def key_write(self, key, filepath , keypool, tenant, apitype, uid, secret, type): ''' write a key parameters: key: key keypool: keypool tenant: tenant name value: value apitype: api to be used uid: user id secret: secret Returns: JSON payload response ''' if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) if(apitype == 's3'): s3_key_write(namespace, keypool, key, filepath, uid, secret ) elif(apitype == 'swift'): swift_object_write(namespace, keypool, key, filepath, uid, secret ) elif(apitype == 'atmos'): atmos_object_write(namespace, keypool, key, filepath, uid, secret, type ) else: raise SOSError(SOSError.VALUE_ERR, "Wrong API type " + apitype + " specified")
def keypool_list(self, projectname, tenant, apitype, uid, secret): ''' Returns all the keypools in a vdc Parameters: keypool: label of the keypool project: project name tenant: tenant name apitype: api type(s3, swift or atmos) uid: user id secret: secret key Returns: JSON payload of keypool list ''' if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) kplst = [] try: if((not apitype) or (apitype == 's3')): kplst.append( s3_bucket_list( namespace, projectname, uid, secretkey)) if((not apitype) or (apitype == 'swift')): kplst.append( swift_container_list( namespace, projectname, uid, secretkey)) if((not apitype) or (apitype == 'atmos')): kplst.append( atmos_subtenant_list( namespace, projectname, uid, secretkey)) # need to convert to table format return kplst except SOSError as e: raise e
def key_read(self, key, keypool, tenant, apitype, version, filepath , uid, secret, type ): ''' Makes a REST API call to retrieve details of a key based on its key, keypool, apitype,uid, secret ''' if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) if(apitype == 's3'): return s3_key_read(namespace, keypool, key, version, filepath, uid, secret ) elif(apitype == 'swift'): return swift_object_read(namespace, keypool, key, version, filepath, uid, secret ) elif(apitype == 'atmos'): return atmos_object_read(namespace, keypool, key, version, filepath, uid, secret, type ) else: raise SOSError(SOSError.VALUE_ERR, "Wrong API type " + apitype + " specified")
def keypool_list(self, projectname, tenant, apitype, uid, secret): ''' Returns all the keypools in a vdc Parameters: keypool: label of the keypool project: project name tenant: tenant name apitype: api type(s3, swift or atmos) uid: user id secret: secret key Returns: JSON payload of keypool list ''' if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) kplst = [] try: if ((not apitype) or (apitype == 's3')): kplst.append( s3_bucket_list(namespace, projectname, uid, secretkey)) if ((not apitype) or (apitype == 'swift')): kplst.append( swift_container_list(namespace, projectname, uid, secretkey)) if ((not apitype) or (apitype == 'atmos')): kplst.append( atmos_subtenant_list(namespace, projectname, uid, secretkey)) # need to convert to table format return kplst except SOSError as e: raise e
def key_read(self, key, keypool, tenant, apitype, version, filepath, uid, secret, type): ''' Makes a REST API call to retrieve details of a key based on its key, keypool, apitype,uid, secret ''' if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) if (apitype == 's3'): return s3_key_read(namespace, keypool, key, version, filepath, uid, secret) elif (apitype == 'swift'): return swift_object_read(namespace, keypool, key, version, filepath, uid, secret) elif (apitype == 'atmos'): return atmos_object_read(namespace, keypool, key, version, filepath, uid, secret, type) else: raise SOSError(SOSError.VALUE_ERR, "Wrong API type " + apitype + " specified")
def keypool_delete(self, keypool, tenant, uid, secret): '''Makes a REST API call to delete a keypool by its name, project and tenant ''' if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) try: if (apitype == 's3'): return s3_bucket_delete(namespace, keypool, uid, secretkey) elif (apitype == 'swift'): return swift_container_delete(namespace, keypool, uid, secretkey) elif (apitype == 'atmos'): return atmos_subtenant_delete(namespace, keypool, uid, secretkey) else: raise SOSError(SOSError.VALUE_ERR, "Wrong API type " + apitype + " specified") except SOSError as e: raise e
def keypool_create(self, keypool, projectname, tenant, vpoolname, apitype, uid, secret): ''' creates a keypool parameters: keypool: label of the keypool project: project name tenant: tenant name vpool: vpool name apitype: api type(s3, swift or atmos) uid: user id secret: secret key Returns: JSON payload response ''' errorcontext = 0 if ((projectname) and (not common.is_uri(projectname))): from project import Project obj = Project(self.__ipAddr, self.__port) projectlst = obj.project_list(tenant) project_uri = None for projiter in projectlst: if(projiter['name'] == projectname): project_uri = projiter['id'] if(not project_uri): raise SOSError(SOSError.VALUE_ERR, "Porject " + projectname + ": not found") if ((vpoolname) and (not common.is_uri(vpoolname))): from virtualpool import VirtualPool obj = VirtualPool(self.__ipAddr, self.__port) vpool = obj.vpool_show(vpoolname, 'object') vpool_uri = vpool['id'] if (not common.is_uri(tenant)): from tenant import Tenant tenant_obj = Tenant(self.__ipAddr, self.__port) namespace = tenant_obj.namespace_get(tenant) try: if(apitype == 's3'): return s3_bucket_create(namespace, keypool, project_uri, vpool_uri, uid, secretkey) elif(apitype == 'swift'): return swift_container_create(namespace, keypool, project_uri, vpool_uri, uid, secretkey) elif(apitype == 'atmos'): return atmos_subtenant_create(namespace, tenant, keypool, project_uri, vpool_uri, uid, secretkey) else: raise SOSError(SOSError.VALUE_ERR, "Wrong API type " + apitype + " specified") except SOSError as e: raise e