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;
}
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;
}
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;
}
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;
}
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));
}
Aggregations