Search in sources :

Example 1 with ServiceCodeException

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);
}
Also used : ControllerException(com.emc.storageos.volumecontroller.ControllerException) BlockController(com.emc.storageos.volumecontroller.BlockController) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException) Operation(com.emc.storageos.db.client.model.Operation) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) MapBlockConsistencyGroup(com.emc.storageos.api.mapper.functions.MapBlockConsistencyGroup) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) BlockObject(com.emc.storageos.db.client.model.BlockObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) DataObject(com.emc.storageos.db.client.model.DataObject) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with ServiceCodeException

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);
}
Also used : MapVolume(com.emc.storageos.api.mapper.functions.MapVolume) Volume(com.emc.storageos.db.client.model.Volume) RPController(com.emc.storageos.protectioncontroller.RPController) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException) Operation(com.emc.storageos.db.client.model.Operation) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem)

Example 3 with ServiceCodeException

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() });
    }
}
Also used : ExportPathUpdater(com.emc.storageos.volumecontroller.placement.ExportPathUpdater) VpoolRemoteCopyProtectionSettings(com.emc.storageos.db.client.model.VpoolRemoteCopyProtectionSettings) BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) VirtualPoolChangeOperationEnum(com.emc.storageos.model.vpool.VirtualPoolChangeOperationEnum) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) URI(java.net.URI) NullColumnValueGetter.isNullURI(com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI) ITLRestRepList(com.emc.storageos.model.block.export.ITLRestRepList) VirtualPoolChangeList(com.emc.storageos.model.vpool.VirtualPoolChangeList) BlockSnapshotSessionList(com.emc.storageos.model.block.BlockSnapshotSessionList) ArrayList(java.util.ArrayList) TaskList(com.emc.storageos.model.TaskList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) List(java.util.List) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) BulkList(com.emc.storageos.api.service.impl.response.BulkList) MigrationList(com.emc.storageos.model.block.MigrationList) SearchedResRepList(com.emc.storageos.api.service.impl.response.SearchedResRepList) MirrorList(com.emc.storageos.model.block.MirrorList) SnapshotList(com.emc.storageos.model.SnapshotList) BlockObject(com.emc.storageos.db.client.model.BlockObject) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) DataObject(com.emc.storageos.db.client.model.DataObject) Map(java.util.Map) HashMap(java.util.HashMap) StringMap(com.emc.storageos.db.client.model.StringMap) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) ExportPathParams(com.emc.storageos.db.client.model.ExportPathParams)

Example 4 with ServiceCodeException

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[] {});
        }
    }
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException) DataObject(com.emc.storageos.db.client.model.DataObject) Method(java.lang.reflect.Method) InvocationTargetException(java.lang.reflect.InvocationTargetException) Name(com.emc.storageos.db.client.model.Name)

Example 5 with ServiceCodeException

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;
}
Also used : AttributeMatcher(com.emc.storageos.volumecontroller.AttributeMatcher) Set(java.util.Set) HashMap(java.util.HashMap) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException) ArrayList(java.util.ArrayList) List(java.util.List) BeansException(org.springframework.beans.BeansException) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException)

Aggregations

ServiceCodeException (com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException)37 BaseServiceCodeExceptionTest (com.emc.storageos.svcs.errorhandling.mappers.BaseServiceCodeExceptionTest)27 Test (org.junit.Test)27 URI (java.net.URI)10 Operation (com.emc.storageos.db.client.model.Operation)5 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)5 ArrayList (java.util.ArrayList)5 DataObject (com.emc.storageos.db.client.model.DataObject)4 Volume (com.emc.storageos.db.client.model.Volume)4 BlockObject (com.emc.storageos.db.client.model.BlockObject)3 DiscoveredDataObject (com.emc.storageos.db.client.model.DiscoveredDataObject)3 NamedURI (com.emc.storageos.db.client.model.NamedURI)3 MapVolume (com.emc.storageos.api.mapper.functions.MapVolume)2 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)2 StringMap (com.emc.storageos.db.client.model.StringMap)2 VirtualPool (com.emc.storageos.db.client.model.VirtualPool)2 NullColumnValueGetter.isNullURI (com.emc.storageos.db.client.util.NullColumnValueGetter.isNullURI)2 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)2 HashMap (java.util.HashMap)2 List (java.util.List)2