use of com.emc.storageos.db.client.model.VolumeGroup in project coprhd-controller by CoprHD.
the class VolumeGroupService method getVolumeGroup.
/**
* List a volume group
*
* @param id volume group Id
* @brief Show details for a volume group
* @return ApplicationRestRep
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
public VolumeGroupRestRep getVolumeGroup(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, VolumeGroup.class, "id");
VolumeGroup volumeGroup = (VolumeGroup) queryResource(id);
StorageOSUser user = getUserFromContext();
if (!_permissionsHelper.userHasGivenRole(user, null, Role.SYSTEM_MONITOR, Role.TENANT_ADMIN, Role.SECURITY_ADMIN)) {
// Check if the application tenant is the same as the user tenant
List<Volume> volumes = ControllerUtils.getVolumeGroupVolumes(_dbClient, volumeGroup);
if (volumes != null && !volumes.isEmpty()) {
URI tenant = URI.create(user.getTenantId());
Volume firstVol = volumes.get(0);
URI volTenant = firstVol.getTenant().getURI();
if (!volTenant.equals(tenant)) {
APIException.forbidden.insufficientPermissionsForUser(user.getName());
}
}
}
VolumeGroupRestRep resp = DbObjectMapper.map(volumeGroup);
resp.setReplicationGroupNames(CopyVolumeGroupUtils.getReplicationGroupNames(volumeGroup, _dbClient));
resp.setVirtualArrays(CopyVolumeGroupUtils.getVirtualArrays(volumeGroup, _dbClient));
return resp;
}
use of com.emc.storageos.db.client.model.VolumeGroup in project coprhd-controller by CoprHD.
the class VolumeGroupService method validateSnapshotOperation.
/**
* Validates a snapshot operation and throws and exception if the operation cannot be done:
* - checks for pending tasks
* - for deactivate snapshot, check for any exported snapshots
*
* @param volumeGroupId
* @param snapsetToSnapshots
* @param opType
*/
private void validateSnapshotOperation(URI volumeGroupId, Map<String, List<BlockSnapshot>> snapsetToSnapshots, OperationTypeEnum opType) {
// Check for pending tasks
VolumeGroup volumeGroup = _dbClient.queryObject(VolumeGroup.class, volumeGroupId);
if (opType == OperationTypeEnum.RESTORE_VOLUME_GROUP_SNAPSHOT) {
checkForApplicationPendingTasks(volumeGroup, _dbClient, true);
} else {
checkForApplicationPendingTasks(volumeGroup, _dbClient, false);
if (opType == OperationTypeEnum.DEACTIVATE_VOLUME_GROUP_SNAPSHOT) {
for (Entry<String, List<BlockSnapshot>> entry : snapsetToSnapshots.entrySet()) {
String snapsetName = entry.getKey();
List<BlockSnapshot> snapshotList = entry.getValue();
for (BlockSnapshot snapshot : snapshotList) {
if (snapshot.isSnapshotExported(_dbClient)) {
throw APIException.badRequests.cannotDeleteApplicationSnapshotExportExists(volumeGroup.getLabel(), snapsetName);
}
}
}
}
}
}
use of com.emc.storageos.db.client.model.VolumeGroup in project coprhd-controller by CoprHD.
the class VolumeGroupService method getChildrenVolumeGroups.
/**
* Get the list of child volume groups
*
* @param id
* @brief List the child volume groups
* @return
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/volume-groups")
public NamedVolumeGroupsList getChildrenVolumeGroups(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, VolumeGroup.class, "id");
VolumeGroup volumeGroup = _dbClient.queryObject(VolumeGroup.class, id);
NamedVolumeGroupsList result = new NamedVolumeGroupsList();
List<VolumeGroup> volumeGroups = getVolumeGroupChildren(_dbClient, volumeGroup);
for (VolumeGroup group : volumeGroups) {
result.getVolumeGroups().add(toNamedRelatedResource(group));
}
return result;
}
use of com.emc.storageos.db.client.model.VolumeGroup in project coprhd-controller by CoprHD.
the class VolumeGroupService method getVolumeGroupSnapsetSessionSets.
/**
* Get all snapshot session set names for a volume group.
*
* @param volumeGroupId The URI of the volume group
*
* @brief List snapset labels for a volume group
*
* @return VolumeGroupCopySetList
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/snapshot-sessions/copy-sets")
@CheckPermission(roles = { Role.SYSTEM_MONITOR, Role.TENANT_ADMIN }, acls = { ACL.ANY })
public VolumeGroupCopySetList getVolumeGroupSnapsetSessionSets(@PathParam("id") final URI volumeGroupId) {
ArgValidator.checkFieldUriType(volumeGroupId, VolumeGroup.class, ID_FIELD);
// query volume group
final VolumeGroup volumeGroup = (VolumeGroup) queryResource(volumeGroupId);
return getVolumeGroupSnapsetSessionSets(volumeGroup);
}
use of com.emc.storageos.db.client.model.VolumeGroup in project coprhd-controller by CoprHD.
the class VolumeGroupService method exposeVolumeGroupSnapshotAsVolume.
/**
* Exposes the target volumes associated with application BlockSnapshot instances
* as ViPR Volumes. The BlockSnapshot instances must represent snapshots
* whose parent volumes are the backend volumes for VPLEX volumes. That is, it must be a
* VPLEX snapshot. The purpose is to expose the backend snapshot as a VPLEX volume so
* that access to the snapshot is via the VPLEX rather than directly via the backend
* storage system.
*
* The volumes created are not added to the application
*
* @prereq Create volume group snapshot
*
* @param volumeGroupId The URI of the volume group
* @param param VolumeGroupSnapshotOperationParam
*
* @brief Expose application snapshots as vplex volumes
*
* @return TaskList
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/snapshots/expose")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.ANY })
public TaskList exposeVolumeGroupSnapshotAsVolume(@PathParam("id") final URI volumeGroupId, final VolumeGroupSnapshotOperationParam param) {
Map<String, List<BlockSnapshot>> snapsetToSnapshots = getSnapshotsGroupedBySnapset(volumeGroupId, param);
// Check for pending tasks
VolumeGroup volumeGroup = _dbClient.queryObject(VolumeGroup.class, volumeGroupId);
checkForApplicationPendingTasks(volumeGroup, _dbClient, false);
TaskList taskList = new TaskList();
for (List<BlockSnapshot> snapshots : snapsetToSnapshots.values()) {
for (BlockSnapshot snapshot : snapshots) {
taskList.addTask(_blockSnapshotService.exposeSnapshotAsVolume(snapshot.getId()));
}
}
return taskList;
}
Aggregations