Search in sources :

Example 1 with ComputeController

use of com.emc.storageos.computecontroller.ComputeController in project coprhd-controller by CoprHD.

the class ComputeSystemService method deleteComputeSystem.

/**
 * Deletes a Compute System and the discovered information about it from
 * ViPR
 *
 * @param id
 *            the URN of a ViPR Compute System to be deleted
 * @brief Delete compute system
 * @return TaskResourceRep (asynchronous call)
 * @throws DatabaseException
 */
@POST
@Path("/{id}/deactivate")
@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 deleteComputeSystem(@PathParam("id") URI id) throws DatabaseException {
    ComputeSystem cs = queryObject(ComputeSystem.class, id, true);
    ArgValidator.checkEntity(cs, id, isIdEmbeddedInURL(id));
    if (!RegistrationStatus.UNREGISTERED.toString().equals(cs.getRegistrationStatus())) {
        throw APIException.badRequests.invalidParameterCannotDeactivateRegisteredComputeSystem(cs.getId());
    }
    List<String> provHosts = getProvisionedBlades(cs);
    if (!provHosts.isEmpty()) {
        throw APIException.badRequests.unableToDeactivateProvisionedComputeSystem(cs.getLabel(), org.springframework.util.StringUtils.collectionToCommaDelimitedString(provHosts));
    }
    ComputeController controller = getController(ComputeController.class, cs.getSystemType());
    controller.clearDeviceSession(cs.getId());
    String taskId = UUID.randomUUID().toString();
    Operation op = _dbClient.createTaskOpStatus(ComputeSystem.class, cs.getId(), taskId, ResourceOperationTypeEnum.DELETE_COMPUTE_SYSTEM);
    PurgeRunnable.executePurging(_dbClient, _dbPurger, _asynchJobService.getExecutorService(), cs, 0, /* _retry_attempts */
    taskId, 60);
    recordAndAudit(cs, OperationTypeEnum.DELETE_COMPUTE_SYSTEM, true, AuditLogManager.AUDITOP_BEGIN);
    return toTask(cs, taskId, op);
}
Also used : ComputeController(com.emc.storageos.computecontroller.ComputeController) Operation(com.emc.storageos.db.client.model.Operation) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) Path(javax.ws.rs.Path) ComputeSanBootImagePath(com.emc.storageos.db.client.model.ComputeSanBootImagePath) ComputeLanBootImagePath(com.emc.storageos.db.client.model.ComputeLanBootImagePath) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 2 with ComputeController

use of com.emc.storageos.computecontroller.ComputeController in project coprhd-controller by CoprHD.

the class HostService method createHostTasks.

private TaskList createHostTasks(Set<Host> hosts, URI cvpUri, URI varray) {
    TaskList tl = new TaskList();
    Set<AsyncTask> tasks = new HashSet<AsyncTask>();
    for (Host host : hosts) {
        String taskId = UUID.randomUUID().toString();
        AsyncTask task = new AsyncTask(Host.class, host.getId(), taskId);
        Operation op = new Operation();
        op.setResourceType(ResourceOperationTypeEnum.CREATE_HOST);
        _dbClient.createTaskOpStatus(Host.class, host.getId(), task._opId, op);
        tasks.add(task);
        tl.getTaskList().add(TaskMapper.toTask(host, task._opId, op));
        host.setProvisioningStatus(Host.ProvisioningJobStatus.IN_PROGRESS.toString());
        auditOp(OperationTypeEnum.CREATE_HOST, true, AuditLogManager.AUDITOP_BEGIN, host.auditParameters());
    }
    /*
         * Persist the IN_PROGRESS ProvisioningJobStatus
         */
    _dbClient.persistObject(hosts);
    /*
         * Dispatch the request to the controller
         */
    ComputeController computeController = getController(ComputeController.class, null);
    computeController.createHosts(varray, cvpUri, tasks.toArray(new AsyncTask[0]));
    return tl;
}
Also used : TaskList(com.emc.storageos.model.TaskList) ComputeController(com.emc.storageos.computecontroller.ComputeController) AsyncTask(com.emc.storageos.volumecontroller.AsyncTask) ArrayAffinityAsyncTask(com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask) Host(com.emc.storageos.db.client.model.Host) Operation(com.emc.storageos.db.client.model.Operation) HashSet(java.util.HashSet)

Example 3 with ComputeController

use of com.emc.storageos.computecontroller.ComputeController in project coprhd-controller by CoprHD.

the class ComputeSystemService method doDiscoverComputeSystem.

private TaskResourceRep doDiscoverComputeSystem(ComputeSystem cs) {
    ComputeController controller = getController(ComputeController.class, cs.getSystemType());
    DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new ComputeSystemJobExec(controller));
    String taskId = UUID.randomUUID().toString();
    ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
    tasks.add(new AsyncTask(ComputeSystem.class, cs.getId(), taskId));
    TaskList taskList = scheduler.scheduleAsyncTasks(tasks);
    return taskList.getTaskList().iterator().next();
}
Also used : ComputeController(com.emc.storageos.computecontroller.ComputeController) 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) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem)

Aggregations

ComputeController (com.emc.storageos.computecontroller.ComputeController)3 ComputeSystem (com.emc.storageos.db.client.model.ComputeSystem)2 Operation (com.emc.storageos.db.client.model.Operation)2 TaskList (com.emc.storageos.model.TaskList)2 AsyncTask (com.emc.storageos.volumecontroller.AsyncTask)2 DiscoveredObjectTaskScheduler (com.emc.storageos.api.service.impl.resource.utils.DiscoveredObjectTaskScheduler)1 ComputeLanBootImagePath (com.emc.storageos.db.client.model.ComputeLanBootImagePath)1 ComputeSanBootImagePath (com.emc.storageos.db.client.model.ComputeSanBootImagePath)1 Host (com.emc.storageos.db.client.model.Host)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 ArrayAffinityAsyncTask (com.emc.storageos.volumecontroller.ArrayAffinityAsyncTask)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1