use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOSDS 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.ScaleIOSDS in project coprhd-controller by CoprHD.
the class ScaleIOCommunicationInterface method createStoragePorts.
/**
* Create a StoragePort for each SDS in the ScaleIO instance. These are psuedo-StoragePorts
* for the purpose of tying up the host-end to the storage-end of the Network
*
* @param storageSystem [in] - StorageSystem object (ProtectionDomain)
* @param compatibilityStatus [in] - Compatibility status to use on the ports
* @param network [in] - Network to associate with the ports
* @param queryAllSDSResult [in] - SDS query result
* @param protectionDomainName [in] - Protection Domain name
*/
private List<StoragePort> createStoragePorts(StorageSystem storageSystem, String compatibilityStatus, Network network, List<ScaleIOSDS> allSDSs, String protectionDomainName) throws IOException {
List<StoragePort> ports = new ArrayList<>();
List<String> endpoints = new ArrayList<>();
for (ScaleIOSDS sds : allSDSs) {
String sdsId = sds.getId();
List<IP> ips = sds.getIpList();
String sdsIP = null;
if (ips != null && !ips.isEmpty()) {
sdsIP = ips.get(0).getIp();
}
StoragePort port;
List<StoragePort> results = CustomQueryUtility.queryActiveResourcesByAltId(_dbClient, StoragePort.class, "portNetworkId", sdsId);
if (results == null || results.isEmpty()) {
String nativeGUID = NativeGUIDGenerator.generateNativeGuid(storageSystem, protectionDomainName, NativeGUIDGenerator.ADAPTER);
StorageHADomain adapter = new StorageHADomain();
adapter.setStorageDeviceURI(storageSystem.getId());
adapter.setId(URIUtil.createId(StorageHADomain.class));
adapter.setAdapterName(protectionDomainName);
adapter.setLabel(protectionDomainName);
adapter.setNativeGuid(nativeGUID);
adapter.setNumberofPorts("1");
adapter.setAdapterType(StorageHADomain.HADomainType.FRONTEND.name());
adapter.setInactive(false);
_dbClient.createObject(adapter);
port = new StoragePort();
port.setId(URIUtil.createId(StoragePort.class));
port.setPortNetworkId(sdsId);
port.setLabel(String.format("%s-%s-StoragePort", protectionDomainName, sdsId));
port.setStorageDevice(storageSystem.getId());
port.setCompatibilityStatus(compatibilityStatus);
port.setOperationalStatus(OperationalStatus.OK.name());
port.setIpAddress(sdsIP);
port.setNetwork(network.getId());
port.setPortGroup(sdsId);
port.setPortName(sdsId);
port.setPortType(StoragePort.PortType.frontend.name());
port.setStorageHADomain(adapter.getId());
port.setTransportType(StorageProtocol.Transport.ScaleIO.name());
port.setDiscoveryStatus(DiscoveryStatus.VISIBLE.name());
port.setInactive(false);
_dbClient.createObject(port);
endpoints.add(port.getPortNetworkId());
} else {
port = results.get(0);
}
ports.add(port);
}
network.addEndpoints(endpoints, true);
_dbClient.updateAndReindexObject(network);
return ports;
}
use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOSDS 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.ScaleIOSDS 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());
}
use of com.emc.storageos.scaleio.api.restapi.response.ScaleIOSDS in project coprhd-controller by CoprHD.
the class ScaleIORestClientTest method testQuerySDS.
// @Test
public void testQuerySDS() {
List<ScaleIOSDS> result = null;
try {
result = restClient.queryAllSDS();
for (ScaleIOSDS sds : result) {
String sdsId = sds.getId();
String sdsPort = sds.getPort();
String sdsIp = sds.getIpList().get(0).getIp();
System.out.printf("Sds id : %s port : %s IP: %s %n", sdsId, sdsPort, sdsIp);
}
} catch (Exception e) {
log.error("Exception: ", e);
Assert.fail();
}
}
Aggregations