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