Search in sources :

Example 86 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class BlockConsistencyGroupService method deleteConsistencyGroup.

/**
 * Deletes a consistency group
 *
 * Do not delete if snapshots exist for consistency group
 *
 * @prereq Dependent snapshot resources must be deleted
 *
 * @param id the URN of a ViPR Consistency group
 *
 * @brief Delete consistency group
 * @return TaskResourceRep
 *
 * @throws InternalException
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deactivate")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep deleteConsistencyGroup(@PathParam("id") final URI id, @DefaultValue("FULL") @QueryParam("type") String type) throws InternalException {
    // Query for the given consistency group and verify it is valid.
    final BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) queryResource(id);
    ArgValidator.checkReference(BlockConsistencyGroup.class, id, checkForDelete(consistencyGroup));
    // Create a unique task identifier.
    String task = UUID.randomUUID().toString();
    // So, we do need to verify that no volumes reference the CG.
    if (deletingUncreatedConsistencyGroup(consistencyGroup) || VolumeDeleteTypeEnum.VIPR_ONLY.name().equals(type)) {
        markCGForDeletion(consistencyGroup);
        return finishDeactivateTask(consistencyGroup, task);
    }
    // Otherwise, we need to clean up the array consistency groups.
    TaskResourceRep taskRep = null;
    try {
        List<StorageSystem> vplexSystems = BlockConsistencyGroupUtils.getVPlexStorageSystems(consistencyGroup, _dbClient);
        if (!vplexSystems.isEmpty()) {
            // If there is a VPLEX system, then we simply call the VPLEX controller which
            // will delete all VPLEX CGS on all VPLEX systems, and also all local CGs on
            // all local systems.
            BlockServiceApi blockServiceApi = getBlockServiceImpl(DiscoveredDataObject.Type.vplex.name());
            taskRep = blockServiceApi.deleteConsistencyGroup(vplexSystems.get(0), consistencyGroup, task);
        } else {
            // Otherwise, we call the block controller to delete the local CGs on all local systems.
            List<URI> localSystemURIs = BlockConsistencyGroupUtils.getLocalSystems(consistencyGroup, _dbClient);
            if (!localSystemURIs.isEmpty()) {
                boolean foundSystem = false;
                for (URI localSystemURI : localSystemURIs) {
                    StorageSystem localSystem = _dbClient.queryObject(StorageSystem.class, localSystemURI);
                    if (localSystem != null) {
                        foundSystem = true;
                        BlockServiceApi blockServiceApi = getBlockServiceImpl(BLOCKSERVICEAPIIMPL_GROUP);
                        taskRep = blockServiceApi.deleteConsistencyGroup(localSystem, consistencyGroup, task);
                        if (Task.Status.error.name().equals(taskRep.getState())) {
                            break;
                        }
                    } else {
                        _log.warn("Local system {} for consistency group {} does not exist", localSystemURI, consistencyGroup.getLabel());
                    }
                }
                // Check to make sure we found at least one of these local systems.
                if (!foundSystem) {
                    // For some reason we have a CG with local systems, but none of them
                    // are in the database. In this case, we will log a warning and mark
                    // it for deletion.
                    _log.warn("Deleting created consistency group {} where none of the local systems for the group exist", consistencyGroup.getLabel());
                    markCGForDeletion(consistencyGroup);
                    return finishDeactivateTask(consistencyGroup, task);
                }
            } else {
                // For some reason the CG has no VPLEX or local systems but is
                // marked as being active and created. In this case, we will log
                // a warning and mark it for deletion.
                _log.info("Deleting created consistency group {} with no local or VPLEX systems", consistencyGroup.getLabel());
                markCGForDeletion(consistencyGroup);
                return finishDeactivateTask(consistencyGroup, task);
            }
        }
    } catch (APIException | InternalException e) {
        String errorMsg = String.format("Exception attempting to delete consistency group %s: %s", consistencyGroup.getLabel(), e.getMessage());
        _log.error(errorMsg);
        taskRep.setState(Operation.Status.error.name());
        taskRep.setMessage(errorMsg);
        _dbClient.error(BlockConsistencyGroup.class, taskRep.getResource().getId(), task, e);
    } catch (Exception e) {
        String errorMsg = String.format("Exception attempting to delete consistency group %s: %s", consistencyGroup.getLabel(), e.getMessage());
        _log.error(errorMsg);
        APIException apie = APIException.internalServerErrors.genericApisvcError(errorMsg, e);
        taskRep.setState(Operation.Status.error.name());
        taskRep.setMessage(apie.getMessage());
        _dbClient.error(BlockConsistencyGroup.class, taskRep.getResource().getId(), task, apie);
    }
    // the request was successful.
    if (Task.Status.ready.name().equals(taskRep.getState())) {
        markCGForDeletion(consistencyGroup);
    }
    return taskRep;
}
Also used : TaskResourceRep(com.emc.storageos.model.TaskResourceRep) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException) MapBlockConsistencyGroup(com.emc.storageos.api.mapper.functions.MapBlockConsistencyGroup) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) 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 87 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class BlockConsistencyGroupService method deactivateConsistencyGroupSnapshot.

/**
 * Deactivate the specified Consistency Group Snapshot
 *
 * @prereq none
 *
 * @param consistencyGroupId
 *            - Consistency group URI
 * @param snapshotId
 *            - Consistency group snapshot URI
 *
 * @brief Deactivate consistency group snapshot session
 * @return TaskResourceRep
 */
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/snapshots/{sid}/deactivate")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.ANY })
public TaskList deactivateConsistencyGroupSnapshot(@PathParam("id") final URI consistencyGroupId, @PathParam("sid") final URI snapshotId) {
    final BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) queryResource(consistencyGroupId);
    // Snapshots of RecoverPoint consistency groups is not supported.
    if (isIdEmbeddedInURL(consistencyGroupId) && consistencyGroup.checkForType(Types.RP)) {
        throw APIException.badRequests.snapshotsNotSupportedForRPCGs();
    }
    // 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 BlockSnapshot snapshot = (BlockSnapshot) queryResource(snapshotId);
    verifySnapshotIsForConsistencyGroup(snapshot, consistencyGroup);
    // We can ignore dependencies on BlockSnapshotSession. In this case
    // the BlockSnapshot instance is a linked target for a BlockSnapshotSession
    // and we will unlink the snapshot from the session and delete it.
    List<Class<? extends DataObject>> excludeTypes = new ArrayList<Class<? extends DataObject>>();
    excludeTypes.add(BlockSnapshotSession.class);
    ArgValidator.checkReference(BlockSnapshot.class, snapshotId, checkForDelete(snapshot, excludeTypes));
    // Snapshot session linked targets must be unlinked instead.
    BlockSnapshotSession session = BlockSnapshotSessionUtils.getLinkedTargetSnapshotSession(snapshot, _dbClient);
    if (session != null) {
        return deactivateAndUnlinkTargetVolumesForSession(session, snapshot);
    }
    // Generate task id
    final String task = UUID.randomUUID().toString();
    TaskList response = new TaskList();
    // Not an error if the snapshot we try to delete is already deleted
    if (snapshot.getInactive()) {
        Operation op = new Operation();
        op.ready("The consistency group snapshot has already been deactivated");
        op.setResourceType(ResourceOperationTypeEnum.DELETE_CONSISTENCY_GROUP_SNAPSHOT);
        _dbClient.createTaskOpStatus(BlockSnapshot.class, snapshot.getId(), task, op);
        response.getTaskList().add(toTask(snapshot, task, op));
        return response;
    }
    List<BlockSnapshot> snapshots = new ArrayList<BlockSnapshot>();
    snapshots = ControllerUtils.getSnapshotsPartOfReplicationGroup(snapshot, _dbClient);
    // Get the snapshot parent volume.
    Volume parentVolume = _permissionsHelper.getObjectById(snapshot.getParent(), Volume.class);
    // Check that there are no pending tasks for these snapshots.
    checkForPendingTasks(Arrays.asList(parentVolume.getTenant().getURI()), snapshots);
    for (BlockSnapshot snap : snapshots) {
        Operation snapOp = _dbClient.createTaskOpStatus(BlockSnapshot.class, snap.getId(), task, ResourceOperationTypeEnum.DEACTIVATE_VOLUME_SNAPSHOT);
        response.getTaskList().add(toTask(snap, task, snapOp));
    }
    addConsistencyGroupTask(consistencyGroup, response, task, ResourceOperationTypeEnum.DEACTIVATE_CONSISTENCY_GROUP_SNAPSHOT);
    try {
        BlockServiceApi blockServiceApiImpl = BlockService.getBlockServiceImpl(parentVolume, _dbClient);
        blockServiceApiImpl.deleteSnapshot(snapshot, snapshots, task, VolumeDeleteTypeEnum.FULL.name());
    } catch (APIException | InternalException e) {
        String errorMsg = String.format("Exception attempting to delete snapshot %s: %s", snapshot.getId(), e.getMessage());
        _log.error(errorMsg);
        for (TaskResourceRep taskResourceRep : response.getTaskList()) {
            taskResourceRep.setState(Operation.Status.error.name());
            taskResourceRep.setMessage(errorMsg);
            @SuppressWarnings({ "unchecked" }) Class<? extends DataObject> clazz = URIUtil.getModelClass(taskResourceRep.getResource().getId());
            _dbClient.error(clazz, taskResourceRep.getResource().getId(), task, e);
        }
        throw e;
    } catch (Exception e) {
        String errorMsg = String.format("Exception attempting to delete snapshot %s: %s", snapshot.getId(), e.getMessage());
        _log.error(errorMsg);
        APIException apie = APIException.internalServerErrors.genericApisvcError(errorMsg, e);
        for (TaskResourceRep taskResourceRep : response.getTaskList()) {
            taskResourceRep.setState(Operation.Status.error.name());
            taskResourceRep.setMessage(apie.getMessage());
            @SuppressWarnings("unchecked") Class<? extends DataObject> clazz = URIUtil.getModelClass(taskResourceRep.getResource().getId());
            _dbClient.error(clazz, taskResourceRep.getResource().getId(), task, apie);
        }
        throw apie;
    }
    auditBlockConsistencyGroup(OperationTypeEnum.DELETE_CONSISTENCY_GROUP_SNAPSHOT, AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_BEGIN, snapshot.getId().toString(), snapshot.getLabel());
    return response;
}
Also used : BlockSnapshotSession(com.emc.storageos.db.client.model.BlockSnapshotSession) TaskList(com.emc.storageos.model.TaskList) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) TaskResourceRep(com.emc.storageos.model.TaskResourceRep) Operation(com.emc.storageos.db.client.model.Operation) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException) MapBlockConsistencyGroup(com.emc.storageos.api.mapper.functions.MapBlockConsistencyGroup) BlockConsistencyGroup(com.emc.storageos.db.client.model.BlockConsistencyGroup) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DiscoveredDataObject(com.emc.storageos.db.client.model.DiscoveredDataObject) DataObject(com.emc.storageos.db.client.model.DataObject) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) Volume(com.emc.storageos.db.client.model.Volume) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 88 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class ECSObjectStorageDevice method doAddUserSecretKey.

