Search in sources :

Example 6 with ProtectionController

use of com.emc.storageos.protectioncontroller.ProtectionController in project coprhd-controller by CoprHD.

the class ProtectionSystemService method discoverProtectionSystem.

/**
 * Allows the user to manually discover the registered protection system with
 * the passed id.
 *
 * @param id the URN of a ViPR protection system.
 * @QueryParam namespace
 *             ProtectionSystem Auto Discovery is grouped into multiple namespaces.
 *             Namespace is used to discover specific parts of Storage System.
 *
 *             Possible Values :
 *             UNMANAGED_CGS
 *             ALL
 *
 *             UNMANAGED_CGS will discover all the consistency groups which are present in the
 *             Protection System (RPA).
 *
 * @brief Discover protection system
 * @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 })
@Path("/{id}/discover")
public TaskResourceRep discoverProtectionSystem(@PathParam("id") URI id, @QueryParam("namespace") String namespace) {
    ProtectionSystem protectionSystem = _dbClient.queryObject(ProtectionSystem.class, id);
    ArgValidator.checkEntity(protectionSystem, id, isIdEmbeddedInURL(id), true);
    // If Namespace is empty or null set it to ALL as default
    if (namespace == null || namespace.trim().length() < 1) {
        namespace = Discovery_Namespaces.ALL.toString();
    }
    if (!validateNameSpace(namespace)) {
        throw APIException.badRequests.invalidParameterProtectionSystemNamespace(namespace);
    }
    String deviceType = protectionSystem.getSystemType();
    ProtectionController controller = getController(RPController.class, deviceType);
    DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new DiscoverJobExec(controller));
    ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
    String taskId = UUID.randomUUID().toString();
    tasks.add(new AsyncTask(ProtectionSystem.class, protectionSystem.getId(), taskId, namespace));
    TaskList taskList = scheduler.scheduleAsyncTasks(tasks);
    return taskList.getTaskList().listIterator().next();
}
Also used : TaskList(com.emc.storageos.model.TaskList) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayList(java.util.ArrayList) DiscoveredObjectTaskScheduler(com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler) 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 7 with ProtectionController

use of com.emc.storageos.protectioncontroller.ProtectionController in project coprhd-controller by CoprHD.

the class ProtectionSystemService method startProtectionSystem.

/**
 * Invoke connect protection. Once system is verified to be registered.
 * Statistics, Events will be collected for only registered systems.
 *
 * @param system Protection system to start Metering & Monitoring.
 * @throws InternalException
 */
private void startProtectionSystem(ProtectionSystem system) throws InternalException {
    ProtectionController controller = getProtectionController(system.getSystemType());
    controller.connect(system.getId());
}
Also used : ProtectionController(com.emc.storageos.protectioncontroller.ProtectionController)

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