use of com.emc.storageos.db.client.model.ComputeVirtualPool in project coprhd-controller by CoprHD.
the class UcsDiscoveryWorker method removeServiceProfileTemplatesFromComputeVirtualPool.
private void removeServiceProfileTemplatesFromComputeVirtualPool(Collection<UCSServiceProfileTemplate> removeTemplates) {
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 (UCSServiceProfileTemplate template : removeTemplates) {
if (cvp.getServiceProfileTemplates() != null && cvp.getServiceProfileTemplates().contains(template.getId().toString())) {
_log.info("Removing UCSServiceProfileTemplate {} from ComputePool", template.getDn());
cvp.removeServiceProfileTemplate(template.getId().toString());
dbUpdateRequired = true;
}
}
if (dbUpdateRequired) {
_log.info("Persisting ComputeVirtualPool {},after UCSServiceProfileTemplate removal", cvp.getId());
_dbClient.persistObject(cvp);
}
}
}
use of com.emc.storageos.db.client.model.ComputeVirtualPool in project coprhd-controller by CoprHD.
the class ComputeDeviceControllerImpl method createHost.
/**
* Create host using the specified params
*
* @param csId
* {@link URI} computesystem Id
* @param vcpoolId
* {@link URI} vcpoolId
* @param varray
* {@link URI} varray Id
* @param hostId
* {@link URI} host Id
* @param opId
* (@link String} operation Id
*/
@Override
public void createHost(URI csId, URI vcpoolId, URI varray, URI hostId, String opId) throws InternalException {
log.info("createHost");
Host host = _dbClient.queryObject(Host.class, hostId);
// TODO COP-28960 check for null -- host, ce, etc.
ComputeElement ce = _dbClient.queryObject(ComputeElement.class, host.getComputeElement());
ComputeVirtualPool vcp = _dbClient.queryObject(ComputeVirtualPool.class, vcpoolId);
VirtualArray vArray = _dbClient.queryObject(VirtualArray.class, varray);
ComputeSystem cs = _dbClient.queryObject(ComputeSystem.class, ce.getComputeSystem());
TaskCompleter tc = new ComputeHostCompleter(hostId, opId, OperationTypeEnum.CREATE_HOST, EVENT_SERVICE_TYPE);
getDevice(cs.getSystemType()).createHost(cs, host, vcp, vArray, tc);
}
use of com.emc.storageos.db.client.model.ComputeVirtualPool 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.ComputeVirtualPool in project coprhd-controller by CoprHD.
the class ComputeVirtualPoolService method createComputeVirtualPool.
/**
* Create a Compute Virtual Pool
*
* @brief Create a compute virtual pool
* @param param The Compute Virtual Pool create spec
* @return ComputeVirtualPoolRestRep The created Compute Virtual Pool
*/
@POST
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public ComputeVirtualPoolRestRep createComputeVirtualPool(ComputeVirtualPoolCreateParam param) throws DatabaseException {
checkForDuplicateName(param.getName(), ComputeVirtualPool.class);
ComputeVirtualPool cvp = constructAndValidateComputeVirtualPool(param);
_dbClient.createObject(cvp);
updateHostToCVPRelation(cvp);
recordOperation(OperationTypeEnum.CREATE_COMPUTE_VPOOL, VPOOL_CREATED_DESCRIPTION, cvp);
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 getComputeVirtualPool.
/**
* Get all compute virtual pools
*
* @brief Get all compute virtual pools
* @return ComputeVirtualPoolList representations of Compute Virtual Pools
*/
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public ComputeVirtualPoolList getComputeVirtualPool(@DefaultValue("") @QueryParam(TENANT_ID_QUERY_PARAM) String tenantId) {
List<URI> ids = _dbClient.queryByType(ComputeVirtualPool.class, true);
ComputeVirtualPoolList list = new ComputeVirtualPoolList();
// if input tenant is not empty, but user have no access to it, an exception will be thrown.
TenantOrg tenant_input = null;
if (!StringUtils.isEmpty(tenantId)) {
tenant_input = getTenantIfHaveAccess(tenantId);
}
StorageOSUser user = getUserFromContext();
Iterator<ComputeVirtualPool> iter = _dbClient.queryIterativeObjects(ComputeVirtualPool.class, ids);
List<ComputeVirtualPool> vpoolObjects = new ArrayList<>();
while (iter.hasNext()) {
vpoolObjects.add(iter.next());
}
// else only return the list, which input tenant has access.
if (_permissionsHelper.userHasGivenRole(user, null, Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR)) {
for (ComputeVirtualPool virtualPool : vpoolObjects) {
if (tenant_input == null || _permissionsHelper.tenantHasUsageACL(tenant_input.getId(), virtualPool)) {
list.getComputeVirtualPool().add(toNamedRelatedResource(virtualPool));
}
}
} else {
// otherwise, filter by only authorized to use
URI tenant = null;
if (tenant_input == null) {
tenant = URI.create(user.getTenantId());
} else {
tenant = tenant_input.getId();
}
Set<ComputeVirtualPool> vpoolSet = new HashSet<ComputeVirtualPool>();
for (ComputeVirtualPool virtualPool : vpoolObjects) {
if (_permissionsHelper.tenantHasUsageACL(tenant, virtualPool)) {
vpoolSet.add(virtualPool);
}
}
// if no tenant specified in request, also adding vpools which sub-tenants of the user have access to.
if (tenant_input == null) {
List<URI> subtenants = _permissionsHelper.getSubtenantsWithRoles(user);
for (ComputeVirtualPool virtualPool : vpoolObjects) {
if (_permissionsHelper.tenantHasUsageACL(subtenants, virtualPool)) {
vpoolSet.add(virtualPool);
}
}
}
for (ComputeVirtualPool virtualPool : vpoolSet) {
list.getComputeVirtualPool().add(toNamedRelatedResource(virtualPool));
}
}
return list;
}
Aggregations