@Override
public ObjectUserSecretKey doAddUserSecretKey(StorageSystem storageObj, String userId, String secretKey) throws InternalException {
    ECSApi ecsApi = getAPI(storageObj);
    ObjectUserSecretKey secretKeyRes = new ObjectUserSecretKey();
    try {
        UserSecretKeysAddCommandResult cmdRes = ecsApi.addUserSecretKey(userId, secretKey);
        // secretKeyRes.setSecret_key_1(cmdRes.getSecret_key()); //for security reason hiding the secrete key
        secretKeyRes.setSecret_key_1_expiry_timestamp(cmdRes.getKey_expiry_timestamp());
        return secretKeyRes;
    } catch (Exception e) {
        _log.error("ECSObjectStorageDevice:doAddUserSecretKey failed");
        throw e;
    }
}
Also used : ECSApi(com.emc.storageos.ecs.api.ECSApi) ObjectUserSecretKey(com.emc.storageos.db.client.model.ObjectUserSecretKey) UserSecretKeysAddCommandResult(com.emc.storageos.ecs.api.UserSecretKeysAddCommandResult) URISyntaxException(java.net.URISyntaxException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) ECSException(com.emc.storageos.ecs.api.ECSException)

Example 89 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class CinderCloneOperations method createSingleClone.

