Search in sources :

Example 16 with Cluster

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;
}
Also used : UnManagedExportMaskList(com.emc.storageos.model.block.UnManagedExportMaskList) MapCluster(com.emc.storageos.api.mapper.functions.MapCluster) Cluster(com.emc.storageos.db.client.model.Cluster) UnManagedExportMask(com.emc.storageos.db.client.model.UnManagedDiscoveredObjects.UnManagedExportMask) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 17 with Cluster

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;
}
Also used : MapCluster(com.emc.storageos.api.mapper.functions.MapCluster) Cluster(com.emc.storageos.db.client.model.Cluster) HostList(com.emc.storageos.model.host.HostList) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 18 with Cluster

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;
        }
    }));
}
Also used : Function(com.google.common.base.Function) ComputeElementBulkRep(com.emc.storageos.model.compute.ComputeElementBulkRep) 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)

Example 19 with Cluster

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

Example 20 with Cluster

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;
}
Also used : Cluster(com.emc.storageos.db.client.model.Cluster) VcenterDataCenter(com.emc.storageos.db.client.model.VcenterDataCenter) Host(com.emc.storageos.db.client.model.Host) NamedElementQueryResultList(com.emc.storageos.db.client.constraint.NamedElementQueryResultList)

Aggregations

Cluster (com.emc.storageos.db.client.model.Cluster)67 Host (com.emc.storageos.db.client.model.Host)38 URI (java.net.URI)26 InternalException (com.emc.storageos.svcs.errorhandling.resources.InternalException)20 VcenterDataCenter (com.emc.storageos.db.client.model.VcenterDataCenter)19 Initiator (com.emc.storageos.db.client.model.Initiator)15 DeviceControllerException (com.emc.storageos.exceptions.DeviceControllerException)15 Path (javax.ws.rs.Path)14 Produces (javax.ws.rs.Produces)14 VcenterControllerException (com.emc.storageos.vcentercontroller.exceptions.VcenterControllerException)13 VcenterObjectConnectionException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectConnectionException)13 VcenterObjectNotFoundException (com.emc.storageos.vcentercontroller.exceptions.VcenterObjectNotFoundException)13 ArrayList (java.util.ArrayList)13 Vcenter (com.emc.storageos.db.client.model.Vcenter)12 VcenterServerConnectionException (com.emc.storageos.vcentercontroller.exceptions.VcenterServerConnectionException)11 HashSet (java.util.HashSet)9 MapCluster (com.emc.storageos.api.mapper.functions.MapCluster)8 VcenterApiClient (com.emc.storageos.vcentercontroller.VcenterApiClient)8 GET (javax.ws.rs.GET)8 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)6