use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume in project coprhd-controller by CoprHD.
the class StorageSystemDataCollectionService method discoverScaleIO.
/**
* Collect Data for ScaleIO system
*
* @param param ScaleIO discovery information
* @return Data collected for ScaleIO system
*/
@POST
@Path("/scaleio")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public ScaleIOSystemDataRestRep discoverScaleIO(ScaleIOCollectDataParam param) {
log.debug("discovering ScaleIO: {}", param.getIPAddress());
URI baseURI = URI.create(ScaleIOConstants.getAPIBaseURI(param.getIPAddress(), param.getPortNumber()));
ScaleIORestClient client = (ScaleIORestClient) scaleIORestClientFactory.getRESTClient(baseURI, param.getUserName(), param.getPassword());
ScaleIOSystemDataRestRep sio = null;
try {
// collect and map scaleIO system
ScaleIOSystem system = client.getSystem();
sio = ScaleIODataMapper.map(system);
// collect sds,device,fault set, and protection domain data
List<ScaleIOSDS> allSDS = client.queryAllSDS();
Map<String, ScaleIOProtectionDomain> pdMap = null;
List<ScaleIOProtectionDomain> pdList = client.getProtectionDomains();
if (null != pdList) {
pdMap = pdList.stream().collect(Collectors.toMap(ScaleIOProtectionDomain::getId, p -> p));
}
List<ScaleIOFaultSet> fsList = client.queryAllFaultSets();
Map<String, ScaleIOFaultSet> fsMap = null;
if (null != fsList) {
fsMap = client.queryAllFaultSets().stream().collect(Collectors.toMap(ScaleIOFaultSet::getId, f -> f));
}
Map<String, ScaleIOStoragePool> spMap = client.queryAllStoragePools().stream().collect(Collectors.toMap(ScaleIOStoragePool::getId, s -> s));
// map SDS data
List<ScaleIOSDSDataRestRep> scaleIOSDSDataRestReps = new ArrayList<ScaleIOSDSDataRestRep>();
for (ScaleIOSDS sds : allSDS) {
ScaleIOSDSDataRestRep sdsData = ScaleIODataMapper.map(sds);
// map device data
List<ScaleIODevice> devices = client.getSdsDevices(sds.getId());
List<ScaleIODeviceDataRestRep> scaleIODeviceDataRestReps = new ArrayList<ScaleIODeviceDataRestRep>();
if (null != devices) {
for (ScaleIODevice device : devices) {
ScaleIODeviceDataRestRep scaleIODeviceDataRestRep = ScaleIODataMapper.map(device);
// map storagepool data
scaleIODeviceDataRestRep.setStoragePool(ScaleIODataMapper.map(spMap.get(device.getStoragePoolId())));
scaleIODeviceDataRestReps.add(scaleIODeviceDataRestRep);
}
sdsData.setDevices(scaleIODeviceDataRestReps);
}
// map fault set data
if (null != fsMap) {
sdsData.setFaultSet(ScaleIODataMapper.map(fsMap.get(sds.getFaultSetId())));
}
// map protection domain and IP data
if (null != pdMap) {
sdsData.setProtectionDomain(ScaleIODataMapper.map(pdMap.get(sds.getProtectionDomainId())));
}
sdsData.setIpList(ScaleIODataMapper.mapIpList(sds.getIpList()));
scaleIOSDSDataRestReps.add(sdsData);
}
sio.setSdsList(scaleIOSDSDataRestReps);
// collect and map SDC data
List<ScaleIOSDC> allSDC = client.queryAllSDC();
List<ScaleIOSDCDataRestRep> scaleIOSDCDataRestReps = new ArrayList<ScaleIOSDCDataRestRep>();
for (ScaleIOSDC sdc : allSDC) {
ScaleIOSDCDataRestRep sdcData = ScaleIODataMapper.map(sdc);
// map device data
List<ScaleIOVolume> volumes = client.getSdcVolumes(sdc.getId());
List<ScaleIOVolumeDataRestRep> scaleIOVolumeDataRestReps = new ArrayList<ScaleIOVolumeDataRestRep>();
if (null != volumes) {
for (ScaleIOVolume volume : volumes) {
ScaleIOVolumeDataRestRep scaleIOVolumeDataRestRep = ScaleIODataMapper.map(volume);
// map storagepool data
scaleIOVolumeDataRestRep.setStoragePool(ScaleIODataMapper.map(spMap.get(volume.getStoragePoolId())));
scaleIOVolumeDataRestReps.add(scaleIOVolumeDataRestRep);
}
sdcData.setVolumes(scaleIOVolumeDataRestReps);
}
scaleIOSDCDataRestReps.add(sdcData);
}
sio.setSdcList(scaleIOSDCDataRestReps);
} catch (ScaleIOException e) {
log.error(String.format("Exception was encountered in the ScaleIO client when connecting to instance %s", param.getIPAddress()), e);
throw APIException.badRequests.storageSystemClientException(SCALEIO, e.getLocalizedMessage());
} catch (JSONException e) {
log.error(String.format("Exception was encountered when attempting to discover ScaleIO Instance %s", param.getIPAddress()), e);
throw APIException.badRequests.cannotDiscoverStorageSystemUnexpectedResponse(SCALEIO);
}
return sio;
}
use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume in project coprhd-controller by CoprHD.
the class ScaleIOCloneOperations method createGroupClone.
@Override
public void createGroupClone(StorageSystem storage, List<URI> cloneList, Boolean createInactive, TaskCompleter taskCompleter) {
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
List<Volume> clones = dbClient.queryObject(Volume.class, cloneList);
Map<String, String> parent2snap = new HashMap<>();
Set<URI> poolsToUpdate = new HashSet<>();
for (Volume clone : clones) {
Volume parent = dbClient.queryObject(Volume.class, clone.getAssociatedSourceVolume());
parent2snap.put(parent.getNativeId(), clone.getLabel());
poolsToUpdate.add(parent.getPool());
}
String systemId = scaleIOHandle.getSystemId();
ScaleIOSnapshotVolumeResponse result = scaleIOHandle.snapshotMultiVolume(parent2snap, systemId);
List<String> nativeIds = result.getVolumeIdList();
Map<String, ScaleIOVolume> cloneNameMap = scaleIOHandle.getVolumeNameMap(nativeIds);
Multimap<URI, String> poolToVolumesMap = ArrayListMultimap.create();
for (Volume clone : clones) {
String name = clone.getLabel();
ScaleIOVolume sioVolume = cloneNameMap.get(name);
ScaleIOHelper.updateSnapshotWithSnapshotVolumeResult(dbClient, clone, systemId, sioVolume.getId(), storage);
clone.setAllocatedCapacity(Long.parseLong(sioVolume.getSizeInKb()) * 1024L);
clone.setProvisionedCapacity(clone.getAllocatedCapacity());
clone.setCapacity(clone.getAllocatedCapacity());
clone.setReplicationGroupInstance(result.getSnapshotGroupId());
poolToVolumesMap.put(clone.getPool(), clone.getId().toString());
}
dbClient.updateObject(clones);
List<StoragePool> pools = dbClient.queryObject(StoragePool.class, Lists.newArrayList(poolsToUpdate));
for (StoragePool pool : pools) {
pool.removeReservedCapacityForVolumes(poolToVolumesMap.get(pool.getId()));
ScaleIOHelper.updateStoragePoolCapacity(dbClient, scaleIOHandle, pool, storage);
}
taskCompleter.ready(dbClient);
} catch (Exception e) {
log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("createGroupClone", e.getMessage());
taskCompleter.error(dbClient, code);
}
}
use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume in project coprhd-controller by CoprHD.
the class ScaleIORestClient method addVolume.
/**
* Create a volume
*
* @param protectionDomainId The protection domain ID
* @param storagePoolId The storage pool ID
* @param volumeName The volume name
* @param volumeSize The volume Size
* @param thinProvisioned true for thinProvisioned, false for thickProvisioned
* @return
* @throws Exception
*/
public ScaleIOVolume addVolume(String protectionDomainId, String storagePoolId, String volumeName, String volumeSize, boolean thinProvisioned) throws Exception {
ScaleIOCreateVolume volume = new ScaleIOCreateVolume();
Long sizeInKb = Long.parseLong(volumeSize) / 1024L;
volume.setVolumeSizeInKb(sizeInKb.toString());
volume.setStoragePoolId(storagePoolId);
volume.setName(volumeName);
volume.setProtectionDomainId(protectionDomainId);
if (thinProvisioned) {
volume.setVolumeType(ScaleIOConstants.THIN_PROVISIONED);
} else {
volume.setVolumeType(ScaleIOConstants.THICK_PROVISIONED);
}
ClientResponse response = post(URI.create(ScaleIOConstants.VOLUMES_URI), getJsonForEntity(volume));
ScaleIOVolume createdVol = getResponseObject(ScaleIOVolume.class, response);
return queryVolume(createdVol.getId());
}
use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume in project coprhd-controller by CoprHD.
the class ScaleIORestClient method getVolumeNameMap.
/**
* Get the volumes for the given volume Ids
*
* @param volumeIds The list of volume IDs
* @return The map of the ScaleIO volume and volume ID
* @throws Exception
*/
public Map<String, ScaleIOVolume> getVolumeNameMap(List<String> volumeIds) throws Exception {
Map<String, ScaleIOVolume> result = new HashMap<String, ScaleIOVolume>();
ScaleIOVolumeList parm = new ScaleIOVolumeList();
parm.setIds(volumeIds);
ClientResponse response = post(URI.create(ScaleIOConstants.GET_VOLUMES_BYIDS_URI), getJsonForEntity(parm));
List<ScaleIOVolume> volumes = getResponseObjects(ScaleIOVolume.class, response);
for (ScaleIOVolume volume : volumes) {
result.put(volume.getName(), volume);
}
return result;
}
use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOVolume in project coprhd-controller by CoprHD.
the class ScaleIORestClient method getVolumes.
/**
* Get the volume names for the given volume Ids
*
* @param volumeIds The list of volume IDs
* @return The map of the volume name and volume ID
* @throws Exception
*/
public Map<String, String> getVolumes(List<String> volumeIds) throws Exception {
Map<String, String> result = new HashMap<String, String>();
ScaleIOVolumeList parm = new ScaleIOVolumeList();
parm.setIds(volumeIds);
ClientResponse response = post(URI.create(ScaleIOConstants.GET_VOLUMES_BYIDS_URI), getJsonForEntity(parm));
List<ScaleIOVolume> volumes = getResponseObjects(ScaleIOVolume.class, response);
for (ScaleIOVolume volume : volumes) {
result.put(volume.getName(), volume.getId());
}
return result;
}
Aggregations