use of com.emc.storageos.scaleio.api.restapi.ScaleIORestClient in project coprhd-controller by CoprHD.
the class ScaleIOSnapshotOperations method createGroupSnapshots.
@Override
public void createGroupSnapshots(StorageSystem storage, List<URI> snapshotList, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
List<BlockSnapshot> blockSnapshots = dbClient.queryObject(BlockSnapshot.class, snapshotList);
Map<String, String> parent2snap = new HashMap<>();
Set<URI> poolsToUpdate = new HashSet<>();
for (BlockSnapshot blockSnapshot : blockSnapshots) {
Volume parent = dbClient.queryObject(Volume.class, blockSnapshot.getParent().getURI());
parent2snap.put(parent.getNativeId(), blockSnapshot.getLabel());
poolsToUpdate.add(parent.getPool());
}
String systemId = scaleIOHandle.getSystemId();
ScaleIOSnapshotVolumeResponse result = scaleIOHandle.snapshotMultiVolume(parent2snap, systemId);
List<String> nativeIds = result.getVolumeIdList();
Map<String, String> snapNameIdMap = scaleIOHandle.getVolumes(nativeIds);
ScaleIOHelper.updateSnapshotsWithSnapshotMultiVolumeResult(dbClient, blockSnapshots, systemId, snapNameIdMap, result.getSnapshotGroupId(), storage);
dbClient.persistObject(blockSnapshots);
List<StoragePool> pools = dbClient.queryObject(StoragePool.class, Lists.newArrayList(poolsToUpdate));
for (StoragePool pool : pools) {
ScaleIOHelper.updateStoragePoolCapacity(dbClient, scaleIOHandle, pool, storage);
}
taskCompleter.ready(dbClient);
} catch (Exception e) {
log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("createGroupVolumeSnapshot", e.getMessage());
taskCompleter.error(dbClient, code);
}
}
use of com.emc.storageos.scaleio.api.restapi.ScaleIORestClient in project coprhd-controller by CoprHD.
the class ScaleIOSnapshotOperations method deleteGroupSnapshots.
@Override
public void deleteGroupSnapshots(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
BlockSnapshot blockSnapshot = dbClient.queryObject(BlockSnapshot.class, snapshot);
Set<URI> poolsToUpdate = new HashSet<>();
scaleIOHandle.removeConsistencyGroupSnapshot(blockSnapshot.getSnapsetLabel());
List<BlockSnapshot> groupSnapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(blockSnapshot, dbClient);
for (BlockSnapshot groupSnapshot : groupSnapshots) {
Volume parent = dbClient.queryObject(Volume.class, groupSnapshot.getParent().getURI());
poolsToUpdate.add(parent.getPool());
groupSnapshot.setInactive(true);
}
dbClient.updateObject(groupSnapshots);
List<StoragePool> pools = dbClient.queryObject(StoragePool.class, Lists.newArrayList(poolsToUpdate));
for (StoragePool pool : pools) {
ScaleIOHelper.updateStoragePoolCapacity(dbClient, scaleIOHandle, pool, storage);
}
taskCompleter.ready(dbClient);
} catch (Exception e) {
log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("deleteGroupSnapshots", e.getMessage());
taskCompleter.error(dbClient, code);
}
}
use of com.emc.storageos.scaleio.api.restapi.ScaleIORestClient in project coprhd-controller by CoprHD.
the class ScaleIOSnapshotOperations method createSingleVolumeSnapshot.
@Override
public void createSingleVolumeSnapshot(StorageSystem storage, URI snapshot, Boolean createInactive, Boolean readOnly, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
BlockSnapshot blockSnapshot = dbClient.queryObject(BlockSnapshot.class, snapshot);
Volume parent = dbClient.queryObject(Volume.class, blockSnapshot.getParent().getURI());
String systemId = scaleIOHandle.getSystemId();
ScaleIOSnapshotVolumeResponse result = scaleIOHandle.snapshotVolume(parent.getNativeId(), blockSnapshot.getLabel(), systemId);
String nativeId = result.getVolumeIdList().get(0);
ScaleIOHelper.updateSnapshotWithSnapshotVolumeResult(dbClient, blockSnapshot, systemId, nativeId, storage);
dbClient.persistObject(blockSnapshot);
ScaleIOHelper.updateStoragePoolCapacity(dbClient, scaleIOHandle, blockSnapshot);
taskCompleter.ready(dbClient);
} catch (Exception e) {
log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("createSingleVolumeSnapshot", e.getMessage());
taskCompleter.error(dbClient, code);
}
}
use of com.emc.storageos.scaleio.api.restapi.ScaleIORestClient in project coprhd-controller by CoprHD.
the class ScaleIOStorageDevice method refreshConnectionStatusForAllSIOProviders.
/**
* Refresh connection status for all ScaleIO providers.
*
* @return A list of providers whose connections were successful.
*/
public List<URI> refreshConnectionStatusForAllSIOProviders() {
log.info("Refreshing connection statuses for ScaleIO providers");
List<URI> activeProviders = Lists.newArrayList();
List<StorageProvider> providers = CustomQueryUtility.getActiveStorageProvidersByInterfaceType(dbClient, StorageProvider.InterfaceType.scaleioapi.name());
for (StorageProvider provider : providers) {
try {
// Flag for success/failure
boolean success = false;
// Prepare to try secondary IPs if necessary
StringSet secondaryIps = provider.getSecondaryIps();
Iterator<String> iterator = secondaryIps.iterator();
// Cache the current IP address
String currentIPAddress = provider.getIPAddress();
String nextIp = null;
do {
try {
ScaleIORestClient handle = scaleIOHandleFactory.using(dbClient).getClientHandle(provider);
// Ignore the result on success, otherwise catch the exception
handle.getSystem();
log.info("Successfully connected to ScaleIO MDM {}: {}", provider.getIPAddress(), provider.getId());
success = true;
break;
} catch (Exception e) {
log.error(String.format("Failed to connect to ScaleIO MDM %s: %s", provider.getIPAddress(), provider.getId()), e);
if (iterator.hasNext()) {
nextIp = iterator.next();
log.info("Attempting connection to potential new Primary MDM {}: {}", nextIp, provider.getId());
provider.setIPAddress(nextIp);
} else {
log.warn("Exhausted list of secondary IPs for ScaleIO provider: {}", provider.getId());
nextIp = null;
}
}
} while (// while we have more IPs to try
nextIp != null);
if (success) {
// Update secondary IP addresses if we switched over
if (!provider.getIPAddress().equalsIgnoreCase(currentIPAddress)) {
StringSet newSecondaryIps = new StringSet();
// Copy old secondary list
newSecondaryIps.addAll(secondaryIps);
// Remove the new primary IP
newSecondaryIps.remove(provider.getIPAddress());
// Add the old primary IP
newSecondaryIps.add(currentIPAddress);
// TODO Improve how we update the StringSet based on infra team suggestions
provider.setSecondaryIps(newSecondaryIps);
}
activeProviders.add(provider.getId());
provider.setConnectionStatus(StorageProvider.ConnectionStatus.CONNECTED.toString());
} else {
provider.setIPAddress(currentIPAddress);
provider.setConnectionStatus(StorageProvider.ConnectionStatus.NOTCONNECTED.toString());
}
} finally {
dbClient.persistObject(provider);
}
}
return activeProviders;
}
use of com.emc.storageos.scaleio.api.restapi.ScaleIORestClient 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