Search in sources :

Example 1 with ProtectionController

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;
}
Also used : ProtectionController(com.emc.storageos.protectioncontroller.ProtectionController)

Example 2 with ProtectionController

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());
}
Also used : ProtectionController(com.emc.storageos.protectioncontroller.ProtectionController)

Example 3 with ProtectionController

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();
}
Also used : TaskList(com.emc.storageos.model.TaskList) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayList(java.util.ArrayList) MapProtectionSystem(com.emc.storageos.api.mapper.functions.MapProtectionSystem) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) ProtectionController(com.emc.storageos.protectioncontroller.ProtectionController) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 4 with ProtectionController

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);
}
Also used : AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayList(java.util.ArrayList) URI(java.net.URI) MapProtectionSystem(com.emc.storageos.api.mapper.functions.MapProtectionSystem) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) ProtectionController(com.emc.storageos.protectioncontroller.ProtectionController) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 5 with ProtectionController

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();
}
Also used : TaskList(com.emc.storageos.model.TaskList) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayList(java.util.ArrayList) MapProtectionSystem(com.emc.storageos.api.mapper.functions.MapProtectionSystem) ProtectionSystem(com.emc.storageos.db.client.model.ProtectionSystem) ProtectionController(com.emc.storageos.protectioncontroller.ProtectionController) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

ProtectionController (com.emc.storageos.protectioncontroller.ProtectionController)7 MapProtectionSystem (com.emc.storageos.api.mapper.functions.MapProtectionSystem)4 ProtectionSystem (com.emc.storageos.db.client.model.ProtectionSystem)4 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)4 AsyncTask (com.emc.storageos.volumecontroller.AsyncTask)4 ArrayList (java.util.ArrayList)4 Consumes (javax.ws.rs.Consumes)4 Produces (javax.ws.rs.Produces)4 TaskList (com.emc.storageos.model.TaskList)3 POST (javax.ws.rs.POST)3 Path (javax.ws.rs.Path)3 DiscoveredObjectTaskScheduler (com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler)1 URI (java.net.URI)1 PUT (javax.ws.rs.PUT)1