use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class ComputeSystemService method getComputeSystem.
/**
* Gets a detailed representation of the Compute System
*
* @param id
* the URN of a ViPR Compute System
* @brief Show compute system
* @return A detailed representation of the Compute System
* @throws DatabaseException
*/
@GET
@Path("/{id}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public ComputeSystemRestRep getComputeSystem(@PathParam("id") URI id) throws DatabaseException {
ArgValidator.checkFieldUriType(id, ComputeSystem.class, "id");
ComputeSystem cs = queryResource(id);
return new mapComputeSystemWithServiceProfileTemplates().apply(cs);
}
use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class ComputeSystemService method registerComputeSystem.
/**
* Registers a previously de-registered Compute System. (Creation and Discovery of the Compute System marks the Compute System
* "Registered" by default)
*
* @param id the URN of a ViPR Compute System
* @brief Register compute system
* @return TaskResourceRep (asynchronous call)
* @throws ControllerException
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/register")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public ComputeSystemRestRep registerComputeSystem(@PathParam("id") URI id) throws ControllerException {
// Validate the Compute system.
ArgValidator.checkUri(id);
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, id);
ArgValidator.checkEntity(cs, id, isIdEmbeddedInURL(id));
// If not already registered, register it now.
if (RegistrationStatus.UNREGISTERED.toString().equalsIgnoreCase(cs.getRegistrationStatus())) {
cs.setRegistrationStatus(RegistrationStatus.REGISTERED.toString());
_dbClient.persistObject(cs);
List<URI> cvpIds = _dbClient.queryByType(ComputeVirtualPool.class, true);
Iterator<ComputeVirtualPool> iter = _dbClient.queryIterativeObjects(ComputeVirtualPool.class, cvpIds);
while (iter.hasNext()) {
ComputeVirtualPool cvp = iter.next();
if (cvp.getUseMatchedElements()) {
_log.debug("Compute pool " + cvp.getLabel() + " configured to use dynamic matching -- refresh matched elements");
computeVirtualPoolService.getMatchingCEsforCVPAttributes(cvp);
_dbClient.updateAndReindexObject(cvp);
}
}
recordAndAudit(cs, OperationTypeEnum.REGISTER_COMPUTE_SYSTEM, true, null);
}
return getComputeSystem(id);
}
use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class ComputeSystemService method discoverComputeSystem.
/**
* Discovers an already created Compute System
*
* @param id
* the URN of a ViPR Compute System
* @brief Discover compute system
* @return Returns an instance of {@link TaskResourceRep} which represents
* the Task created for Discovery. The task can then be queried to
* know status and progress
*/
@POST
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/discover")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public TaskResourceRep discoverComputeSystem(@PathParam("id") URI id) {
ArgValidator.checkFieldUriType(id, ComputeSystem.class, "id");
ComputeSystem cs = queryObject(ComputeSystem.class, id, true);
return doDiscoverComputeSystem(cs);
}
use of com.emc.storageos.db.client.model.ComputeSystem in project coprhd-controller by CoprHD.
the class ComputeSystemService method getComputeElements.
/**
* Fetches all the Compute Elements belonging to a Compute System in ViPR
*
* @param id
* the URN of a ViPR Compute System
* @brief Show compute elements
* @return A detailed representation of compute elements
* @throws InternalException
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}/compute-elements")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public ComputeElementListRestRep getComputeElements(@PathParam("id") URI id) throws InternalException {
ComputeElementListRestRep result = new ComputeElementListRestRep();
ArgValidator.checkFieldUriType(id, ComputeSystem.class, "id");
ComputeSystem cs = queryResource(id);
URIQueryResultList ceUriList = new URIQueryResultList();
_dbClient.queryByConstraint(ContainmentConstraint.Factory.getComputeSystemComputeElemetsConstraint(cs.getId()), ceUriList);
Iterator<URI> iterator = ceUriList.iterator();
Collection<URI> hostIds = _dbClient.queryByType(Host.class, true);
Collection<Host> hosts = _dbClient.queryObjectFields(Host.class, Arrays.asList("label", "computeElement", "cluster"), ControllerUtils.getFullyImplementedCollection(hostIds));
while (iterator.hasNext()) {
ComputeElement ce = _dbClient.queryObject(ComputeElement.class, iterator.next());
if (ce != null) {
Host associatedHost = null;
for (Host host : hosts) {
if (!NullColumnValueGetter.isNullURI(host.getComputeElement()) && host.getComputeElement().equals(ce.getId())) {
associatedHost = host;
break;
}
}
Cluster cluster = null;
if (associatedHost != null && !NullColumnValueGetter.isNullURI(associatedHost.getCluster())) {
cluster = _dbClient.queryObject(Cluster.class, associatedHost.getCluster());
}
ComputeElementRestRep rest = map(ce, associatedHost, cluster);
if (rest != null) {
result.getList().add(rest);
}
}
}
return result;
}
use of com.emc.storageos.db.client.model.ComputeSystem 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