use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOSystem 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.ScaleIOSystem in project coprhd-controller by CoprHD.
the class ScaleIOCommunicationInterface method scan.
@Override
public void scan(AccessProfile accessProfile) throws BaseCollectionException {
log.info("Starting scan of ScaleIO StorageProvider. IP={}", accessProfile.getIpAddress());
StorageProvider.ConnectionStatus cxnStatus = StorageProvider.ConnectionStatus.CONNECTED;
StorageProvider provider = _dbClient.queryObject(StorageProvider.class, accessProfile.getSystemId());
if (provider.getInterfaceType().equalsIgnoreCase(DiscoveredDataObject.Type.scaleio.name())) {
provider.setConnectionStatus(StorageProvider.ConnectionStatus.NOTCONNECTED.name());
ScaleIOException ex = ScaleIOException.exceptions.scaleioCliNotSupported();
provider.setLastScanStatusMessage(ex.getLocalizedMessage());
_dbClient.persistObject(provider);
throw ScaleIOException.exceptions.scaleioCliNotSupported();
}
_locker.acquireLock(accessProfile.getIpAddress(), LOCK_WAIT_SECONDS);
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(_dbClient).getClientHandle(provider);
if (scaleIOHandle != null) {
Map<String, StorageSystemViewObject> storageSystemsCache = accessProfile.getCache();
ScaleIOSystem sioSystem = scaleIOHandle.getSystem();
String[] ipList = null;
if (sioSystem.getVersion().substring(0, 1).compareTo("2") >= 0) {
Slaves[] slaves = sioSystem.getMdmCluster().getSlaves();
if ((slaves.length > 0))
ipList = new String[slaves.length];
for (int iterInd = 0; iterInd < slaves.length; iterInd++) {
ipList[iterInd] = slaves[iterInd].getIps()[0];
}
} else {
ipList = sioSystem.getSecondaryMdmActorIpList();
}
if (ipList != null && ipList.length > 0) {
StringSet secondaryIps = new StringSet();
secondaryIps.add(ipList[0]);
provider.setSecondaryIps(secondaryIps);
}
String scaleIOType = StorageSystem.Type.scaleio.name();
String installationId = sioSystem.getInstallId();
String version = sioSystem.getVersion().replaceAll("_", ".");
String minimumSupported = VersionChecker.getMinimumSupportedVersion(StorageSystem.Type.scaleio);
String compatibility = (VersionChecker.verifyVersionDetails(minimumSupported, version) < 0) ? StorageSystem.CompatibilityStatus.INCOMPATIBLE.name() : StorageSystem.CompatibilityStatus.COMPATIBLE.name();
provider.setCompatibilityStatus(compatibility);
provider.setVersionString(version);
List<ScaleIOProtectionDomain> protectionDomains = scaleIOHandle.getProtectionDomains();
for (ScaleIOProtectionDomain protectionDomain : protectionDomains) {
log.info("For ScaleIO instance {}, found ProtectionDomain {}", installationId, protectionDomain.getName());
String id = String.format("%s+%s", installationId, protectionDomain.getName());
String nativeGuid = generateNativeGuid(scaleIOType, id);
StorageSystemViewObject viewObject = storageSystemsCache.get(nativeGuid);
if (viewObject == null) {
viewObject = new StorageSystemViewObject();
}
viewObject.setDeviceType(scaleIOType);
viewObject.addprovider(accessProfile.getSystemId().toString());
viewObject.setProperty(StorageSystemViewObject.MODEL, "ScaleIO ECS");
viewObject.setProperty(StorageSystemViewObject.SERIAL_NUMBER, id);
storageSystemsCache.put(nativeGuid, viewObject);
}
}
} catch (Exception e) {
cxnStatus = StorageProvider.ConnectionStatus.NOTCONNECTED;
log.error(String.format("Exception was encountered when attempting to scan ScaleIO Instance %s", accessProfile.getIpAddress()), e);
throw ScaleIOException.exceptions.scanFailed(e);
} finally {
provider.setConnectionStatus(cxnStatus.name());
_dbClient.persistObject(provider);
log.info("Completed scan of ScaleIO StorageProvider. IP={}", accessProfile.getIpAddress());
_locker.releaseLock(accessProfile.getIpAddress());
}
}
use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOSystem in project coprhd-controller by CoprHD.
the class ScaleIORestClient method getVersion.
/**
* Get the system version
*
* @return The version
*/
public String getVersion() {
String result = null;
try {
ScaleIOSystem system = getSystem();
result = system.getVersion();
} catch (Exception e) {
log.error("Exception while getting version", e);
}
return result;
}
use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOSystem in project coprhd-controller by CoprHD.
the class ScaleIORestClientTest method testQuerySystemName.
@Test
public void testQuerySystemName() {
try {
ScaleIOSystem result = restClient.getSystem();
System.out.println("ScaleIO System Name " + result.getName());
System.out.println("ScaleIO Primary MDM IPs ");
for (String ip : result.getMdmCluster().getMaster().getManagementIPs()) {
System.out.println(ip);
}
} catch (Exception e) {
log.error("Exception: ", e);
Assert.fail();
}
}
use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOSystem in project coprhd-controller by CoprHD.
the class ScaleIORestClient method getSystem.
/**
* Get the system
*
* @return The details of the system
* @throws Exception
*/
public ScaleIOSystem getSystem() throws JSONException {
ClientResponse response = get(URI.create(ScaleIOConstants.GET_SYSTEMS_URI));
List<ScaleIOSystem> systemsInfo = getResponseObjects(ScaleIOSystem.class, response);
return systemsInfo.get(0);
}
Aggregations