Search in sources :

Example 31 with OpStatusMap

use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.

the class RPBlockServiceApiImpl method prepareVolume.

/**
 * Prepare Volume for a RecoverPoint protected volume
 *
 * @param volume Volume to prepare, could be null if brand new vol
 * @param project Project for volume
 * @param varray Varray for volume
 * @param vpool Vpool for volume
 * @param size Size of volume
 * @param recommendation Main rec for this volume
 * @param label Volume label
 * @param consistencyGroup CG for volume
 * @param protectionSystemURI URI for the Protection System
 * @param personality Personality of the volume
 * @param rsetName Replication Set Name
 * @param internalSiteName RP Internal site of the volume
 * @param rpCopyName RP Copy Name
 * @param sourceVolume The source volume
 * @param vplex Boolean that is true if this is a vplex volume
 * @param changeVpoolVolume Existing volume if this is a change vpool
 * @param isPreCreatedVolume
 * @return Fully prepared Volume for RP
 */
public Volume prepareVolume(Volume volume, Project project, VirtualArray varray, VirtualPool vpool, String size, RPRecommendation recommendation, String label, BlockConsistencyGroup consistencyGroup, URI protectionSystemURI, Volume.PersonalityTypes personality, String rsetName, String internalSiteName, String rpCopyName, Volume sourceVolume, boolean vplex, Volume changeVpoolVolume, boolean isPreCreatedVolume) {
    // Check to see if this is a change vpool volume, if so, use it as the already existing volume.
    volume = (changeVpoolVolume != null) ? changeVpoolVolume : volume;
    // If volume is still null, then it's a brand new volume
    boolean isNewVolume = (volume == null);
    if (isNewVolume || isPreCreatedVolume) {
        if (!isPreCreatedVolume) {
            volume = new Volume();
            volume.setId(URIUtil.createId(Volume.class));
            volume.setOpStatus(new OpStatusMap());
        } else {
            // Reload volume object from DB
            volume = _dbClient.queryObject(Volume.class, volume.getId());
        }
        volume.setSyncActive(true);
        volume.setLabel(label);
        volume.setCapacity(SizeUtil.translateSize(size));
        volume.setThinlyProvisioned(VirtualPool.ProvisioningType.Thin.toString().equalsIgnoreCase(vpool.getSupportedProvisioningType()));
        volume.setVirtualPool(vpool.getId());
        volume.setProject(new NamedURI(project.getId(), volume.getLabel()));
        volume.setTenant(new NamedURI(project.getTenantOrg().getURI(), volume.getLabel()));
        volume.setVirtualArray(varray.getId());
        if (null != recommendation.getSourceStoragePool()) {
            StoragePool pool = _dbClient.queryObject(StoragePool.class, recommendation.getSourceStoragePool());
            if (null != pool) {
                volume.setProtocol(new StringSet());
                volume.getProtocol().addAll(VirtualPoolUtil.getMatchingProtocols(vpool.getProtocols(), pool.getProtocols()));
                if (!vplex) {
                    volume.setPool(pool.getId());
                    volume.setStorageController(pool.getStorageDevice());
                    StorageSystem storageSystem = _dbClient.queryObject(StorageSystem.class, pool.getStorageDevice());
                    String systemType = storageSystem.checkIfVmax3() ? DiscoveredDataObject.Type.vmax3.name() : storageSystem.getSystemType();
                    volume.setSystemType(systemType);
                }
            }
        }
        volume.setVirtualArray(varray.getId());
    }
    // Set all Journal Volumes to have the INTERNAL_OBJECT flag.
    if (personality.equals(Volume.PersonalityTypes.METADATA)) {
        volume.addInternalFlags(Flag.INTERNAL_OBJECT);
        volume.addInternalFlags(Flag.SUPPORTS_FORCE);
        volume.setAccessState(Volume.VolumeAccessState.NOT_READY.name());
    } else if (personality.equals(Volume.PersonalityTypes.SOURCE)) {
        volume.setAccessState(Volume.VolumeAccessState.READWRITE.name());
        volume.setLinkStatus(Volume.LinkStatus.OTHER.name());
    } else if (personality.equals(Volume.PersonalityTypes.TARGET)) {
        volume.setAccessState(Volume.VolumeAccessState.NOT_READY.name());
        volume.setLinkStatus(Volume.LinkStatus.OTHER.name());
    }
    if (consistencyGroup != null) {
        volume.setConsistencyGroup(consistencyGroup.getId());
        // backend volumes added to backend CGs.
        if (changeVpoolVolume != null && !changeVpoolVolume.checkForRp() && RPHelper.isVPlexVolume(changeVpoolVolume, _dbClient)) {
            // if the CG has array consistency enabled and the CG supports LOCAL type.
            if (consistencyGroup.getArrayConsistency()) {
                if (null == changeVpoolVolume.getAssociatedVolumes() || changeVpoolVolume.getAssociatedVolumes().isEmpty()) {
                    _log.error("VPLEX volume {} has no backend volumes.", changeVpoolVolume.forDisplay());
                    throw InternalServerErrorException.internalServerErrors.noAssociatedVolumesForVPLEXVolume(changeVpoolVolume.forDisplay());
                }
                for (String backendVolumeId : changeVpoolVolume.getAssociatedVolumes()) {
                    Volume backingVolume = _dbClient.queryObject(Volume.class, URI.create(backendVolumeId));
                    String rgName = consistencyGroup.getCgNameOnStorageSystem(backingVolume.getStorageController());
                    if (rgName == null) {
                        // for new CG
                        rgName = consistencyGroup.getLabel();
                    } else {
                        // if other volumes in the same CG are in an application, add this volume to the same application
                        VolumeGroup volumeGroup = ControllerUtils.getApplicationForCG(_dbClient, consistencyGroup, rgName);
                        if (volumeGroup != null) {
                            backingVolume.getVolumeGroupIds().add(volumeGroup.getId().toString());
                        }
                    }
                    _log.info(String.format("Preparing VPLEX volume [%s](%s) for RP Protection, " + "backend end volume [%s](%s) updated with replication group name: %s", volume.getLabel(), volume.getId(), backingVolume.getLabel(), backingVolume.getId(), rgName));
                    backingVolume.setReplicationGroupInstance(rgName);
                    changeVpoolVolume.setBackingReplicationGroupInstance(rgName);
                    _dbClient.updateObject(backingVolume);
                }
            }
        }
    }
    volume.setPersonality(personality.toString());
    volume.setProtectionController(protectionSystemURI);
    volume.setRSetName(rsetName);
    volume.setInternalSiteName(internalSiteName);
    volume.setRpCopyName(rpCopyName);
    if (NullColumnValueGetter.isNotNullValue(vpool.getAutoTierPolicyName())) {
        URI autoTierPolicyUri = StorageScheduler.getAutoTierPolicy(volume.getPool(), vpool.getAutoTierPolicyName(), _dbClient);
        if (null != autoTierPolicyUri) {
            volume.setAutoTieringPolicyUri(autoTierPolicyUri);
        }
    }
    if (isNewVolume && !isPreCreatedVolume) {
        // Create the volume in the db
        _dbClient.createObject(volume);
    } else {
        _dbClient.updateObject(volume);
    }
    // Keep track of target volumes associated with the source volume
    if (sourceVolume != null) {
        if (sourceVolume.getRpTargets() == null) {
            sourceVolume.setRpTargets(new StringSet());
        }
        sourceVolume.getRpTargets().add(volume.getId().toString());
        _dbClient.updateObject(sourceVolume);
    }
    return volume;
}
Also used : StoragePool(com.emc.storageos.db.client.model.StoragePool) Volume(com.emc.storageos.db.client.model.Volume) NamedURI(com.emc.storageos.db.client.model.NamedURI) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) StringSet(com.emc.storageos.db.client.model.StringSet) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) StorageSystem(com.emc.storageos.db.client.model.StorageSystem)

