use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.
the class ProtectionSystemService method queryResource.
/**
* Gets the protection system with the passed id from the database.
*
* @param id the URN of a ViPR protection system
*
* @return A reference to the registered ProtectionSystem.
*
* @throws BadRequestException When the protection system is not
* registered.
*/
@Override
protected ProtectionSystem queryResource(URI id) {
ArgValidator.checkUri(id);
ProtectionSystem system = _dbClient.queryObject(ProtectionSystem.class, id);
ArgValidator.checkEntityNotNull(system, id, isIdEmbeddedInURL(id));
if (!RegistrationStatus.REGISTERED.toString().equalsIgnoreCase(system.getRegistrationStatus())) {
throw APIException.badRequests.resourceAlreadyRegistered(ProtectionSystem.class.getSimpleName(), id);
}
return system;
}
use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.
the class ProtectionSystemService method updateProtectionSystem.
/**
* Allows the user to update credentials for a manually created protection systems.
*
* @param id the URN of a ViPR protection system
* @param param The protection system details to update.
*
* @brief Update protection system credentials
* @return A ProtectionSystemRestRep reference specifying the protection system
* data.
*
* @throws InternalException When an error occurs discovering the protection
* system.
*/
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep updateProtectionSystem(@PathParam("id") URI id, ProtectionSystemUpdateRequestParam param) throws InternalException {
ProtectionSystem system = _dbClient.queryObject(ProtectionSystem.class, id);
ArgValidator.checkEntityNotNull(system, id, isIdEmbeddedInURL(id));
// and Compatibility Status.
if (!system.getIpAddress().equals(param.getIpAddress())) {
system.setMajorVersion("");
system.setCompatibilityStatus(DiscoveredDataObject.CompatibilityStatus.UNKNOWN.toString());
}
// Update the IP, port, username, and password with the new incoming values
system.setIpAddress(param.getIpAddress());
system.setPortNumber(param.getPortNumber());
system.setUsername(param.getUserName());
system.setPassword(param.getPassword());
// Must force a discover during an update.
system.setLastDiscoveryRunTime(new Long(0));
// Make necessary changes to the protection system's cluster->varray assignments
modifyClusterVarrayAssignments(system, param.getVarrayChanges());
// Persist the object changes
_dbClient.persistObject(system);
auditOp(OperationTypeEnum.UPDATE_PROTECTION_SYSTEM, true, null, system.getId().toString(), param.getIpAddress(), param.getPortNumber(), param.getUserName());
startProtectionSystem(system);
// execute discovery
ProtectionController controller = getController(RPController.class, system.getSystemType());
ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
String taskId = UUID.randomUUID().toString();
tasks.add(new AsyncTask(ProtectionSystem.class, system.getId(), taskId));
TaskList taskList = discoverProtectionSystems(tasks, controller);
return taskList.getTaskList().iterator().next();
}
use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.
the class RPBlockServiceApiImpl method updateVolumesInVolumeGroup.
/**
* {@inheritDoc}
*/
@Override
public void updateVolumesInVolumeGroup(VolumeGroupVolumeList addVolumes, List<Volume> removeVolumes, URI applicationId, String taskId) {
VolumeGroup volumeGroup = _dbClient.queryObject(VolumeGroup.class, applicationId);
ApplicationAddVolumeList addVolumeList = null;
List<URI> removeVolumesURI = null;
RPController controller = null;
URI protSystemUri = null;
Volume firstVolume = null;
if (addVolumes != null && addVolumes.getVolumes() != null && !addVolumes.getVolumes().isEmpty()) {
addVolumeList = addVolumesToApplication(addVolumes, volumeGroup);
List<URI> vols = addVolumeList.getVolumes();
if (vols != null && !vols.isEmpty()) {
firstVolume = _dbClient.queryObject(Volume.class, vols.get(0));
}
}
if (removeVolumes != null && !removeVolumes.isEmpty()) {
removeVolumesURI = getValidVolumesToRemoveFromCG(removeVolumes);
if (firstVolume == null) {
firstVolume = removeVolumes.get(0);
}
}
if ((addVolumeList != null && !addVolumeList.getVolumes().isEmpty()) || (removeVolumesURI != null && !removeVolumesURI.isEmpty())) {
protSystemUri = firstVolume.getProtectionController();
ProtectionSystem system = _dbClient.queryObject(ProtectionSystem.class, protSystemUri);
controller = getController(RPController.class, system.getSystemType());
controller.updateApplication(protSystemUri, addVolumeList, removeVolumesURI, volumeGroup.getId(), taskId);
} else {
// No need to call to controller. update the application task
Operation op = volumeGroup.getOpStatus().get(taskId);
op.ready();
volumeGroup.getOpStatus().updateTaskStatus(taskId, op);
_dbClient.updateObject(volumeGroup);
}
}
use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.
the class RPBlockServiceApiImpl method getConnectedVarrays.
@Override
protected Set<URI> getConnectedVarrays(URI varrayUID) {
Set<URI> varrays = new HashSet<URI>();
List<ProtectionSystem> protectionSystems = CustomQueryUtility.queryActiveResourcesByConstraint(_dbClient, ProtectionSystem.class, AlternateIdConstraint.Factory.getConstraint(ProtectionSystem.class, VIRTUAL_ARRAYS_CONSTRAINT, varrayUID.toString()));
// Create and return the result.
for (ProtectionSystem protectionSystem : protectionSystems) {
if (protectionSystem.getVirtualArrays() != null) {
for (String varrayURIStr : protectionSystem.getVirtualArrays()) {
varrays.add(URI.create(varrayURIStr));
}
}
}
return varrays;
}
use of com.emc.storageos.db.client.model.ProtectionSystem in project coprhd-controller by CoprHD.
the class BlockConsistencyGroupService method performProtectionAction.
/**
* Since all of the protection operations are very similar, this method does all of the work.
* We keep the actual REST methods separate mostly for the purpose of documentation generators.
*
* @param consistencyGroupId the URI of the BlockConsistencyGroup to perform the protection action against.
* @param targetVarrayId the target virtual array.
* @param pointInTime any point in time, specified in UTC.
* Allowed values: "yyyy-MM-dd_HH:mm:ss" formatted date or datetime in milliseconds.
* @param op operation to perform (pause, stop, failover, etc)
* @return task resource rep
* @throws InternalException
*/
private TaskResourceRep performProtectionAction(URI consistencyGroupId, Copy copy, String op) throws InternalException {
ArgValidator.checkFieldUriType(consistencyGroupId, BlockConsistencyGroup.class, "id");
ArgValidator.checkFieldUriType(copy.getCopyID(), VirtualArray.class, "copyId");
// Get the BlockConsistencyGroup and target VirtualArray associated with the request.
final BlockConsistencyGroup consistencyGroup = (BlockConsistencyGroup) queryResource(consistencyGroupId);
final VirtualArray targetVirtualArray = _permissionsHelper.getObjectById(copy.getCopyID(), VirtualArray.class);
ArgValidator.checkEntity(consistencyGroup, consistencyGroupId, true);
ArgValidator.checkEntity(targetVirtualArray, copy.getCopyID(), true);
// The consistency group needs to be associated with RecoverPoint in order to perform the operation.
if (!consistencyGroup.checkForType(Types.RP)) {
// Attempt to do protection link management on unprotected CG
throw APIException.badRequests.consistencyGroupMustBeRPProtected(consistencyGroupId);
}
if (op.equalsIgnoreCase(ProtectionOp.SWAP.getRestOp()) && !NullColumnValueGetter.isNullURI(consistencyGroupId)) {
ExportUtils.validateConsistencyGroupBookmarksExported(_dbClient, consistencyGroupId);
}
// Catch any attempts to use an invalid access mode
if (op.equalsIgnoreCase(ProtectionOp.CHANGE_ACCESS_MODE.getRestOp()) && !Copy.ImageAccessMode.DIRECT_ACCESS.name().equalsIgnoreCase(copy.getAccessMode())) {
throw APIException.badRequests.unsupportedAccessMode(copy.getAccessMode());
}
// Verify that the supplied target Virtual Array is being referenced by at least one target volume in the CG.
List<Volume> targetVolumes = getTargetVolumes(consistencyGroup, copy.getCopyID());
if (targetVolumes == null || targetVolumes.isEmpty()) {
// The supplied target varray is not referenced by any target volumes in the CG.
throw APIException.badRequests.targetVirtualArrayDoesNotMatch(consistencyGroupId, copy.getCopyID());
}
// Get the first target volume
Volume targetVolume = targetVolumes.get(0);
String task = UUID.randomUUID().toString();
Operation status = new Operation();
status.setResourceType(ProtectionOp.getResourceOperationTypeEnum(op));
_dbClient.createTaskOpStatus(BlockConsistencyGroup.class, consistencyGroupId, task, status);
ProtectionSystem system = _dbClient.queryObject(ProtectionSystem.class, targetVolume.getProtectionController());
String deviceType = system.getSystemType();
if (!deviceType.equals(DiscoveredDataObject.Type.rp.name())) {
throw APIException.badRequests.protectionForRpClusters();
}
RPController controller = getController(RPController.class, system.getSystemType());
controller.performProtectionOperation(system.getId(), consistencyGroupId, targetVolume.getId(), copy.getPointInTime(), copy.getAccessMode(), op, task);
/*
* auditOp(OperationTypeEnum.PERFORM_PROTECTION_ACTION, true, AuditLogManager.AUDITOP_BEGIN,
* op, copyID.toString(), id.toString(), system.getId().toString());
*/
return toTask(consistencyGroup, task, status);
}
Aggregations