Search in sources :

Example 46 with ComputeSystem

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);
}
Also used : 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) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 47 with ComputeSystem

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);
}
Also used : URI(java.net.URI) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) ComputeVirtualPool(com.emc.storageos.db.client.model.ComputeVirtualPool) 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) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 48 with ComputeSystem

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);
}
Also used : 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) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 49 with ComputeSystem

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;
}
Also used : ComputeElementListRestRep(com.emc.storageos.model.compute.ComputeElementListRestRep) ComputeElement(com.emc.storageos.db.client.model.ComputeElement) Cluster(com.emc.storageos.db.client.model.Cluster) Host(com.emc.storageos.db.client.model.Host) ComputeElementRestRep(com.emc.storageos.model.compute.ComputeElementRestRep) URI(java.net.URI) ComputeSystem(com.emc.storageos.db.client.model.ComputeSystem) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList) Path(javax.ws.rs.Path) ComputeSanBootImagePath(com.emc.storageos.db.client.model.ComputeSanBootImagePath) ComputeLanBootImagePath(com.emc.storageos.db.client.model.ComputeLanBootImagePath) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 50 with ComputeSystem

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

ComputeSystem (com.emc.storageos.db.client.model.ComputeSystem)50 ComputeElement (com.emc.storageos.db.client.model.ComputeElement)15 URI (java.net.URI)15 Host (com.emc.storageos.db.client.model.Host)14 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)13 Produces (javax.ws.rs.Produces)13 ComputeSystemControllerException (com.emc.storageos.computesystemcontroller.exceptions.ComputeSystemControllerException)12 Path (javax.ws.rs.Path)11 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)10 ImageServerControllerException (com.emc.storageos.imageservercontroller.exceptions.ImageServerControllerException)8 ComputeLanBootImagePath (com.emc.storageos.db.client.model.ComputeLanBootImagePath)7 ComputeSanBootImagePath (com.emc.storageos.db.client.model.ComputeSanBootImagePath)7 VcenterControllerException (com.emc.storageos.vcentercontroller.exceptions.VcenterControllerException)7 VcenterObjectConnectionException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException)7 VcenterObjectNotFoundException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException)7 ClientGeneralException (com.emc.cloud.platform.clientlib.ClientGeneralException)6 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)6 MalformedURLException (java.net.MalformedURLException)6 POST (javax.ws.rs.POST)6 URL (java.net.URL)5