Search in sources :

Example 1 with HostRestRep

use of com.emc.storageos.model.host.HostRestRep in project coprhd-controller by CoprHD.

the class BaseHostProvider method getClustersMap.

protected Map<URI, String> getClustersMap(AssetOptionsContext context, List<HostRestRep> hosts) {
    Set<URI> clusterIds = Sets.newHashSet();
    for (HostRestRep host : hosts) {
        URI clusterId = ResourceUtils.id(host.getCluster());
        if (clusterId != null) {
            clusterIds.add(clusterId);
        }
    }
    Collection<ClusterRestRep> clusters = api(context).clusters().getByIds(clusterIds, null);
    Map<URI, String> clusterMap = new HashMap<URI, String>();
    for (ClusterRestRep cluster : clusters) {
        clusterMap.put(cluster.getId(), cluster.getName());
    }
    return clusterMap;
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) HostRestRep(com.emc.storageos.model.host.HostRestRep) HashMap(java.util.HashMap) URI(java.net.URI)

Example 2 with HostRestRep

use of com.emc.storageos.model.host.HostRestRep in project coprhd-controller by CoprHD.

the class BaseHostProvider method createFileHostOptions.

protected List<AssetOption> createFileHostOptions(AssetOptionsContext ctx, Collection<HostRestRep> hosts) {
    List<AssetOption> options = Lists.newArrayList();
    for (HostRestRep value : hosts) {
        options.add(createFileHostOption(ctx, value));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : HostRestRep(com.emc.storageos.model.host.HostRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption)

Example 3 with HostRestRep

use of com.emc.storageos.model.host.HostRestRep in project coprhd-controller by CoprHD.

the class VMWareProvider method filterClusterHosts.

/**
 * Filter out hosts in the cluster when other hosts in that cluster have failed discovery or
 * are incompatible.
 *
 * @param context
 *            asset context
 * @param datacenter
 *            data center
 * @param storageType
 *            storage type (exclusive or shared)
 * @param esxHosts
 *            list of all esx hosts that are discovered and compatible
 */
private void filterClusterHosts(AssetOptionsContext context, URI datacenter, String storageType, List<HostRestRep> esxHosts) {
    // Gather all ESX hosts that didn't match the filter
    if (esxHosts != null && !esxHosts.isEmpty() && storageType.equalsIgnoreCase(BlockProvider.SHARED_STORAGE.toString())) {
        List<HostRestRep> misfitEsxHosts = api(context).hosts().getByDataCenter(datacenter, HostTypeFilter.ESX.and(REGISTERED.not()).or(INCOMPATIBLE).or(COMPLETE.not()));
        Set<URI> misfitEsxClusterIds = new HashSet<>();
        if (misfitEsxHosts != null && !misfitEsxHosts.isEmpty()) {
            for (HostRestRep misfitEsxHost : misfitEsxHosts) {
                if (misfitEsxHost.getCluster() != null && !NullColumnValueGetter.isNullURI(misfitEsxHost.getCluster().getId())) {
                    misfitEsxClusterIds.add(misfitEsxHost.getCluster().getId());
                }
            }
            Iterator<HostRestRep> esxHostIter = esxHosts.iterator();
            while (esxHostIter.hasNext()) {
                HostRestRep esxHost = esxHostIter.next();
                if (esxHost.getCluster() != null && !NullColumnValueGetter.isNullURI(esxHost.getCluster().getId()) && misfitEsxClusterIds.contains(esxHost.getCluster().getId())) {
                    esxHostIter.remove();
                }
            }
        }
    }
}
Also used : HostRestRep(com.emc.storageos.model.host.HostRestRep) URI(java.net.URI) HashSet(java.util.HashSet)

Example 4 with HostRestRep

use of com.emc.storageos.model.host.HostRestRep in project coprhd-controller by CoprHD.

the class ClusterProvider method getEsxClusterOptions.

@Asset("esxCluster")
public List<AssetOption> getEsxClusterOptions(AssetOptionsContext ctx) {
    debug("getting esx clusters");
    Collection<ClusterRestRep> clusters = getClusters(ctx);
    List<AssetOption> options = Lists.newArrayList();
    for (ClusterRestRep value : clusters) {
        // If Cluster has an esx host - then add it to the list
        List<HostRestRep> hostList = api(ctx).hosts().getByCluster(value.getId());
        for (HostRestRep host : hostList) {
            if (host.getType().equalsIgnoreCase(Host.HostType.Esx.name())) {
                String dataCenterName = getDataCenterName(ctx, value);
                options.add(createClusterOption(ctx, value, dataCenterName));
                break;
            }
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) HostRestRep(com.emc.storageos.model.host.HostRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) Asset(com.emc.sa.asset.annotation.Asset)

Example 5 with HostRestRep

use of com.emc.storageos.model.host.HostRestRep in project coprhd-controller by CoprHD.

the class ClusterProvider method getVblockClusterOptions.

@Asset("vblockCluster")
public List<AssetOption> getVblockClusterOptions(AssetOptionsContext ctx) {
    debug("getting vblock clusters");
    Collection<ClusterRestRep> clusters = getClusters(ctx);
    List<AssetOption> options = Lists.newArrayList();
    for (ClusterRestRep value : clusters) {
        List<HostRestRep> hostList = api(ctx).hosts().getByCluster(value.getId());
        for (HostRestRep host : hostList) {
            // If Cluster has an esx or No-OS host and if host has a computeElement - then add it to the list
            if (host.getType() != null && (host.getType().equalsIgnoreCase(Host.HostType.Esx.name()) || host.getType().equalsIgnoreCase(Host.HostType.No_OS.name())) && host.getComputeElement() != null && !NullColumnValueGetter.isNullURI(host.getComputeElement().getId())) {
                String dataCenterName = getDataCenterName(ctx, value);
                options.add(createClusterOption(ctx, value, dataCenterName));
                break;
            }
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) HostRestRep(com.emc.storageos.model.host.HostRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) Asset(com.emc.sa.asset.annotation.Asset)

Aggregations

HostRestRep (com.emc.storageos.model.host.HostRestRep)46 URI (java.net.URI)17 ArrayList (java.util.ArrayList)10 ExecutionException (com.emc.sa.engine.ExecutionException)7 Host (com.emc.storageos.db.client.model.Host)6 ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)6 DeactivateHost (com.emc.sa.service.vipr.compute.tasks.DeactivateHost)5 DiscoverHost (com.emc.sa.service.vipr.compute.tasks.DiscoverHost)5 GetHost (com.emc.sa.service.vipr.tasks.GetHost)5 ExportGroupRestRep (com.emc.storageos.model.block.export.ExportGroupRestRep)5 TimeoutException (com.emc.vipr.client.exceptions.TimeoutException)5 ViPRException (com.emc.vipr.client.exceptions.ViPRException)5 HashMap (java.util.HashMap)5 HostUpdateParam (com.emc.storageos.model.host.HostUpdateParam)4 InitiatorRestRep (com.emc.storageos.model.host.InitiatorRestRep)4 Asset (com.emc.sa.asset.annotation.Asset)3 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)3 BlockObjectRestRep (com.emc.storageos.model.block.BlockObjectRestRep)3 VcenterDataCenterRestRep (com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep)3 Task (com.emc.vipr.client.Task)3