use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class BlockVirtualPoolService method updateHAParametersForVirtualPool.
/**
* Updates the virtual pool high availability parameters based
* values of the update request.
*
* @param vPool A reference to the virtual pool to update.
* @param haParam The HA update parameters.
*/
private void updateHAParametersForVirtualPool(VirtualPool vPool, VirtualPoolHighAvailabilityParam haParam) {
// Get the HA varray/vpool map.
StringMap haVarrayVpoolMap = vPool.getHaVarrayVpoolMap();
// Set the MetroPoint value
if (haParam != null) {
vPool.setMetroPoint(haParam.getMetroPoint());
}
// Set the autoCrossConnectExport if set in the haParam
if (haParam.getAutoCrossConnectExport() != null) {
vPool.setAutoCrossConnectExport(haParam.getAutoCrossConnectExport());
}
// is used as continuous copies vpool, if yes then throw exception.
if (vPool.getHighAvailability() != null && haParam.getType() != null && !vPool.getHighAvailability().equals(haParam.getType())) {
checkIfVpoolIsSetAsContinuousCopiesVpool(vPool);
} else if (vPool.getHighAvailability() == null && haParam.getType() != null && (haParam.getType().equals(VirtualPool.HighAvailabilityType.vplex_local.name()) || haParam.getType().equals(VirtualPool.HighAvailabilityType.vplex_distributed.name()))) {
checkIfVpoolIsSetAsContinuousCopiesVpool(vPool);
} else if (vPool.getHighAvailability() != null && (vPool.getHighAvailability().equals(VirtualPool.HighAvailabilityType.vplex_local.name()) || vPool.getHighAvailability().equals(VirtualPool.HighAvailabilityType.vplex_distributed.name())) && (haParam.getType() == null || String.valueOf(haParam.getType()).isEmpty())) {
checkIfVpoolIsSetAsContinuousCopiesVpool(vPool);
}
// Check for removal of HA from the virtual pool.
if ((haParam.getType() == null || String.valueOf(haParam.getType()).isEmpty()) && (haParam.getHaVirtualArrayVirtualPool() == null || String.valueOf(haParam.getHaVirtualArrayVirtualPool()).isEmpty())) {
_log.info("Removing HA from vPool");
// for the virtual pool.
if (vPool.getHighAvailability() != null) {
vPool.setHighAvailability(NullColumnValueGetter.getNullStr());
}
if ((haVarrayVpoolMap != null) && (!haVarrayVpoolMap.isEmpty())) {
haVarrayVpoolMap.remove(haVarrayVpoolMap.keySet().iterator().next());
vPool.setHaVarrayConnectedToRp(NullColumnValueGetter.getNullStr());
}
}
// Make sure the HA virtual array/pool map is empty.
if (haParam.getType() != null && !String.valueOf(haParam.getType()).isEmpty()) {
// Update the type.
vPool.setHighAvailability(haParam.getType());
if ((haParam.getType().equals(VirtualPool.HighAvailabilityType.vplex_local.name())) && (haVarrayVpoolMap != null) && (!haVarrayVpoolMap.isEmpty())) {
haVarrayVpoolMap.remove(haVarrayVpoolMap.keySet().iterator().next());
vPool.setHaVarrayConnectedToRp(NullColumnValueGetter.getNullStr());
}
}
// Update the HA virtual array and pool settings.
if (haParam.getHaVirtualArrayVirtualPool() != null) {
// Check for removal.
if (haParam.getHaVirtualArrayVirtualPool().getVirtualArray() == null && haParam.getHaVirtualArrayVirtualPool().getVirtualPool() == null) {
// settings should be removed.
if ((haVarrayVpoolMap != null) && (!haVarrayVpoolMap.isEmpty())) {
haVarrayVpoolMap.remove(haVarrayVpoolMap.keySet().iterator().next());
vPool.setHaVarrayConnectedToRp(NullColumnValueGetter.getNullStr());
// If the type is vplex_distributed, remove the type as well
if (vPool.getHighAvailability() != null && vPool.getHighAvailability().equals(VirtualPool.HighAvailabilityType.vplex_distributed.name())) {
vPool.setHighAvailability(NullColumnValueGetter.getNullStr());
}
}
} else {
// Determine the HA virtual pool.
String haVpoolId = NullColumnValueGetter.getNullURI().toString();
if (haParam.getHaVirtualArrayVirtualPool().getVirtualPool() != null) {
// Pool is specified in the update.
if (!haParam.getHaVirtualArrayVirtualPool().getVirtualPool().toString().isEmpty()) {
// Note that an empty pool will mean remove the pool.
haVpoolId = haParam.getHaVirtualArrayVirtualPool().getVirtualPool().toString();
// value specified.
if (NullColumnValueGetter.isNotNullValue(haVpoolId)) {
if ((haVarrayVpoolMap == null) || (haVarrayVpoolMap.isEmpty())) {
// No HA vpool is currently specified, so just verify the new HA vpool.
verifyNewHAVpoolForHAVpoolUpdate(vPool, haVpoolId);
} else {
String currentHAVpoolId = haVarrayVpoolMap.get(haVarrayVpoolMap.keySet().iterator().next());
if (!NullColumnValueGetter.isNotNullValue(currentHAVpoolId)) {
// The current specified is null, so just verify the new HA vpool.
verifyNewHAVpoolForHAVpoolUpdate(vPool, haVpoolId);
} else if (!haVpoolId.equals(currentHAVpoolId)) {
// Otherwise, verify the HA vpool only if it is changing.
verifyNewHAVpoolForHAVpoolUpdate(vPool, haVpoolId);
}
}
}
}
}
// Update settings for the HA virtual array.
if (haParam.getHaVirtualArrayVirtualPool().getVirtualArray() != null) {
// update must supply a valid value.
if ((haVarrayVpoolMap != null) && (!haVarrayVpoolMap.isEmpty())) {
// Replace entry with new HA virtual array.
String haVarray = haVarrayVpoolMap.keySet().iterator().next();
if (!haParam.getHaVirtualArrayVirtualPool().getVirtualArray().toString().equals(haVarray)) {
// only remove the entry if the varray has changed
haVarrayVpoolMap.remove(haVarray);
vPool.setHaVarrayConnectedToRp(NullColumnValueGetter.getNullStr());
}
haVarrayVpoolMap.put(haParam.getHaVirtualArrayVirtualPool().getVirtualArray().toString(), haVpoolId);
// Use HA Varray as RP Source if boolean is set to true
if (haParam.getHaVirtualArrayVirtualPool().getActiveProtectionAtHASite() != null && haParam.getHaVirtualArrayVirtualPool().getActiveProtectionAtHASite()) {
vPool.setHaVarrayConnectedToRp(haParam.getHaVirtualArrayVirtualPool().getVirtualArray().toString());
} else {
vPool.setHaVarrayConnectedToRp(NullColumnValueGetter.getNullStr());
}
} else if (haVarrayVpoolMap == null) {
// Create new map and entry.
haVarrayVpoolMap = new StringMap();
haVarrayVpoolMap.put(haParam.getHaVirtualArrayVirtualPool().getVirtualArray().toString(), haVpoolId);
vPool.setHaVarrayVpoolMap(haVarrayVpoolMap);
// Use HA Varray as RP Source if boolean is set to true
if (haParam.getHaVirtualArrayVirtualPool().getActiveProtectionAtHASite() != null && haParam.getHaVirtualArrayVirtualPool().getActiveProtectionAtHASite()) {
vPool.setHaVarrayConnectedToRp(haParam.getHaVirtualArrayVirtualPool().getVirtualArray().toString());
} else {
vPool.setHaVarrayConnectedToRp(NullColumnValueGetter.getNullStr());
}
} else {
// Map exists but is empty, just add.
haVarrayVpoolMap.put(haParam.getHaVirtualArrayVirtualPool().getVirtualArray().toString(), haVpoolId);
// Use HA Varray as RP Source if boolean is set to true
if (haParam.getHaVirtualArrayVirtualPool().getActiveProtectionAtHASite() != null && haParam.getHaVirtualArrayVirtualPool().getActiveProtectionAtHASite()) {
vPool.setHaVarrayConnectedToRp(haParam.getHaVirtualArrayVirtualPool().getVirtualArray().toString());
} else {
vPool.setHaVarrayConnectedToRp(NullColumnValueGetter.getNullStr());
}
}
} else if ((haParam.getHaVirtualArrayVirtualPool().getVirtualPool() != null) && (haVarrayVpoolMap != null) && (!haVarrayVpoolMap.isEmpty())) {
// Only HA virtual pool update, update setting for current
// HA virtual array.
String haVarray = haVarrayVpoolMap.keySet().iterator().next();
haVarrayVpoolMap.put(haVarray, haVpoolId);
// Use HA Varray as RP Source if boolean is set to true
if (haParam.getHaVirtualArrayVirtualPool().getActiveProtectionAtHASite() != null && haParam.getHaVirtualArrayVirtualPool().getActiveProtectionAtHASite()) {
vPool.setHaVarrayConnectedToRp(haParam.getHaVirtualArrayVirtualPool().getVirtualArray().toString());
} else {
vPool.setHaVarrayConnectedToRp(NullColumnValueGetter.getNullStr());
}
}
}
}
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class BlockVirtualPoolService method updateRemoteCopyVPool.
private void updateRemoteCopyVPool(VirtualPool virtualPool, BlockVirtualPoolProtectionUpdateParam param) {
if (param.getRemoteCopies() != null) {
StringMap remoteCopySettingsMap = virtualPool.getProtectionRemoteCopySettings();
if (remoteCopySettingsMap == null) {
remoteCopySettingsMap = new StringMap();
virtualPool.setProtectionRemoteCopySettings(remoteCopySettingsMap);
}
// and an add, which is buggy in the StringMap.
if (param.getRemoteCopies().getRemove() != null && !param.getRemoteCopies().getRemove().isEmpty() && param.getRemoteCopies().getAdd() != null && !param.getRemoteCopies().getAdd().isEmpty()) {
Iterator<VirtualPoolRemoteProtectionVirtualArraySettingsParam> removeRemoteCopies = param.getRemoteCopies().getRemove().iterator();
Iterator<VirtualPoolRemoteProtectionVirtualArraySettingsParam> addRemoteCopies = param.getRemoteCopies().getAdd().iterator();
while (removeRemoteCopies.hasNext()) {
VirtualPoolRemoteProtectionVirtualArraySettingsParam removeRemoteCopySettingsParam = removeRemoteCopies.next();
while (addRemoteCopies.hasNext()) {
VirtualPoolRemoteProtectionVirtualArraySettingsParam addRemoteCopySettingsParam = addRemoteCopies.next();
// remote copy setting from the add/remove lists so they do not get processed individually.
if (removeRemoteCopySettingsParam.getVarray().toString().equals(addRemoteCopySettingsParam.getVarray().toString())) {
String remoteCopySettingsUri = remoteCopySettingsMap.get(addRemoteCopySettingsParam.getVarray().toString());
VpoolRemoteCopyProtectionSettings remoteSettingsObj = _dbClient.queryObject(VpoolRemoteCopyProtectionSettings.class, URI.create(remoteCopySettingsUri));
if (remoteSettingsObj != null) {
remoteSettingsObj.setVirtualPool(addRemoteCopySettingsParam.getVpool());
if (null != addRemoteCopySettingsParam.getRemoteCopyMode()) {
if (!CopyModes.lookup(addRemoteCopySettingsParam.getRemoteCopyMode())) {
throw APIException.badRequests.invalidCopyMode(addRemoteCopySettingsParam.getRemoteCopyMode());
}
remoteSettingsObj.setCopyMode(addRemoteCopySettingsParam.getRemoteCopyMode());
}
_dbClient.persistObject(remoteSettingsObj);
// Only remove from the add list if the remote copy setting actually
// exists. We will still want to add it if it does not exist.
param.getRemoteCopies().getAdd().remove(addRemoteCopySettingsParam);
}
// Always remove the remote copy setting from the remove list
param.getRemoteCopies().getRemove().remove(removeRemoteCopySettingsParam);
}
}
}
}
if (param.getRemoteCopies().getRemove() != null && !param.getRemoteCopies().getRemove().isEmpty()) {
for (VirtualPoolRemoteProtectionVirtualArraySettingsParam remoteSettings : param.getRemoteCopies().getRemove()) {
if (remoteSettings.getVarray() != null && remoteCopySettingsMap.containsKey(remoteSettings.getVarray().toString())) {
String remoteCopySettingsUri = remoteCopySettingsMap.get(remoteSettings.getVarray().toString());
remoteCopySettingsMap.remove(remoteSettings.getVarray().toString());
VpoolRemoteCopyProtectionSettings remoteSettingsObj = _dbClient.queryObject(VpoolRemoteCopyProtectionSettings.class, URI.create(remoteCopySettingsUri));
remoteSettingsObj.setInactive(true);
_dbClient.persistObject(remoteSettingsObj);
}
}
}
if (param.getRemoteCopies().getAdd() != null && !param.getRemoteCopies().getAdd().isEmpty()) {
List<VpoolRemoteCopyProtectionSettings> remoteSettingsList = new ArrayList<VpoolRemoteCopyProtectionSettings>();
// already existing remote VArrays
List<String> existingRemoteUris = new ArrayList<String>(remoteCopySettingsMap.keySet());
for (VirtualPoolRemoteProtectionVirtualArraySettingsParam remoteSettings : param.getRemoteCopies().getAdd()) {
// CTRL-275 fix
VirtualArray remoteVArray = _dbClient.queryObject(VirtualArray.class, remoteSettings.getVarray());
if (null == remoteVArray || remoteVArray.getInactive()) {
throw APIException.badRequests.inactiveRemoteVArrayDetected(remoteSettings.getVarray());
}
VpoolRemoteCopyProtectionSettings remoteCopySettingsParam = new VpoolRemoteCopyProtectionSettings();
remoteSettingsList.add(remoteCopySettingsParam);
remoteCopySettingsParam.setId(URIUtil.createId(VpoolRemoteCopyProtectionSettings.class));
remoteCopySettingsParam.setVirtualArray(remoteSettings.getVarray());
if (existingRemoteUris.contains(remoteSettings.getVarray().toString()) || remoteCopySettingsMap.containsKey(remoteSettings.getVarray().toString())) {
throw APIException.badRequests.duplicateRemoteSettingsDetected(remoteSettings.getVarray());
}
remoteCopySettingsMap.put(remoteSettings.getVarray().toString(), remoteCopySettingsParam.getId().toString());
remoteCopySettingsParam.setVirtualPool(remoteSettings.getVpool());
if (null != remoteSettings.getRemoteCopyMode()) {
if (!CopyModes.lookup(remoteSettings.getRemoteCopyMode())) {
throw APIException.badRequests.invalidCopyMode(remoteSettings.getRemoteCopyMode());
}
remoteCopySettingsParam.setCopyMode(remoteSettings.getRemoteCopyMode());
}
}
_dbClient.createObject(remoteSettingsList);
}
}
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class VirtualPoolUtil method checkHighAvailabilityChanged.
/**
* On an update of a block virtual pool, determines if the update request
* modifies the high availability parameters for the virtual pool.
*
* @param vPool A reference to the virtual pool being updated..
* @param haParam The high availability param from the update request.
*
* @return true if the high availability parameters for the virtual pool are
* being modified, false otherwise.
*/
public static boolean checkHighAvailabilityChanged(VirtualPool vPool, VirtualPoolHighAvailabilityParam haParam) {
// If the HA param is null, then no HA changes were requested.
if (haParam == null) {
_log.info("No HA changes");
return false;
}
// Check if the virtual pool currently specify high availability.
if (VirtualPool.vPoolSpecifiesHighAvailability(vPool)) {
_log.info("Virtual pool specifies HA");
// changed or removed.
if ((haParam.getType() == null) && (haParam.getHaVirtualArrayVirtualPool() == null)) {
_log.info("Removing HA");
// availability from the virtual pool.
return true;
}
// Check if the update request changes the high availability type.
_log.info("HA type is {}", haParam.getType());
if ((haParam.getType() != null) && (!haParam.getType().equals(vPool.getHighAvailability()))) {
_log.info("HA type changed");
return true;
}
// changed or removed.
if (haParam.getHaVirtualArrayVirtualPool() != null) {
_log.info("Update specifies HA virtual array/pool changes.");
// Get the current HA vArray and vPool for the vPool being
// updated.
String haVarray = null;
String haVpool = null;
String haVarrayConnectedToRp = vPool.getHaVarrayConnectedToRp();
StringMap haVarrayVpoolMap = vPool.getHaVarrayVpoolMap();
if (haVarrayVpoolMap != null && !haVarrayVpoolMap.isEmpty()) {
haVarray = haVarrayVpoolMap.keySet().iterator().next();
haVpool = haVarrayVpoolMap.get(haVarray);
if (haVpool.equals(NullColumnValueGetter.getNullURI().toString())) {
haVpool = null;
}
}
_log.info("Current vArray is {}", haVarray);
_log.info("Current vPool is {}", haVpool);
_log.info("HA vArray set as {}", haVarrayConnectedToRp);
if ((haParam.getHaVirtualArrayVirtualPool().getVirtualArray() == null) && (haParam.getHaVirtualArrayVirtualPool().getVirtualPool() == null) && ((haVarray != null || haVpool != null))) {
_log.info("Removing HA vArray/vPool params");
// there is a change.
return true;
}
_log.info("Update vArray is {}", haParam.getHaVirtualArrayVirtualPool().getVirtualArray());
if ((haParam.getHaVirtualArrayVirtualPool().getVirtualArray() != null) && (!String.valueOf(haParam.getHaVirtualArrayVirtualPool().getVirtualArray()).equals(haVarray))) {
// If the update param specifies an HA vArray, see if
// it's the same as the current value for the virtual
// pool.
_log.info("Changing vArray");
return true;
}
_log.info("Update vPool is {}", haParam.getHaVirtualArrayVirtualPool().getVirtualPool());
if ((haParam.getHaVirtualArrayVirtualPool().getVirtualPool() != null) && (!(String.valueOf(haParam.getHaVirtualArrayVirtualPool().getVirtualPool()).isEmpty() && haVpool == null) && !String.valueOf(haParam.getHaVirtualArrayVirtualPool().getVirtualPool()).equals(haVpool))) {
// If the update param specifies an HA vPool, see if
// it's the same as the current value for the virtual
// pool. If the existing HA vpool is null and the updated HA vpool is an
// empty String, there are no changes.
_log.info("Changing vPool");
return true;
}
if ((haVarrayConnectedToRp != null && !haVarrayConnectedToRp.isEmpty() && !haParam.getHaVirtualArrayVirtualPool().getActiveProtectionAtHASite()) || ((haVarrayConnectedToRp == null || haVarrayConnectedToRp.isEmpty()) && haParam.getHaVirtualArrayVirtualPool().getActiveProtectionAtHASite())) {
return true;
}
}
} else if (haParam.getType() != null) {
// The virtual pool does not currently specify high availability,
// but the update request specifies a non-null high availability
// type, so the request is attempting to add high availability
// to the virtual pool.
_log.info("Adding HA type {}", haParam.getType());
return true;
}
return false;
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class StorageScheduler method addVolumeCapacityToReservedCapacityMap.
public static void addVolumeCapacityToReservedCapacityMap(DbClient _dbClient, Volume volume) {
Long reservedCapacity = 0L;
// For thin volumes reserve only capacity required for pre-allocation (when set)
if (volume.getThinlyProvisioned() && volume.getThinVolumePreAllocationSize() != null) {
reservedCapacity = volume.getThinVolumePreAllocationSize();
} else if (!volume.getThinlyProvisioned()) {
reservedCapacity = volume.getCapacity();
}
URI poolId = volume.getPool();
StoragePool pool = _dbClient.queryObject(StoragePool.class, poolId);
StringMap reservationMap = pool.getReservedCapacityMap();
reservationMap.put(volume.getId().toString(), String.valueOf(reservedCapacity));
_dbClient.persistObject(pool);
}
use of com.emc.storageos.db.client.model.StringMap in project coprhd-controller by CoprHD.
the class VPlexScheduler method getRecommendationsForResources.
public List<Recommendation> getRecommendationsForResources(VirtualArray vArray, Project project, VirtualPool vPool, VirtualPoolCapabilityValuesWrapper capabilities, Map<VpoolUse, List<Recommendation>> currentRecommendations) {
_log.info("Getting recommendations for VPlex volume placement");
// availability volumes.
if (!VirtualPool.HighAvailabilityType.vplex_distributed.name().equals(vPool.getHighAvailability()) && !VirtualPool.HighAvailabilityType.vplex_local.name().equals(vPool.getHighAvailability())) {
throw APIException.badRequests.invalidHighAvailability(vPool.getHighAvailability());
}
_log.info("VirtualPool has high availability {}", vPool.getHighAvailability());
Set<URI> vplexSystemsForPlacement = getVPlexSystemsForPlacement(vArray, vPool, capabilities);
// Determine if the volume creation request is for HA volumes.
boolean isHAVolumeRequest = VirtualPool.HighAvailabilityType.vplex_distributed.name().equals(vPool.getHighAvailability());
// Get and validate the high availability VirtualArray and VirtualPool.
// Note that the HA VirtualPool is optional. When not specified, the
// high availability VirtualPool is the passed VirtualPool is use.
VirtualPool haVPool = vPool;
VirtualArray haVArray = null;
StringMap haVaVpMap = vPool.getHaVarrayVpoolMap();
if ((isHAVolumeRequest) && (haVaVpMap != null)) {
_log.info("Is HA request and with an HA VirtualArray VirtualPool map");
Iterator<String> vaIter = haVaVpMap.keySet().iterator();
while (vaIter.hasNext()) {
String haVaId = vaIter.next();
_log.info("HA VirtualArray is {}", haVaId);
if (!haVaId.equals(NullColumnValueGetter.getNullURI().toString())) {
_log.info("HA VirtualArray is not a null URI");
haVArray = getVirtualArrayForVolumeCreateRequest(project, URI.create(haVaId));
if (vArray.getId().toString().equals(haVArray.getId().toString())) {
throw APIException.badRequests.sameVirtualArrayAndHighAvailabilityArray();
}
}
// Now get the VirtualPool.
String haVpId = haVaVpMap.get(haVaId);
_log.info("HA VirtualPool is {}", haVpId);
if (!haVpId.equals(NullColumnValueGetter.getNullURI().toString())) {
_log.info("HA VirtualPool is not a null URI");
haVPool = BlockService.getVirtualPoolForRequest(project, URI.create(haVpId), _dbClient, _permissionsHelper);
}
}
}
// Get the volume placement based on passed parameters.
_log.info("VirtualPool: {}, HA VirtualPool: {}", vPool.getId().toString(), haVPool.getId().toString());
List<Recommendation> recommendations = scheduleStorage(vArray, vplexSystemsForPlacement, null, vPool, isHAVolumeRequest, haVArray, haVPool, capabilities, project, VpoolUse.ROOT, currentRecommendations);
return recommendations;
}
Aggregations