def consistencygroup_list(args): obj = ConsistencyGroup(args.ip, args.port) try: uris = obj.list(args.project, args.tenant) output = [] for uri in uris: cg = obj.show(uri, args.project, args.tenant) if(cg): from volume import Volume from storagesystem import StorageSystem if( "volumes" in cg): volumeuris = common.get_node_value(cg, "volumes") volobj = Volume(args.ip, args.port) volumenames = [] for volume in volumeuris: vol = volobj.show_by_uri(volume['id']) if(vol): volumenames.append(vol['name']) cg['volumes'] = volumenames ssobj = StorageSystem(args.ip, args.port) if( "storage_controller" in cg): ssrow = common.get_node_value(cg, "storage_controller") storagesystem = ssobj.show_by_uri(ssrow['id']) cg['storage_controller'] = storagesystem['name'] output.append(cg) if(len(output)): TableGenerator(output, ['name', 'volumes', 'storage_controller']).printTable() except SOSError as e: raise SOSError(SOSError.SOS_FAILURE_ERR, "Consistency Group List failed:\n" + e.err_text)
def consistencygroup_list(args): obj = ConsistencyGroup(args.ip, args.port) try: uris = obj.list(args.project, args.tenant) output = [] rawoutput = [] for uri in uris: cg = obj.show(uri, args.project, args.tenant) if(cg): rawoutput.append(cg) from volume import Volume from storagesystem import StorageSystem cg["system_consistency_groups"] = " " if("volumes" in cg): volumeuris = common.get_node_value(cg, "volumes") volobj = Volume(args.ip, args.port) volumenames = [] for volume in volumeuris: vol = volobj.show_by_uri(volume['id']) if(vol): volumenames.append(vol['name']) cg['volumes'] = volumenames volumenames = [] output.append(cg) if(not args.verbose): if(len(output)): TableGenerator(output, ['name', 'volumes']).printTable() else: if(len(rawoutput)): return common.format_json_object(rawoutput) except SOSError as e: raise SOSError(SOSError.SOS_FAILURE_ERR, "Consistency Group List failed:\n" + e.err_text)
def consistencygroup_list(args): obj = ConsistencyGroup(args.ip, args.port) try: uris = obj.list(args.project, args.tenant) output = [] rawoutput = [] for uri in uris: cg = obj.show(uri, args.project, args.tenant) if (cg): rawoutput.append(cg) from volume import Volume from storagesystem import StorageSystem cg["system_consistency_groups"] = " " if ("volumes" in cg): volumeuris = common.get_node_value(cg, "volumes") volobj = Volume(args.ip, args.port) volumenames = [] for volume in volumeuris: vol = volobj.show_by_uri(volume['id']) if (vol): volumenames.append(vol['name']) cg['volumes'] = volumenames volumenames = [] output.append(cg) if (not args.verbose): if (len(output)): TableGenerator(output, ['name', 'volumes']).printTable() else: if (len(rawoutput)): return common.format_json_object(rawoutput) except SOSError as e: raise SOSError(SOSError.SOS_FAILURE_ERR, "Consistency Group List failed:\n" + e.err_text)
def list(self, project, tenant): ''' This function will give us the list of consistency group uris separated by comma. prameters: project: Name of the project path. return returns with list of consistency group ids separated by comma. ''' if (tenant is None): tenant = "" projobj = Project(self.__ipAddr, self.__port) fullproj = tenant + "/" + project projuri = projobj.project_query(fullproj) (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", self.URI_CONSISTENCY_GROUPS_SEARCH.format(projuri), None) o = common.json_decode(s) if not o: return [] congroups = [] resources = common.get_node_value(o, "resource") for resource in resources: congroups.append(resource["id"]) return congroups
def project_show_by_uri(self, uri, xml=False): ''' Makes REST API call and retrieves project derails based on UUID Parameters: uri: UUID of project Returns: Project details in JSON response payload ''' if (xml): (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", Project.URI_PROJECT.format(uri), None, None, xml) return s (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", Project.URI_PROJECT.format(uri), None) o = common.json_decode(s) inactive = common.get_node_value(o, 'inactive') if (inactive == True): return None return o
def list(self, project, tenant): ''' This function will give us the list of consistency group uris separated by comma. prameters: project: Name of the project path. return returns with list of consistency group ids separated by comma. ''' if(tenant == None): tenant = "" projobj = Project(self.__ipAddr, self.__port) fullproj = tenant+"/"+project projuri = projobj.project_query(fullproj) (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", self.URI_CONSISTENCY_GROUPS_SEARCH.format(projuri), None) o = common.json_decode(s) if not o: return [] congroups=[] resources = common.get_node_value(o, "resource") for resource in resources: congroups.append(resource["id"]) return congroups
def get_catalog(self, uriPath, xml=False): if (uriPath is None): uriPath = "" elif (uriPath.startswith("/") is False): uriPath = "/" + uriPath command = singletonURIHelperInstance.getUri( self.COMPONENT_TYPE, "catalog") port = self.__port if(len(uriPath) == 0): port = common.getenv('VIPR_UI_PORT') (s, h) = common.service_json_request(self.__ipAddr, port, "GET", command.format(uriPath), None) o = common.json_decode(s) inactive = common.get_node_value(o, 'inactive') if (inactive): return None if (xml): (s, h) = common.service_json_request(self.__ipAddr, port, "GET", command.format(uriPath), None, None, xml) return s else: return o
def exportgroup_list(self, project, tenant): ''' This function will give us the list of export group uris separated by comma. prameters: project: Name of the project path. return returns with list of export group ids separated by comma. ''' if(tenant == None): tenant = "" projobj = Project(self.__ipAddr, self.__port) fullproj = tenant+"/"+project projuri = projobj.project_query(fullproj) uri = self.URI_EXPORT_GROUP_SEARCH if ('?' in uri): uri += '&project=' + projuri else: uri += '?project=' + projuri (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", uri, None) o = common.json_decode(s) if not o: return [] exportgroups=[] resources = common.get_node_value(o, "resource") for resource in resources: exportgroups.append(resource["id"]) return exportgroups
def get_catalog(self, uriPath, xml=False): if (uriPath is None): uriPath = "" elif (uriPath.startswith("/") is False): uriPath = "/" + uriPath command = singletonURIHelperInstance.getUri(self.COMPONENT_TYPE, "catalog") port = self.__port if (len(uriPath) == 0): port = common.getenv('VIPR_UI_PORT') (s, h) = common.service_json_request(self.__ipAddr, port, "GET", command.format(uriPath), None) o = common.json_decode(s) inactive = common.get_node_value(o, 'inactive') if (inactive): return None if (xml): (s, h) = common.service_json_request(self.__ipAddr, port, "GET", command.format(uriPath), None, None, xml) return s else: return o
def ps_list_uris(self): """ This function will give us the list of RecoverPoint uris separated by comma. """ (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", self.URI_PROTECTION_SYSTEMS, None) o = common.json_decode(s) return common.get_node_value(o, "protection_system")
def snapshotsession_name_to_uri(self, storageresType, storageresTypeName, resuri, snapsession_label): if(resuri is not None): uris = self.snapshotsession_list(storageresType, storageresTypeName, resuri) for uri in uris: snapshotsession = self.snapshotsession_show_uri(storageresType, storageresTypeName, uri['id'], resuri) if(False == (common.get_node_value(snapshotsession, 'inactive'))): if (snapshotsession['name'] == snapsession_label): return snapshotsession['id'] return None
def ps_list_uris(self): ''' This function will give us the list of RecoverPoint uris separated by comma. ''' (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", self.URI_PROTECTION_SYSTEMS, None) o = common.json_decode(s) return common.get_node_value(o, 'protection_system')
def search_by_name(self, host_name): """ Search host by its name """ (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", self.URI_HOSTS_SEARCH_BY_NAME.format(host_name), None ) o = common.json_decode(s) if not o: return [] return common.get_node_value(o, "resource")
def list_by_project_uri(self, project_uri): """ Searches all hosts those belong to a project """ (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", self.URI_HOSTS_SEARCH_FOR_PROJECT.format(project_uri), None ) o = common.json_decode(s) if not o: return [] return common.get_node_value(o, "resource")
def snapshotsession_query(self, storageresType, storageresTypeName, resuri, snapshotsessionName): if(resuri is not None): uris = self.snapshotsession_list(storageresType, storageresTypeName, resuri) for uri in uris: snapshotsession = self.snapshotsession_show_uri(storageresType, storageresTypeName, uri['id'], resuri) if(False == (common.get_node_value(snapshotsession, 'inactive'))): if (snapshotsession['name'] == snapshotsessionName): return snapshotsession['id'] raise SOSError( SOSError.SOS_FAILURE_ERR, "snapshot Session with the name:" + snapshotsessionName + " Not Found")
def storageport_show_uri(self, ssuri, spuri, xml=False): ''' Makes a REST API call to retrieve details of a storage port based on its UUID ''' (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", Storageport.URI_STORAGEPORT_DETAILS.format(ssuri, spuri), None) if(xml == False): o = common.json_decode(s) inactive = common.get_node_value(o, 'inactive') if(inactive): return None else: return o return s
def exportgroup_list(args): obj = ExportGroup(args.ip, args.port) try: uris = obj.exportgroup_list(args.project, args.tenant) output = [] if len(uris) > 0: for uri in uris: eg = obj.exportgroup_show(uri, args.project, args.tenant) # The following code is to get volume/snapshot name part of # export group list. if eg: if "project" in eg and "name" in eg["project"]: del eg["project"]["name"] volumeuris = common.get_node_value(eg, "volumes") volobj = Volume(args.ip, args.port) snapobj = Snapshot(args.ip, args.port) volnames = [] strvol = "" for volumeuri in volumeuris: strvol = str(volumeuri["id"]) if strvol.find("urn:storageos:Volume") >= 0: vol = volobj.show_by_uri(strvol) if vol: volnames.append(vol["name"]) elif strvol.find("urn:storageos:BlockSnapshot") >= 0: snapshot = snapobj.snapshot_show_uri("block", None, strvol) if snapshot: volnames.append(snapshot["name"]) eg["volumes_snapshots"] = volnames output.append(eg) if args.verbose: return common.format_json_object(output) if len(output) > 0: if args.long: from common import TableGenerator TableGenerator( output, ["module/name", "volumes_snapshots", "initiator_node", "initiator_port", "tags"] ).printTable() else: from common import TableGenerator TableGenerator(output, ["module/name"]).printTable() except SOSError as e: raise common.format_err_msg_and_raise("list", "exportgroup", e.err_text, e.err_code)
def query_by_name(self, nwName): (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", self.URI_NETWORK_SEARCH.format(nwName), None) o = common.json_decode(s) if not o: return None resources = common.get_node_value(o, "resource") if (len(resources) > 0): component_uri = resources[0]['id'] nw_details = self.show_by_uri(component_uri, False) if (nw_details is not None): return component_uri return None
def query_by_name(self, nwName): (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", self.URI_NETWORK_SEARCH.format(nwName), None) o = common.json_decode(s) if not o: return None resources = common.get_node_value(o, "resource") if(len(resources) > 0): component_uri = resources[0]['id'] nw_details = self.show_by_uri(component_uri, False) if(nw_details is not None): return component_uri return None
def storageport_show_uri(self, ssuri, spuri, xml=False): ''' Makes a REST API call to retrieve details of a storage port based on its UUID ''' (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", Storageport.URI_STORAGEPORT_DETAILS.format(ssuri, spuri), None) if (xml is False): o = common.json_decode(s) inactive = common.get_node_value(o, 'inactive') if (inactive): return None else: return o return s
def vdc_show_by_uri(self, uri, xml=False): (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", VirtualDatacenter.URI_VDC_GET.format(uri), None, None) o = common.json_decode(s) inactive = common.get_node_value(o, 'inactive') if (inactive == True): return None if (xml == True): (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", VirtualDatacenter.URI_VDC_GET.format(uri), None, None, xml) return s else: return o
def get_service(self, uri, xml=False): command = singletonURIHelperInstance.getUri(self.COMPONENT_TYPE, "get-service") (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", command.format(uri), None, None) o = common.json_decode(s) inactive = common.get_node_value(o, 'inactive') if (inactive): return None if (xml): (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", command.format(uri), None, None, xml) return s else: return o
def get_service(self, uri, xml=False): command = singletonURIHelperInstance.getUri( self.COMPONENT_TYPE, "get-service") (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", command.format(uri), None, None) o = common.json_decode(s) inactive = common.get_node_value(o, 'inactive') if (inactive): return None if (xml): (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", command.format(uri), None, None, xml) return s else: return o
def list_by_tenant(self, tenantName): """ Lists all the hosts Parameters tenant : The name of the tenant for which host list to be returned """ tenantId = self.get_tenant_id(tenantName) (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", Host.URI_TENANT_HOSTS.format(tenantId), None ) o = common.json_decode(s) if not o or "host" not in o: return [] return common.get_node_value(o, "host")
def exportgroup_list(args): obj = ExportGroup(args.ip, args.port) try: uris = obj.exportgroup_list(args.project, args.tenant) output = [] if(len(uris) > 0): for uri in uris: eg = obj.exportgroup_show(uri, args.project, args.tenant) # The following code is to get volume/snapshot name part of export group list. if(eg): if("project" in eg and "name" in eg["project"]): del eg["project"]["name"] volumeuris = common.get_node_value(eg, "volumes") volobj = Volume(args.ip, args.port) snapobj = Snapshot(args.ip, args.port) volnames = [] strvol = "" for volumeuri in volumeuris: strvol = str(volumeuri['id']) if(strvol.find('urn:storageos:Volume') >= 0): vol = volobj.show_by_uri(strvol) if(vol): volnames.append(vol['name']) elif(strvol.find('urn:storageos:BlockSnapshot')>= 0): snapshot = snapobj.snapshot_show_uri('block', None, strvol) if(snapshot): volnames.append(snapshot['name']) eg['volumes_snapshots']=volnames output.append(eg) 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', 'volumes_snapshots','initiator_node', 'initiator_port']).printTable() else: from common import TableGenerator TableGenerator(output, ['name']).printTable() except SOSError as e: raise common.format_err_msg_and_raise("list", "exportgroup", e.err_text, e.err_code)
def show_by_uri(self, uri, xml=False): ''' Makes a REST API call to retrieve details of a Host based on its UUID ''' (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", HostIPInterface.URI_IPINTERFACE_DETAILS.format(uri), None, None) o = common.json_decode(s) inactive = common.get_node_value(o, 'inactive') if(inactive == True): return None if(xml == True): (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", HostIPInterface.URI_IPINTERFACE_DETAILS.format(uri), None, None, xml) return s else: return o
def show_by_uri(self, uri, xml=False): """ Makes a REST API call to retrieve details of a Host based on its UUID """ (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", HostInitiator.URI_INITIATOR_DETAILS.format(uri), None, None ) o = common.json_decode(s) inactive = common.get_node_value(o, "inactive") if inactive: return None if xml: (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", HostInitiator.URI_INITIATOR_DETAILS.format(uri), None, None, xml ) return s else: return o
def show_by_uri(self, uri, xml=False): ''' Makes a REST API call to retrieve details of a Host based on its UUID ''' (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", HostInitiator.URI_INITIATOR_DETAILS.format(uri), None, None) o = common.json_decode(s) inactive = common.get_node_value(o, 'inactive') if (inactive): return None if (xml): (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", HostInitiator.URI_INITIATOR_DETAILS.format(uri), None, None, xml) return s else: return o
def project_show_by_uri(self, uri, xml=False): ''' Makes REST API call and retrieves project derails based on UUID Parameters: uri: UUID of project Returns: Project details in JSON response payload ''' if(xml): (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", Project.URI_PROJECT.format(uri), None, None, xml) return s (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", Project.URI_PROJECT.format(uri), None) o = common.json_decode(s) inactive = common.get_node_value(o, 'inactive') if(inactive == True): return None return o
def list_initiators(self, hostName): """ Lists all initiators Parameters hostName : The name of the host for which initiators to be returned """ if common.is_uri(hostName) == False: hostUri = self.query_by_name(hostName, None) else: hostUri = hostName (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", Host.URI_HOST_LIST_INITIATORS.format(hostUri), None ) o = common.json_decode(s) if not o or "initiator" not in o: return [] return common.get_node_value(o, "initiator")
def list_ipinterfaces(self, hostName): """ Lists all IPInterfaces belonging to a given host Parameters hostName : The name of the host for which ipinterfaces to be returned """ if common.is_uri(hostName) == False: hostUri = self.query_by_name(hostName, None) else: hostUri = hostName (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", Host.URI_HOST_LIST_IPINTERFACES.format(hostUri), None ) o = common.json_decode(s) if not o or "ip_interface" not in o: return [] return common.get_node_value(o, "ip_interface")
def vdc_show_by_uri(self, uri, xml=False): (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", VirtualDatacenter.URI_VDC_GET.format(uri), None, None) o = common.json_decode(s) inactive = common.get_node_value(o, 'inactive') if(inactive == True): return None if(xml == True): (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", VirtualDatacenter.URI_VDC_GET.format(uri), None, None, xml) return s else: return o
def show_by_uri(self, uri, xml=False): ''' Makes REST API call and retrieves volume group details based on UUID Parameters: uri: UUID of volume group Returns: volume group details in JSON response payload ''' if(xml): (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", VolumeGroup.URI_VOLUME_GROUP.format(uri), None, None, xml) return s (s, h) = common.service_json_request(self.__ipAddr, self.__port, "GET", VolumeGroup.URI_VOLUME_GROUP.format(uri), None) o = common.json_decode(s) inactive = common.get_node_value(o, 'inactive') if(inactive == True): return None return o
def filepolicy_show_by_uri(self, uri, xml=False): if xml: (s, h) = common.service_json_request( self.__ipAddr, self.__port, 'GET', FilePolicy.URI_FILE_POLICY_SHOW.format(uri), None, None, xml, ) return s (s, h) = common.service_json_request(self.__ipAddr, self.__port, 'GET', FilePolicy.URI_FILE_POLICY_SHOW.format(uri), None) o = common.json_decode(s) inactive = common.get_node_value(o, 'inactive') if inactive == True: return None return o
def filepolicy_update( self, label, name, description, priority, num_worker_threads, policyschedulefrequency, policyschedulerepeat, policyscheduletime, policyscheduleweek, policyschedulemonth, replicationtype, snapshotnamepattern, snapshotexpiretype, snapshotexpirevalue, applyat, ): ''' Creates a filepolicy based on policy name parameters: tenants_access tenants access flag, description policy description, priority priority of the policys, policyschedulefrequency sType of schedule frequency e.g days, week or months, policyschedulerepeat policy run on every, policyscheduletime Time when policy run, policyscheduleweek day of week when policy run, policyschedulemonth day of month when policy run, replicationcopymode, replicationtype, snapshotnamepattern, snapshotexpiretype, snapshotexpirevalue ''' filepolicy = self.filepolicy_query(label) (s, h) = common.service_json_request( self.__ipAddr, self.__port, 'GET', FilePolicy.URI_FILE_POLICY_SHOW.format(filepolicy['id']), None, None, False, ) o = common.json_decode(s) pol_type = common.get_node_value(o,"type") update_request = {} if name is not None: update_request['policy_name'] = name if description is not None: update_request['policy_description'] = description if priority is not None: update_request['priority'] = priority if applyat is not None: update_request['apply_at'] = applyat policy_schedule = {} snapshot_params = {} replication_params = {} snapshot_expire_params = {} if policyschedulefrequency is not None: policy_schedule['schedule_frequency'] = policyschedulefrequency if policyschedulerepeat is not None: policy_schedule['schedule_repeat'] = policyschedulerepeat if policyscheduletime is not None: policy_schedule['schedule_time'] = policyscheduletime if policyscheduleweek is not None: policy_schedule['schedule_day_of_week'] = policyscheduleweek if policyschedulemonth is not None: policy_schedule['schedule_day_of_month'] = policyschedulemonth if pol_type == 'file_replication': if replicationtype is not None: replication_params['replication_type'] = replicationtype if policy_schedule is not None and (len(policy_schedule) >0): replication_params['policy_schedule'] = policy_schedule if priority is not None: update_request['priority'] = priority if num_worker_threads is not None: update_request['num_worker_threads'] = num_worker_threads if replication_params is not None and (len(replication_params) >0): replication_params['replication_copy_mode'] = 'ASYNC' update_request['replication_params'] = replication_params elif pol_type == 'file_snapshot': if snapshotexpiretype is not None: snapshot_expire_params['expire_type'] = snapshotexpiretype if snapshotexpirevalue is not None: snapshot_expire_params['expire_value'] = snapshotexpirevalue if snapshotnamepattern is not None: snapshot_params['snapshot_name_pattern'] = snapshotnamepattern if snapshot_expire_params is not None and (len(snapshot_expire_params) >0): snapshot_params['snapshot_expire_params'] = snapshot_expire_params if policy_schedule is not None and (len(policy_schedule) >0): snapshot_params['policy_schedule'] = policy_schedule if snapshot_params is not None and (len(snapshot_params) >0): update_request['snapshot_params'] = snapshot_params try: body = json.dumps(update_request) (s, h) = common.service_json_request(self.__ipAddr, self.__port, 'PUT', FilePolicy.URI_FILE_POLICY_UPDATE.format(filepolicy['id']), body) if not s: return None o = common.json_decode(s) return o except SOSError, e: errorMessage = str(e)
def filepolicy_assign( self, name, assign_to_vpools, project_assign_vpool, assign_to_projects, source_varray, target_varrays, ): filepolicy = self.filepolicy_query(name) (s, h) = common.service_json_request( self.__ipAddr, self.__port, 'GET', FilePolicy.URI_FILE_POLICY_SHOW.format(filepolicy['id']), None, None, False, ) o = common.json_decode(s) appliedat = common.get_node_value(o,"applied_at") pol_type = common.get_node_value(o,"type") assign_request = {} if ( appliedat == "vpool"): vpool_assign_param = {} assign_request_vpools = [] if assign_to_vpools is None: raise SOSError(SOSError.VALUE_ERR,"File policyassign error:"+ "Vpool(assign_to_vpools) value should be provided") elif( len(assign_to_vpools)>1): vpool_names = assign_to_vpools.split(',') vpool_obj = VirtualPool(self.__ipAddr, self.__port) for name in vpool_names: uri = vpool_obj.vpool_query(name, 'file') assign_request_vpools.append(uri) elif( assign_to_vpools is not None ): uri = vpool_obj.vpool_query(assign_to_vpools, 'file') assign_request_vpools.append(uri) vpool_assign_param['assign_to_vpools'] = assign_request_vpools assign_request['vpool_assign_param'] = vpool_assign_param elif ( appliedat == "project"): project_assign_param = {} assign_request_projects = [] assign_request_project_vpools = [] project_obj = Project(self.__ipAddr, self.__port) if assign_to_projects is None or project_assign_vpool is None: raise SOSError(SOSError.VALUE_ERR,"File policyassign error:"+ "Vpool (project_assign_vpool) and project (assign_to_projects) value should be provided") if( len(assign_to_projects)>1): project_names = assign_to_projects.split(',') for name in project_names: uri = project_obj.project_query(name) assign_request_projects.append(uri) else: uri = project_obj.project_query(assign_to_projects) assign_request_projects.append(uri) vpool_obj = VirtualPool(self.__ipAddr, self.__port) uri = vpool_obj.vpool_query(project_assign_vpool, 'file') project_assign_param['vpool'] = uri project_assign_param['assign_to_projects'] = assign_request_projects assign_request['project_assign_param'] = project_assign_param if (pol_type == "file_replication"): if (source_varray is not None and target_varrays is not None): file_replication_topologies = [] file_replication_topology = {} assign_target_varrays = [] from virtualarray import VirtualArray varray_obj = VirtualArray(self.__ipAddr, self.__port) src_varray_uri = varray_obj.varray_query(source_varray) file_replication_topology['source_varray']= src_varray_uri if( len(target_varrays)>1): trg_varrays= target_varrays.split(',') for varray in trg_varrays: uri = varray_obj.varray_query(varray) assign_target_varrays.append(uri) else: uri = varray_obj.varray_query(target_varrays) assign_target_varrays.append(uri) file_replication_topology['target_varrays']= assign_target_varrays file_replication_topologies.append(file_replication_topology) assign_request['file_replication_topologies']= file_replication_topologies else: raise SOSError(SOSError.VALUE_ERR, "File policyassign error:"+ "Target and source virtual array should be provided") try: body = json.dumps(assign_request) (s, h) = common.service_json_request(self.__ipAddr, self.__port, 'POST', FilePolicy.URI_FILE_POLICY_ASSIGN.format(filepolicy['id']), body) if not s: return None o = common.json_decode(s) return o except SOSError, e: errorMessage = str(e)