Search in sources :

Example 1 with NamedVolumesList

use of com.emc.storageos.model.block.NamedVolumesList in project coprhd-controller by CoprHD.

the class VolumeGroupService method getVolumeGroupFullCopies.

/**
 * List full copies for a volume group
 *
 * @prereq none
 *
 * @param volumeGroupId The URI of the volume group.
 *
 * @brief List full copies for a volume group
 *
 * @return The list of full copies for the volume group
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/full-copies")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public NamedVolumesList getVolumeGroupFullCopies(@PathParam("id") final URI volumeGroupId) {
    ArgValidator.checkFieldUriType(volumeGroupId, VolumeGroup.class, "id");
    // Query Volume Group
    final VolumeGroup volumeGroup = (VolumeGroup) queryResource(volumeGroupId);
    // get all volumes
    List<Volume> volumes = ControllerUtils.getVolumeGroupVolumes(_dbClient, volumeGroup);
    // Cycle over the volumes in the volume group and
    // get the full copies for each volume in the group.
    NamedVolumesList fullCopyList = new NamedVolumesList();
    for (Volume volume : volumes) {
        NamedVolumesList volumeFullCopies = getFullCopyManager().getFullCopiesForSource(volume.getId());
        fullCopyList.getVolumes().addAll(volumeFullCopies.getVolumes());
    }
    return fullCopyList;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with NamedVolumesList

use of com.emc.storageos.model.block.NamedVolumesList in project coprhd-controller by CoprHD.

the class VolumeGroupService method getVolumeGroupFullCopiesForSet.

/**
 * List full copies for a volume group belonging to the provided copy set name
 *
 * @param volumeGroupId The URI of the volume group.
 * @param param VolumeGroupCopySetParam containing the copy set name
 *
 * @brief List full copies for a volume group belonging to the provided copy set name
 *
 * @return The list of full copies for the volume group belonging to the provided copy set name
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/full-copies/copy-sets")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public NamedVolumesList getVolumeGroupFullCopiesForSet(@PathParam("id") final URI volumeGroupId, final VolumeGroupCopySetParam param) {
    ArgValidator.checkFieldUriType(volumeGroupId, VolumeGroup.class, "id");
    // Query Volume Group
    final VolumeGroup volumeGroup = (VolumeGroup) queryResource(volumeGroupId);
    // validate that full copy set name is provided
    String fullCopySetName = param.getCopySetName();
    ArgValidator.checkFieldNotEmpty(fullCopySetName, COPY_SET_NAME_FIELD);
    // validate that the provided set name actually belongs to this Application
    VolumeGroupCopySetList fullCopySetNames = getVolumeGroupFullCopySets(volumeGroupId);
    if (!fullCopySetNames.getCopySets().contains(fullCopySetName)) {
        throw APIException.badRequests.setNameDoesNotBelongToVolumeGroup("Full Copy Set name", fullCopySetName, volumeGroup.getLabel());
    }
    NamedVolumesList fullCopyList = new NamedVolumesList();
    List<Volume> fullCopiesForSet = getClonesBySetName(fullCopySetName, volumeGroupId);
    for (Volume fullCopy : fullCopiesForSet) {
        fullCopyList.getVolumes().add(toNamedRelatedResource(fullCopy));
    }
    return fullCopyList;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) VolumeGroup(com.emc.storageos.db.client.model.VolumeGroup) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) VolumeGroupCopySetList(com.emc.storageos.model.application.VolumeGroupCopySetList) 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 3 with NamedVolumesList

use of com.emc.storageos.model.block.NamedVolumesList in project coprhd-controller by CoprHD.

the class BlockService method getVolumesForVirtualArrayChange.

/**
 * Get Volumes For Virtual Array Change
 *
 * @param projectURI
 * 			the URI of a ViPR project
 *
 * @param varrayURI
 * 			the URI of a ViPR vArray
 *
 * @brief Show potential volumes for virtual array change
 *
 * @return Get Volume for Virtual Array Change
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/varray-change")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public NamedVolumesList getVolumesForVirtualArrayChange(@QueryParam("project") URI projectURI, @QueryParam("targetVarray") URI varrayURI) {
    NamedVolumesList volumeList = new NamedVolumesList();
    // Get the project.
    ArgValidator.checkFieldUriType(projectURI, Project.class, "project");
    Project project = _permissionsHelper.getObjectById(projectURI, Project.class);
    ArgValidator.checkEntity(project, projectURI, false);
    _log.info("Found project {}:{}", projectURI);
    // Verify the user is authorized for the project.
    BlockServiceUtils.verifyUserIsAuthorizedForRequest(project, getUserFromContext(), _permissionsHelper);
    _log.info("User is authorized for project");
    // Get the target virtual array.
    ArgValidator.checkFieldUriType(varrayURI, VirtualArray.class, "targetVarray");
    VirtualArray tgtVarray = _permissionsHelper.getObjectById(varrayURI, VirtualArray.class);
    ArgValidator.checkEntity(tgtVarray, varrayURI, false);
    _log.info("Found target virtual array {}:{}", tgtVarray.getLabel(), varrayURI);
    // Determine all volumes in the project that could potentially
    // be moved to the target virtual array.
    URIQueryResultList volumeIds = new URIQueryResultList();
    _dbClient.queryByConstraint(ContainmentConstraint.Factory.getProjectVolumeConstraint(projectURI), volumeIds);
    Iterator<Volume> volumeItr = _dbClient.queryIterativeObjects(Volume.class, volumeIds);
    while (volumeItr.hasNext()) {
        Volume volume = volumeItr.next();
        try {
            // Don't operate on VPLEX backend, RP Journal volumes,
            // or other internal volumes.
            BlockServiceUtils.validateNotAnInternalBlockObject(volume, false);
            // Don't operate on ingested volumes.
            VolumeIngestionUtil.checkOperationSupportedOnIngestedVolume(volume, ResourceOperationTypeEnum.CHANGE_BLOCK_VOLUME_VARRAY, _dbClient);
            // Can't change to the same varray.
            if (volume.getVirtualArray().equals(varrayURI)) {
                _log.info("Virtual array change not supported for volume {} already in the target varray", volume.getId());
                continue;
            }
            // Get the appropriate block service implementation.
            BlockServiceApi blockServiceAPI = getBlockServiceImpl(volume);
            // Verify that the virtual array change is allowed for the
            // volume and target virtual array.
            blockServiceAPI.verifyVarrayChangeSupportedForVolumeAndVarray(volume, tgtVarray);
            // If so, add it to the list.
            volumeList.getVolumes().add(toNamedRelatedResource(volume));
        } catch (Exception e) {
            _log.info("Virtual array change not supported for volume {}:{}", volume.getId(), e.getMessage());
        }
    }
    return volumeList;
}
Also used : Project(com.emc.storageos.db.client.model.Project) VirtualArray(com.emc.storageos.db.client.model.VirtualArray) MapVolume(com.emc.storageos.api.mapper.functions.MapVolume) Volume(com.emc.storageos.db.client.model.Volume) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) InternalServerErrorException(com.emc.storageos.svcs.errorhandling.resources.InternalServerErrorException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) ServiceCodeException(com.emc.storageos.svcs.errorhandling.resources.ServiceCodeException) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) SOURCE_TO_TARGET(com.emc.storageos.model.block.Copy.SyncDirection.SOURCE_TO_TARGET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 4 with NamedVolumesList

use of com.emc.storageos.model.block.NamedVolumesList in project coprhd-controller by CoprHD.

the class BlockConsistencyGroupService method getConsistencyGroupFullCopies.

/**
 * List full copies for a consistency group
 *
 * @prereq none
 *
 * @param cgURI The URI of the consistency group.
 *
 * @brief List full copies for a consistency group
 *
 * @return The list of full copies for the consistency group
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/full-copies")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public NamedVolumesList getConsistencyGroupFullCopies(@PathParam("id") URI cgURI) {
    // Verify the consistency group in the request and get the
    // volumes in the consistency group.
    List<Volume> cgVolumes = verifyCGForFullCopyRequest(cgURI);
    // if any of the source volumes are in an application, replica management must be done via the application
    for (Volume srcVol : cgVolumes) {
        if (srcVol.getApplication(_dbClient) != null) {
            return new NamedVolumesList();
        }
    }
    // Cycle over the volumes in the consistency group and
    // get the full copies for each volume in the group.
    NamedVolumesList cgFullCopyList = new NamedVolumesList();
    for (Volume cgVolume : cgVolumes) {
        NamedVolumesList cgVolumeFullCopies = getFullCopyManager().getFullCopiesForSource(cgVolume.getId());
        cgFullCopyList.getVolumes().addAll(cgVolumeFullCopies.getVolumes());
    }
    return cgFullCopyList;
}
Also used : Volume(com.emc.storageos.db.client.model.Volume) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) SOURCE_TO_TARGET(com.emc.storageos.model.block.Copy.SyncDirection.SOURCE_TO_TARGET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 5 with NamedVolumesList

use of com.emc.storageos.model.block.NamedVolumesList in project coprhd-controller by CoprHD.

the class BlockProvider method getApplicationReplicationGroups.

@Asset("replicationGroup")
@AssetDependencies({ "application", "applicationSnapshotVirtualArray" })
public List<AssetOption> getApplicationReplicationGroups(AssetOptionsContext ctx, URI applicationId, String virtualArrayParameter) {
    ViPRCoreClient client = api(ctx);
    boolean isTarget = false;
    URI virtualArray = null;
    if (virtualArrayParameter != null && StringUtils.split(virtualArrayParameter, ':')[0].equals("tgt")) {
        virtualArray = URI.create(StringUtils.substringAfter(virtualArrayParameter, ":"));
        isTarget = true;
    } else {
        isTarget = false;
    }
    Set<String> subGroups = Sets.newHashSet();
    NamedVolumesList applicationVolumes = client.application().getVolumeByApplication(applicationId);
    for (NamedRelatedResourceRep volumeId : applicationVolumes.getVolumes()) {
        VolumeRestRep volume = client.blockVolumes().get(volumeId);
        VolumeRestRep parentVolume = volume;
        if (volume.getHaVolumes() != null && !volume.getHaVolumes().isEmpty()) {
            volume = BlockStorageUtils.getVPlexSourceVolume(client, volume);
        }
        if (volume != null && volume.getReplicationGroupInstance() != null) {
            if (isTarget) {
                if (volume.getVirtualArray().getId().equals(virtualArray)) {
                    subGroups.add(volume.getReplicationGroupInstance());
                }
            } else {
                if (!BlockStorageUtils.isRPVolume(parentVolume) || BlockStorageUtils.isRPSourceVolume(parentVolume)) {
                    subGroups.add(volume.getReplicationGroupInstance());
                }
            }
        }
    }
    return createStringOptions(BlockStorageUtils.stripRPTargetFromReplicationGroup(subGroups));
}
Also used : ViPRCoreClient(com.emc.vipr.client.ViPRCoreClient) NamedVolumesList(com.emc.storageos.model.block.NamedVolumesList) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) VolumeRestRep(com.emc.storageos.model.block.VolumeRestRep) URI(java.net.URI) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

NamedVolumesList (com.emc.storageos.model.block.NamedVolumesList)17 VolumeRestRep (com.emc.storageos.model.block.VolumeRestRep)7 Volume (com.emc.storageos.db.client.model.Volume)6 URI (java.net.URI)6 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 GET (javax.ws.rs.GET)4 VolumeGroup (com.emc.storageos.db.client.model.VolumeGroup)3 VolumeGroupCopySetParam (com.emc.storageos.model.application.VolumeGroupCopySetParam)3 ViPRCoreClient (com.emc.vipr.client.ViPRCoreClient)3 HashSet (java.util.HashSet)3 Asset (com.emc.sa.asset.annotation.Asset)2 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)2 SOURCE_TO_TARGET (com.emc.storageos.model.block.Copy.SyncDirection.SOURCE_TO_TARGET)2 CreateCloneOfApplication (com.emc.sa.service.vipr.application.tasks.CreateCloneOfApplication)1 CreateSnapshotForApplication (com.emc.sa.service.vipr.application.tasks.CreateSnapshotForApplication)1 WaitForTasks (com.emc.sa.service.vipr.tasks.WaitForTasks)1 MapVolume (com.emc.storageos.api.mapper.functions.MapVolume)1