def storagesystem_query(self, storagedeviceName, serialNumber, storagedeviceType): urideviceid = None storagesystemObj = StorageSystem(self.__ipAddr, self.__port) if serialNumber: urideviceid = storagesystemObj.query_by_serial_number_and_type(serialNumber, storagedeviceType) elif storagedeviceName: urideviceidTemp = storagesystemObj.show(name=storagedeviceName, type=storagedeviceType) urideviceid = urideviceidTemp["id"] else: return return urideviceid
def aliasget(self, initiator_uri, device_name, device_type): ''' Makes a REST API call to get the initiator alias against a storage system ''' from storagesystem import StorageSystem obj = StorageSystem(self.__ipAddr, self.__port) device_detail = obj.show(name=device_name, type=device_type) system_uri = device_detail['id'] (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", HostInitiator.URI_INITIATOR_ALIASGET.format(initiator_uri, system_uri), None) o = common.json_decode(s) return o
def aliasget(self, initiator_uri, device_name, device_type): ''' Makes a REST API call to get the initiator alias against a storage system ''' from storagesystem import StorageSystem obj = StorageSystem(self.__ipAddr, self.__port) device_detail = obj.show(name=device_name, type=device_type) system_uri = device_detail['id'] (s, h) = common.service_json_request( self.__ipAddr, self.__port, "GET", HostInitiator.URI_INITIATOR_ALIASGET.format( initiator_uri, system_uri), None) o = common.json_decode(s) return o
def storagesystem_query(self, storagedeviceName, serialNumber, storagedeviceType): urideviceid = None storagesystemObj = StorageSystem(self.__ipAddr, self.__port) if (serialNumber): urideviceid = storagesystemObj.query_by_serial_number_and_type( serialNumber, storagedeviceType) elif (storagedeviceName): urideviceidTemp = storagesystemObj.show(name=storagedeviceName, type=storagedeviceType) urideviceid = urideviceidTemp['id'] else: return return urideviceid
def storageport_add(self, storagedeviceName, serialNumber, storagedeviceType, label, portname, portid, transportType, portspeed, portgroup, networkId): storagesystemObj = StorageSystem(self.__ipAddr, self.__port) urideviceid = None if(serialNumber): urideviceid = storagesystemObj.query_storagesystem_by_serial_number(serialNumber) elif(storagedeviceName): urideviceidTemp = storagesystemObj.show(name=storagedeviceName, type=storagedeviceType) urideviceid = urideviceidTemp['id'] else: raise SOSError(SOSError.CMD_LINE_ERR, "error: For device type " + storagedeviceType + " -storagesystem name or serialnumber are required") #check snapshot is already exist is_storageport_exist = True try: self.storageport_query(storagedeviceName, serialNumber, storagedeviceType, portname) except SOSError as e: if(e.err_code == SOSError.NOT_FOUND_ERR): is_storageport_exist = False else: raise e if(is_storageport_exist): raise SOSError(SOSError.ENTRY_ALREADY_EXISTS_ERR, "storageport with name " + portname + " already exists under device under type" + storagedeviceType) body = json.dumps({ 'label' : label, 'portName' : portname, 'portId' : portid, 'transportType' : transportType, 'portSpeed' : portspeed, 'portGroup' : portgroup, 'network':networkId }) (s, h) = common.service_json_request(self.__ipAddr, self.__port, "POST", Storageport.URI_STORAGEPORT_LIST.format(urideviceid), body) return common.json_decode(s)
def aliasset(self, initiator_uri, device_name, device_type, alias): ''' Makes a REST API call to get the initiator alias against a storage system ''' from storagesystem import StorageSystem obj = StorageSystem(self.__ipAddr, self.__port) device_detail = obj.show(name=device_name, type=device_type) system_uri = device_detail['id'] request = {'system_uri': system_uri, 'initiator_alias': alias} body = json.dumps(request) (s, h) = common.service_json_request( self.__ipAddr, self.__port, "PUT", HostInitiator.URI_INITIATOR_ALIASSET.format(initiator_uri), body) o = common.json_decode(s) return o
def aliasset(self, initiator_uri, device_name, device_type, alias): ''' Makes a REST API call to get the initiator alias against a storage system ''' from storagesystem import StorageSystem obj = StorageSystem(self.__ipAddr, self.__port) device_detail = obj.show(name=device_name, type=device_type) system_uri = device_detail['id'] request = {'system_uri': system_uri, 'initiator_alias': alias } body = json.dumps(request) (s, h) = common.service_json_request( self.__ipAddr, self.__port, "PUT", HostInitiator.URI_INITIATOR_ALIASSET.format(initiator_uri), body) o = common.json_decode(s) return o
def storagesystem_query(self, devicename, devicetype, serialnumber=None): ''' Returns the URI of the storage system given either name or serialnumber Parameters: devicename:name of the system devicetype: type of system serialnumber: serial number Returns: System URI ''' from storagesystem import StorageSystem if (not common.is_uri(devicename)): obj = StorageSystem(self.__ipAddr, self.__port) if(not serialnumber or len(serialnumber)> 0): device_id = obj.query_by_serial_number_and_type(serialnumber, devicetype) else: device = obj.show(name=devicename, type=devicetype) device_id = device['id'] else: device_id = devicename return device_id
def storagesystem_query(self, devicename, devicetype, serialnumber=None): ''' Returns the URI of the storage system given either name or serialnumber Parameters: devicename:name of the system devicetype: type of system serialnumber: serial number Returns: System URI ''' from storagesystem import StorageSystem if (not common.is_uri(devicename)): obj = StorageSystem(self.__ipAddr, self.__port) if (serialnumber and len(serialnumber) > 0): device_id = obj.query_by_serial_number_and_type( serialnumber, devicetype) else: device = obj.show(name=devicename, type=devicetype) device_id = device['id'] else: device_id = devicename return device_id
def storagepool_create(self, storagename, poolname, protocol, maxSnapshots, consistency, freeCapacity, totalCapacity, extensions, deviceType): ''' Creates a storagepool with specified parameters Parameters: storagename: name of the storage system poolname: name of the storage pool protocol: protocols supported by pool nativeId: native ID fothe pool extentions: extended parameters and attributes resiliency: resiliency assosiated with pool performance: performance associated with the storage pool efficiency: efficiency associated with the storage pool allocation allocation of storage pool maxSnapshots: maxSnapshots permitted on the storage pool consistency: consistency details of storage pool resiliencymap: resiliencymap of the storage pool freeCapacity: freeCapacity of the storage pool totalCapacity: totalCapacity of the storage pool returns: JSON payload of the created storagepool ''' uri = None sstype = None if (not common.is_uri(storagename)): from storagesystem import StorageSystem obj = StorageSystem(self.__ipAddr, self.__port) device = obj.show(name=storagename, type=deviceType) uri = device['id'] sstype = deviceType checklist = [] for iter in extensions: (key, value) = iter.split('=', 1) checklist.append(key) if ((sstype == 'vnxblock') or (sstype == 'vnxfile') or (sstype == 'vmax')): if ('NativeId' not in checklist) or ('PoolType' not in checklist): raise SOSError( SOSError.CMD_LINE_ERR, "error: For device type " + sstype + " -nativeid, -pooltype are required") if (sstype == 'vnxfile'): if ('Name' not in checklist): raise SOSError( SOSError.CMD_LINE_ERR, "error: For device type " + sstype + " -controllerpoolname is required") '''check for storage pool with existing name''' storage_pool_exists = True try: self.storagepool_show(poolname, storagename, None, deviceType) except SOSError as e: if (e.err_code == SOSError.NOT_FOUND_ERR): storage_pool_exists = False else: raise e if (storage_pool_exists): raise SOSError( SOSError.ENTRY_ALREADY_EXISTS_ERR, "Storage pool with name: " + poolname + " already exists") parms = dict() if (poolname): parms['name'] = poolname if (protocol): parms['protocols'] = protocol if (maxSnapshots): parms['max_snapshots'] = maxSnapshots if (consistency): parms['multi_volume_consistency'] = consistency if (extensions): parms['controller_params'] = self.__encode_map(extensions) if (freeCapacity): parms['free_capacity'] = freeCapacity if (totalCapacity): parms['total_capacity'] = totalCapacity body = None if (parms): body = json.dumps(parms) (s, h) = common.service_json_request( self.__ipAddr, self.__port, "POST", StoragePool.URI_STORAGEPOOLS.format(uri), body) o = common.json_decode(s) return o
def storagepool_create(self, storagename, poolname, protocol, maxSnapshots, consistency, freeCapacity, totalCapacity, extensions, deviceType): ''' Creates a storagepool with specified parameters Parameters: storagename: name of the storage system poolname: name of the storage pool protocol: protocols supported by pool nativeId: native ID fothe pool extentions: extended parameters and attributes resiliency: resiliency assosiated with pool performance: performance associated with the storage pool efficiency: efficiency associated with the storage pool allocation allocation of storage pool maxSnapshots: maxSnapshots permitted on the storage pool consistency: consistency details of storage pool resiliencymap: resiliencymap of the storage pool freeCapacity: freeCapacity of the storage pool totalCapacity: totalCapacity of the storage pool returns: JSON payload of the created storagepool ''' uri = None sstype = None if (not common.is_uri(storagename)): from storagesystem import StorageSystem obj = StorageSystem(self.__ipAddr, self.__port) device = obj.show(name=storagename, type=deviceType) uri = device['id'] sstype = deviceType checklist = [] for iter in extensions: (key, value) = iter.split('=', 1) checklist.append(key) if((sstype == 'vnxblock') or (sstype == 'vnxfile') or (sstype == 'vmax')): if('NativeId' not in checklist)or ('PoolType' not in checklist): raise SOSError(SOSError.CMD_LINE_ERR, "error: For device type " + sstype + " -nativeid, -pooltype are required") if(sstype == 'vnxfile'): if('Name' not in checklist): raise SOSError(SOSError.CMD_LINE_ERR, "error: For device type " + sstype + " -controllerpoolname is required") '''check for storage pool with existing name''' storage_pool_exists = True try: self.storagepool_show(poolname, storagename, None, deviceType) except SOSError as e: if(e.err_code == SOSError.NOT_FOUND_ERR): storage_pool_exists = False else: raise e if(storage_pool_exists): raise SOSError(SOSError.ENTRY_ALREADY_EXISTS_ERR, "Storage pool with name: " + poolname + " already exists") parms = dict() if (poolname): parms['name'] = poolname if (protocol): parms['protocols'] = protocol if (maxSnapshots): parms['max_snapshots'] = maxSnapshots if (consistency): parms['multi_volume_consistency'] = consistency if (extensions): parms['controller_params'] = self.__encode_map(extensions) if (freeCapacity): parms['free_capacity'] = freeCapacity if (totalCapacity): parms['total_capacity'] = totalCapacity body = None if (parms): body = json.dumps(parms) (s, h) = common.service_json_request(self.__ipAddr, self.__port, "POST", StoragePool.URI_STORAGEPOOLS.format(uri), body) o = common.json_decode(s) return o