Search in sources :

Example 11 with ClusterRestRep

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

the class VcenterClusterProvider method getClusterOptions.

@Asset("vcenterCluster")
public List<AssetOption> getClusterOptions(AssetOptionsContext ctx) {
    debug("getting clusters");
    Collection<ClusterRestRep> clusters = getClusters(ctx);
    List<AssetOption> options = Lists.newArrayList();
    Map<URI, String> vcenterMap = getVcenters(ctx);
    Map<URI, String> dataCenterNameMap = new HashMap<URI, String>();
    Map<URI, String> dataCenterVcenterMap = new HashMap<URI, String>();
    String vcenterName;
    String datacenterName;
    for (ClusterRestRep value : clusters) {
        if (value.getVcenterDataCenter() != null) {
            RelatedResourceRep datacenterVal = value.getVcenterDataCenter();
            if (datacenterVal != null) {
                if (dataCenterVcenterMap.get(datacenterVal.getId()) == null) {
                    VcenterDataCenterRestRep restResponse = api(ctx).vcenterDataCenters().get(datacenterVal.getId());
                    datacenterName = restResponse.getName();
                    dataCenterNameMap.put(datacenterVal.getId(), datacenterName);
                    RelatedResourceRep vcenterResp = restResponse.getVcenter();
                    if (vcenterMap.get(vcenterResp.getId()) == null) {
                        VcenterRestRep vcenterRep = api(ctx).vcenters().get(vcenterResp);
                        vcenterMap.put(vcenterResp.getId(), vcenterRep.getName());
                        vcenterName = vcenterRep.getName();
                        dataCenterVcenterMap.put(datacenterVal.getId(), vcenterName);
                    } else {
                        vcenterName = vcenterMap.get(vcenterResp.getId());
                        dataCenterVcenterMap.put(datacenterVal.getId(), vcenterName);
                    }
                } else {
                    datacenterName = dataCenterNameMap.get(datacenterVal.getId());
                    vcenterName = dataCenterVcenterMap.get(datacenterVal.getId());
                }
                options.add(createClusterOption(ctx, value, true, vcenterName, datacenterName));
            }
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) HashMap(java.util.HashMap) VcenterRestRep(com.emc.storageos.model.host.vcenter.VcenterRestRep) VcenterDataCenterRestRep(com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep) URI(java.net.URI) Asset(com.emc.sa.asset.annotation.Asset)

Example 12 with ClusterRestRep

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

the class VcenterClusterProvider method getNewClusterOptions.

@Asset("newVcenterCluster")
public List<AssetOption> getNewClusterOptions(AssetOptionsContext ctx) {
    debug("getting clusters");
    Collection<ClusterRestRep> clusters = getClusters(ctx);
    List<AssetOption> options = Lists.newArrayList();
    for (ClusterRestRep value : clusters) {
        if (value.getVcenterDataCenter() == null) {
            options.add(createClusterOption(ctx, value, false, "", ""));
        }
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) Asset(com.emc.sa.asset.annotation.Asset)

Example 13 with ClusterRestRep

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

the class CreateComputeClusterService method pushToVcenter.

private void pushToVcenter() {
    if (vcenterId != null) {
        boolean isVCenterUpdate = false;
        List<ClusterRestRep> clusters = getClient().clusters().getByDataCenter(datacenterId);
        for (ClusterRestRep resp : clusters) {
            if (cluster.getLabel().equals(resp.getName())) {
                isVCenterUpdate = true;
                break;
            }
        }
        try {
            Vcenter vcenter = null;
            VcenterDataCenter dataCenter = null;
            vcenter = ComputeUtils.getVcenter(vcenterId);
            if (null != datacenterId) {
                dataCenter = ComputeUtils.getVcenterDataCenter(datacenterId);
            }
            boolean status = true;
            if (isVCenterUpdate) {
                logInfo("vcenter.cluster.update", cluster.getLabel());
                if (dataCenter == null) {
                    status = ComputeUtils.updateVcenterCluster(cluster, datacenterId);
                } else {
                    status = ComputeUtils.updateVcenterCluster(cluster, dataCenter);
                }
                if (!status) {
                    throw new IllegalStateException(ExecutionUtils.getMessage("vcenter.cluster.update.failed", cluster.getLabel()));
                }
            } else {
                logInfo("compute.cluster.create.vcenter.cluster.datacenter", (vcenter != null ? vcenter.getLabel() : vcenterId), (dataCenter != null ? dataCenter.getLabel() : datacenterId));
                if (dataCenter == null) {
                    status = ComputeUtils.createVcenterCluster(cluster, datacenterId);
                } else {
                    status = ComputeUtils.createVcenterCluster(cluster, dataCenter);
                }
                if (!status) {
                    throw new IllegalStateException(ExecutionUtils.getMessage("vcenter.cluster.create.failed", cluster.getLabel()));
                }
            }
        } catch (Exception e) {
            logError("compute.cluster.vcenter.sync.failed.corrective.user.message", cluster.getLabel());
            logError("compute.cluster.vcenter.push.failed", e.getMessage());
            throw e;
        }
    }
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) Vcenter(com.emc.storageos.db.client.model.Vcenter) VcenterDataCenter(com.emc.storageos.db.client.model.VcenterDataCenter)

Example 14 with ClusterRestRep

use of com.emc.storageos.model.host.cluster.ClusterRestRep 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 15 with ClusterRestRep

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

the class BaseHostProvider method createClusterOptions.

protected List<AssetOption> createClusterOptions(AssetOptionsContext ctx, Collection<ClusterRestRep> clusters) {
    List<AssetOption> options = Lists.newArrayList();
    for (ClusterRestRep value : clusters) {
        options.add(createClusterOption(ctx, value));
    }
    AssetOptionsUtils.sortOptionsByLabel(options);
    return options;
}
Also used : ClusterRestRep(com.emc.storageos.model.host.cluster.ClusterRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption)

Aggregations

ClusterRestRep (com.emc.storageos.model.host.cluster.ClusterRestRep)23 HostRestRep (com.emc.storageos.model.host.HostRestRep)7 Asset (com.emc.sa.asset.annotation.Asset)6 AssetOption (com.emc.vipr.model.catalog.AssetOption)6 URI (java.net.URI)6 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)5 VcenterDataCenterRestRep (com.emc.storageos.model.host.vcenter.VcenterDataCenterRestRep)4 VcenterRestRep (com.emc.storageos.model.host.vcenter.VcenterRestRep)4 DefaultResourceFilter (com.emc.vipr.client.core.filters.DefaultResourceFilter)3 ProjectRestRep (com.emc.storageos.model.project.ProjectRestRep)2 FlashException (controllers.util.FlashException)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)1 Vcenter (com.emc.storageos.db.client.model.Vcenter)1 VcenterDataCenter (com.emc.storageos.db.client.model.VcenterDataCenter)1 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)1 SnapshotList (com.emc.storageos.model.SnapshotList)1 VirtualArrayRelatedResourceRep (com.emc.storageos.model.VirtualArrayRelatedResourceRep)1 VolumeGroupList (com.emc.storageos.model.application.VolumeGroupList)1