Example 32 with OpStatusMap

use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.

the class RPBlockServiceApiImpl method prepareSnapshots.

/**
 * Prepares the snapshots for a snapshot request.
 *
 * @param volumes The volumes for which snapshots are to be created.
 * @param snapShotType The snapshot technology type.
 * @param snapshotName The snapshot name.
 * @param snapshotURIs [OUT] The URIs for the prepared snapshots.
 * @param taskId The unique task identifier
 *
 * @return The list of snapshots
 */
@Override
public List<BlockSnapshot> prepareSnapshots(List<Volume> volumes, String snapshotType, String snapshotName, List<URI> snapshotURIs, String taskId) {
    List<BlockSnapshot> snapshots = new ArrayList<BlockSnapshot>();
    int index = 1;
    for (Volume volume : volumes) {
        VolumeGroup volumeGroup = volume.getApplication(_dbClient);
        boolean isInApplication = volumeGroup != null && !volumeGroup.getInactive();
        if (RPHelper.isProtectionBasedSnapshot(volume, snapshotType, _dbClient) && snapshotType.equalsIgnoreCase(BlockSnapshot.TechnologyType.RP.toString())) {
            // need to create snapshots on
            if (!volume.getRpTargets().isEmpty()) {
                List<URI> targetVolumeURIs = new ArrayList<URI>();
                // Build a URI list of target volumes for the call to obtain copy access states
                for (String targetVolumeStr : volume.getRpTargets()) {
                    targetVolumeURIs.add(URI.create(targetVolumeStr));
                }
                // Get a handle on the RPController so we can query the access states associated with the
                // target volumes.
                RPController rpController = getController(RPController.class, ProtectionSystem._RP);
                Map<URI, String> copyAccessStates = rpController.getCopyAccessStates(volume.getProtectionController(), targetVolumeURIs);
                for (URI targetVolumeURI : targetVolumeURIs) {
                    Volume targetVolume = _dbClient.queryObject(Volume.class, targetVolumeURI);
                    // can be created for that copy.
                    if (copyAccessStates != null && !copyAccessStates.isEmpty() && RPHelper.isValidBookmarkState(copyAccessStates.get(targetVolume.getId()))) {
                        BlockSnapshot snapshot = prepareSnapshotFromVolume(volume, snapshotName, targetVolume, 0, snapshotType, isInApplication);
                        snapshot.setOpStatus(new OpStatusMap());
                        snapshot.setEmName(snapshotName);
                        snapshot.setEmInternalSiteName(targetVolume.getInternalSiteName());
                        snapshot.setVirtualArray(targetVolume.getVirtualArray());
                        snapshots.add(snapshot);
                        _log.info(String.format("Prepared snapshot : [%s]", snapshot.getLabel()));
                    } else {
                        _log.warn(String.format("A BlockSnapshot is not being prepared for target volume %s because copy %s is currently in a state [%s] that does not allow bookmarks to be created.", targetVolume.getId(), targetVolume.getRpCopyName(), copyAccessStates.get(targetVolume.getId())));
                    }
                }
            }
        } else {
            boolean vplex = RPHelper.isVPlexVolume(volume, _dbClient);
            Volume volumeToSnap = volume;
            if (vplex) {
                volumeToSnap = vplexBlockServiceApiImpl.getVPLEXSnapshotSourceVolume(volume);
            }
            boolean isRPTarget = false;
            if (NullColumnValueGetter.isNotNullValue(volume.getPersonality()) && volume.getPersonality().equals(PersonalityTypes.TARGET.name())) {
                isRPTarget = true;
            }
            BlockSnapshot snapshot = prepareSnapshotFromVolume(volumeToSnap, snapshotName, (isRPTarget ? volume : null), index++, snapshotType, isInApplication);
            snapshot.setTechnologyType(snapshotType);
            // Check to see if the RP Copy Name of this volume contains any of the RP Source
            // suffix's appended by ViPR
            boolean rpCopyNameContainsSrcSuffix = NullColumnValueGetter.isNotNullValue(volume.getRpCopyName()) && (volume.getRpCopyName().contains(SRC_COPY_SUFFIX) || volume.getRpCopyName().contains(MP_ACTIVE_COPY_SUFFIX) || volume.getRpCopyName().contains(MP_STANDBY_COPY_SUFFIX));
            // Hotfix for COP-18957
            // Check to see if the requested volume is a former Source.
            // We do this by checking to see if this is a Target volume and that the RP Copy Name
            // contains any of the RP Source suffix's appended by ViPR.
            // 
            // TODO: This is a short term solution since there will be a better way of determining
            // this in future releases.
            // 
            // FIXME: One concern here is RP ingestion where ViPR isn't the one who sets the copy names.
            // Valid concern and this needs to be changed when RP ingest supports RP+VPLEX: Yoda/Yoda+.
            boolean isFormerSource = isRPTarget && rpCopyNameContainsSrcSuffix;
            // Check to see if the requested volume is a former target that is now the
            // source as a result of a swap. This is done by checking the source volume's
            // virtual pool for RP protection. If RP protection does not exist, we know this
            // is a former target.
            // TODO: In the future the swap functionality should update the vpools accordingly to
            // add/remove protection. This check should be removed at that point and another
            // method to check for a swapped state should be used.
            boolean isFormerTarget = false;
            if (NullColumnValueGetter.isNotNullValue(volume.getPersonality()) && volume.getPersonality().equals(PersonalityTypes.SOURCE.name()) && !rpCopyNameContainsSrcSuffix) {
                isFormerTarget = true;
            }
            if (!isInApplication && (((isRPTarget || isFormerTarget) && vplex && !isFormerSource) || !vplex)) {
                // For RP+Vplex targets (who are not former source volumes) and former target volumes,
                // we do not want to create a backing array CG snap. To avoid doing this, we do not
                // set the consistency group.
                // OR
                // This is a native snapshot so do not set the consistency group, otherwise
                // the SMIS code/array will get confused trying to look for a consistency
                // group that only exists in RecoverPoint.
                snapshot.setConsistencyGroup(null);
            }
            snapshots.add(snapshot);
            _log.info(String.format("Prepared snapshot : [%s]", snapshot.getLabel()));
        }
    }
    if (!snapshots.isEmpty()) {
        for (BlockSnapshot snapshot : snapshots) {
            Operation op = new Operation();
            op.setResourceType(ResourceOperationTypeEnum.CREATE_VOLUME_SNAPSHOT);
            op.setStartTime(Calendar.getInstance());
            snapshot.getOpStatus().createTaskStatus(taskId, op);
            snapshotURIs.add(snapshot.getId());
        }
        // Create all the snapshot objects
        _dbClient.createObject(snapshots);
    } else {
        // are in direct access mode (invalid bookmark state).
        throw APIException.badRequests.cannotCreateSnapshots();
    }
    // But only return the unique ones
    return snapshots;
}
Also used : BlockSnapshot(com.emc.storageos.db.client.model.BlockSnapshot) ArrayList(java.util.ArrayList) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) Operation(com.emc.storageos.db.client.model.Operation) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) AlternateIdConstraint(com.emc.storageos.db.client.constraint.AlternateIdConstraint) Volume(com.emc.storageos.db.client.model.Volume) RPController(com.emc.storageos.protectioncontroller.RPController) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup)

