use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class AbstractBlockServiceApiImpl method checkCommonVpoolUpdates.
/**
* Checks for Vpool updates that can be done on any device type.
* For now, this is just the Export Path Params or Auto-tiering policy change.
* If the update was processed, return true, else false.
*
* @param volumes
* @param newVirtualPool
* @param taskId
* @return true if update processed
* @throws InternalException
*/
protected boolean checkCommonVpoolUpdates(List<Volume> volumes, VirtualPool newVirtualPool, String taskId) throws InternalException {
VirtualPool volumeVirtualPool = _dbClient.queryObject(VirtualPool.class, volumes.get(0).getVirtualPool());
StringBuffer notSuppReasonBuff = new StringBuffer();
if (VirtualPoolChangeAnalyzer.isSupportedPathParamsChange(volumes.get(0), volumeVirtualPool, newVirtualPool, _dbClient, notSuppReasonBuff)) {
BlockExportController exportController = getController(BlockExportController.class, BlockExportController.EXPORT);
for (Volume volume : volumes) {
exportController.updateVolumePathParams(volume.getId(), newVirtualPool.getId(), taskId);
}
return true;
}
if (VirtualPoolChangeAnalyzer.isSupportedAutoTieringPolicyAndLimitsChange(volumes.get(0), volumeVirtualPool, newVirtualPool, _dbClient, notSuppReasonBuff)) {
/**
* If it is a Auto-tiering policy change, it is sufficient to check on one volume in the list.
* Mixed type volumes case has already been taken care in BlockService API.
*/
BlockExportController exportController = getController(BlockExportController.class, BlockExportController.EXPORT);
List<URI> volumeURIs = new ArrayList<URI>();
for (Volume volume : volumes) {
volumeURIs.add(volume.getId());
}
exportController.updatePolicyAndLimits(volumeURIs, newVirtualPool.getId(), taskId);
return true;
}
return false;
}
use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class AbstractBlockServiceApiImpl method verifyAddVolumeToCG.
/**
* {@inheritDoc}
*/
@Override
public void verifyAddVolumeToCG(Volume volume, BlockConsistencyGroup cg, List<Volume> cgVolumes, StorageSystem cgStorageSystem) {
// Verify that the Virtual Pool for the volume specifies
// consistency.
URI volumeURI = volume.getId();
VirtualPool vPool = _permissionsHelper.getObjectById(volume.getVirtualPool(), VirtualPool.class);
if (vPool.getMultivolumeConsistency() == null || !vPool.getMultivolumeConsistency()) {
throw APIException.badRequests.invalidParameterConsistencyGroupVirtualPoolMustSpecifyMultiVolumeConsistency(volumeURI);
}
// Validate the volume is not in any other CG.
if (!NullColumnValueGetter.isNullURI(volume.getConsistencyGroup()) && !cg.getId().equals(volume.getConsistencyGroup())) {
throw APIException.badRequests.invalidParameterVolumeAlreadyInAConsistencyGroup(cg.getId(), volume.getConsistencyGroup());
}
// Verify the project for the volumes to be added is the same
// as the project for the consistency group.
BlockConsistencyGroupUtils.verifyProjectForVolumeToBeAddedToCG(volume, cg, _dbClient);
// Verify that the volume is on the storage system for
// the consistency group.
verifySystemForVolumeToBeAddedToCG(volume, cg, cgStorageSystem);
// Don't allow partially ingested volume to be added to CG.
BlockServiceUtils.validateNotAnInternalBlockObject(volume, false);
}
use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class AbstractBlockServiceApiImpl method getTaskAssociatedResources.
/**
* Determines if there are any associated resources that are indirectly affected by this volume operation. If
* there are we should add them to the Task object.
*
* @param volume
* The volume the operation is being performed on
* @param vpool
* The vpool needed for extra information on whether to add associated resources
* @return A list of any associated resources, null otherwise
*/
protected List<? extends DataObject> getTaskAssociatedResources(Volume volume, VirtualPool vpool) {
List<? extends DataObject> associatedResources = null;
VirtualPool currentVpool = _dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
// change has been made.
if (VirtualPool.vPoolSpecifiesProtection(currentVpool) && VirtualPool.vPoolSpecifiesProtection(vpool) && !NullColumnValueGetter.isNullURI(volume.getConsistencyGroup())) {
// Get all RP Source volumes in the CG
List<Volume> allRPSourceVolumesInCG = RPHelper.getCgSourceVolumes(volume.getConsistencyGroup(), _dbClient);
// Remove the volume in question from the associated list, don't want a double entry because the
// volume passed in will already be counted as an associated resource for the Task.
allRPSourceVolumesInCG.remove(volume.getId());
if (VirtualPool.vPoolSpecifiesRPVPlex(currentVpool) && !VirtualPool.vPoolSpecifiesMetroPoint(currentVpool) && VirtualPool.vPoolSpecifiesMetroPoint(vpool)) {
// For an upgrade to MetroPoint (moving from RP+VPLEX vpool to MetroPoint vpool), even though the user
// would have chosen 1 volume to update but we need to update ALL the RSets/volumes in the CG.
// We can't just update one RSet/volume.
s_logger.info("VirtualPool change for to upgrade to MetroPoint.");
return allRPSourceVolumesInCG;
}
// Determine if the copy mode setting has changed. For this type of change, all source volumes
// in the consistency group are affected.
String currentCopyMode = NullColumnValueGetter.isNullValue(currentVpool.getRpCopyMode()) ? "" : currentVpool.getRpCopyMode();
String newCopyMode = NullColumnValueGetter.isNullValue(vpool.getRpCopyMode()) ? "" : vpool.getRpCopyMode();
if (!newCopyMode.equals(currentCopyMode)) {
// The copy mode setting has changed.
s_logger.info(String.format("VirtualPool change to update copy from %s to %s.", currentCopyMode, newCopyMode));
return allRPSourceVolumesInCG;
}
}
return associatedResources;
}
use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class BlockMirrorServiceApiImpl method startNativeContinuousCopies.
@Override
public TaskList startNativeContinuousCopies(StorageSystem storageSystem, Volume sourceVolume, VirtualPool sourceVirtualPool, VirtualPoolCapabilityValuesWrapper capabilities, NativeContinuousCopyCreate param, String taskId) throws ControllerException {
if (!((storageSystem.getUsingSmis80() && storageSystem.deviceIsType(Type.vmax)) || storageSystem.deviceIsType(Type.vnxblock))) {
validateNotAConsistencyGroupVolume(sourceVolume, sourceVirtualPool);
}
TaskList taskList = new TaskList();
// Currently, this will create a single mirror and add it to the source volume
// Two steps: first place the mirror and then prepare the mirror.
List<Recommendation> volumeRecommendations = new ArrayList<Recommendation>();
// Prepare mirror.
int volumeCounter = 1;
int volumeCount = capabilities.getResourceCount();
String volumeLabel = param.getName();
List<Volume> preparedVolumes = new ArrayList<Volume>();
// If the requested volume is part of CG
if (sourceVolume.isInCG()) {
if (volumeCount > 1) {
throw APIException.badRequests.invalidMirrorCountForVolumesInConsistencyGroup();
}
URIQueryResultList cgVolumeList = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getVolumesByConsistencyGroup(sourceVolume.getConsistencyGroup()), cgVolumeList);
// recommendation
while (cgVolumeList.iterator().hasNext()) {
Volume cgSourceVolume = _dbClient.queryObject(Volume.class, cgVolumeList.iterator().next());
_log.info("Processing volume {} in CG {}", cgSourceVolume.getId(), sourceVolume.getConsistencyGroup());
VirtualPool cgVolumeVPool = _dbClient.queryObject(VirtualPool.class, cgSourceVolume.getVirtualPool());
populateVolumeRecommendations(capabilities, cgVolumeVPool, cgSourceVolume, taskId, taskList, volumeCount, volumeCounter, volumeLabel, preparedVolumes, volumeRecommendations);
}
} else {
// Source Volume without CG
populateVolumeRecommendations(capabilities, sourceVirtualPool, sourceVolume, taskId, taskList, volumeCount, volumeCounter, volumeLabel, preparedVolumes, volumeRecommendations);
}
List<URI> mirrorList = new ArrayList<URI>(preparedVolumes.size());
for (Volume volume : preparedVolumes) {
Operation op = _dbClient.createTaskOpStatus(BlockMirror.class, volume.getId(), taskId, ResourceOperationTypeEnum.ATTACH_BLOCK_MIRROR);
volume.getOpStatus().put(taskId, op);
TaskResourceRep volumeTask = toTask(volume, taskId, op);
taskList.getTaskList().add(volumeTask);
mirrorList.add(volume.getId());
}
BlockController controller = getController(BlockController.class, storageSystem.getSystemType());
try {
controller.attachNativeContinuousCopies(storageSystem.getId(), sourceVolume.getId(), mirrorList, taskId);
} catch (ControllerException ce) {
String errorMsg = format("Failed to start continuous copies on volume %s: %s", sourceVolume.getId(), ce.getMessage());
_log.error(errorMsg, ce);
for (TaskResourceRep taskResourceRep : taskList.getTaskList()) {
taskResourceRep.setState(Operation.Status.error.name());
taskResourceRep.setMessage(errorMsg);
Operation statusUpdate = new Operation(Operation.Status.error.name(), errorMsg);
_dbClient.updateTaskOpStatus(Volume.class, taskResourceRep.getResource().getId(), taskId, statusUpdate);
}
throw ce;
}
return taskList;
}
use of com.emc.storageos.db.client.model.VirtualPool in project coprhd-controller by CoprHD.
the class BlockService method validateVpoolCopyModeSetting.
private void validateVpoolCopyModeSetting(Volume srcVolume, String newCopyMode) {
if (srcVolume != null) {
URI virtualPoolURI = srcVolume.getVirtualPool();
VirtualPool virtualPool = _dbClient.queryObject(VirtualPool.class, virtualPoolURI);
if (virtualPool != null) {
StringMap remoteCopySettingsMap = virtualPool.getProtectionRemoteCopySettings();
if (remoteCopySettingsMap != null) {
for (Map.Entry<URI, VpoolRemoteCopyProtectionSettings> entry : VirtualPool.getRemoteProtectionSettings(virtualPool, _dbClient).entrySet()) {
VpoolRemoteCopyProtectionSettings copySetting = entry.getValue();
if (!newCopyMode.equalsIgnoreCase(copySetting.getCopyMode())) {
throw APIException.badRequests.invalidCopyModeOp(newCopyMode, copySetting.getCopyMode());
}
}
}
}
}
}
Aggregations