Search in sources :

Example 1 with ComputeVirtualPool

use of com.emc.storageos.db.client.model.ComputeVirtualPool in project coprhd-controller by CoprHD.

the class HostService method provisionBareMetalHosts.

/**
 * Provision bare metal hosts by taking compute elements from the compute
 * virtual pool.
 *
 * @param param
 *            parameter for multiple host creation
 * @brief Provision bare metal hosts
 * @return TaskResourceRep (asynchronous call)
 * @throws DatabaseException
 */
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/provision-bare-metal")
public TaskList provisionBareMetalHosts(ProvisionBareMetalHostsParam param) throws DatabaseException {
    ComputeVirtualPool cvp = _dbClient.queryObject(ComputeVirtualPool.class, param.getComputeVpool());
    ArgValidator.checkEntity(cvp, param.getComputeVpool(), false);
    VirtualArray varray = _dbClient.queryObject(VirtualArray.class, param.getVarray());
    ArgValidator.checkEntity(varray, param.getVarray(), false);
    TenantOrg tenant = _dbClient.queryObject(TenantOrg.class, param.getTenant());
    ArgValidator.checkEntity(tenant, param.getTenant(), false);
    if (!NullColumnValueGetter.isNullURI(param.getCluster())) {
        Cluster cluster = _dbClient.queryObject(Cluster.class, param.getCluster());
        ArgValidator.checkEntity(cluster, param.getCluster(), false);
    }
    _log.debug("checking if CVP is accessible");
    _permissionsHelper.checkTenantHasAccessToComputeVirtualPool(tenant.getId(), cvp);
    validateHostNames(param);
    InterProcessLock lock = lockBladeReservation();
    List<String> ceList = null;
    try {
        ceList = takeComputeElementsFromPool(cvp, param.getHostNames().size(), varray, param.getCluster());
    } catch (Exception e) {
        _log.error("unable to takeComputeElementsFromPool", e);
        throw e;
    } finally {
        unlockBladeReservation(lock);
    }
    Set<Host> hosts = new HashSet<Host>();
    for (int i = 0; i < param.getHostNames().size(); i++) {
        Host host = populateHost(tenant, param.getHostNames().get(i), ceList.get(i), param.getCluster(), cvp.getId());
        hosts.add(host);
        _dbClient.createObject(host);
    }
    return createHostTasks(hosts, param.getComputeVpool(), param.getVarray());
}
Also used : VirtualArray(com.emc.storageos.db.client.model.VirtualArray) TenantOrg(com.emc.storageos.db.client.model.TenantOrg) Cluster(com.emc.storageos.db.client.model.Cluster) InterProcessLock(org.apache.curator.framework.recipes.locks.InterProcessLock) Host(com.emc.storageos.db.client.model.Host) ComputeVirtualPool(com.emc.storageos.db.client.model.ComputeVirtualPool) InternalException(com.emc.storageos.svcs.errorhandling.resources.InternalException) ControllerException(com.emc.storageos.volumecontroller.ControllerException) APIException(com.emc.storageos.svcs.errorhandling.resources.APIException) BadRequestException(com.emc.storageos.svcs.errorhandling.resources.BadRequestException) DatabaseException(com.emc.storageos.db.exceptions.DatabaseException) ContainmentConstraint(com.emc.storageos.db.client.constraint.ContainmentConstraint) HashSet(java.util.HashSet) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces)

Example 2 with ComputeVirtualPool

use of com.emc.storageos.db.client.model.ComputeVirtualPool in project coprhd-controller by CoprHD.

the class UcsDiscoveryWorker method removeBladesFromComputeVirtualPools.

private void removeBladesFromComputeVirtualPools(Collection<ComputeElement> removeBlades) {
    List<URI> ids = _dbClient.queryByType(ComputeVirtualPool.class, true);
    Iterator<ComputeVirtualPool> iter = _dbClient.queryIterativeObjects(ComputeVirtualPool.class, ids);
    while (iter.hasNext()) {
        Boolean dbUpdateRequired = false;
        ComputeVirtualPool cvp = iter.next();
        for (ComputeElement computeElement : removeBlades) {
            if (cvp.getMatchedComputeElements() != null && cvp.getMatchedComputeElements().contains(computeElement.getId().toString())) {
                _log.info("Removing ComputeElement {} from ComputeVirtualPool {} ", computeElement.getDn(), cvp.getLabel());
                cvp.removeMatchedComputeElement(computeElement.getId().toString());
                dbUpdateRequired = true;
            }
        }
        if (dbUpdateRequired) {
            _log.info("Persisting ComputeVirtualPool {},after ComputeElement removal", cvp.getLabel());
            _dbClient.persistObject(cvp);
        }
    }
}
Also used : ComputeElement(com.emc.storageos.db.client.model.ComputeElement) URI(java.net.URI) ComputeVirtualPool(com.emc.storageos.db.client.model.ComputeVirtualPool)

Example 3 with ComputeVirtualPool

use of com.emc.storageos.db.client.model.ComputeVirtualPool in project coprhd-controller by CoprHD.

the class ComputeVirtualPoolService method updateAcls.

/**
 * Add or remove individual compute virtual pool ACL entry(s). Request body must include at least one add or remove operation.
 *
 * @prereq none
 * @param id the URN of a ViPR VirtualPool
 * @param changes ACL assignment changes
 * @brief Add or remove compute virtual pool ACL entries
 * @return No data returned in response body
 */
