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