/*
     * (non-Javadoc)
     * 
     * @see com.emc.storageos.volumecontroller.CloneOperations#createSingleClone(
     * com.emc.storageos.db.client.model.StorageSystem, java.net.URI, java.net.URI,
     * java.lang.Boolean,
     * com.emc.storageos.volumecontroller.TaskCompleter)
     */
@Override
public void createSingleClone(StorageSystem storageSystem, URI sourceObject, URI cloneVolume, Boolean createInactive, TaskCompleter taskCompleter) {
    log.info("START createSingleClone operation");
    boolean isVolumeClone = true;
    try {
        BlockObject sourceObj = BlockObject.fetch(dbClient, sourceObject);
        URI tenantUri = null;
        if (sourceObj instanceof BlockSnapshot) {
            // In case of snapshot, get the tenant from its parent volume
            NamedURI parentVolUri = ((BlockSnapshot) sourceObj).getParent();
            Volume parentVolume = dbClient.queryObject(Volume.class, parentVolUri);
            tenantUri = parentVolume.getTenant().getURI();
            isVolumeClone = false;
        } else {
            // This is a default flow
            tenantUri = ((Volume) sourceObj).getTenant().getURI();
            isVolumeClone = true;
        }
        Volume cloneObj = dbClient.queryObject(Volume.class, cloneVolume);
        StoragePool targetPool = dbClient.queryObject(StoragePool.class, cloneObj.getPool());
        TenantOrg tenantOrg = dbClient.queryObject(TenantOrg.class, tenantUri);
        // String cloneLabel = generateLabel(tenantOrg, cloneObj);
        CinderEndPointInfo ep = CinderUtils.getCinderEndPoint(storageSystem.getActiveProviderURI(), dbClient);
        log.info("Getting the cinder APi for the provider with id " + storageSystem.getActiveProviderURI());
        CinderApi cinderApi = cinderApiFactory.getApi(storageSystem.getActiveProviderURI(), ep);
        String volumeId = "";
        if (isVolumeClone) {
            volumeId = cinderApi.cloneVolume(cloneObj.getLabel(), (cloneObj.getCapacity() / (1024 * 1024 * 1024)), targetPool.getNativeId(), sourceObj.getNativeId());
        } else {
            volumeId = cinderApi.createVolumeFromSnapshot(cloneObj.getLabel(), (cloneObj.getCapacity() / (1024 * 1024 * 1024)), targetPool.getNativeId(), sourceObj.getNativeId());
        }
        log.debug("Creating volume with the id " + volumeId + " on Openstack cinder node");
        if (volumeId != null) {
            // Cinder volume/snapshot clones are not sync with source, so
            // set the replication state as DETACHED
            cloneObj.setReplicaState(ReplicationState.DETACHED.name());
            dbClient.persistObject(cloneObj);
            Map<String, URI> volumeIds = new HashMap<String, URI>();
            volumeIds.put(volumeId, cloneObj.getId());
            ControllerServiceImpl.enqueueJob(new QueueJob(new CinderSingleVolumeCreateJob(volumeId, cloneObj.getLabel(), storageSystem.getId(), CinderConstants.ComponentType.volume.name(), ep, taskCompleter, targetPool.getId(), volumeIds)));
        }
    } catch (InternalException e) {
        String errorMsg = String.format(CREATE_ERROR_MSG_FORMAT, sourceObject, cloneVolume);
        log.error(errorMsg, e);
        taskCompleter.error(dbClient, e);
    } catch (Exception e) {
        String errorMsg = String.format(CREATE_ERROR_MSG_FORMAT, sourceObject, cloneVolume);
        log.error(errorMsg, e);
        ServiceError serviceError = DeviceControllerErrors.cinder.operationFailed("createSingleClone", e.getMessage());
        taskCompleter.error(dbClient, serviceError);
    }
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) StoragePool(com.emc.storageos.db.client.model.StoragePool) NamedURI(com.emc.storageos.db.client.model.NamedURI) HashMap(java.util.HashMap) BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) CinderApi(com.emc.storageos.cinder.api.CinderApi) CinderSingleVolumeCreateJob(com.emc.storageos.volumecontroller.impl.cinder.job.CinderSingleVolumeCreateJob) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Volume(com.emc.storageos.db.client.model.Volume) CinderEndPointInfo(com.emc.storageos.cinder.CinderEndPointInfo) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) BlockObject(com.emc.storageos.db.client.model.BlockObject)

