use of com.emc.storageos.computesystemcontroller.ComputeSystemController in project coprhd-controller by CoprHD.
the class HostService method doDiscoverHost.
/**
* Host Discovery
*
* @param host {@link Host} The Host to be discovered.
* @param taskId {@link String} taskId for the host discovery. as new taskId is generated if null passed.
* @param updateTaskStatus if true, mark the task status as completed for non-discovered host
* @return the task used to track the discovery job
*/
protected TaskResourceRep doDiscoverHost(URI hostId, String taskId, boolean updateTaskStatus) {
Host host = queryObject(Host.class, hostId, true);
if (taskId == null) {
taskId = UUID.randomUUID().toString();
}
if (host.getDiscoverable() != null && !host.getDiscoverable()) {
host.setDiscoveryStatus(DataCollectionJobStatus.COMPLETE.name());
_dbClient.updateObject(host);
}
if ((host.getDiscoverable() == null || host.getDiscoverable())) {
ComputeSystemController controller = getController(ComputeSystemController.class, "host");
DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new DiscoverJobExec(controller));
ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
tasks.add(new AsyncTask(Host.class, host.getId(), taskId));
TaskList taskList = scheduler.scheduleAsyncTasks(tasks);
return taskList.getTaskList().iterator().next();
} else {
// if not discoverable, manually create a ready task
Operation op = new Operation();
op.setResourceType(ResourceOperationTypeEnum.DISCOVER_HOST);
if (updateTaskStatus) {
op.ready("Host is not discoverable");
} else {
op.pending();
}
_dbClient.createTaskOpStatus(Host.class, host.getId(), taskId, op);
return toTask(host, taskId, op);
}
}
use of com.emc.storageos.computesystemcontroller.ComputeSystemController in project coprhd-controller by CoprHD.
the class InitiatorService method deleteInitiator.
/**
* Deactivate an initiator.
*
* @param id the URN of a ViPR initiator
* @prereq The initiator must not have active exports
* @brief Delete host initiator
* @return A Response indicating success or failure.
*
* @throws DatabaseException When an error occurs querying the database.
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/deactivate")
@CheckPermission(roles = { Role.TENANT_ADMIN })
public TaskResourceRep deleteInitiator(@PathParam("id") URI id) {
_log.info("Delete initiator {}", id);
Initiator initiator = queryObject(Initiator.class, id, isIdEmbeddedInURL(id));
if (!initiator.getIsManualCreation()) {
throw APIException.badRequests.initiatorNotCreatedManuallyAndCannotBeDeleted();
}
ArgValidator.checkReference(Initiator.class, id, checkForDelete(initiator));
String taskId = UUID.randomUUID().toString();
Operation op = _dbClient.createTaskOpStatus(Initiator.class, initiator.getId(), taskId, ResourceOperationTypeEnum.DELETE_INITIATOR);
if (ComputeSystemHelper.isInitiatorInUse(_dbClient, id.toString())) {
ComputeSystemController controller = getController(ComputeSystemController.class, null);
controller.removeInitiatorFromExport(initiator.getHost(), initiator.getId(), taskId);
} else {
_dbClient.ready(Initiator.class, initiator.getId(), taskId);
_dbClient.markForDeletion(initiator);
}
auditOp(OperationTypeEnum.DELETE_HOST_INITIATOR, true, null, initiator.auditParameters());
return toTask(initiator, taskId, op);
}
use of com.emc.storageos.computesystemcontroller.ComputeSystemController in project coprhd-controller by CoprHD.
the class IpInterfaceService method deactivateIpInterface.
/**
* Deactivate an IP interface.
*
* @param id the URN of a ViPR IP interface
* @prereq The IP interface must not have active exports
* @brief Delete IP interface
* @return OK if deactivation completed successfully
* @throws DatabaseException
*/
@POST
@Path("/{id}/deactivate")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.TENANT_ADMIN })
public TaskResourceRep deactivateIpInterface(@PathParam("id") URI id) throws DatabaseException {
IpInterface ipInterface = queryResource(id);
ArgValidator.checkEntity(ipInterface, id, isIdEmbeddedInURL(id));
if (ipInterface.getIsManualCreation() != null && !ipInterface.getIsManualCreation()) {
throw APIException.badRequests.ipInterfaceNotCreatedManuallyAndCannotBeDeleted();
}
String taskId = UUID.randomUUID().toString();
Operation op = _dbClient.createTaskOpStatus(IpInterface.class, ipInterface.getId(), taskId, ResourceOperationTypeEnum.DELETE_HOST_IPINTERFACE);
// Clean up File Export if host is in use
if (ComputeSystemHelper.isHostIpInterfacesInUse(_dbClient, Collections.singletonList(ipInterface.getIpAddress()), ipInterface.getHost())) {
ComputeSystemController controller = getController(ComputeSystemController.class, null);
controller.removeIpInterfaceFromFileShare(ipInterface.getHost(), ipInterface.getId(), taskId);
} else {
_dbClient.ready(IpInterface.class, ipInterface.getId(), taskId);
_dbClient.markForDeletion(ipInterface);
}
auditOp(OperationTypeEnum.DELETE_HOST_IPINTERFACE, true, null, ipInterface.auditParameters());
return toTask(ipInterface, taskId, op);
}
use of com.emc.storageos.computesystemcontroller.ComputeSystemController in project coprhd-controller by CoprHD.
the class VcenterService method detachStorage.
/**
* Detaches storage from the vCenter.
*
* @param id the URN of a ViPR vCenter
* @brief Detach storage from vCenter
* @return task
* @throws DatabaseException when a DB error occurs
*/
@POST
@Path("/{id}/detach-storage")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.TENANT_ADMIN })
public TaskResourceRep detachStorage(@PathParam("id") URI id) throws DatabaseException {
Vcenter vcenter = queryObject(Vcenter.class, id, true);
ArgValidator.checkEntity(vcenter, id, true);
checkIfOtherTenantsUsingTheVcenter(vcenter);
String taskId = UUID.randomUUID().toString();
Operation op = _dbClient.createTaskOpStatus(Vcenter.class, vcenter.getId(), taskId, ResourceOperationTypeEnum.DETACH_VCENTER_DATACENTER_STORAGE);
ComputeSystemController controller = getController(ComputeSystemController.class, null);
controller.detachVcenterStorage(vcenter.getId(), false, taskId);
return toTask(vcenter, taskId, op);
}
use of com.emc.storageos.computesystemcontroller.ComputeSystemController in project coprhd-controller by CoprHD.
the class VcenterService method doDiscoverVcenter.
/**
* Vcenter Discovery
*
* @param vcenter the Vcenter to be discovered.
* provided, a new taskId is generated.
* @return the task used to track the discovery job
*/
protected TaskResourceRep doDiscoverVcenter(Vcenter vcenter) {
ComputeSystemController controller = getController(ComputeSystemController.class, "vcenter");
DiscoveredObjectTaskScheduler scheduler = new DiscoveredObjectTaskScheduler(_dbClient, new DiscoverJobExec(controller));
String taskId = UUID.randomUUID().toString();
ArrayList<AsyncTask> tasks = new ArrayList<AsyncTask>(1);
tasks.add(new AsyncTask(Vcenter.class, vcenter.getId(), taskId));
TaskList taskList = scheduler.scheduleAsyncTasks(tasks);
TaskResourceRep taskResourceRep = taskList.getTaskList().iterator().next();
updateTaskTenant(taskResourceRep);
return taskResourceRep;
}
Aggregations