use of com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException in project coprhd-controller by CoprHD.
the class BlockConsistencyGroupService method activateConsistencyGroupSnapshot.
/**
* Activate the specified Consistency Group Snapshot
*
* @prereq Create consistency group snapshot as inactive
*
* @param consistencyGroupId
* - Consistency group URI
* @param snapshotId
* - Consistency group snapshot URI
*
* @brief Activate consistency group snapshot
* @return TaskResourceRep
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/snapshots/{sid}/activate")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.ANY })
public TaskResourceRep activateConsistencyGroupSnapshot(@PathParam("id") final URI consistencyGroupId, @PathParam("sid") final URI snapshotId) {
Operation op = new Operation();
op.setResourceType(ResourceOperationTypeEnum.ACTIVATE_CONSISTENCY_GROUP_SNAPSHOT);
final BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) queryResource(consistencyGroupId);
final BlockSnapshot snapshot = (BlockSnapshot) queryResource(snapshotId);
verifySnapshotIsForConsistencyGroup(snapshot, consistencyGroup);
// check for backend CG
if (BlockConsistencyGroupUtils.getLocalSystemsInCG(consistencyGroup, _dbClient).isEmpty()) {
_log.error("{} Group Snapshot operations not supported when there is no backend CG", consistencyGroup.getId());
throw APIException.badRequests.cannotCreateSnapshotOfCG();
}
final StorageSystem device = _dbClient.queryObject(StorageSystem.class, snapshot.getStorageController());
final BlockController controller = getController(BlockController.class, device.getSystemType());
final String task = UUID.randomUUID().toString();
// activate it again.
if (snapshot.getIsSyncActive()) {
op.ready();
op.setMessage("The consistency group snapshot is already active.");
_dbClient.createTaskOpStatus(BlockSnapshot.class, snapshot.getId(), task, op);
return toTask(snapshot, task, op);
}
_dbClient.createTaskOpStatus(BlockSnapshot.class, snapshot.getId(), task, op);
try {
final List<URI> snapshotList = new ArrayList<URI>();
// Query all the snapshots by snapshot label
final List<BlockSnapshot> snaps = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshot, _dbClient);
// Build a URI list with all the snapshots ids
for (BlockSnapshot snap : snaps) {
snapshotList.add(snap.getId());
}
// Activate snapshots
controller.activateSnapshot(device.getId(), snapshotList, task);
} catch (final ControllerException e) {
throw new ServiceCodeException(CONTROLLER_ERROR, e, "An exception occurred when activating consistency group snapshot {0}. Caused by: {1}", new Object[] { snapshotId, e.getMessage() });
}
auditBlockConsistencyGroup(OperationTypeEnum.ACTIVATE_CONSISTENCY_GROUP_SNAPSHOT, AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_BEGIN, snapshot.getId().toString(), snapshot.getLabel());
return toTask(snapshot, task, op);
}
use of com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException in project coprhd-controller by CoprHD.
the class BlockService method performProtectionAction.
/**
* Since all of the protection operations are very similar, this method does all of the work.
* We keep the actual REST methods separate mostly for the purpose of documentation generators.
*
* @param id
* the URN of a ViPR source volume
* @param copyID
* id of the target volume
* @param pointInTime
* any point in time used for failover, specified in UTC.
* Allowed values: "yyyy-MM-dd_HH:mm:ss" formatted date or datetime in milliseconds. Can be
* null.
* @param op
* operation to perform (pause, stop, failover, etc)
* @return task resource rep
* @throws InternalException
*/
private TaskResourceRep performProtectionAction(URI id, Copy copy, String op) throws InternalException {
ArgValidator.checkFieldUriType(copy.getCopyID(), Volume.class, "copyID");
// Get the volume associated with the URI
Volume volume = queryVolumeResource(id);
Volume copyVolume = queryVolumeResource(copy.getCopyID());
ArgValidator.checkEntity(volume, id, true);
ArgValidator.checkEntity(copyVolume, copy.getCopyID(), true);
if (op.equalsIgnoreCase(ProtectionOp.SWAP.getRestOp()) && !NullColumnValueGetter.isNullURI(volume.getConsistencyGroup())) {
ExportUtils.validateConsistencyGroupBookmarksExported(_dbClient, volume.getConsistencyGroup());
}
// cancel operations)
if ((op.equalsIgnoreCase(ProtectionOp.CHANGE_ACCESS_MODE.getRestOp()) || op.equalsIgnoreCase(ProtectionOp.FAILOVER.getRestOp()) || op.equalsIgnoreCase(ProtectionOp.FAILOVER_CANCEL.getRestOp())) && !NullColumnValueGetter.isNullURI(volume.getConsistencyGroup()) && !volume.getConsistencyGroup().equals(copyVolume.getConsistencyGroup())) {
throw APIException.badRequests.invalidConsistencyGroupsForProtectionOperation();
}
// Catch any attempts to use an invalid access mode
if (op.equalsIgnoreCase(ProtectionOp.CHANGE_ACCESS_MODE.getRestOp()) && !Copy.ImageAccessMode.DIRECT_ACCESS.name().equalsIgnoreCase(copy.getAccessMode())) {
throw APIException.badRequests.unsupportedAccessMode(copy.getAccessMode());
}
if (isNullURI(volume.getProtectionController())) {
throw new ServiceCodeException(ServiceCode.IO_ERROR, "Attempt to do protection link management on unprotected volume: {0}", new Object[] { volume.getWWN() });
}
// Make sure that we don't have some pending
// operation against the volume
checkForPendingTasks(Arrays.asList(volume.getTenant().getURI()), Arrays.asList(volume));
String task = UUID.randomUUID().toString();
Operation status = new Operation();
status.setResourceType(ProtectionOp.getResourceOperationTypeEnum(op));
_dbClient.createTaskOpStatus(Volume.class, volume.getId(), task, status);
_log.info(String.format("Protection %s --- VolumeId id: %s on Protection Appliance: %s", task, id, volume.getProtectionController()));
ProtectionSystem system = _dbClient.queryObject(ProtectionSystem.class, volume.getProtectionController());
String deviceType = system.getSystemType();
if (!deviceType.equals(DiscoveredDataObject.Type.rp.name())) {
throw APIException.badRequests.protectionForRpClusters();
}
RPController controller = getController(RPController.class, system.getSystemType());
controller.performProtectionOperation(system.getId(), id, copy.getCopyID(), copy.getPointInTime(), copy.getAccessMode(), op, task);
/*
* auditOp(OperationTypeEnum.PERFORM_PROTECTION_ACTION, true, AuditLogManager.AUDITOP_BEGIN,
* op, copyID.toString(), id.toString(), system.getId().toString());
*/
return toTask(volume, task, status);
}
use of com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException in project coprhd-controller by CoprHD.
the class BlockService method verifyVirtualPoolChangeSupportedForVolumeAndVirtualPool.
/**
* Determines whether or not the passed VirtualPool change for the passed Volume is
* supported. Throws a ServiceCodeException when the vpool change is not
* supported.
*
* @param volume
* A reference to the volume.
* @param newVpool
* A reference to the new VirtualPool.
*/
private void verifyVirtualPoolChangeSupportedForVolumeAndVirtualPool(Volume volume, VirtualPool newVpool) {
// Currently, Vpool change is only supported for volumes on
// VPlex storage systems and volumes (both regular and VPLEX i.e. RP+VPLEX) that are currently
// unprotected by RP to a Vpool that has RP, as long as the source volume doesn't have to move.
VirtualPool currentVpool = _dbClient.queryObject(VirtualPool.class, volume.getVirtualPool());
URI systemURI = volume.getStorageController();
StorageSystem system = _dbClient.queryObject(StorageSystem.class, systemURI);
String systemType = system.getSystemType();
StringBuffer notSuppReasonBuff = new StringBuffer();
notSuppReasonBuff.setLength(0);
/**
* Do not support following vpool change operations for the volume part of application
* 1. Move into Vplex
* 2. Add RecoverPoint
* 3. Remove RecoverPoint
* 4. Add SRDF
*/
if (volume.getApplication(_dbClient) != null) {
// Move into VPLEX
if (!VirtualPool.vPoolSpecifiesHighAvailability(currentVpool) && VirtualPool.vPoolSpecifiesHighAvailability(newVpool)) {
notSuppReasonBuff.append("Non VPLEX volumes in applications cannot be moved into VPLEX pools");
throw APIException.badRequests.changeToVirtualPoolNotSupported(newVpool.getLabel(), notSuppReasonBuff.toString());
}
// Add recoverPoint
if (!VirtualPool.vPoolSpecifiesProtection(currentVpool) && VirtualPool.vPoolSpecifiesProtection(newVpool)) {
notSuppReasonBuff.append("Non RP volumes in applications cannot be moved into RP pools");
throw APIException.badRequests.changeToVirtualPoolNotSupported(newVpool.getLabel(), notSuppReasonBuff.toString());
}
// Remove RecoverPoint
if (VirtualPool.vPoolSpecifiesProtection(currentVpool) && !VirtualPool.vPoolSpecifiesProtection(newVpool)) {
notSuppReasonBuff.append("RP volumes in applications cannot be moved into non RP pools");
throw APIException.badRequests.changeToVirtualPoolNotSupported(newVpool.getLabel(), notSuppReasonBuff.toString());
}
// Add SRDF
if (!VirtualPool.vPoolSpecifiesSRDF(currentVpool) && VirtualPool.vPoolSpecifiesSRDF(newVpool)) {
notSuppReasonBuff.append("volumes in applications cannot be moved into SRDF pools");
throw APIException.badRequests.changeToVirtualPoolNotSupported(newVpool.getLabel(), notSuppReasonBuff.toString());
}
}
// Check if an Export Path Params change.
if (VirtualPoolChangeAnalyzer.isSupportedPathParamsChange(volume, currentVpool, newVpool, _dbClient, notSuppReasonBuff)) {
ExportPathUpdater updater = new ExportPathUpdater(_dbClient);
ExportPathParams newParam = new ExportPathParams(newVpool.getNumPaths(), newVpool.getMinPaths(), newVpool.getPathsPerInitiator());
updater.validateChangePathParams(volume.getId(), newParam);
_log.info("New VPool specifies an Export Path Params change");
return;
}
// Check if it is an Auto-tiering policy change.
notSuppReasonBuff.setLength(0);
if (VirtualPoolChangeAnalyzer.isSupportedAutoTieringPolicyAndLimitsChange(volume, currentVpool, newVpool, _dbClient, notSuppReasonBuff)) {
_log.info("New VPool specifies an Auto-tiering policy change");
return;
}
if (VirtualPoolChangeAnalyzer.isSupportedReplicationModeChange(currentVpool, newVpool, notSuppReasonBuff)) {
_log.info("New VPool specifies a replication mode change");
return;
}
if (DiscoveredDataObject.Type.vplex.name().equals(systemType)) {
_log.info("Volume is a VPlex virtual volume.");
// the Vpool specifies a different grade of disk drives.
if (!VirtualPool.vPoolSpecifiesHighAvailability(newVpool)) {
_log.info("New VirtualPool does not specify VPlex high availability.");
throw new ServiceCodeException(ServiceCode.API_VOLUME_VPOOL_CHANGE_DISRUPTIVE, "New VirtualPool {0} does not specify vplex high availability", new Object[] { newVpool.getId() });
} else {
notSuppReasonBuff.setLength(0);
// can be exposed in the Migration Services catalog to support RP+VPLEX Data Migrations.
if (volume.checkPersonality(Volume.PersonalityTypes.METADATA)) {
if (VirtualPoolChangeAnalyzer.vpoolChangeRequiresMigration(currentVpool, newVpool)) {
verifyVPlexVolumeForDataMigration(volume, currentVpool, newVpool, _dbClient);
return;
}
}
// if the request is trying to remove RP protection.
if (volume.checkForRp() && VirtualPool.vPoolSpecifiesProtection(currentVpool) && !VirtualPool.vPoolSpecifiesProtection(newVpool)) {
notSuppReasonBuff.setLength(0);
if (!VirtualPoolChangeAnalyzer.isSupportedRPRemoveProtectionVirtualPoolChange(volume, currentVpool, newVpool, _dbClient, notSuppReasonBuff)) {
throw APIException.badRequests.changeToVirtualPoolNotSupported(newVpool.getLabel(), notSuppReasonBuff.toString());
}
} else if (VirtualPool.vPoolSpecifiesRPVPlex(newVpool)) {
notSuppReasonBuff.setLength(0);
// Check to see if any of the operations for protected vpool to protected vpool changes are supported
if (VirtualPool.vPoolSpecifiesRPVPlex(currentVpool)) {
if (VirtualPoolChangeAnalyzer.isSupportedRPVPlexMigrationVirtualPoolChange(volume, currentVpool, newVpool, _dbClient, notSuppReasonBuff, null)) {
verifyVPlexVolumeForDataMigration(volume, currentVpool, newVpool, _dbClient);
} else if (!VirtualPoolChangeAnalyzer.isSupportedUpgradeToMetroPointVirtualPoolChange(volume, currentVpool, newVpool, _dbClient, notSuppReasonBuff)) {
_log.warn("RP Change Protection VirtualPool change for volume is not supported: {}", notSuppReasonBuff.toString());
throw APIException.badRequests.changeToVirtualPoolNotSupported(newVpool.getLabel(), notSuppReasonBuff.toString());
}
} else // Otherwise, check to see if we're trying to protect a VPLEX volume.
if (!VirtualPoolChangeAnalyzer.isSupportedAddRPProtectionVirtualPoolChange(volume, currentVpool, newVpool, _dbClient, notSuppReasonBuff)) {
_log.warn("RP+VPLEX VirtualPool change for volume is not supported: {}", notSuppReasonBuff.toString());
throw APIException.badRequests.changeToVirtualPoolNotSupported(newVpool.getLabel(), notSuppReasonBuff.toString());
} else if (BlockFullCopyUtils.volumeHasFullCopySession(volume, _dbClient)) {
// Full copies not supported for RP protected volumes.
throw APIException.badRequests.volumeForRPVpoolChangeHasFullCopies(volume.getLabel());
}
} else {
VirtualPoolChangeOperationEnum vplexVpoolChangeOperation = VirtualPoolChangeAnalyzer.getSupportedVPlexVolumeVirtualPoolChangeOperation(volume, currentVpool, newVpool, _dbClient, notSuppReasonBuff);
if (vplexVpoolChangeOperation == null) {
_log.warn("VPlex volume VirtualPool change not supported {}", notSuppReasonBuff.toString());
throw APIException.badRequests.changeToVirtualPoolNotSupported(newVpool.getLabel(), notSuppReasonBuff.toString());
} else if (VPlexUtil.isVolumeBuiltOnBlockSnapshot(_dbClient, volume)) {
// created using the target volume of a block snapshot.
throw APIException.badRequests.vpoolChangeNotAllowedVolumeIsExposedSnapshot(volume.getId().toString());
} else if (vplexVpoolChangeOperation == VirtualPoolChangeOperationEnum.VPLEX_DATA_MIGRATION) {
verifyVPlexVolumeForDataMigration(volume, currentVpool, newVpool, _dbClient);
}
}
}
} else if (DiscoveredDataObject.Type.vmax.name().equals(systemType) || DiscoveredDataObject.Type.vnxblock.name().equals(systemType) || DiscoveredDataObject.Type.hds.name().equals(systemType) || DiscoveredDataObject.Type.xtremio.name().equals(systemType) || DiscoveredDataObject.Type.ibmxiv.name().equals(systemType) || DiscoveredDataObject.Type.unity.name().equals(systemType)) {
if (VirtualPool.vPoolSpecifiesHighAvailability(newVpool)) {
// VNX/VMAX import to VPLEX cases
notSuppReasonBuff.setLength(0);
if (!VirtualPoolChangeAnalyzer.isVPlexImport(volume, currentVpool, newVpool, notSuppReasonBuff) || (!VirtualPoolChangeAnalyzer.doesVplexVpoolContainVolumeStoragePool(volume, newVpool, notSuppReasonBuff))) {
_log.warn("VNX/VMAX cos change for volume is not supported: {}", notSuppReasonBuff.toString());
throw APIException.badRequests.changeToVirtualPoolNotSupported(newVpool.getLabel(), notSuppReasonBuff.toString());
}
if (volume.isVolumeExported(_dbClient)) {
throw APIException.badRequests.cannotImportExportedVolumeToVplex(volume.getId());
} else if (BlockFullCopyUtils.volumeHasFullCopySession(volume, _dbClient)) {
// The backend would have a full copy, but the VPLEX volume would not.
throw APIException.badRequests.volumeForVpoolChangeHasFullCopies(volume.getLabel());
} else {
// Can't be imported if it has snapshot sessions, because we
// don't currently support these behind VPLEX.
List<BlockSnapshotSession> snapSessions = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, BlockSnapshotSession.class, ContainmentConstraint.Factory.getParentSnapshotSessionConstraint(volume.getId()));
if (!snapSessions.isEmpty()) {
throw APIException.badRequests.cannotImportVolumeWithSnapshotSessions(volume.getLabel());
}
}
} else if (VirtualPool.vPoolSpecifiesProtection(newVpool)) {
// VNX/VMAX import to RP cases (currently one)
notSuppReasonBuff.setLength(0);
if (!VirtualPoolChangeAnalyzer.isSupportedAddRPProtectionVirtualPoolChange(volume, currentVpool, newVpool, _dbClient, notSuppReasonBuff)) {
_log.warn("VirtualPool change to Add RP Protection for volume is not supported: {}", notSuppReasonBuff.toString());
throw APIException.badRequests.changeToVirtualPoolNotSupported(newVpool.getLabel(), notSuppReasonBuff.toString());
} else if (BlockFullCopyUtils.volumeHasFullCopySession(volume, _dbClient)) {
// Full copies not supported for RP protected volumes.
throw APIException.badRequests.volumeForRPVpoolChangeHasFullCopies(volume.getLabel());
} else {
// Can't add RP if it has snapshot sessions, because we
// don't currently support these for RP protected volumes.
List<BlockSnapshotSession> snapSessions = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, BlockSnapshotSession.class, ContainmentConstraint.Factory.getParentSnapshotSessionConstraint(volume.getId()));
if (!snapSessions.isEmpty()) {
throw APIException.badRequests.volumeForRPVpoolChangeHasSnapshotSessions(volume.getLabel());
}
}
} else if (VirtualPool.vPoolSpecifiesProtection(currentVpool) && !VirtualPool.vPoolSpecifiesProtection(newVpool)) {
notSuppReasonBuff.setLength(0);
if (!VirtualPoolChangeAnalyzer.isSupportedRPRemoveProtectionVirtualPoolChange(volume, currentVpool, newVpool, _dbClient, notSuppReasonBuff)) {
throw APIException.badRequests.changeToVirtualPoolNotSupported(newVpool.getLabel(), notSuppReasonBuff.toString());
}
} else if (VirtualPool.vPoolSpecifiesSRDF(newVpool)) {
// VMAX import to SRDF cases (currently one)
notSuppReasonBuff.setLength(0);
if (!VirtualPoolChangeAnalyzer.isSupportedSRDFVolumeVirtualPoolChange(volume, currentVpool, newVpool, _dbClient, notSuppReasonBuff)) {
_log.warn("VMAX VirtualPool change for volume is not supported: {}", notSuppReasonBuff.toString());
throw APIException.badRequests.changeToVirtualPoolNotSupported(newVpool.getLabel(), notSuppReasonBuff.toString());
} else if (BlockFullCopyUtils.volumeHasFullCopySession(volume, _dbClient)) {
// Full copy not supported for volumes with asynchronous copy mode.
Map<URI, VpoolRemoteCopyProtectionSettings> remoteCopySettingsMap = VirtualPool.getRemoteProtectionSettings(newVpool, _dbClient);
VpoolRemoteCopyProtectionSettings remoteCopyProtectionSettings = remoteCopySettingsMap.values().iterator().next();
if (SupportedCopyModes.ASYNCHRONOUS.toString().equalsIgnoreCase(remoteCopyProtectionSettings.getCopyMode())) {
throw APIException.badRequests.volumeForSRDFVpoolChangeHasFullCopies(volume.getLabel());
}
}
} else if (!NullColumnValueGetter.isNullNamedURI(volume.getSrdfParent()) || (volume.getSrdfTargets() != null && !volume.getSrdfTargets().isEmpty())) {
// Cannot move SRDF Volume to non SRDF VPool
throw APIException.badRequests.srdfVolumeVPoolChangeToNonSRDFVPoolNotSupported(volume.getId());
} else if (VirtualPool.vPoolSpecifiesMirrors(newVpool, _dbClient)) {
notSuppReasonBuff.setLength(0);
if (!VirtualPoolChangeAnalyzer.isSupportedAddMirrorsVirtualPoolChange(volume, currentVpool, newVpool, _dbClient, notSuppReasonBuff)) {
_log.warn("VirtualPool change to add continuous copies for volume {} is not supported: {}", volume.getId(), notSuppReasonBuff.toString());
throw APIException.badRequests.changeToVirtualPoolNotSupported(newVpool.getLabel(), notSuppReasonBuff.toString());
}
} else {
String errMsg = "there was an invalid property mismatch between source and target vPools.";
_log.error(errMsg);
notSuppReasonBuff.append(errMsg);
throw APIException.badRequests.changeToVirtualPoolNotSupported(newVpool.getLabel(), notSuppReasonBuff.toString());
}
} else {
_log.info("VirtualPool change volume is not a vplex, vmax or vnxblock volume");
throw new ServiceCodeException(ServiceCode.API_VOLUME_VPOOL_CHANGE_DISRUPTIVE, "VirtualPool change is not supported for volume {0}", new Object[] { volume.getId() });
}
}
use of com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException in project coprhd-controller by CoprHD.
the class DataObjectChangeAnalyzer method lookForChanges.
/**
* Scans the methods looking for ones annotated with the Name annotation.
* When found (if not excluded), invokes the method on each of the DataObjects
* and then compares the results.
*
* @param left
* @param right
* @param changes
* @param included -- If not null, only fields in included are checked.
* @param excluded -- Fields that are excluded are not checked. Must not be null.
* @param contained -- If not null, values for fields in contained are checked.
*/
private static void lookForChanges(DataObject left, DataObject right, HashMap<String, Change> changes, Set<String> included, Set<String> excluded, Set<String> contained) {
Class refClass = left.getClass();
Method[] methods = refClass.getMethods();
for (Method method : methods) {
boolean contain = false;
// We only analyze methods that have the "Name" annotation
Name nameAnn = method.getAnnotation(Name.class);
if (nameAnn == null) {
continue;
}
String key = nameAnn.value();
// If contained is not null and it contains the key set contain flag to true
if (contained != null && contained.contains(key)) {
contain = true;
} else // If included is not null, and does not contain the name, exclude it.
if (included != null && !included.contains(key)) {
continue;
}
// Skip any excluded annotation names
if (excluded.contains(key)) {
continue;
}
Class type = method.getReturnType();
try {
Object obja = method.invoke(left);
Object objb = method.invoke(right);
if (type == StringSet.class) {
if (contain) {
analyzeNewStringSetContainsOldStringSetValues((StringSet) obja, (StringSet) objb, key, changes);
} else {
analyzeStringSets((StringSet) obja, (StringSet) objb, key, changes);
}
} else if (type == StringMap.class) {
analyzeStringMaps((StringMap) obja, (StringMap) objb, key, changes);
} else if (type == StringSetMap.class) {
analyzeStringSetMaps((StringSetMap) obja, (StringSetMap) objb, key, changes);
} else {
if (!isEqual(obja, objb)) {
Change change = new Change(key, obja, objb, nameAnn.value());
changes.put(key, change);
}
}
} catch (IllegalAccessException ex) {
throw new ServiceCodeException(ServiceCode.UNFORSEEN_ERROR, ex, ex.getMessage(), new String[] {});
} catch (InvocationTargetException ex) {
throw new ServiceCodeException(ServiceCode.UNFORSEEN_ERROR, ex, ex.getMessage(), new String[] {});
}
}
}
use of com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException in project coprhd-controller by CoprHD.
the class AttributeMatcherFramework method getAvailableAttributes.
/**
* Find the available attributes in a given varray.
*
* @param vArrayId
* @param neighborhoodPools
* @param dbClient
* @param matcherGroupName
*/
public Map<String, Set<String>> getAvailableAttributes(URI vArrayId, List<StoragePool> neighborhoodPools, ObjectLocalCache cache, String matcherGroupName) {
Map<String, Set<String>> vArrayAvailableAttrs = new HashMap<String, Set<String>>();
try {
@SuppressWarnings("unchecked") List<AttributeMatcher> attrMatcherList = (List<AttributeMatcher>) getBeanFromContext(matcherGroupName);
for (AttributeMatcher matcher : attrMatcherList) {
matcher.setObjectCache(cache);
Map<String, Set<String>> availableAttribute = matcher.getAvailableAttribute(neighborhoodPools, vArrayId);
if (!availableAttribute.isEmpty()) {
_logger.info("Found available attributes using matcher {}", matcher);
vArrayAvailableAttrs.putAll(availableAttribute);
}
}
_logger.info("Found {} available attributes for vArray {}", vArrayAvailableAttrs, vArrayId);
} catch (Exception ex) {
_logger.error("Exception occurred while getting available attributes for vArray {}", vArrayId, ex);
vArrayAvailableAttrs.clear();
throw new ServiceCodeException(ServiceCode.CONTROLLER_STORAGE_ERROR, "Exception occurred while getting available attributes for vArray.", new Object[] { vArrayId });
}
return vArrayAvailableAttrs;
}
Aggregations