Example 33 with OpStatusMap

use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.

the class FileService method mountExport.

/**
 * Perform a mount operation for a file system
 * <p>
 * NOTE: This is an asynchronous operation.
 *
 * @param id
 *            the URN of a ViPR File system
 * @param param
 *            File system mount parameters
 * @brief Mount a file system
 * @return Task resource representation
 * @throws InternalException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/mount")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep mountExport(@PathParam("id") URI id, FileSystemMountParam param) throws InternalException {
    _log.info("FileService::mount Request recieved {}", id);
    String task = UUID.randomUUID().toString();
    ArgValidator.checkFieldUriType(id, FileShare.class, "id");
    // Get the FileSystem object from the URN
    FileShare fs = queryResource(id);
    ArgValidator.checkEntity(fs, id, isIdEmbeddedInURL(id));
    // validations
    if (!isSubDirValid(fs, param.getSubDir())) {
        throw APIException.badRequests.invalidParameter("sub_directory", param.getSubDir());
    }
    if (!isFSTypeValid(param)) {
        throw APIException.badRequests.invalidParameter("fs_type", param.getFsType());
    }
    if (!isSecurityValid(fs, param)) {
        throw APIException.badRequests.invalidParameter("security", param.getSecurity());
    }
    fs.setOpStatus(new OpStatusMap());
    Operation op = new Operation();
    op.setResourceType(ResourceOperationTypeEnum.MOUNT_NFS_EXPORT);
    fs.getOpStatus().createTaskStatus(task, op);
    _dbClient.updateObject(fs);
    // Now get ready to make calls into the controller
    ComputeSystemOrchestrationController controller = getController(ComputeSystemOrchestrationController.class, null);
    try {
        controller.mountDevice(param.getHost(), id, param.getSubDir(), param.getSecurity(), param.getPath(), param.getFsType(), task);
    } catch (Exception e) {
        // should discriminate between validation problems vs. internal errors
        throw e;
    }
    auditOp(OperationTypeEnum.MOUNT_NFS_EXPORT, true, AuditLogManager.AUDITOP_BEGIN, fs.getName(), fs.getId().toString(), param.getHost().toString(), param.getSubDir(), param.getPath());
    fs = _dbClient.queryObject(FileShare.class, id);
    _log.debug("FileService::Mount Before sending response, FS ID : {}, Taks : {} ; Status {}", fs.getOpStatus().get(task), fs.getOpStatus().get(task).getStatus());
    return toTask(fs, task, op);
}
Also used : ComputeSystemOrchestrationController(com.emc.storageos.computesystemorchestrationcontroller.ComputeSystemOrchestrationController) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) URISyntaxException(java.net.URISyntaxException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 34 with OpStatusMap

use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.

the class FileService method snapshot.

/**
 * Create file system snapshot
 * <p>
 * NOTE: This is an asynchronous operation.
 *
 * @param id
 *            the URN of a ViPR File system
 * @param param
 *            file system snapshot parameters
 * @brief Create file system snapshot
 * @return Task resource representation
 * @throws InternalException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/snapshots")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.ANY })
public TaskResourceRep snapshot(@PathParam("id") URI id, FileSystemSnapshotParam param) throws InternalException {
    ArgValidator.checkFieldUriType(id, FileShare.class, "id");
    FileShare fs = queryResource(id);
    ArgValidator.checkEntity(fs, id, isIdEmbeddedInURL(id));
    StorageSystem device = _dbClient.queryObject(StorageSystem.class, fs.getStorageDevice());
    VirtualPool vpool = _dbClient.queryObject(VirtualPool.class, fs.getVirtualPool());
    if (vpool == null) {
        throw APIException.badRequests.invalidParameterFileSystemHasNoVirtualPool(id);
    }
    if (getNumSnapshots(fs) >= vpool.getMaxNativeSnapshots()) {
        throw APIException.methodNotAllowed.maximumNumberSnapshotsReached();
    }
    String label = TimeUtils.formatDateForCurrent(param.getLabel());
    // check duplicate fileshare snapshot names for this fileshare
    checkForDuplicateName(label, Snapshot.class, id, "parent", _dbClient);
    Snapshot snap = new Snapshot();
    snap.setId(URIUtil.createId(Snapshot.class));
    snap.setParent(new NamedURI(id, label));
    snap.setLabel(label);
    snap.setOpStatus(new OpStatusMap());
    snap.setProject(new NamedURI(fs.getProject().getURI(), label));
    String convertedName = label.replaceAll("[^\\dA-Za-z_]", "");
    _log.info("Original name {} and converted name {}", label, convertedName);
    snap.setName(convertedName);
    fs.setOpStatus(new OpStatusMap());
    Operation op = new Operation();
    op.setResourceType(ResourceOperationTypeEnum.CREATE_FILE_SYSTEM_SNAPSHOT);
    String task = UUID.randomUUID().toString();
    snap.getOpStatus().createTaskStatus(task, op);
    fs.getOpStatus().createTaskStatus(task, op);
    _dbClient.createObject(snap);
    _dbClient.persistObject(fs);
    // find storageport for fs and based on protocol
    if (null == fs.getStoragePort()) {
        StoragePort storagePort;
        try {
            // assigned storageport to fs
            storagePort = _fileScheduler.placeFileShareExport(fs, PROTOCOL_NFS, null);
            _log.info("FS is not mounted so we are mounting the FS first and then creating the Snapshot and the returned storage port- {} and supported protocol-{}", storagePort.getPortName(), PROTOCOL_NFS);
        } catch (APIException e) {
            // if we don't find port for NFS protocol then
            // in catch exception we get port for CIFS protocol
            storagePort = _fileScheduler.placeFileShareExport(fs, PROTOCOL_CIFS, null);
            _log.info("FS is not mounted so we are mounting the FS first and then creating the Snapshot and the returned storage port- {} and supported protocol-{}", storagePort.getPortName(), PROTOCOL_NFS);
        }
    }
    // send request to controller
    try {
        FileServiceApi fileServiceApi = getFileShareServiceImpl(fs, _dbClient);
        fileServiceApi.snapshotFS(device.getId(), snap.getId(), fs.getId(), task);
    } catch (InternalException e) {
        snap.setInactive(true);
        _dbClient.persistObject(snap);
        // should discriminate between validation problems vs. internal errors
        throw e;
    }
    auditOp(OperationTypeEnum.CREATE_FILE_SYSTEM_SNAPSHOT, true, AuditLogManager.AUDITOP_BEGIN, snap.getLabel(), snap.getId().toString(), fs.getId().toString());
    fs = _dbClient.queryObject(FileShare.class, id);
    _log.debug("Before sending response, FS ID : {}, Taks : {} ; Status {}", fs.getOpStatus().get(task), fs.getOpStatus().get(task).getStatus());
    return toTask(snap, task, op);
}
Also used : Snapshot(com.emc.storageos.db.client.model.Snapshot) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) NamedURI(com.emc.storageos.db.client.model.NamedURI) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) StoragePort(com.emc.storageos.db.client.model.StoragePort) VirtualPool(com.emc.storageos.db.client.model.VirtualPool) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) StorageSystem(com.emc.storageos.db.client.model.StorageSystem) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 35 with OpStatusMap

use of com.emc.storageos.db.client.model.OpStatusMap in project coprhd-controller by CoprHD.

the class FileService method unmountExport.

/**
 * unmount an exported filesystem
 * <p>
 * NOTE: This is an asynchronous operation.
 *
 * @param id
 *            the URN of the fs
 * @param param
 *            FileSystemUnmountParam
 * @brief Unmount a file system
 * @return Task resource representation
 * @throws com.emc.storageos.svcs.errorhandling.resources.InternalException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/unmount")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep unmountExport(@PathParam("id") URI id, FileSystemUnmountParam param) throws InternalException {
    FileShare fs = queryResource(id);
    ArgValidator.checkEntity(fs, id, isIdEmbeddedInURL(id));
    // validations
    if (!isMountPathValid(param.getHostId(), param.getMountPath())) {
        throw APIException.badRequests.invalidParameter("mount_path", param.getMountPath());
    }
    _log.info("FileService::unmount export Request recieved {}", id);
    String task = UUID.randomUUID().toString();
    Operation op = new Operation();
    op.setResourceType(ResourceOperationTypeEnum.UNMOUNT_NFS_EXPORT);
    fs.setOpStatus(new OpStatusMap());
    fs.getOpStatus().createTaskStatus(task, op);
    _dbClient.updateObject(fs);
    // Now get ready to make calls into the controller
    ComputeSystemOrchestrationController controller = getController(ComputeSystemOrchestrationController.class, null);
    try {
        controller.unmountDevice(param.getHostId(), id, param.getMountPath(), task);
    } catch (InternalException e) {
        throw e;
    }
    auditOp(OperationTypeEnum.UNMOUNT_NFS_EXPORT, true, AuditLogManager.AUDITOP_BEGIN, param.getHostId(), param.getMountPath());
    fs = _dbClient.queryObject(FileShare.class, fs.getId());
    _log.debug("FileService::unmount Before sending response, FS ID : {}, Task : {} ; Status {}", fs.getOpStatus().get(task), fs.getOpStatus().get(task).getStatus());
    return toTask(fs, task, op);
}
Also used : ComputeSystemOrchestrationController(com.emc.storageos.computesystemorchestrationcontroller.ComputeSystemOrchestrationController) OpStatusMap(com.emc.storageos.db.client.model.OpStatusMap) Operation(com.emc.storageos.db.client.model.Operation) FileShare(com.emc.storageos.db.client.model.FileShare) SMBFileShare(com.emc.storageos.db.client.model.SMBFileShare) MapFileShare(com.emc.storageos.api.mapper.functions.MapFileShare) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

OpStatusMap (com.emc.storageos.db.client.model.OpStatusMap)48 Operation (com.emc.storageos.db.client.model.Operation)29 NamedURI (com.emc.storageos.db.client.model.NamedURI)28 Volume (com.emc.storageos.db.client.model.Volume)15 URI (java.net.URI)15 StorageSystem (com.emc.storageos.db.client.model.StorageSystem)13 StringSet (com.emc.storageos.db.client.model.StringSet)13 FileShare (com.emc.storageos.db.client.model.FileShare)12 ArrayList (java.util.ArrayList)10 SMBFileShare (com.emc.storageos.db.client.model.SMBFileShare)9 StringMap (com.emc.storageos.db.client.model.StringMap)9 HashMap (java.util.HashMap)9 StoragePool (com.emc.storageos.db.client.model.StoragePool)8 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)7 MapFileShare (com.emc.storageos.api.mapper.functions.MapFileShare)6 BlockSnapshot (com.emc.storageos.db.client.model.BlockSnapshot)6 DataObject (com.emc.storageos.db.client.model.DataObject)6 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)6 Consumes (javax.ws.rs.Consumes)6 AlternateIdConstraint (com.emc.storageos.db.client.constraint.AlternateIdConstraint)5