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);
}
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;
}
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();
}
Aggregations