use of com.emc.storageos.db.client.model.Cluster in project coprhd-controller by CoprHD.
the class ClusterService method getUnmanagedExportMasks.
/**
* Gets the UnManagedExportMasks found for a Cluster.
*
* @param id the URI of a ViPR Cluster
* @brief List unmanaged export masks for a cluster
* @return a list of UnManagedExportMasks found for the Cluster
* @throws DatabaseException when a database error occurs
*/
@GET
@Path("/{id}/unmanaged-export-masks")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public UnManagedExportMaskList getUnmanagedExportMasks(@PathParam("id") URI id) throws DatabaseException {
Cluster cluster = queryObject(Cluster.class, id, false);
// check the user permissions
verifyAuthorizedInTenantOrg(cluster.getTenant(), getUserFromContext());
// get the unmanaged export masks
List<UnManagedExportMask> uems = VolumeIngestionUtil.findUnManagedExportMasksForCluster(id, _dbClient);
UnManagedExportMaskList list = new UnManagedExportMaskList();
for (UnManagedExportMask uem : uems) {
list.getUnManagedExportMasks().add(toRelatedResource(ResourceTypeEnum.UNMANAGED_EXPORT_MASKS, uem.getId()));
}
return list;
}
use of com.emc.storageos.db.client.model.Cluster in project coprhd-controller by CoprHD.
the class ClusterService method getClusterHosts.
/**
* List the hosts of a cluster.
*
* @param id the URN of a ViPR cluster
* @prereq none
* @brief List cluster hosts
* @return The list of hosts of the cluster.
* @throws DatabaseException when a DB error occurs.
*/
@GET
@Path("/{id}/hosts")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public HostList getClusterHosts(@PathParam("id") URI id) throws DatabaseException {
Cluster cluster = queryObject(Cluster.class, id, true);
// check the user permissions
verifyAuthorizedInTenantOrg(cluster.getTenant(), getUserFromContext());
HostList list = new HostList();
list.setHosts(map(ResourceTypeEnum.HOST, listChildren(id, Host.class, "label", "cluster")));
return list;
}
use of com.emc.storageos.db.client.model.Cluster in project coprhd-controller by CoprHD.
the class ComputeElementService method queryBulkResourceReps.
@Override
public ComputeElementBulkRep queryBulkResourceReps(List<URI> ids) {
Iterator<ComputeElement> _dbIterator = _dbClient.queryIterativeObjects(getResourceClass(), ids);
return new ComputeElementBulkRep(BulkList.wrapping(_dbIterator, new Function<ComputeElement, ComputeElementRestRep>() {
@Override
public ComputeElementRestRep apply(ComputeElement ce) {
Host associatedHost = getAssociatedHost(ce, _dbClient);
Cluster cluster = null;
if (associatedHost != null && !NullColumnValueGetter.isNullURI(associatedHost.getCluster())) {
cluster = _dbClient.queryObject(Cluster.class, associatedHost.getCluster());
}
ComputeElementRestRep restRep = ComputeMapper.map(ce, associatedHost, cluster);
return restRep;
}
}));
}
use of com.emc.storageos.db.client.model.Cluster in project coprhd-controller by CoprHD.
the class ComputeVirtualPoolService method extractComputeElements.
private ComputeElementListRestRep extractComputeElements(ComputeVirtualPool cvp) {
ComputeElementListRestRep result = new ComputeElementListRestRep();
if (cvp.getMatchedComputeElements() != null) {
Collection<ComputeElement> computeElements = _dbClient.queryObject(ComputeElement.class, toUriList(cvp.getMatchedComputeElements()));
Collection<URI> hostIds = _dbClient.queryByType(Host.class, true);
Collection<Host> hosts = _dbClient.queryObjectFields(Host.class, Arrays.asList("label", "computeElement", "cluster"), ControllerUtils.getFullyImplementedCollection(hostIds));
for (ComputeElement computeElement : computeElements) {
if (computeElement != null) {
Host associatedHost = null;
for (Host host : hosts) {
if (!NullColumnValueGetter.isNullURI(host.getComputeElement()) && host.getComputeElement().equals(computeElement.getId())) {
associatedHost = host;
break;
}
}
Cluster cluster = null;
if (associatedHost != null && !NullColumnValueGetter.isNullURI(associatedHost.getCluster())) {
cluster = _dbClient.queryObject(Cluster.class, associatedHost.getCluster());
}
ComputeElementRestRep rest = map(computeElement, associatedHost, cluster);
result.getList().add(rest);
}
}
}
return result;
}
use of com.emc.storageos.db.client.model.Cluster in project coprhd-controller by CoprHD.
the class ComputeSystemControllerImpl method addStepForVcenterDataCenter.
public String addStepForVcenterDataCenter(Workflow workflow, String waitFor, URI datacenterUri) {
VcenterDataCenter dataCenter = _dbClient.queryObject(VcenterDataCenter.class, datacenterUri);
if (dataCenter != null && !dataCenter.getInactive()) {
// clean all export related to host in datacenter
List<NamedElementQueryResultList.NamedElement> hostUris = ComputeSystemHelper.listChildren(_dbClient, dataCenter.getId(), Host.class, "label", "vcenterDataCenter");
for (NamedElementQueryResultList.NamedElement hostUri : hostUris) {
Host host = _dbClient.queryObject(Host.class, hostUri.getId());
// do not detach storage of provisioned hosts
if (host != null && !host.getInactive() && NullColumnValueGetter.isNullURI(host.getComputeElement())) {
waitFor = unmountHostStorage(workflow, waitFor, host.getId());
}
}
List<NamedElementQueryResultList.NamedElement> clustersUris = ComputeSystemHelper.listChildren(_dbClient, dataCenter.getId(), Cluster.class, "label", "vcenterDataCenter");
for (NamedElementQueryResultList.NamedElement clusterUri : clustersUris) {
Cluster cluster = _dbClient.queryObject(Cluster.class, clusterUri.getId());
if (cluster != null && !cluster.getInactive()) {
waitFor = unmountClusterStorage(workflow, waitFor, cluster.getId());
}
}
for (NamedElementQueryResultList.NamedElement hostUri : hostUris) {
Host host = _dbClient.queryObject(Host.class, hostUri.getId());
// do not detach storage of provisioned hosts
if (host != null && !host.getInactive() && NullColumnValueGetter.isNullURI(host.getComputeElement())) {
waitFor = addStepsForExportGroups(workflow, waitFor, host.getId());
waitFor = addStepsForFileShares(workflow, waitFor, host.getId());
}
}
// cluster unexport removes the storage.(because we didn't consider the skipped hosts above)
for (NamedElementQueryResultList.NamedElement clusterUri : clustersUris) {
Cluster cluster = _dbClient.queryObject(Cluster.class, clusterUri.getId());
if (cluster != null && !cluster.getInactive()) {
waitFor = addStepsForClusterExportGroups(workflow, waitFor, cluster.getId());
}
}
}
return waitFor;
}
Aggregations