use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class BlockConsistencyGroupService method resynchronizeConsistencyGroupSnapshot.
/**
* Resynchronize the specified consistency group snapshot
*
* @prereq Activate consistency group snapshot
*
* @param consistencyGroupId
* - Consistency group URI
* @param snapshotId
* - Consistency group snapshot URI
*
* @brief Resynchronize consistency group snapshot
* @return TaskResourceRep
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/snapshots/{sid}/resynchronize")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskResourceRep resynchronizeConsistencyGroupSnapshot(@PathParam("id") final URI consistencyGroupId, @PathParam("sid") final URI snapshotId) {
// Get the consistency group and snapshot and verify the snapshot
// is actually associated with the consistency group.
final BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) queryResource(consistencyGroupId);
final BlockSnapshot snapshot = (BlockSnapshot) queryResource(snapshotId);
verifySnapshotIsForConsistencyGroup(snapshot, consistencyGroup);
// check for backend CG
if (BlockConsistencyGroupUtils.getLocalSystemsInCG(consistencyGroup, _dbClient).isEmpty()) {
_log.error("{} Group Snapshot operations not supported when there is no backend CG", consistencyGroup.getId());
throw APIException.badRequests.cannotCreateSnapshotOfCG();
}
// Get the storage system for the consistency group.
StorageSystem storage = _permissionsHelper.getObjectById(snapshot.getStorageController(), StorageSystem.class);
// resync for OpenStack storage system type is not supported
if (Type.openstack.name().equalsIgnoreCase(storage.getSystemType())) {
throw APIException.methodNotAllowed.notSupportedWithReason(String.format("Snapshot resynchronization is not possible on third-party storage systems"));
}
// resync for IBM XIV storage system type is not supported
if (Type.ibmxiv.name().equalsIgnoreCase(storage.getSystemType())) {
throw APIException.methodNotAllowed.notSupportedWithReason("Snapshot resynchronization is not supported on IBM XIV storage systems");
}
// resync for VNX storage system type is not supported
if (Type.vnxblock.name().equalsIgnoreCase(storage.getSystemType())) {
throw APIException.methodNotAllowed.notSupportedWithReason("Snapshot resynchronization is not supported on VNX storage systems");
}
if (storage.checkIfVmax3()) {
throw APIException.methodNotAllowed.notSupportedWithReason("Snapshot resynchronization is not supported on VMAX3 storage systems");
}
// Get the parent volume.
final Volume snapshotParentVolume = _permissionsHelper.getObjectById(snapshot.getParent(), Volume.class);
// Get the block implementation
BlockServiceApi blockServiceApiImpl = getBlockServiceImpl(consistencyGroup);
// Validate the snapshot restore.
blockServiceApiImpl.validateResynchronizeSnapshot(snapshot, snapshotParentVolume);
// Create the restore operation task for the snapshot.
final String taskId = UUID.randomUUID().toString();
final Operation op = _dbClient.createTaskOpStatus(BlockSnapshot.class, snapshot.getId(), taskId, ResourceOperationTypeEnum.RESYNCHRONIZE_CONSISTENCY_GROUP_SNAPSHOT);
// Resync the snapshot.
blockServiceApiImpl.resynchronizeSnapshot(snapshot, snapshotParentVolume, taskId);
auditBlockConsistencyGroup(OperationTypeEnum.RESTORE_CONSISTENCY_GROUP_SNAPSHOT, AuditLogManager.AUDITLOG_SUCCESS, AuditLogManager.AUDITOP_BEGIN, snapshotId.toString(), consistencyGroupId.toString(), snapshot.getStorageController().toString());
return toTask(snapshot, taskId, op);
}
use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class BlockConsistencyGroupService method validateSessionPartOfConsistencyGroup.
private void validateSessionPartOfConsistencyGroup(URI cgId, URI sessionId) {
ArgValidator.checkUri(sessionId);
ArgValidator.checkUri(cgId);
BlockSnapshotSession session = _dbClient.queryObject(BlockSnapshotSession.class, sessionId);
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, cgId);
if (session == null) {
throw APIException.notFound.unableToFindEntityInURL(sessionId);
}
if (cg == null) {
throw APIException.notFound.unableToFindEntityInURL(cgId);
}
if (!cg.getId().equals(session.getConsistencyGroup())) {
throw APIException.badRequests.snapshotSessionIsNotForConsistencyGroup(session.getLabel(), cg.getLabel());
}
}
use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class BlockConsistencyGroupService method failoverProtection.
/**
* Request to failover the protection link associated with the copy. The target
* copy is specified by identifying the virtual array in param.copyId.
*
* NOTE: This is an asynchronous operation.
*
* If volume is srdf protected, then invoking failover internally triggers
* SRDF SWAP on volume pairs.
*
* @prereq none
*
* @param id the URI of a BlockConsistencyGroup
* @param param Copy to failover to
*
* @brief Failover the protection link
* @return TaskList
*
* @throws ControllerException
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/protection/continuous-copies/failover")
@CheckPermission(roles = { Role.TENANT_ADMIN }, acls = { ACL.OWN, ACL.ALL })
public TaskList failoverProtection(@PathParam("id") URI id, CopiesParam param) throws ControllerException {
TaskResourceRep taskResp = null;
TaskList taskList = new TaskList();
// Validate the consistency group URI
ArgValidator.checkFieldUriType(id, BlockConsistencyGroup.class, "id");
// Validate the list of copies
ArgValidator.checkFieldNotEmpty(param.getCopies(), "copies");
// Query Consistency Group
final BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) queryResource(id);
// system types.
if (!consistencyGroup.created()) {
throw APIException.badRequests.consistencyGroupNotCreated();
}
List<Copy> copies = param.getCopies();
if (copies.size() > 1) {
throw APIException.badRequests.failoverCopiesParamCanOnlyBeOne();
}
Copy copy = copies.get(0);
ArgValidator.checkFieldUriType(copy.getCopyID(), VirtualArray.class, "copyId");
ArgValidator.checkFieldNotEmpty(copy.getType(), "type");
if (TechnologyType.RP.name().equalsIgnoreCase(copy.getType())) {
taskResp = performProtectionAction(id, copy, ProtectionOp.FAILOVER.getRestOp());
taskList.getTaskList().add(taskResp);
} else if (TechnologyType.SRDF.name().equalsIgnoreCase(copy.getType())) {
taskResp = performSRDFProtectionAction(id, copy, ProtectionOp.FAILOVER.getRestOp());
taskList.getTaskList().add(taskResp);
} else {
throw APIException.badRequests.invalidCopyType(copy.getType());
}
return taskList;
}
use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class BlockService method queryConsistencyGroup.
/**
* Gets and verifies the consistency group passed in the request.
*
* @param consistencyGroupUri
* URI of the Consistency Group
*
* @return A reference to the BlockConsistencyGroup.
*/
private BlockConsistencyGroup queryConsistencyGroup(final URI consistencyGroupUri) {
ArgValidator.checkFieldNotNull(consistencyGroupUri, "consistency_group");
ArgValidator.checkUri(consistencyGroupUri);
final BlockConsistencyGroup consistencyGroup = _dbClient.queryObject(BlockConsistencyGroup.class, consistencyGroupUri);
ArgValidator.checkEntity(consistencyGroup, consistencyGroupUri, isIdEmbeddedInURL(consistencyGroupUri));
return consistencyGroup;
}
use of com.emc.storageos.db.client.model.BlockConsistencyGroup in project coprhd-controller by CoprHD.
the class ExportGroupService method validateDuplicateRPBlockSnapshotsForExport.
/**
* Validates the list of BlockObjects for RecoverPoint bookmarks that reference
* the same consistency group and RP site.
*
* @param blockObjURIs the list of BlockObject URIs.
*/
private void validateDuplicateRPBlockSnapshotsForExport(List<URI> blockObjURIs) {
Map<URI, List<String>> cgToRpSiteMap = new HashMap<URI, List<String>>();
for (URI blockObjectURI : blockObjURIs) {
if (URIUtil.isType(blockObjectURI, BlockSnapshot.class)) {
BlockSnapshot snapshot = _dbClient.queryObject(BlockSnapshot.class, blockObjectURI);
if (TechnologyType.RP.name().equalsIgnoreCase(snapshot.getTechnologyType()) && !NullColumnValueGetter.isNullURI(snapshot.getConsistencyGroup())) {
// Check to see if there is an RP bookmark that references
// the same RP copy and consistency group.
List<String> rpSites = cgToRpSiteMap.get(snapshot.getConsistencyGroup());
if (rpSites == null) {
// Initialize the list of RP sites
rpSites = new ArrayList<String>();
cgToRpSiteMap.put(snapshot.getConsistencyGroup(), rpSites);
}
if (rpSites.contains(snapshot.getEmInternalSiteName())) {
// Request is trying to export 2 RP bookmarks for the same target copy and
// consistency group.
BlockConsistencyGroup cg = _dbClient.queryObject(BlockConsistencyGroup.class, snapshot.getConsistencyGroup());
String rpCopyName = RPHelper.getCgCopyName(_dbClient, cg, snapshot.getVirtualArray(), false);
throw APIException.badRequests.duplicateRpBookmarkExport(rpCopyName, cg.getLabel());
} else {
rpSites.add(snapshot.getEmInternalSiteName());
}
}
}
}
}
Aggregations