use of com.emc.storageos.protectioncontroller.ProtectionController in project coprhd-controller by CoprHD.
the class ProtectionSystemService method getProtectionController.
/**
* Return the protection controller for a given system type.
*
* @param systemType The type of the protection system.
*
* @return A reference to the protection controller
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
private ProtectionController getProtectionController(String systemType) {
Class controllerClass = protectionSystemClass(systemType);
ProtectionController controller = (ProtectionController) getController(controllerClass, systemType);
return controller;
}
use of com.emc.storageos.protectioncontroller.ProtectionController in project coprhd-controller by CoprHD.
the class ProtectionSystemService method stopProtectionSystem.
/**
* Invoke disconnect protection to stop events and statistics gathering of this
* protection system.
*
* @param protectionSystem A reference to the protection system.
* @throws InternalException
*/
private void stopProtectionSystem(ProtectionSystem protectionSystem) throws InternalException {
ProtectionController controller = getProtectionController(protectionSystem.getSystemType());
controller.disconnect(protectionSystem.getId());
}
use of com.emc.storageos.protectioncontroller.ProtectionController 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.protectioncontroller.ProtectionController in project coprhd-controller by CoprHD.
the class ProtectionSystemService method discoverProtectionSystemsAll.
/**
* Allows the user to manually discover all protection systems.
*
* @brief Discover all protection systems
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
@Path("/discover")
public TaskList discoverProtectionSystemsAll() {
Iterator<URI> protectionIter = _dbClient.queryByType(ProtectionSystem.class, true).iterator();
ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>();
while (protectionIter.hasNext()) {
URI protection = protectionIter.next();
String taskId = UUID.randomUUID().toString();
tasks.add(new AsyncTask(ProtectionSystem.class, protection, taskId));
}
ProtectionController controller = getController(RPController.class, ProtectionSystem._RP);
return discoverProtectionSystems(tasks, controller);
}
use of com.emc.storageos.protectioncontroller.ProtectionController in project coprhd-controller by CoprHD.
the class ProtectionSystemService method createProtectionSystem.
/**
* Allow the user to manually create a protection system.
*
* @param param The protection system details.
*
* @brief Create protection system
* @return An asynchronous task corresponding to the discovery job scheduled for the new Protection System.
*
* @throws BadRequestException When the system type is not valid or a
* protection system with the same native guid already exists.
* @throws DatabaseException When an error occurs querying the database.
* @throws ControllerException When an error occurs discovering the protection
* system.
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep createProtectionSystem(ProtectionSystemRequestParam param) throws Exception {
ProtectionSystem system = null;
ProtectionSystem.Type systemType = ProtectionSystem.Type.valueOf(param.getSystemType());
if (!systemType.equals(ProtectionSystem.Type.rp)) {
throw APIException.badRequests.cannotRegisterSystemWithType(systemType.name());
}
system = new ProtectionSystem();
system.setId(URIUtil.createId(ProtectionSystem.class));
system.setSystemType(systemType.name());
system.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
system.setIpAddress(param.getIpAddress());
system.setPortNumber(param.getPortNumber());
system.setUsername(param.getUserName());
system.setPassword(param.getPassword());
system.setLabel(param.getLabel());
system.setDiscoveryStatus(DiscoveredDataObject.DataCollectionJobStatus.CREATED.toString());
_dbClient.createObject(system);
auditOp(OperationTypeEnum.CREATE_PROTECTION_SYSTEM, true, null, param.getLabel(), systemType.name(), param.getIpAddress(), param.getPortNumber(), param.getUserName(), system.getId().toString());
startProtectionSystem(system);
ProtectionController controller = getController(RPController.class, ProtectionSystem._RP);
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().listIterator().next();
}
Aggregations