use of com.emc.storageos.scaleio.api.restapi.ScaleIORestClient in project coprhd-controller by CoprHD.
the class ScaleIOStorageDevice method doDeleteVolumes.
@Override
public void doDeleteVolumes(StorageSystem storageSystem, String opId, List<Volume> volumes, TaskCompleter completer) throws DeviceControllerException {
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storageSystem);
Set<URI> poolsToUpdate = new HashSet<>();
for (Volume volume : volumes) {
scaleIOHandle.removeVolume(volume.getNativeId());
volume.setInactive(true);
poolsToUpdate.add(volume.getPool());
if (!NullColumnValueGetter.isNullURI(volume.getConsistencyGroup())) {
volume.setConsistencyGroup(NullColumnValueGetter.getNullURI());
}
}
dbClient.persistObject(volumes);
List<StoragePool> pools = dbClient.queryObject(StoragePool.class, Lists.newArrayList(poolsToUpdate));
for (StoragePool pool : pools) {
ScaleIOHelper.updateStoragePoolCapacity(dbClient, scaleIOHandle, pool, storageSystem);
}
completer.ready(dbClient);
} catch (Exception e) {
log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("deleteVolume", e.getMessage());
completer.error(dbClient, code);
}
}
use of com.emc.storageos.scaleio.api.restapi.ScaleIORestClient in project coprhd-controller by CoprHD.
the class ScaleIOStorageDevice method mapVolumes.
/**
* Given a mapping of volumes and initiators, make the ScaleIO API calls to map the volume
* to the specified ScaleIO initiators
*
* @param storage
* [in] - StorageSystem object (ScaleIO array abstraction)
* @param volumeMap
* [in] - Volume URI to Integer LUN map
* @param initiators
* [in] - Collection of Initiator objects
* @param completer
* [in] - TaskCompleter
*/
private void mapVolumes(StorageSystem storage, Map<URI, Integer> volumeMap, Collection<Initiator> initiators, TaskCompleter completer) {
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
for (Map.Entry<URI, Integer> volMapEntry : volumeMap.entrySet()) {
BlockObject blockObject = BlockObject.fetch(dbClient, volMapEntry.getKey());
String nativeId = blockObject.getNativeId();
for (Initiator initiator : initiators) {
String port = initiator.getInitiatorPort();
boolean wasMapped = false;
if (initiator.getProtocol().equals(HostInterface.Protocol.ScaleIO.name())) {
wasMapped = mapToSDC(scaleIOHandle, nativeId, port, completer);
} else if (initiator.getProtocol().equals(HostInterface.Protocol.iSCSI.name())) {
wasMapped = mapToSCSI(scaleIOHandle, nativeId, port, initiator.getLabel(), completer);
} else {
ServiceCoded code = DeviceControllerErrors.scaleio.mapVolumeToClientFailed(nativeId, port, String.format("Unexpected initiator type %s", initiator.getProtocol()));
completer.error(dbClient, code);
}
if (!wasMapped) {
// Failed to map the volume
return;
}
}
}
completer.ready(dbClient);
} catch (Exception e) {
log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("mapVolume", e.getMessage());
completer.error(dbClient, code);
}
}
use of com.emc.storageos.scaleio.api.restapi.ScaleIORestClient in project coprhd-controller by CoprHD.
the class ScaleIOStorageDevice method doCreateVolumes.
@Override
public void doCreateVolumes(StorageSystem storage, StoragePool storagePool, String opId, List<Volume> volumes, VirtualPoolCapabilityValuesWrapper capabilities, TaskCompleter taskCompleter) throws DeviceControllerException {
int index = 1;
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
String protectionDomainName = storage.getSerialNumber();
Long volumeSize = capabilities.getSize() / ScaleIOHelper.BYTES_IN_GB;
int count = volumes.size();
Set<URI> poolsToUpdate = new HashSet<>();
boolean thinlyProvisioned = capabilities.getThinProvisioning();
Set<URI> consistencyGroups = new HashSet<>();
Multimap<URI, String> poolToVolumesMap = ArrayListMultimap.create();
String systemId = scaleIOHandle.getSystemId();
for (; index <= count; index++) {
Volume volume = volumes.get(index - 1);
Long size = capabilities.getSize();
String poolId = storagePool.getNativeId();
ScaleIOVolume result = scaleIOHandle.addVolume(protectionDomainName, poolId, volume.getLabel(), size.toString(), thinlyProvisioned);
ScaleIOHelper.updateVolumeWithAddVolumeInfo(dbClient, volume, systemId, volumeSize, result);
poolsToUpdate.add(volume.getPool());
if (!NullColumnValueGetter.isNullURI(volume.getConsistencyGroup())) {
consistencyGroups.add(volume.getConsistencyGroup());
}
poolToVolumesMap.put(volume.getPool(), volume.getId().toString());
}
updateConsistencyGroupsWithStorageSystem(consistencyGroups, storage);
List<StoragePool> pools = dbClient.queryObject(StoragePool.class, Lists.newArrayList(poolsToUpdate));
for (StoragePool pool : pools) {
pool.removeReservedCapacityForVolumes(poolToVolumesMap.get(pool.getId()));
ScaleIOHelper.updateStoragePoolCapacity(dbClient, scaleIOHandle, pool, storage);
}
dbClient.persistObject(volumes);
taskCompleter.ready(dbClient);
} catch (Exception e) {
log.error("Encountered an exception", e);
for (int cleanup = index; cleanup <= volumes.size(); cleanup++) {
volumes.get(cleanup - 1).setInactive(true);
}
dbClient.persistObject(volumes);
ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("addVolume", e.getMessage());
taskCompleter.error(dbClient, code);
}
}
Aggregations