use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class DataDomainFileStorageDevice method doDeleteShare.
@Override
public BiosCommandResult doDeleteShare(StorageSystem storage, FileDeviceInputOutput args, SMBFileShare smbFileShare) throws ControllerException {
try {
_log.info("DataDomainFileStorageDevice doDeleteShare: {} - start");
DataDomainClient ddClient = getDataDomainClient(storage);
if (ddClient == null) {
_log.error("doDeleteShare failed, provider unreachable");
String op = "FS share delete";
return BiosCommandResult.createErrorResult(DeviceControllerErrors.datadomain.operationFailedProviderInaccessible(op));
}
URI storagePoolId = args.getFs().getPool();
StoragePool storagePool = _dbClient.queryObject(StoragePool.class, storagePoolId);
SMBShareMap currentShares = args.getFileObjShares();
List<SMBFileShare> sharesToDelete = new ArrayList<SMBFileShare>();
sharesToDelete.add(smbFileShare);
ddDeleteShares(ddClient, storagePool.getNativeId(), currentShares, sharesToDelete);
_log.info("DataDomainFileStorageDevice doDeleteShare {} - complete");
return BiosCommandResult.createSuccessfulResult();
} catch (DataDomainApiException e) {
_log.error("doDeleteShare failed, device error.", e);
return BiosCommandResult.createErrorResult(e);
}
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class ExternalBlockStorageDevice method doCreateClone.
@Override
public void doCreateClone(StorageSystem storageSystem, URI volume, URI clone, Boolean createInactive, TaskCompleter taskCompleter) {
Volume cloneObject = null;
DriverTask task = null;
try {
cloneObject = dbClient.queryObject(Volume.class, clone);
BlockObject sourceVolume = BlockObject.fetch(dbClient, volume);
VolumeClone driverClone = new VolumeClone();
if (sourceVolume instanceof Volume) {
driverClone.setSourceType(VolumeClone.SourceType.VOLUME);
} else if (sourceVolume instanceof BlockSnapshot) {
driverClone.setSourceType(VolumeClone.SourceType.SNAPSHOT);
} else {
cloneObject.setInactive(true);
dbClient.updateObject(cloneObject);
String errorMsg = String.format("doCreateClone -- Failed to create volume clone: unexpected source type %s .", sourceVolume.getClass().getSimpleName());
_log.error(errorMsg);
ServiceError serviceError = ExternalDeviceException.errors.createVolumeCloneFailed("doCreateClone", errorMsg);
taskCompleter.error(dbClient, serviceError);
return;
}
// Prepare driver clone
driverClone.setParentId(sourceVolume.getNativeId());
driverClone.setStorageSystemId(storageSystem.getNativeId());
driverClone.setDisplayName(cloneObject.getLabel());
driverClone.setRequestedCapacity(cloneObject.getCapacity());
driverClone.setThinlyProvisioned(cloneObject.getThinlyProvisioned());
// Call driver
BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
List<VolumeClone> driverClones = new ArrayList<>();
driverClones.add(driverClone);
task = driver.createVolumeClone(Collections.unmodifiableList(driverClones), null);
if (!isTaskInTerminalState(task.getStatus())) {
// If the task is not in a terminal state and will be completed asynchronously
// create a job to monitor the progress of the request and update the clone
// volume and call the completer as appropriate based on the result of the request.
CreateVolumeCloneExternalDeviceJob job = new CreateVolumeCloneExternalDeviceJob(storageSystem.getId(), clone, task.getTaskId(), taskCompleter);
ControllerServiceImpl.enqueueJob(new QueueJob(job));
} else if (task.getStatus() == DriverTask.TaskStatus.READY) {
// Update clone
String msg = String.format("doCreateClone -- Created volume clone: %s .", task.getMessage());
_log.info(msg);
VolumeClone driverCloneResult = driverClones.get(0);
ExternalDeviceUtils.updateNewlyCreatedClone(cloneObject, driverCloneResult, dbClient);
taskCompleter.ready(dbClient);
} else {
cloneObject.setInactive(true);
dbClient.updateObject(cloneObject);
String errorMsg = String.format("doCreateClone -- Failed to create volume clone: %s .", task.getMessage());
_log.error(errorMsg);
ServiceError serviceError = ExternalDeviceException.errors.createVolumeCloneFailed("doCreateClone", errorMsg);
taskCompleter.error(dbClient, serviceError);
}
} catch (Exception e) {
if (cloneObject != null) {
cloneObject.setInactive(true);
dbClient.updateObject(cloneObject);
}
_log.error("Failed to create volume clone. ", e);
ServiceError serviceError = ExternalDeviceException.errors.createVolumeCloneFailed("doCreateClone", e.getMessage());
taskCompleter.error(dbClient, serviceError);
} finally {
try {
if (task == null || isTaskInTerminalState(task.getStatus())) {
StoragePool dbPool = dbClient.queryObject(StoragePool.class, cloneObject.getPool());
updateStoragePoolCapacity(dbPool, storageSystem, Collections.singletonList(clone), dbClient);
}
} catch (Exception ex) {
_log.error("Failed to update storage pool {} after create clone operation completion.", cloneObject.getPool(), ex);
}
}
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class ExternalBlockStorageDevice method doCreateGroupClone.
@Override
public void doCreateGroupClone(StorageSystem storageSystem, List<URI> cloneURIs, Boolean createInactive, TaskCompleter taskCompleter) {
BlockStorageDriver driver = getDriver(storageSystem.getSystemType());
List<VolumeClone> driverClones = new ArrayList<>();
Map<VolumeClone, Volume> driverCloneToCloneMap = new HashMap<>();
Set<URI> consistencyGroups = new HashSet<>();
List<Volume> clones = null;
DriverTask task = null;
try {
clones = dbClient.queryObject(Volume.class, cloneURIs);
// We assume here that all volumes belong to the same consistency group
URI parentUri = clones.get(0).getAssociatedSourceVolume();
Volume parentVolume = dbClient.queryObject(Volume.class, parentUri);
BlockConsistencyGroup cg = null;
if (!NullColumnValueGetter.isNullURI(parentVolume.getConsistencyGroup())) {
cg = dbClient.queryObject(BlockConsistencyGroup.class, parentVolume.getConsistencyGroup());
} else {
String errorMsg = String.format("doCreateGroupClone -- Failed to create group clone, parent volumes do not belong to consistency group." + " Clones: %s .", cloneURIs);
_log.error(errorMsg);
ServiceError serviceError = ExternalDeviceException.errors.createGroupCloneFailed("doCreateGroupClone", errorMsg);
taskCompleter.error(dbClient, serviceError);
return;
}
// Prepare driver consistency group of parent volume
VolumeConsistencyGroup driverCG = new VolumeConsistencyGroup();
driverCG.setDisplayName(cg.getLabel());
driverCG.setNativeId(cg.getNativeId());
driverCG.setStorageSystemId(storageSystem.getNativeId());
// Prepare driver clones
for (Volume clone : clones) {
URI sourceVolumeUri = clone.getAssociatedSourceVolume();
Volume sourceVolume = dbClient.queryObject(Volume.class, sourceVolumeUri);
VolumeClone driverClone = new VolumeClone();
driverClone.setParentId(sourceVolume.getNativeId());
driverClone.setStorageSystemId(storageSystem.getNativeId());
driverClone.setDisplayName(clone.getLabel());
driverClone.setRequestedCapacity(clone.getCapacity());
driverClone.setThinlyProvisioned(clone.getThinlyProvisioned());
driverClones.add(driverClone);
driverCloneToCloneMap.put(driverClone, clone);
}
// Call driver to create group snapshot
task = driver.createConsistencyGroupClone(driverCG, Collections.unmodifiableList(driverClones), null);
if (!isTaskInTerminalState(task.getStatus())) {
// If the task is not in a terminal state and will be completed asynchronously
// create a job to monitor the progress of the request and update the clone
// volume and call the completer as appropriate based on the result of the request.
CreateGroupCloneExternalDeviceJob job = new CreateGroupCloneExternalDeviceJob(storageSystem.getId(), cloneURIs, parentVolume.getConsistencyGroup(), task.getTaskId(), taskCompleter);
ControllerServiceImpl.enqueueJob(new QueueJob(job));
} else if (task.getStatus() == DriverTask.TaskStatus.READY) {
// Update clone object with driver data
String msg = String.format("doCreateGroupClone -- Created group clone: %s .", task.getMessage());
_log.info(msg);
List<Volume> cloneObjects = new ArrayList<>();
for (VolumeClone driverCloneResult : driverClones) {
Volume cloneObject = driverCloneToCloneMap.get(driverCloneResult);
ExternalDeviceUtils.updateNewlyCreatedGroupClone(cloneObject, driverCloneResult, parentVolume.getConsistencyGroup(), dbClient);
cloneObjects.add(cloneObject);
}
dbClient.updateObject(cloneObjects);
taskCompleter.ready(dbClient);
} else {
// Process failure
for (Volume cloneObject : clones) {
cloneObject.setInactive(true);
}
dbClient.updateObject(clones);
String errorMsg = String.format("doCreateGroupClone -- Failed to create group clone: %s .", task.getMessage());
_log.error(errorMsg);
ServiceError serviceError = ExternalDeviceException.errors.createGroupCloneFailed("doCreateGroupClone", errorMsg);
taskCompleter.error(dbClient, serviceError);
}
} catch (Exception e) {
if (clones != null) {
// Process failure
for (Volume cloneObject : clones) {
cloneObject.setInactive(true);
}
dbClient.updateObject(clones);
}
_log.error("Failed to create group clone. ", e);
ServiceError serviceError = ExternalDeviceException.errors.createGroupCloneFailed("doCreateGroupClone", e.getMessage());
taskCompleter.error(dbClient, serviceError);
} finally {
try {
if (task == null || isTaskInTerminalState(task.getStatus())) {
// post process storage pool capacity for clone's pools
// map clones to their storage pool
Map<URI, List<URI>> dbPoolToClone = new HashMap<>();
for (Volume clone : clones) {
URI dbPoolUri = clone.getPool();
List<URI> poolClones = dbPoolToClone.get(dbPoolUri);
if (poolClones == null) {
poolClones = new ArrayList<>();
dbPoolToClone.put(dbPoolUri, poolClones);
}
poolClones.add(clone.getId());
}
for (URI dbPoolUri : dbPoolToClone.keySet()) {
StoragePool dbPool = dbClient.queryObject(StoragePool.class, dbPoolUri);
updateStoragePoolCapacity(dbPool, storageSystem, dbPoolToClone.get(dbPoolUri), dbClient);
}
}
} catch (Exception ex) {
_log.error("Failed to update storage pool after create group clone operation completion.", ex);
}
}
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class XtremIOCommunicationInterface method discoverXtremIOSystem.
private void discoverXtremIOSystem(XtremIOClient restClient, StorageSystem systemInDB) {
try {
List<StoragePool> pools = new ArrayList<StoragePool>();
XtremIOSystem clusterObject = restClient.getClusterDetails(systemInDB.getSerialNumber());
updateStorageSystemAndPools(clusterObject, systemInDB, pools);
Map<String, List<StoragePort>> portMap = discoverPorts(restClient, systemInDB);
List<StoragePort> allPorts = new ArrayList<StoragePort>();
allPorts.addAll(portMap.get(NEW));
allPorts.addAll(portMap.get(EXISTING));
List<StoragePort> notVisiblePorts = DiscoveryUtils.checkStoragePortsNotVisible(allPorts, _dbClient, systemInDB.getId());
List<StoragePort> allExistingPorts = new ArrayList<StoragePort>(portMap.get(EXISTING));
if (notVisiblePorts != null && !notVisiblePorts.isEmpty()) {
allExistingPorts.addAll(notVisiblePorts);
}
StoragePortAssociationHelper.runUpdatePortAssociationsProcess(portMap.get(NEW), allExistingPorts, _dbClient, _coordinator, pools);
discoverInitiators(restClient, systemInDB);
} catch (Exception e) {
_logger.error("Error discovering XtremIO cluster", e);
// throw exception only if system discovery failed.
throw XtremIOApiException.exceptions.discoveryFailed(systemInDB.toString());
}
}
use of com.emc.storageos.db.client.model.StoragePool in project coprhd-controller by CoprHD.
the class UpdtableStoragePoolModel method updateStoragePoolObject.
/**
* update the Storage Pool object with the available data came as part of
* indication.
*
* @return
*/
private boolean updateStoragePoolObject(UpdtableStoragePoolModel spModel) {
Long freeCapacity = spModel.getFreeCapacityInKB();
String poolName = spModel.getPoolName();
Long totalCapacity = spModel.getTotalCapacityInKB();
Long subscribedCapacity = spModel.getSubscribedCapacityInKB();
try {
StoragePool pool = retriveStoragePoolFromDatabase();
if (pool != null) {
boolean isUpdateRequired = Boolean.FALSE;
logMessage("==> Comparing Existing StoregPool Object with Recieved Information :\n freeCapacity: Existing Value [{}] - Recieved Value [{}], \n PoolName: Existing Value [{}] - Recieved Value [{}], \n TotalCapacity: Existing Value [{}] - Recieved Value [{}], \n SubscribedCapacity: Existing Value [{}] - Recieved Value [{}] \n", new Object[] { pool.calculateFreeCapacityWithoutReservations(), freeCapacity, pool.getPoolName(), poolName, pool.getTotalCapacity(), totalCapacity, pool.getSubscribedCapacity(), subscribedCapacity });
if (freeCapacity != null && freeCapacity.longValue() != pool.calculateFreeCapacityWithoutReservations().longValue()) {
logMessage("Updating Free Capacity : from {} to {}", new Object[] { pool.calculateFreeCapacityWithoutReservations(), freeCapacity });
pool.setFreeCapacity(freeCapacity);
isUpdateRequired = true;
}
if (poolName != null && !poolName.equals(pool.getPoolName())) {
logMessage("Updating Pool Name : from {} to {}", new Object[] { pool.getPoolName(), poolName });
pool.setPoolName(poolName);
isUpdateRequired = true;
}
if (totalCapacity != null && totalCapacity.longValue() != pool.getTotalCapacity().longValue()) {
logMessage("Updating Total Capacity : from {} to {}", new Object[] { pool.getTotalCapacity(), totalCapacity });
pool.setTotalCapacity(totalCapacity);
isUpdateRequired = true;
}
if (subscribedCapacity != null && subscribedCapacity.longValue() != pool.getSubscribedCapacity().longValue()) {
logMessage("Updating Subscribed Capacity : from {} to {}", new Object[] { pool.getSubscribedCapacity(), subscribedCapacity });
pool.setSubscribedCapacity(subscribedCapacity);
isUpdateRequired = true;
}
if (isUpdateRequired) {
_dbClient.persistObject(pool);
logMessage("Storage Pool Object Updated", new Object[] {});
}
return isUpdateRequired;
} else {
_logger.debug("Indication not processed as no assosiated Storage Pool Object found");
}
} catch (IOException e) {
_logger.error("Error occured while retriving StoragePool Object for Corresponding Indication {}", e.getMessage());
} catch (NumberFormatException e) {
_logger.error("Error occured while reading capacity data from Corresponding Indication {}", e.getMessage());
}
return Boolean.FALSE;
}
Aggregations