use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOProtectionDomain 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.ScaleIOProtectionDomain 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.ScaleIOProtectionDomain 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.ScaleIOProtectionDomain in project coprhd-controller by CoprHD.
the class ScaleIOCommunicationInterface method discover.
@Override
public void discover(AccessProfile accessProfile) throws BaseCollectionException {
StorageSystem.CompatibilityStatus compatibilityStatus = StorageSystem.CompatibilityStatus.COMPATIBLE;
StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, accessProfile.getSystemId());
_locker.acquireLock(accessProfile.getIpAddress(), LOCK_WAIT_SECONDS);
log.info("Starting discovery of ScaleIO StorageProvider. IP={} StorageSystem {}", accessProfile.getIpAddress(), storageSystem.getNativeGuid());
String statusMsg = "";
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(_dbClient).getClientHandle(storageSystem);
if (scaleIOHandle != null) {
ScaleIOSystem sioSystem = scaleIOHandle.getSystem();
List<ScaleIOProtectionDomain> protectionDomains = scaleIOHandle.getProtectionDomains();
List<ScaleIOSDC> allSDCs = scaleIOHandle.queryAllSDC();
List<ScaleIOSDS> allSDSs = scaleIOHandle.queryAllSDS();
List<ScaleIOScsiInitiator> allSCSIInitiators = scaleIOHandle.queryAllSCSIInitiators();
List<StoragePort> ports = new ArrayList<>();
List<StoragePool> newPools = new ArrayList<StoragePool>();
List<StoragePool> updatePools = new ArrayList<StoragePool>();
List<StoragePool> allPools = new ArrayList<StoragePool>();
String scaleIOType = StorageSystem.Type.scaleio.name();
String installationId = sioSystem.getInstallId();
String version = sioSystem.getVersion().replaceAll("_", ".");
String minimumSupported = VersionChecker.getMinimumSupportedVersion(StorageSystem.Type.scaleio);
compatibilityStatus = (VersionChecker.verifyVersionDetails(minimumSupported, version) < 0) ? StorageSystem.CompatibilityStatus.INCOMPATIBLE : StorageSystem.CompatibilityStatus.COMPATIBLE;
storageSystem.setFirmwareVersion(version);
storageSystem.setCompatibilityStatus(compatibilityStatus.name());
storageSystem.setReachableStatus(true);
storageSystem.setLabel(storageSystem.getNativeGuid());
for (ScaleIOProtectionDomain protectionDomain : protectionDomains) {
String domainName = protectionDomain.getName();
String id = String.format("%s+%s", installationId, domainName);
String storageSystemNativeGUID = generateNativeGuid(scaleIOType, id);
if (!storageSystemNativeGUID.equals(storageSystem.getNativeGuid())) {
// This is not the ProtectionDomain that we're looking for
continue;
}
String protectionDomainId = protectionDomain.getId();
storageSystem.setSerialNumber(protectionDomainId);
Network network = createNetwork(installationId);
List<ScaleIOSDS> sdsList = new ArrayList<ScaleIOSDS>();
for (ScaleIOSDS sds : allSDSs) {
String pdId = sds.getProtectionDomainId();
if (pdId.equals(protectionDomainId)) {
sdsList.add(sds);
}
}
List<StoragePort> thesePorts = createStoragePorts(storageSystem, compatibilityStatus.name(), network, sdsList, domainName);
ports.addAll(thesePorts);
createHost(network, allSDCs);
boolean hasSCSIInitiators = createSCSIInitiatorsAndStoragePorts(storageSystem, domainName, compatibilityStatus, installationId, allSCSIInitiators, allSDCs, ports);
List<StoragePort> notVisiblePorts = DiscoveryUtils.checkStoragePortsNotVisible(ports, _dbClient, storageSystem.getId());
if (notVisiblePorts != null && !notVisiblePorts.isEmpty()) {
ports.addAll(notVisiblePorts);
}
Set<String> supportedProtocols = (hasSCSIInitiators) ? SCALEIO_AND_ISCSI : SCALEIO_ONLY;
List<ScaleIOStoragePool> storagePools = scaleIOHandle.getProtectionDomainStoragePools(protectionDomainId);
for (ScaleIOStoragePool storagePool : storagePools) {
String poolName = storagePool.getName();
String nativeGuid = String.format("%s-%s-%s", installationId, domainName, poolName);
log.info("Attempting to discover pool {} for ProtectionDomain {}", poolName, domainName);
List<StoragePool> pools = queryActiveResourcesByAltId(_dbClient, StoragePool.class, "nativeGuid", nativeGuid);
StoragePool pool = null;
if (pools.isEmpty()) {
log.info("Pool {} is new", poolName);
pool = new StoragePool();
pool.setId(URIUtil.createId(StoragePool.class));
pool.setStorageDevice(accessProfile.getSystemId());
pool.setPoolServiceType(StoragePool.PoolServiceType.block.toString());
pool.setOperationalStatus(StoragePool.PoolOperationalStatus.READY.name());
pool.setCompatibilityStatus(compatibilityStatus.name());
pool.setThinVolumePreAllocationSupported(false);
pool.addDriveTypes(Collections.singleton(StoragePool.SupportedDriveTypeValues.SATA.name()));
StringSet copyTypes = new StringSet();
copyTypes.add(StoragePool.CopyTypes.ASYNC.name());
copyTypes.add(StoragePool.CopyTypes.UNSYNC_UNASSOC.name());
pool.setSupportedCopyTypes(copyTypes);
pool.setMaximumThickVolumeSize(1048576L);
pool.setMinimumThickVolumeSize(1L);
newPools.add(pool);
} else if (pools.size() == 1) {
log.info("Pool {} was previously discovered", storagePool);
pool = pools.get(0);
updatePools.add(pool);
} else {
log.warn(String.format("There are %d StoragePools with nativeGuid = %s", pools.size(), nativeGuid));
continue;
}
pool.setPoolName(poolName);
pool.setNativeId(storagePool.getId());
pool.setNativeGuid(nativeGuid);
String availableCapacityString = storagePool.getCapacityAvailableForVolumeAllocationInKb();
pool.setFreeCapacity(Long.parseLong(availableCapacityString));
String totalCapacityString = storagePool.getMaxCapacityInKb();
pool.setTotalCapacity(Long.parseLong(totalCapacityString));
pool.addProtocols(supportedProtocols);
pool.setSupportedResourceTypes(StoragePool.SupportedResourceTypes.THIN_AND_THICK.name());
Long maxThinSize = 1048576L;
Long minThinSize = 1L;
pool.setMaximumThinVolumeSize(maxThinSize);
pool.setMinimumThinVolumeSize(minThinSize);
pool.setInactive(false);
pool.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
}
}
log.info(String.format("For StorageSystem %s, discovered %d new pools and %d pools to update", storageSystem.getNativeGuid(), newPools.size(), updatePools.size()));
StoragePoolAssociationHelper.setStoragePoolVarrays(storageSystem.getId(), newPools, _dbClient);
allPools.addAll(newPools);
allPools.addAll(updatePools);
_dbClient.createObject(newPools);
_dbClient.updateAndReindexObject(updatePools);
List<StoragePool> notVisiblePools = DiscoveryUtils.checkStoragePoolsNotVisible(allPools, _dbClient, storageSystem.getId());
if (notVisiblePools != null && !notVisiblePools.isEmpty()) {
allPools.addAll(notVisiblePools);
}
StoragePortAssociationHelper.runUpdatePortAssociationsProcess(ports, null, _dbClient, _coordinator, allPools);
statusMsg = String.format("Discovery completed successfully for Storage System: %s", storageSystem.getNativeGuid());
}
} catch (Exception e) {
storageSystem.setReachableStatus(false);
log.error(String.format("Exception was encountered when attempting to discover ScaleIO Instance %s", accessProfile.getIpAddress()), e);
statusMsg = String.format("Discovery failed because %s", e.getLocalizedMessage());
throw ScaleIOException.exceptions.discoveryFailed(e);
} finally {
_locker.releaseLock(accessProfile.getIpAddress());
if (storageSystem != null) {
storageSystem.setLastDiscoveryStatusMessage(statusMsg);
}
}
_dbClient.updateAndReindexObject(storageSystem);
log.info("Completed of ScaleIO StorageProvider. IP={} StorageSystem {}", accessProfile.getIpAddress(), storageSystem.getNativeGuid());
}
Aggregations