use of com.emc.storageos.scaleio.api.restapi.ScaleIORestClient in project coprhd-controller by CoprHD.
the class ScaleIOHandleFactory method getClientHandle.
public ScaleIORestClient getClientHandle(StorageProvider provider) throws Exception {
ScaleIORestClient handle = null;
synchronized (syncObject) {
String providerId = provider.getProviderID();
handle = ScaleIORestClientMap.get(providerId);
handle = getHandle(handle, provider);
}
return handle;
}
use of com.emc.storageos.scaleio.api.restapi.ScaleIORestClient in project coprhd-controller by CoprHD.
the class ScaleIOHandleFactory method getHandle.
private ScaleIORestClient getHandle(ScaleIORestClient handle, StorageProvider provider) throws Exception {
if (StorageProvider.InterfaceType.scaleioapi.name().equals(provider.getInterfaceType())) {
if (handle == null) {
URI baseURI = URI.create(ScaleIOConstants.getAPIBaseURI(provider.getIPAddress(), provider.getPortNumber()));
handle = (ScaleIORestClient) scaleIORestClientFactory.getRESTClient(baseURI, provider.getUserName(), provider.getPassword(), true);
ScaleIORestClient client = (ScaleIORestClient) handle;
ScaleIORestClientMap.put(provider.getProviderID(), client);
}
ScaleIORestClient client = (ScaleIORestClient) handle;
if (!Strings.isNullOrEmpty(provider.getUserName())) {
client.setUsername(provider.getUserName());
}
if (!Strings.isNullOrEmpty(provider.getPassword())) {
client.setPassword(provider.getPassword());
}
} else {
log.info("The storage provider interface type is not supported: {} ", provider.getInterfaceType());
// not supported
handle = null;
}
return handle;
}
use of com.emc.storageos.scaleio.api.restapi.ScaleIORestClient in project coprhd-controller by CoprHD.
the class ScaleIOSnapshotOperations method deleteSingleVolumeSnapshot.
@Override
public void deleteSingleVolumeSnapshot(StorageSystem storage, URI snapshot, TaskCompleter taskCompleter) throws DeviceControllerException {
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
BlockSnapshot blockSnapshot = dbClient.queryObject(BlockSnapshot.class, snapshot);
if (blockSnapshot != null && !blockSnapshot.getInactive() && // state against the BlockSnapshot object can be set.
!Strings.isNullOrEmpty(blockSnapshot.getNativeId())) {
scaleIOHandle.removeVolume(blockSnapshot.getNativeId());
}
if (blockSnapshot != null) {
blockSnapshot.setInactive(true);
dbClient.updateObject(blockSnapshot);
ScaleIOHelper.updateStoragePoolCapacity(dbClient, scaleIOHandle, blockSnapshot);
}
taskCompleter.ready(dbClient);
} catch (Exception e) {
log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("deleteSingleVolumeSnapshot", 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 unmapVolumes.
/**
* Given a mapping of volumes and initiators, make the ScaleIO API calls to un-map the volume
* to the specified ScaleIO initiators
*
* @param storage
* [in] - StorageSystem object (ScaleIO array abstraction)
* @param volumeURIs
* [in] - Collection of Volume URIs
* @param initiators
* [in] - Collection of Initiator objects
* @param completer
* [in] - TaskCompleter
*/
private void unmapVolumes(StorageSystem storage, Collection<URI> volumeURIs, Collection<Initiator> initiators, TaskCompleter completer) {
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
for (URI volumeURI : volumeURIs) {
BlockObject blockObject = BlockObject.fetch(dbClient, volumeURI);
if (blockObject == null || blockObject.getInactive()) {
log.warn(String.format("Attempted to unmap BlockObject %s, which was either not found in the DB or was inactive", volumeURI.toString()));
continue;
}
String nativeId = blockObject.getNativeId();
for (Initiator initiator : initiators) {
String port = initiator.getInitiatorPort();
boolean wasUnMapped = false;
if (initiator.getProtocol().equals(HostInterface.Protocol.ScaleIO.name())) {
wasUnMapped = unmapFromSDC(scaleIOHandle, nativeId, port, completer);
} else if (initiator.getProtocol().equals(HostInterface.Protocol.iSCSI.name())) {
wasUnMapped = unmapFromSCSI(scaleIOHandle, nativeId, port, initiator.getLabel(), completer);
} else {
ServiceCoded code = DeviceControllerErrors.scaleio.unmapVolumeToClientFailed(nativeId, port, String.format("Unexpected initiator type %s", initiator.getProtocol()));
completer.error(dbClient, code);
}
if (!wasUnMapped) {
// Failed to map the volume
return;
}
}
}
completer.ready(dbClient);
} catch (Exception e) {
log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("unmapVolume", 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 doExpandVolume.
@Override
public void doExpandVolume(StorageSystem storage, StoragePool pool, Volume volume, Long size, TaskCompleter taskCompleter) throws DeviceControllerException {
Long volumeSize = size / ScaleIOHelper.BYTES_IN_GB;
Long expandSize = volumeSize;
// ScaleIO volume size has to be granularity of 8
long remainder = volumeSize % 8;
if (remainder != 0) {
expandSize += (8 - remainder);
log.info("The requested size is {} GB, increase it to {} GB, so that it is granularity of 8", volumeSize, expandSize);
}
try {
ScaleIORestClient scaleIOHandle = scaleIOHandleFactory.using(dbClient).getClientHandle(storage);
ScaleIOVolume result = scaleIOHandle.modifyVolumeCapacity(volume.getNativeId(), expandSize.toString());
long newSize = Long.parseLong(result.getSizeInKb()) * 1024L;
volume.setProvisionedCapacity(newSize);
volume.setAllocatedCapacity(newSize);
volume.setCapacity(size);
dbClient.persistObject(volume);
ScaleIOHelper.updateStoragePoolCapacity(dbClient, scaleIOHandle, pool, storage);
pool.removeReservedCapacityForVolumes(Arrays.asList(volume.getId().toString()));
taskCompleter.ready(dbClient);
} catch (Exception e) {
log.error("Encountered an exception", e);
ServiceCoded code = DeviceControllerErrors.scaleio.encounteredAnExceptionFromScaleIOOperation("expandVolume", e.getMessage());
taskCompleter.error(dbClient, code);
}
}
Aggregations