@PUT
@Path("/{id}/acl")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SECURITY_ADMIN, Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN }, blockProxies = true)
public ACLAssignments updateAcls(@PathParam("id") URI id, ACLAssignmentChanges changes) {
    ComputeVirtualPool vpool = (ComputeVirtualPool) queryResource(id);
    ArgValidator.checkEntityNotNull(vpool, id, isIdEmbeddedInURL(id));
    _permissionsHelper.updateACLs(vpool, changes, new PermissionsHelper.UsageACLFilter(_permissionsHelper, vpool.getSystemType()));
    _dbClient.updateAndReindexObject(vpool);
    auditOp(OperationTypeEnum.MODIFY_VPOOL_ACL, true, null, vpool.getId().toString(), vpool.getLabel(), vpool.getSystemType());
    return getAclsOnVirtualPool(id);
}
Also used : PermissionsHelper(com.emc.storageos.api.service.authorization.PermissionsHelper) ComputeVirtualPool(com.emc.storageos.db.client.model.ComputeVirtualPool) ComputeVirtualPoolMapper.toComputeVirtualPool(com.emc.storageos.api.mapper.ComputeVirtualPoolMapper.toComputeVirtualPool) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 4 with ComputeVirtualPool

use of com.emc.storageos.db.client.model.ComputeVirtualPool in project coprhd-controller by CoprHD.

the class ComputeVirtualPoolService method getComputeVirtualPool.

/**
 * Get compute virtual pool by ID
 *
 * @brief Get compute virtual pool by ID
 * @param id the URN of a Compute Virtual Pool
 * @return ComputeVirtualPoolRestRep representation of Compute Virtual Pool
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR }, acls = { ACL.USE })
public ComputeVirtualPoolRestRep getComputeVirtualPool(@PathParam("id") URI id) {
    ArgValidator.checkUri(id);
    ComputeVirtualPool cvp = _permissionsHelper.getObjectById(id, ComputeVirtualPool.class);
    ArgValidator.checkEntityNotNull(cvp, id, isIdEmbeddedInURL(id));
    return toComputeVirtualPool(_dbClient, cvp, isComputeVirtualPoolInUse(cvp));
}
Also used : ComputeVirtualPool(com.emc.storageos.db.client.model.ComputeVirtualPool) ComputeVirtualPoolMapper.toComputeVirtualPool(com.emc.storageos.api.mapper.ComputeVirtualPoolMapper.toComputeVirtualPool) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 5 with ComputeVirtualPool

use of com.emc.storageos.db.client.model.ComputeVirtualPool in project coprhd-controller by CoprHD.

the class ComputeVirtualPoolService method findAllStaticallyAssignedComputeElementsInOtherPools.

private List<URI> findAllStaticallyAssignedComputeElementsInOtherPools(ComputeVirtualPool computeVirtualPool) {
    List<URI> staticallyAssignedComputeElements = findAllStaticallyAssignedComputeElements();
    // fetch cvp from db
    ComputeVirtualPool cvp = _dbClient.queryObject(ComputeVirtualPool.class, computeVirtualPool.getId());
    List<URI> poolUris = Lists.newArrayList();
    if (null != cvp) {
        poolUris = toUriList(cvp.getMatchedComputeElements());
    } else {
        poolUris = toUriList(computeVirtualPool.getMatchedComputeElements());
    }
    if (!poolUris.isEmpty() && !staticallyAssignedComputeElements.isEmpty()) {
        _log.debug("Remove " + poolUris.size() + " previously assigned compute elements from list of " + staticallyAssignedComputeElements.size() + " static elements");
        for (URI computeElementId : poolUris) {
            boolean removed = staticallyAssignedComputeElements.remove(computeElementId);
            if (removed) {
                _log.debug("Compute element " + computeElementId + " from pool " + computeVirtualPool.getId() + " removed from staticallyAssignedComputeElements");
            }
        }
    }
    return staticallyAssignedComputeElements;
}
Also used : URI(java.net.URI) ComputeVirtualPool(com.emc.storageos.db.client.model.ComputeVirtualPool) ComputeVirtualPoolMapper.toComputeVirtualPool(com.emc.storageos.api.mapper.ComputeVirtualPoolMapper.toComputeVirtualPool)

Aggregations

ComputeVirtualPool (com.emc.storageos.db.client.model.ComputeVirtualPool)23 ComputeVirtualPoolMapper.toComputeVirtualPool (com.emc.storageos.api.mapper.ComputeVirtualPoolMapper.toComputeVirtualPool)15 URI (java.net.URI)12 Produces (javax.ws.rs.Produces)12 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)11 Path (javax.ws.rs.Path)11 POST (javax.ws.rs.POST)7 ComputeElement (com.emc.storageos.db.client.model.ComputeElement)6 Consumes (javax.ws.rs.Consumes)6 StringSet (com.emc.storageos.db.client.model.StringSet)4 HashSet (java.util.HashSet)4 ComputeSystem (com.emc.storageos.db.client.model.ComputeSystem)3 Host (com.emc.storageos.db.client.model.Host)3 APIException (com.emc.storageos.svcs.errorhandling.resources.APIException)3 GET (javax.ws.rs.GET)3 PUT (javax.ws.rs.PUT)3 ComputeLanBootImagePath (com.emc.storageos.db.client.model.ComputeLanBootImagePath)2 ComputeSanBootImagePath (com.emc.storageos.db.client.model.ComputeSanBootImagePath)2 TenantOrg (com.emc.storageos.db.client.model.TenantOrg)2 UCSServiceProfileTemplate (com.emc.storageos.db.client.model.UCSServiceProfileTemplate)2