Example 90 with InternalException

use of com.emc.storageos.svcs.errorhandling.resources.InternalException in project coprhd-controller by CoprHD.

the class SmisStorageDevice method doCreateVolumes.

@Override
public void doCreateVolumes(final StorageSystem storageSystem, final StoragePool storagePool, final String opId, final List<Volume> volumes, final VirtualPoolCapabilityValuesWrapper capabilities, final TaskCompleter taskCompleter) throws DeviceControllerException {
    String label = null;
    Long capacity = null;
    Long thinVolumePreAllocationSize = null;
    CIMInstance poolSetting = null;
    boolean opCreationFailed = false;
    StringBuilder logMsgBuilder = new StringBuilder(String.format("Create Volume Start - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
    StorageSystem forProvider = _helper.getStorageSystemForProvider(storageSystem, volumes.get(0));
    // volumeGroupObjectPath is required for VMAX3
    CIMObjectPath volumeGroupObjectPath = _helper.getVolumeGroupPath(forProvider, storageSystem, volumes.get(0), storagePool);
    List<String> volumeLabels = new ArrayList<>();
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s , IsThinlyProvisioned: %s", volume.getLabel(), volume.getThinlyProvisioned()));
        String tenantName = "";
        try {
            TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, volume.getTenant().getURI());
            tenantName = tenant.getLabel();
        } catch (DatabaseException e) {
            _log.error("Error lookup TenantOrb object", e);
        }
        label = _nameGenerator.generate(tenantName, volume.getLabel(), volume.getId().toString(), '-', SmisConstants.MAX_VOLUME_NAME_LENGTH);
        volumeLabels.add(label);
        if (capacity == null) {
            capacity = volume.getCapacity();
        }
        if (thinVolumePreAllocationSize == null && volume.getThinVolumePreAllocationSize() > 0) {
            thinVolumePreAllocationSize = volume.getThinVolumePreAllocationSize();
        }
    }
    _log.info(logMsgBuilder.toString());
    boolean isThinlyProvisioned = volumes.get(0).getThinlyProvisioned();
    try {
        CIMObjectPath configSvcPath = _cimPath.getConfigSvcPath(storageSystem);
        CIMArgument[] inArgs = null;
        // I didn't find any ways to add this branching logic based on device Types.
        if (DiscoveredDataObject.Type.vnxblock.toString().equalsIgnoreCase(storageSystem.getSystemType())) {
            String autoTierPolicyName = ControllerUtils.getAutoTieringPolicyName(volumes.get(0).getId(), _dbClient);
            if (autoTierPolicyName.equals(Constants.NONE)) {
                autoTierPolicyName = null;
            }
            inArgs = _helper.getCreateVolumesInputArgumentsOnFastEnabledPool(storageSystem, storagePool, volumeLabels, capacity, volumes.size(), isThinlyProvisioned, autoTierPolicyName);
        } else {
            if (!storageSystem.checkIfVmax3() && isThinlyProvisioned && null != thinVolumePreAllocationSize) {
                poolSetting = _smisStorageDevicePreProcessor.createStoragePoolSetting(storageSystem, storagePool, thinVolumePreAllocationSize);
            }
            if (storageSystem.checkIfVmax3()) {
                inArgs = _helper.getCreateVolumesInputArguments(storageSystem, storagePool, volumeLabels, capacity, volumes.size(), isThinlyProvisioned, true, volumeGroupObjectPath, (null != thinVolumePreAllocationSize));
            } else {
                inArgs = _helper.getCreateVolumesInputArguments(storageSystem, storagePool, volumeLabels, capacity, volumes.size(), isThinlyProvisioned, poolSetting, true);
            }
        }
        CIMArgument[] outArgs = new CIMArgument[5];
        _helper.invokeMethod(forProvider, configSvcPath, _helper.createVolumesMethodName(forProvider), inArgs, outArgs);
        CIMObjectPath job = _cimPath.getCimObjectPathFromOutputArgs(outArgs, SmisConstants.JOB);
        if (job != null) {
            SmisJob createSmisJob = volumes.size() > 1 ? new SmisCreateMultiVolumeJob(job, forProvider.getId(), storagePool.getId(), volumes.size(), taskCompleter) : new SmisCreateVolumeJob(job, forProvider.getId(), storagePool.getId(), taskCompleter);
            ControllerServiceImpl.enqueueJob(new QueueJob(createSmisJob));
        }
    } catch (final InternalException e) {
        _log.error("Problem in doCreateVolumes: ", e);
        opCreationFailed = true;
        taskCompleter.error(_dbClient, e);
    } catch (WBEMException e) {
        _log.error("Problem making SMI-S call: ", e);
        opCreationFailed = true;
        ServiceError serviceError = DeviceControllerErrors.smis.unableToCallStorageProvider(e.getMessage());
        taskCompleter.error(_dbClient, serviceError);
    } catch (Exception e) {
        _log.error("Problem in doCreateVolumes: ", e);
        opCreationFailed = true;
        ServiceError serviceError = DeviceControllerErrors.smis.methodFailed("doCreateVolumes", e.getMessage());
        taskCompleter.error(_dbClient, serviceError);
    }
    if (opCreationFailed) {
        for (Volume vol : volumes) {
            vol.setInactive(true);
            _dbClient.updateObject(vol);
        }
    }
    logMsgBuilder = new StringBuilder(String.format("Create Volumes End - Array:%s, Pool:%s", storageSystem.getSerialNumber(), storagePool.getNativeGuid()));
    for (Volume volume : volumes) {
        logMsgBuilder.append(String.format("%nVolume:%s", volume.getLabel()));
    }
    _log.info(logMsgBuilder.toString());
}
Also used : ServiceError(com.emc.storageos.svcs.errorhandling.model.ServiceError) CIMObjectPath(javax.cim.CIMObjectPath) ArrayList(java.util.ArrayList) WBEMException(javax.wbem.WBEMException) CIMInstance(javax.cim.CIMInstance) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) DeviceControllerException(com.emc.storageos.exceptions.DeviceControllerException) WBEMException(javax.wbem.WBEMException) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) SmisCreateVolumeJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisCreateVolumeJob) Volume(com.emc.storageos.db.client.model.Volume) SmisCreateMultiVolumeJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisCreateMultiVolumeJob) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) SmisJob(com.emc.storageos.volumecontroller.impl.smis.job.SmisJob) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) QueueJob(com.emc.storageos.volumecontroller.impl.job.QueueJob) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) CIMArgument(javax.cim.CIMArgument)

Aggregations

InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)209 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)112 URI (java.net.URI)106 ControllerException (com.emc.storageos.volumecontroller.ControllerException)100 Volume (com.emc.storageos.db.client.model.Volume)91 ArrayList (java.util.ArrayList)86 WorkflowException (com.emc.storageos.workflow.WorkflowException)84 DatabaseException (com.emc.storageos.db.exceptions.DatabaseException)83 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)77 NamedURI (com.emc.storageos.db.client.model.NamedURI)63 ServiceError (com.emc.storageos.svcs.errorhandling.model.ServiceError)60 URISyntaxException (java.net.URISyntaxException)58 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)55 Operation (com.emc.storageos.db.client.model.Operation)51 InternalServerErrorException (com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException)45 Workflow (com.emc.storageos.workflow.Workflow)41 TaskResourceRep (com.emc.storageos.model.TaskResourceRep)40 Path (javax.ws.rs.Path)39 Produces (javax.ws.rs.Produces)39 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)37