use of com.emc.storageos.model.vpool.VirtualPoolProtectionVirtualArraySettingsParam in project coprhd-controller by CoprHD.
the class BlockVirtualPoolService method updateProtectionParamsForVirtualPool.
/**
* Performs the protection updates on <code>VirtualPool</code>.
*
* @param virtualPool Reference to the virtual pool to update.
* @param param The updates that need to be applied to the virtual pool.
*/
private void updateProtectionParamsForVirtualPool(VirtualPool virtualPool, BlockVirtualPoolProtectionUpdateParam param, VirtualPoolHighAvailabilityParam haParam) {
// If the update specifies protection, we need to process the update.
if (param != null) {
// If the update specifies protection mirroring, process the mirroring update.
if (param.getContinuousCopies() != null) {
if ((param.getContinuousCopies().getVpool() == null || String.valueOf(param.getContinuousCopies().getVpool()).isEmpty()) && (param.getContinuousCopies().getMaxMirrors() == null || param.getContinuousCopies().getMaxMirrors() == VirtualPoolProtectionMirrorParam.MAX_DISABLED || String.valueOf(param.getContinuousCopies().getMaxMirrors()).isEmpty())) {
// so remove protection mirror vpool and set max native continuous copies to disabled value.
if (virtualPool.getMirrorVirtualPool() != null) {
virtualPool.setMirrorVirtualPool(String.valueOf(NullColumnValueGetter.getNullURI()));
}
virtualPool.setMaxNativeContinuousCopies(VirtualPool.MAX_DISABLED);
} else if ((param.getContinuousCopies().getVpool() == null || String.valueOf(param.getContinuousCopies().getVpool()).isEmpty())) {
// Setting Mirror Virtual Pool is optional so user can choose to remove mirror virtual pool
if (virtualPool.getMirrorVirtualPool() != null) {
virtualPool.setMirrorVirtualPool(String.valueOf(NullColumnValueGetter.getNullURI()));
}
if (param.getContinuousCopies().getMaxMirrors() != null) {
// Updating max mirrors
virtualPool.setMaxNativeContinuousCopies(param.getContinuousCopies().getMaxMirrors());
}
} else if ((param.getContinuousCopies().getVpool() != null && !String.valueOf(param.getContinuousCopies().getVpool()).isEmpty()) && (param.getContinuousCopies().getMaxMirrors() == null)) {
// Update protection mirror vpool
updateProtectionMirrorVPool(param.getContinuousCopies().getVpool(), virtualPool);
} else {
// the protection vpool and max mirrors
if (param.getContinuousCopies().getVpool() != null && !String.valueOf(param.getContinuousCopies().getVpool()).isEmpty()) {
updateProtectionMirrorVPool(param.getContinuousCopies().getVpool(), virtualPool);
}
if (param.getContinuousCopies().getMaxMirrors() != null) {
virtualPool.setMaxNativeContinuousCopies(param.getContinuousCopies().getMaxMirrors());
}
}
}
// Handle the protection snapshot updates
if (param.getSnapshots() != null) {
// but good to have just in case...
if (param.getSnapshots().getMaxSnapshots() != null) {
// Keep in mind that if an empty or 0 value is specified snapshots
// will be removed from the virtual pool.
virtualPool.setMaxNativeSnapshots(param.getSnapshots().getMaxSnapshots());
} else {
// Remove snapshots by setting the disabled value
virtualPool.setMaxNativeSnapshots(VirtualPool.MAX_DISABLED);
}
}
// Handle SRDF update
updateRemoteCopyVPool(virtualPool, param);
// Handle the RP protection updates
if (param.getRecoverPoint() != null) {
if (param.getRecoverPoint().getAdd() == null && param.getRecoverPoint().getRemove() == null && param.getRecoverPoint().getSourcePolicy() == null) {
// Empty RP protection specified. This indicates removal of
// RP protection so remove it.
deleteVPoolProtectionVArraySettings(virtualPool);
} else {
// If the source policy is omitted, do nothing.
ProtectionSourcePolicy sourcePolicy = param.getRecoverPoint().getSourcePolicy();
if (sourcePolicy != null) {
String nullValue = NullColumnValueGetter.getNullStr();
virtualPool.setJournalSize(StringUtils.defaultString(sourcePolicy.getJournalSize(), nullValue));
virtualPool.setJournalVarray(!NullColumnValueGetter.isNullURI(sourcePolicy.getJournalVarray()) ? sourcePolicy.getJournalVarray().toString() : nullValue);
if (NullColumnValueGetter.isNullValue(virtualPool.getJournalVarray())) {
// If the journal varray is null, the journal vpool has to be null too.
virtualPool.setJournalVpool(nullValue);
} else {
// Set the journal virtual pool. If none is specified, we must determine the default, which
// will be the parent vpool or the ha vpool.
String defaultVpoolId = nullValue;
if (haParam == null || Boolean.TRUE.equals(haParam.getMetroPoint())) {
// Default the virtual pool to the parent virtual pool in cases where no high availability
// is specified or when HA is specified but not MetroPoint.
defaultVpoolId = virtualPool.getId().toString();
} else if (Boolean.FALSE.equals(haParam.getMetroPoint()) && haParam.getHaVirtualArrayVirtualPool() != null && Boolean.TRUE.equals(haParam.getHaVirtualArrayVirtualPool().getActiveProtectionAtHASite())) {
// virtual pool.
if (haParam.getHaVirtualArrayVirtualPool().getVirtualPool() != null) {
defaultVpoolId = haParam.getHaVirtualArrayVirtualPool().getVirtualPool().toString();
}
}
virtualPool.setJournalVpool(!NullColumnValueGetter.isNullURI(sourcePolicy.getJournalVpool()) ? sourcePolicy.getJournalVpool().toString() : defaultVpoolId);
}
if (NullColumnValueGetter.isNotNullValue(virtualPool.getHighAvailability())) {
virtualPool.setStandbyJournalVarray(!NullColumnValueGetter.isNullURI(sourcePolicy.getStandbyJournalVarray()) ? sourcePolicy.getStandbyJournalVarray().toString() : nullValue);
if (NullColumnValueGetter.isNullValue(virtualPool.getStandbyJournalVarray())) {
// If the ha journal varray is null, the ha journal vpool has to be null too.
virtualPool.setStandbyJournalVpool(nullValue);
} else {
String defaultHaVpool = nullValue;
// Obtain the default HA virtual pool
Map<String, String> haVarrayVpoolMap = virtualPool.getHaVarrayVpoolMap();
if (haVarrayVpoolMap != null && !haVarrayVpoolMap.isEmpty()) {
if (NullColumnValueGetter.isNotNullValue(haVarrayVpoolMap.get(virtualPool.getStandbyJournalVarray()))) {
defaultHaVpool = haVarrayVpoolMap.get(virtualPool.getStandbyJournalVarray());
}
}
// By default, if no standby vpool is set, set the HA journal vpool to the HA vpool.
virtualPool.setStandbyJournalVpool(!NullColumnValueGetter.isNullURI(sourcePolicy.getStandbyJournalVpool()) ? sourcePolicy.getStandbyJournalVpool().toString() : defaultHaVpool);
}
}
virtualPool.setRpCopyMode(StringUtils.defaultString(sourcePolicy.getRemoteCopyMode(), nullValue));
// If the RPO value is null, set the value to 0 to unset this field.
long rpoValue = (sourcePolicy.getRpoValue() == null) ? 0L : sourcePolicy.getRpoValue();
virtualPool.setRpRpoValue(rpoValue);
virtualPool.setRpRpoType(StringUtils.defaultString(sourcePolicy.getRpoType(), nullValue));
}
if (param.getRecoverPoint().getRemove() != null && !param.getRecoverPoint().getRemove().isEmpty()) {
// Only remove protection copies if there are copies to remove
if (virtualPool.getProtectionVarraySettings() != null && !virtualPool.getProtectionVarraySettings().isEmpty()) {
StringMap settingsMap = virtualPool.getProtectionVarraySettings();
for (VirtualPoolProtectionVirtualArraySettingsParam settingsParam : param.getRecoverPoint().getRemove()) {
if (settingsParam.getVarray() != null && !settingsParam.getVarray().toString().isEmpty()) {
String vpoolProtectionVarraySettingsUri = virtualPool.getProtectionVarraySettings().get(settingsParam.getVarray().toString());
if (vpoolProtectionVarraySettingsUri == null) {
throw APIException.badRequests.protectionNoCopyCorrespondingToVirtualArray(settingsParam.getVarray());
}
deleteVPoolProtectionVArraySettings(virtualPool.getProtectionVarraySettings().get(settingsParam.getVarray().toString()));
settingsMap.remove(settingsParam.getVarray().toString());
}
}
virtualPool.setProtectionVarraySettings(settingsMap);
}
}
if (param.getRecoverPoint().getAdd() != null && !param.getRecoverPoint().getAdd().isEmpty()) {
Set<VpoolProtectionVarraySettings> protectionSettingsToAdd = null;
StringMap settingsMap = virtualPool.getProtectionVarraySettings();
if (settingsMap == null) {
settingsMap = new StringMap();
}
for (VirtualPoolProtectionVirtualArraySettingsParam settingsParam : param.getRecoverPoint().getAdd()) {
VirtualArray virtualArray = _permissionsHelper.getObjectById(settingsParam.getVarray(), VirtualArray.class);
ArgValidator.checkEntity(virtualArray, settingsParam.getVarray(), false);
VpoolProtectionVarraySettings setting = new VpoolProtectionVarraySettings();
setting.setId(URIUtil.createId(VpoolProtectionVarraySettings.class));
setting.setParent(new NamedURI(virtualPool.getId(), virtualPool.getLabel()));
if (settingsParam.getVpool() != null && !String.valueOf(settingsParam.getVpool()).isEmpty()) {
setting.setVirtualPool(settingsParam.getVpool());
}
setting.setJournalSize(settingsParam.getCopyPolicy() != null ? settingsParam.getCopyPolicy().getJournalSize() : null);
setting.setJournalVarray(settingsParam.getCopyPolicy() != null ? settingsParam.getCopyPolicy().getJournalVarray() : settingsParam.getVarray());
setting.setJournalVpool(settingsParam.getCopyPolicy() != null ? settingsParam.getCopyPolicy().getJournalVpool() : settingsParam.getVpool());
settingsMap.put(settingsParam.getVarray().toString(), setting.getId().toString());
if (protectionSettingsToAdd == null) {
protectionSettingsToAdd = new HashSet<VpoolProtectionVarraySettings>();
}
protectionSettingsToAdd.add(setting);
}
// Set the underlying protection setting objects
if (protectionSettingsToAdd != null) {
for (VpoolProtectionVarraySettings setting : protectionSettingsToAdd) {
_dbClient.createObject(setting);
}
}
virtualPool.setProtectionVarraySettings(settingsMap);
}
StringMap settingsMap = virtualPool.getProtectionVarraySettings();
if (settingsMap != null && settingsMap.size() == 0) {
// If there are no copies after the add/remove, remove the source policy
virtualPool.setJournalSize(NullColumnValueGetter.getNullStr());
virtualPool.setJournalVarray(NullColumnValueGetter.getNullStr());
virtualPool.setJournalVpool(NullColumnValueGetter.getNullStr());
}
}
}
}
}
use of com.emc.storageos.model.vpool.VirtualPoolProtectionVirtualArraySettingsParam in project coprhd-controller by CoprHD.
the class VirtualPoolMapper method toBlockVirtualPool.
public static BlockVirtualPoolRestRep toBlockVirtualPool(DbClient dbclient, VirtualPool from, Map<URI, VpoolProtectionVarraySettings> protectionSettings, Map<URI, VpoolRemoteCopyProtectionSettings> remoteProtectionSettings) {
if (from == null) {
return null;
}
BlockVirtualPoolRestRep to = new BlockVirtualPoolRestRep();
to.setDriveType(from.getDriveType());
to.setAutoTieringPolicyName(from.getAutoTierPolicyName());
to.setCompressionEnabled(from.getCompressionEnabled());
to.setThinVolumePreAllocationPercentage(from.getThinVolumePreAllocationPercentage());
to.setExpandable(from.getExpandable());
to.setFastExpansion(from.getFastExpansion());
to.setMultiVolumeConsistent(from.getMultivolumeConsistency());
to.setUniquePolicyNames(from.getUniquePolicyNames());
to.setMaxPaths(from.getNumPaths());
to.setMinPaths(from.getMinPaths());
to.setPathsPerInitiator(from.getPathsPerInitiator());
to.setHostIOLimitBandwidth(from.getHostIOLimitBandwidth());
to.setHostIOLimitIOPs(from.getHostIOLimitIOPs());
to.setPlacementPolicy(from.getPlacementPolicy());
if (from.getArrayInfo() != null) {
StringSetMap arrayInfo = from.getArrayInfo();
// Raid Levels
StringSet raidLevels = arrayInfo.get(VirtualPoolCapabilityValuesWrapper.RAID_LEVEL);
if (raidLevels != null) {
to.setRaidLevels(raidLevels);
}
}
BlockVirtualPoolProtectionParam protection = new BlockVirtualPoolProtectionParam();
// mirror logic
protection.setContinuousCopies(new VirtualPoolProtectionMirrorParam());
if (NullColumnValueGetter.isNotNullValue(from.getMirrorVirtualPool())) {
protection.getContinuousCopies().setVpool(URI.create(from.getMirrorVirtualPool()));
}
protection.getContinuousCopies().setMaxMirrors(from.getMaxNativeContinuousCopies());
// SRDF logic
if (null != remoteProtectionSettings && !remoteProtectionSettings.isEmpty()) {
protection.setRemoteCopies(new VirtualPoolRemoteMirrorProtectionParam());
protection.getRemoteCopies().setRemoteCopySettings(new ArrayList<VirtualPoolRemoteProtectionVirtualArraySettingsParam>());
for (Map.Entry<URI, VpoolRemoteCopyProtectionSettings> remoteSetting : remoteProtectionSettings.entrySet()) {
VirtualPoolRemoteProtectionVirtualArraySettingsParam remoteCopy = new VirtualPoolRemoteProtectionVirtualArraySettingsParam();
remoteCopy.setRemoteCopyMode(remoteSetting.getValue().getCopyMode());
remoteCopy.setVarray(remoteSetting.getValue().getVirtualArray());
remoteCopy.setVpool(remoteSetting.getValue().getVirtualPool());
protection.getRemoteCopies().getRemoteCopySettings().add(remoteCopy);
}
}
// RP logic
if (protectionSettings != null && !protectionSettings.isEmpty()) {
protection.setRecoverPoint(new VirtualPoolProtectionRPParam());
if (isNotNullValue(from.getJournalSize())) {
if (protection.getRecoverPoint().getSourcePolicy() == null) {
protection.getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
}
protection.getRecoverPoint().getSourcePolicy().setJournalSize(from.getJournalSize());
}
if (isNotNullValue(from.getJournalVarray())) {
if (protection.getRecoverPoint().getSourcePolicy() == null) {
protection.getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
}
protection.getRecoverPoint().getSourcePolicy().setJournalVarray(URI.create(from.getJournalVarray()));
}
if (isNotNullValue(from.getJournalVpool())) {
if (protection.getRecoverPoint().getSourcePolicy() == null) {
protection.getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
}
protection.getRecoverPoint().getSourcePolicy().setJournalVpool(URI.create(from.getJournalVpool()));
}
if (isNotNullValue(from.getStandbyJournalVarray())) {
if (protection.getRecoverPoint().getSourcePolicy() == null) {
protection.getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
}
protection.getRecoverPoint().getSourcePolicy().setStandbyJournalVarray(URI.create(from.getStandbyJournalVarray()));
}
if (isNotNullValue(from.getStandbyJournalVpool())) {
if (protection.getRecoverPoint().getSourcePolicy() == null) {
protection.getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
}
protection.getRecoverPoint().getSourcePolicy().setStandbyJournalVpool(URI.create(from.getStandbyJournalVpool()));
}
if (isNotNullValue(from.getRpCopyMode())) {
if (protection.getRecoverPoint().getSourcePolicy() == null) {
protection.getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
}
protection.getRecoverPoint().getSourcePolicy().setRemoteCopyMode(from.getRpCopyMode());
}
if (isNotNullValue(from.getRpRpoType())) {
if (protection.getRecoverPoint().getSourcePolicy() == null) {
protection.getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
}
protection.getRecoverPoint().getSourcePolicy().setRpoType(from.getRpRpoType());
}
if (from.checkRpRpoValueSet()) {
if (protection.getRecoverPoint().getSourcePolicy() == null) {
protection.getRecoverPoint().setSourcePolicy(new ProtectionSourcePolicy());
}
protection.getRecoverPoint().getSourcePolicy().setRpoValue(from.getRpRpoValue());
}
protection.getRecoverPoint().setCopies(new HashSet<VirtualPoolProtectionVirtualArraySettingsParam>());
for (Map.Entry<URI, VpoolProtectionVarraySettings> setting : protectionSettings.entrySet()) {
VirtualPoolProtectionVirtualArraySettingsParam copy = new VirtualPoolProtectionVirtualArraySettingsParam();
VpoolProtectionVarraySettings value = setting.getValue();
if (value != null) {
copy.setVpool(setting.getValue().getVirtualPool());
copy.setVarray(setting.getKey());
copy.setCopyPolicy(new ProtectionCopyPolicy());
copy.getCopyPolicy().setJournalSize(setting.getValue().getJournalSize());
copy.getCopyPolicy().setJournalVarray(setting.getValue().getJournalVarray());
copy.getCopyPolicy().setJournalVpool(setting.getValue().getJournalVpool());
protection.getRecoverPoint().getCopies().add(copy);
}
}
}
// Show the feature even if it's disabled
protection.setSnapshots(new VirtualPoolProtectionSnapshotsParam());
protection.getSnapshots().setMaxSnapshots(from.getMaxNativeSnapshots());
if (protection.hasAnyProtection()) {
to.setProtection(protection);
}
// VPLEX logic
if (isNotNullValue(from.getHighAvailability())) {
VirtualPoolHighAvailabilityParam haParam = new VirtualPoolHighAvailabilityParam(from.getHighAvailability());
// Set the MetroPoint field.
haParam.setMetroPoint(from.getMetroPoint());
haParam.setAutoCrossConnectExport(from.getAutoCrossConnectExport());
StringMap haVarrayVpoolMap = from.getHaVarrayVpoolMap();
if ((haVarrayVpoolMap != null) && (haVarrayVpoolMap.size() != 0)) {
VirtualPoolHighAvailabilityParam.VirtualArrayVirtualPoolMapEntry varrayVpoolMapEntry = null;
for (Map.Entry<String, String> entry : haVarrayVpoolMap.entrySet()) {
URI vpoolUri = null;
// Logic to ensure "null" doesn't get displayed as the HA vpool.
if (isNotNullValue(entry.getValue())) {
vpoolUri = URI.create(entry.getValue());
}
if (entry.getKey() != null && !entry.getKey().isEmpty()) {
varrayVpoolMapEntry = new VirtualPoolHighAvailabilityParam.VirtualArrayVirtualPoolMapEntry(URI.create(entry.getKey()), vpoolUri);
}
if (isNotNullValue(from.getHaVarrayConnectedToRp()) && !from.getHaVarrayConnectedToRp().isEmpty()) {
varrayVpoolMapEntry.setActiveProtectionAtHASite(true);
} else {
varrayVpoolMapEntry.setActiveProtectionAtHASite(false);
}
haParam.setHaVirtualArrayVirtualPool(varrayVpoolMapEntry);
if (vpoolUri != null) {
VirtualPool haVpool = dbclient.queryObject(VirtualPool.class, vpoolUri);
if (haVpool != null) {
if (haVpool.getMirrorVirtualPool() != null) {
protection.getContinuousCopies().setHaVpool(URI.create(haVpool.getMirrorVirtualPool()));
}
protection.getContinuousCopies().setHaMaxMirrors(haVpool.getMaxNativeContinuousCopies());
}
}
}
}
to.setHighAvailability(haParam);
}
// dedup capability
if (from.getDedupCapable() != null) {
to.setDedupCapable(from.getDedupCapable());
}
return mapVirtualPoolFields(from, to, protectionSettings);
}
Aggregations