use of com.emc.storageos.db.client.model.VolumeGroup 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.db.client.model.VolumeGroup in project coprhd-controller by CoprHD.
the class VolumeGroupService method deactivateVolumeGroup.
/**
* Delete the volume group.
* When a volume group is deleted it will move to a "marked for deletion" state.
*
* @param id the URN of the volume group
* @brief Deactivate application
* @return No data returned in response body
*/
@POST
@Path("/{id}/deactivate")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public Response deactivateVolumeGroup(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, VolumeGroup.class, "id");
VolumeGroup volumeGroup = (VolumeGroup) queryResource(id);
if (!ControllerUtils.getVolumeGroupVolumes(_dbClient, volumeGroup).isEmpty()) {
// application could not be deleted if it has volumes
throw APIException.badRequests.volumeGroupWithVolumesCantBeDeleted(volumeGroup.getLabel());
}
if (!getVolumeGroupHosts(_dbClient, volumeGroup).isEmpty()) {
// application could not be deleted if it has hosts
throw APIException.badRequests.volumeGroupWithHostsCantBeDeleted(volumeGroup.getLabel());
}
if (!getVolumeGroupClusters(_dbClient, volumeGroup).isEmpty()) {
// application could not be deleted if it has clusters
throw APIException.badRequests.volumeGroupWithClustersCantBeDeleted(volumeGroup.getLabel());
}
if (!getVolumeGroupChildren(_dbClient, volumeGroup).isEmpty()) {
// application could not be deleted if it has child volume groups
throw APIException.badRequests.volumeGroupWithChildrenCantBeDeleted(volumeGroup.getLabel());
}
// check for any other references to this volume group
ArgValidator.checkReference(VolumeGroup.class, id, checkForDelete(volumeGroup));
_dbClient.markForDeletion(volumeGroup);
auditOp(OperationTypeEnum.DELETE_CONFIG, true, null, id.toString(), volumeGroup.getLabel());
return Response.ok().build();
}
use of com.emc.storageos.db.client.model.VolumeGroup in project coprhd-controller by CoprHD.
the class VolumeGroupService method getHosts.
/**
* Get application hosts
*
* @param id Application Id
* @brief List hosts for an application
* @return HostList
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/hosts")
public HostList getHosts(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, VolumeGroup.class, "id");
VolumeGroup volumeGroup = _dbClient.queryObject(VolumeGroup.class, id);
HostList result = new HostList();
List<Host> hosts = getVolumeGroupHosts(_dbClient, volumeGroup);
for (Host host : hosts) {
result.getHosts().add(toNamedRelatedResource(host));
}
return result;
}
use of com.emc.storageos.db.client.model.VolumeGroup in project coprhd-controller by CoprHD.
the class VolumeGroupService method restoreVolumeGroupFullCopy.
/**
* Restore the specified Volume group full copy.
* - Restores full copy for all the array replication groups within this Application.
* - If partial flag is specified, it restores full copy only for set of array replication groups.
* A Full Copy from each array replication group can be provided to indicate which array replication
* groups's full copies needs to be restored.
*
* @prereq Create Volume group full copy as active.
*
* @param volumeGroupId The URI of the Volume group.
* @param fullCopyURI The URI of the full copy.
*
* @brief Restore Volume group full copy.
*
* @return TaskList
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/full-copies/restore")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.ANY })
public TaskList restoreVolumeGroupFullCopy(@PathParam("id") final URI volumeGroupId, final VolumeGroupFullCopyRestoreParam param) {
ArgValidator.checkFieldUriType(volumeGroupId, VolumeGroup.class, "id");
// Query Volume Group
final VolumeGroup volumeGroup = (VolumeGroup) queryResource(volumeGroupId);
TaskList taskList = new TaskList();
// validate replica operation for volume group
validateCopyOperationForVolumeGroup(volumeGroup, ReplicaTypeEnum.FULL_COPY);
// validate the requested full copies
List<Volume> fullCopyVolumesInRequest = new ArrayList<Volume>();
boolean partial = validateFullCopiesInRequest(fullCopyVolumesInRequest, param.getFullCopies(), param.getCopySetName(), param.getSubGroups(), volumeGroupId);
/**
* 1. VolumeGroupService Clone API accepts a Clone URI (to identify clone set and RG)
* - then get All full copies belonging to same full copy set
* - get full copy set name from the requested full copy
* 2. If partial, there will be a List of Clone URIs (one from each RG)
* 3. Group the full copies by Replication Group(RG)
* 4. For each RG, invoke the ConsistencyGroup full copy API (CG uri, clone uri)
* - a. Skip the CG/RG calls when thrown error and continue with other entries; create 'ERROR' Task for this call
* - b. Finally return the Task List (RG tasks may finish at different times as they are different calls)
*/
if (!partial) {
Volume fullCopy = fullCopyVolumesInRequest.get(0);
log.info("Full Copy operation requested for entire Application, Considering full copy {} in request.", fullCopy.getLabel());
fullCopyVolumesInRequest.clear();
fullCopyVolumesInRequest.addAll(getClonesBySetName(fullCopy.getFullCopySetName(), volumeGroup.getId()));
} else {
log.info("Full Copy operation requested for subset of array replication groups in Application.");
}
checkForApplicationPendingTasks(volumeGroup, _dbClient, true);
Map<String, Volume> repGroupToFullCopyMap = groupVolumesByReplicationGroup(fullCopyVolumesInRequest);
for (Map.Entry<String, Volume> entry : repGroupToFullCopyMap.entrySet()) {
String replicationGroup = entry.getKey();
Volume fullCopy = entry.getValue();
log.info("Processing Array Replication Group {}, Full Copy {}", replicationGroup, fullCopy.getLabel());
try {
// get CG URI
URI cgURI = getConsistencyGroupForFullCopy(fullCopy);
// Restore the full copy. Note that it will take into account the
// fact that the volume is in a ReplicationGroup
// and all volumes in that ReplicationGroup will be restored.
taskList.getTaskList().addAll(_blockConsistencyGroupService.restoreConsistencyGroupFullCopy(cgURI, fullCopy.getId()).getTaskList());
} catch (InternalException | APIException e) {
String errMsg = String.format("Error restoring Array Replication Group %s, Full Copy %s", replicationGroup, fullCopy.getLabel());
log.error(errMsg, e);
TaskResourceRep task = BlockServiceUtils.createFailedTaskOnVolume(_dbClient, fullCopy, ResourceOperationTypeEnum.RESTORE_VOLUME_FULL_COPY, e);
taskList.addTask(task);
}
}
if (!partial) {
auditOp(OperationTypeEnum.RESTORE_VOLUME_GROUP_FULL_COPY, true, AuditLogManager.AUDITOP_BEGIN, volumeGroup.getId().toString(), fullCopyVolumesInRequest.get(0).getLabel());
}
return taskList;
}
use of com.emc.storageos.db.client.model.VolumeGroup in project coprhd-controller by CoprHD.
the class VolumeGroupService method queryResource.
@Override
protected DataObject queryResource(URI id) {
ArgValidator.checkFieldUriType(id, VolumeGroup.class, "id");
VolumeGroup volumeGroup = _permissionsHelper.getObjectById(id, VolumeGroup.class);
ArgValidator.checkEntityNotNull(volumeGroup, id, isIdEmbeddedInURL(id));
return volumeGroup;
}
Aggregations