use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.
the class CreateVolumeCloneSimulatorOperation method getSuccessMessage.
@SuppressWarnings("unchecked")
@Override
public String getSuccessMessage(Object... args) {
List<VolumeClone> clones;
if ((args != null) && (args.length > 0)) {
clones = (List<VolumeClone>) args[0];
} else {
// Must be asynchronous, so updated clones are in the task.
CreateVolumeCloneDriverTask createCloneTask = (CreateVolumeCloneDriverTask) _task;
clones = createCloneTask.getClones();
}
return String.format("StorageDriver: createVolumeClone information for storage system %s, clone nativeIds %s - end", clones.get(0).getStorageSystemId(), clones.toString());
}
use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.
the class RestoreFromCloneSimulatorOperation method getSuccessMessage.
@SuppressWarnings("unchecked")
@Override
public String getSuccessMessage(Object... args) {
List<VolumeClone> clones;
if ((args != null) && (args.length > 0)) {
clones = (List<VolumeClone>) args[0];
} else {
// Must be asynchronous, so updated clones are in the task.
RestoreFromCloneDriverTask restoreCloneTask = (RestoreFromCloneDriverTask) _task;
clones = restoreCloneTask.getClones();
}
return String.format("StorageDriver: restoreFromClone : clones %s", clones.toString());
}
use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.
the class ExternalDeviceUnManagedVolumeDiscoverer method processUnManagedClones.
/**
* Process clones of unManaged volume.
* Check if unManaged clone should be created and create unManaged volume instance for a clone in such a case.
* Add unManaged clone to parent volume CG if needed and update the clone with parent volume CG information.
* Gets export information for clones and stores it in the provided map.
*
* @param driverVolume driver volume for clone parent volume. [IN]
* @param unManagedParentVolume unManaged parent volume [IN/OUT]
* @param storageSystem storage system [IN]
* @param storagePool storage pool [IN]
* @param unManagedVolumesToCreate list of unmanaged volumes to create [OUT]
* @param unManagedVolumesToUpdate list of unmanaged volumes to update [OUT]
* @param allCurrentUnManagedCgURIs set of unManaged CG uris found in the current discovery [OUT]
* @param unManagedCGToUpdateMap map of unManaged CG GUID to unManaged CG instance [IN/OUT]
* @param unManagedVolumeNativeIdToUriMap map of unmanaged volumes nativeId to their uri [OUT]
* @param hostToUnManagedVolumeExportInfoMap map with export data for unmanaged volumes (including snaps and clones)
* @param driver storage driver [IN]
* @param dbClient reference to db client [IN]
* @return set of URIs for unmanaged clones
* @throws Exception
*/
private Set<URI> processUnManagedClones(StorageVolume driverVolume, UnManagedVolume unManagedParentVolume, com.emc.storageos.db.client.model.StorageSystem storageSystem, com.emc.storageos.db.client.model.StoragePool storagePool, List<UnManagedVolume> unManagedVolumesToCreate, List<UnManagedVolume> unManagedVolumesToUpdate, Set<URI> allCurrentUnManagedCgURIs, Map<String, UnManagedConsistencyGroup> unManagedCGToUpdateMap, Map<String, URI> unManagedVolumeNativeIdToUriMap, Map<String, List<HostExportInfo>> hostToUnManagedVolumeExportInfoMap, BlockStorageDriver driver, DbClient dbClient) throws Exception {
log.info("Processing clones for volume {} ", unManagedParentVolume.getNativeGuid());
Set<URI> cloneUris = new HashSet<>();
List<VolumeClone> driverClones = driver.getVolumeClones(driverVolume);
if (driverClones == null || driverClones.isEmpty()) {
log.info("There are no clones for volume {} ", unManagedParentVolume.getNativeGuid());
} else {
log.info("Clones for unManaged volume {}:" + Joiner.on("\t").join(driverClones), unManagedParentVolume.getNativeGuid());
StringSet unManagedClones = new StringSet();
for (VolumeClone driverClone : driverClones) {
String managedCloneNativeGuid = NativeGUIDGenerator.generateNativeGuidForVolumeOrBlockSnapShot(storageSystem.getNativeGuid(), driverClone.getNativeId());
Volume systemClone = DiscoveryUtils.checkStorageVolumeExistsInDB(dbClient, managedCloneNativeGuid);
if (null != systemClone) {
log.info("Skipping clone {} as it is already managed by the system.", managedCloneNativeGuid);
continue;
}
String unManagedCloneNatvieGuid = NativeGUIDGenerator.generateNativeGuidForPreExistingVolume(storageSystem.getNativeGuid(), driverClone.getNativeId());
UnManagedVolume unManagedClone = createUnManagedClone(driverClone, unManagedParentVolume, storageSystem, storagePool, unManagedVolumesToCreate, unManagedVolumesToUpdate, dbClient);
cloneUris.add(unManagedClone.getId());
unManagedClones.add(unManagedCloneNatvieGuid);
// Check if this clone is for a volume in consistency group on device.
String isParentVolumeInCG = unManagedParentVolume.getVolumeCharacterstics().get(UnManagedVolume.SupportedVolumeCharacterstics.IS_VOLUME_ADDED_TO_CONSISTENCYGROUP.toString());
if (isParentVolumeInCG.equals(Boolean.TRUE.toString())) {
log.info("Clone {} is for volume in CG. ", managedCloneNativeGuid);
// add clone to parent volume unManaged consistency group, update clone with parent volume CG information.
addObjectToUnManagedConsistencyGroup(storageSystem, driverVolume.getConsistencyGroup(), unManagedClone, allCurrentUnManagedCgURIs, unManagedCGToUpdateMap, driver, dbClient);
}
// get export data for the clone
unManagedVolumeNativeIdToUriMap.put(driverClone.getNativeId(), unManagedClone.getId());
getCloneExportInfo(driver, driverClone, hostToUnManagedVolumeExportInfoMap);
}
if (!unManagedClones.isEmpty()) {
// set the HAS_REPLICAS property
unManagedParentVolume.getVolumeCharacterstics().put(UnManagedVolume.SupportedVolumeCharacterstics.HAS_REPLICAS.toString(), TRUE);
StringSetMap unManagedVolumeInformation = unManagedParentVolume.getVolumeInformation();
log.info("New unManaged clones for unManaged volume {}:" + Joiner.on("\t").join(unManagedClones), unManagedParentVolume.getNativeGuid());
if (unManagedVolumeInformation.containsKey(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString())) {
log.info("Old unManaged clones for unManaged volume {}:" + Joiner.on("\t").join(unManagedVolumeInformation.get(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString())), unManagedParentVolume.getNativeGuid());
// replace with new StringSet
unManagedVolumeInformation.get(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString()).replace(unManagedClones);
log.info("Replaced clones :" + Joiner.on("\t").join(unManagedVolumeInformation.get(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString())));
} else {
unManagedVolumeInformation.put(UnManagedVolume.SupportedVolumeInformation.FULL_COPIES.toString(), unManagedClones);
}
} else {
log.info("All clones for volume {} are already managed.", unManagedParentVolume.getNativeGuid());
}
}
return cloneUris;
}
use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.
the class CreateGroupCloneExternalDeviceJob method doTaskSucceeded.
/**
* {@inheritDoc}
*/
@Override
protected void doTaskSucceeded(DriverTask driverTask, DbClient dbClient) throws Exception {
s_logger.info(String.format("Successfully created group clone: %s", driverTask.getMessage()));
// Update the ViPR volumes representing the clone with the
// corresponding driver clone.
List<Volume> updatedVolumes = new ArrayList<>();
for (URI volumeURI : _volumeURIs) {
Volume volume = dbClient.queryObject(Volume.class, volumeURI);
if (volume == null) {
s_logger.error(String.format("Failed to find volume %s", volumeURI));
throw DeviceControllerException.exceptions.objectNotFound(volumeURI);
}
// Update the ViPR clone with the driver clone information.
CreateGroupCloneDriverTask createCloneDriverTask = (CreateGroupCloneDriverTask) driverTask;
List<VolumeClone> updatedClones = createCloneDriverTask.getClones();
for (VolumeClone updatedClone : updatedClones) {
if (ExternalDeviceUtils.isVolumeExternalDeviceClone(volume, updatedClone, dbClient)) {
ExternalDeviceUtils.updateNewlyCreatedGroupClone(volume, updatedClone, _cgURI, dbClient);
updatedVolumes.add(volume);
break;
}
}
}
dbClient.updateObject(updatedVolumes);
try {
// post process storage pool capacity for clone's pools
// map clones to their storage pool
updateStoragePoolCapacityAfterOperationComplete(updatedVolumes, dbClient);
} catch (Exception ex) {
s_logger.error("Failed to update storage pool after create group clone operation completion.", ex);
}
}
use of com.emc.storageos.storagedriver.model.VolumeClone in project coprhd-controller by CoprHD.
the class RestoreFromCloneExternalDeviceJob method doTaskSucceeded.
/**
* {@inheritDoc}
*/
@Override
protected void doTaskSucceeded(DriverTask driverTask, DbClient dbClient) throws Exception {
// Get the ViPR volume representing the clone.
s_logger.info(String.format("Successfully restored clone %s:%s", _volumeURI, driverTask.getMessage()));
Volume volume = dbClient.queryObject(Volume.class, _volumeURI);
if (volume == null) {
s_logger.error(String.format("Failed to find volume %s", _volumeURI));
throw DeviceControllerException.exceptions.objectNotFound(_volumeURI);
}
// Update the ViPR clone with the driver clone information.
// Note that we know ViPR only allows you to restore a single
// non-group clone at a time.
RestoreFromCloneDriverTask restoreDriverTask = (RestoreFromCloneDriverTask) driverTask;
List<VolumeClone> updatedClones = restoreDriverTask.getClones();
VolumeClone updatedClone = updatedClones.get(0);
ExternalDeviceUtils.updateRestoredClone(volume, updatedClone, dbClient, true);
}
Aggregations