use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOFaultSet 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.ScaleIOFaultSet in project coprhd-controller by CoprHD.
the class ScaleIORestClientTest method testQuerySDSdetails.
// @Test
public void testQuerySDSdetails() {
List<ScaleIOSDS> result = null;
Map<String, ScaleIOProtectionDomain> pdMap = null;
Map<String, ScaleIOFaultSet> fsMap = null;
Map<String, ScaleIOStoragePool> spMap = null;
try {
result = restClient.queryAllSDS();
pdMap = restClient.getProtectionDomains().stream().collect(Collectors.toMap(ScaleIOProtectionDomain::getId, p -> p));
List<ScaleIOFaultSet> fsList = restClient.queryAllFaultSets();
if (null != fsList) {
fsMap = restClient.queryAllFaultSets().stream().collect(Collectors.toMap(ScaleIOFaultSet::getId, f -> f));
}
spMap = restClient.queryAllStoragePools().stream().collect(Collectors.toMap(ScaleIOStoragePool::getId, s -> s));
for (ScaleIOSDS sds : result) {
List<ScaleIODevice> devices = restClient.getSdsDevices(sds.getId());
String sdsId = sds.getId();
String sdsPort = sds.getPort();
String sdsIp = sds.getIpList().get(0).getIp();
String sdsPd = null;
if (null != pdMap) {
sdsPd = pdMap.get(sds.getProtectionDomainId()).getName();
}
String sdsFs = null;
if (null != fsMap) {
sdsFs = fsMap.get(sds.getFaultSetId()).getName();
}
// Gson gson = new GsonBuilder().setPrettyPrinting().create();
// System.out.println(gson.toJson(sds));
System.out.printf("Sds id : %s port : %s IP: %s PD: %s FS: %s %n", sdsId, sdsPort, sdsIp, sdsPd, sdsFs);
for (ScaleIODevice device : devices) {
String spName = spMap.get(device.getStoragePoolId()).getName();
System.out.printf("\t Storage Pool name: %s device: %s %n", spName, device.getDeviceCurrentPathName());
}
}
} catch (Exception e) {
log.error("Exception: ", e);
}
}
use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOFaultSet in project coprhd-controller by CoprHD.
the class ScaleIORestClientTest method testQueryAllFaultSets.
@Test
public void testQueryAllFaultSets() {
try {
List<ScaleIOFaultSet> result = restClient.queryAllFaultSets();
if (null != result) {
for (ScaleIOFaultSet faultSet : result) {
String faultSetId = faultSet.getId();
String faultSetProtectionDomain = faultSet.getProtectionDomain();
String faultSetName = faultSet.getName();
System.out.printf("Fault Set id : %s name : %s Protection Domain: %s %n", faultSetId, faultSetName, faultSetProtectionDomain);
}
} else {
System.out.println("No Fault Sets to test");
}
} catch (Exception e) {
log.error("Exception: ", e);
Assert.fail();
}
}
Aggregations