use of com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep in project coprhd-controller by CoprHD.
the class ComputeProvider method getComputeVirtualPoolForVirtualArray.
@Asset("computeVirtualPool")
@AssetDependencies({ "blockVirtualArray" })
public List<AssetOption> getComputeVirtualPoolForVirtualArray(AssetOptionsContext ctx, URI virtualArray) {
debug("getting compute virtual pools");
Collection<ComputeVirtualPoolRestRep> computeVirtualPools = api(ctx).computeVpools().getByVirtualArrayAndTenant(virtualArray, ctx.getTenant());
List<AssetOption> options = Lists.newArrayList();
for (ComputeVirtualPoolRestRep value : computeVirtualPools) {
options.add(createComputeVirtualPoolOption(ctx, value));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
use of com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep in project coprhd-controller by CoprHD.
the class AddHostToClusterService method precheck.
@Override
public void precheck() throws Exception {
StringBuilder preCheckErrors = new StringBuilder();
hostNames = ComputeUtils.getHostNamesFromFqdnToIps(fqdnToIps);
copyOfHostNames = ImmutableList.copyOf(hostNames);
hostIps = ComputeUtils.getIpsFromFqdnToIps(fqdnToIps);
List<String> existingHostNames = ComputeUtils.getHostNamesByName(getClient(), hostNames);
cluster = BlockStorageUtils.getCluster(clusterId);
List<String> hostNamesInCluster = ComputeUtils.findHostNamesInCluster(cluster);
if (cluster == null) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.no.cluster.exists"));
}
acquireClusterLock(cluster);
preCheckErrors = ComputeUtils.verifyClusterInVcenter(cluster, preCheckErrors);
if (hostNames == null || hostNames.isEmpty() || hostIps == null || hostIps.isEmpty()) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.osinstall.host.required") + " ");
}
// Check for validity of host names and host Ips
for (String hostName : hostNames) {
if (!ComputeUtils.isValidHostIdentifier(hostName)) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.hostname.invalid", hostName) + " ");
}
}
for (String hostIp : hostIps) {
if (!ComputeUtils.isValidIpAddress(hostIp)) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.ip.invalid", hostIp) + " ");
}
}
if (!ComputeUtils.isCapacityAvailable(getClient(), virtualPool, virtualArray, size, (hostNames.size() - existingHostNames.size()))) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.insufficient.storage.capacity") + " ");
}
if (!ComputeUtils.isComputePoolCapacityAvailable(getClient(), computeVirtualPool, (hostNames.size() - existingHostNames.size()))) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.insufficient.compute.capacity") + " ");
}
if (!ComputeUtils.isValidIpAddress(netmask)) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.invalid.netmask") + " ");
}
if (!ComputeUtils.isValidHostIdentifier(gateway)) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.invalid.gateway") + " ");
}
if (ntpServer != null && ntpServer.trim().length() == 0) {
ntpServer = null;
} else if (ntpServer != null && ntpServer.trim().length() > 0) {
// allowing user to specify comma separated list - use only use the first valid one
String[] ntpServerList = ntpServer.split(",");
String validServer = null;
for (String ntpServerx : ntpServerList) {
if (ComputeUtils.isValidHostIdentifier(ntpServerx.trim())) {
validServer = ntpServerx.trim();
}
break;
}
if (validServer == null) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.invalid.ntp") + " ");
} else {
ntpServer = validServer;
}
}
if (dnsServers != null && dnsServers.trim().length() == 0) {
dnsServers = null;
} else if (dnsServers != null && dnsServers.trim().length() > 0) {
String[] dnsServerList = dnsServers.split(",");
for (String dnsServer : dnsServerList) {
if (!ComputeUtils.isValidIpAddress(dnsServer.trim()) && !ComputeUtils.isValidHostIdentifier(dnsServer.trim())) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.invalid.dns") + " ");
}
}
}
if (hostNamesInCluster != null && !hostNamesInCluster.isEmpty() && !existingHostNames.isEmpty()) {
for (String hostName : hostNamesInCluster) {
if (existingHostNames.contains(hostName)) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.hostname.already.in.cluster", hostName) + " ");
}
}
}
for (String existingHostName : existingHostNames) {
if (!hostNamesInCluster.contains(existingHostName)) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.hosts.exists.elsewhere", existingHostName) + " ");
}
}
ComputeVirtualPoolRestRep cvp = ComputeUtils.getComputeVirtualPool(getClient(), computeVirtualPool);
if (cvp.getServiceProfileTemplates().isEmpty()) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.service.profile.templates.null", cvp.getName()) + " ");
}
if (preCheckErrors.length() > 0) {
throw new IllegalStateException(preCheckErrors.toString() + ComputeUtils.getContextErrors(getModelClient()));
}
}
use of com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep in project coprhd-controller by CoprHD.
the class ComputeUtils method isComputePoolCapacityAvailable.
public static boolean isComputePoolCapacityAvailable(ViPRCoreClient client, URI poolURI, int numHosts) {
ComputeVirtualPoolRestRep resp = client.computeVpools().getComputeVirtualPool(poolURI);
int numAvailableBlades = resp.getAvailableMatchedComputeElements().size();
return numAvailableBlades < numHosts ? false : true;
}
use of com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep in project coprhd-controller by CoprHD.
the class CreateBareMetalClusterService method precheck.
@Override
public void precheck() throws Exception {
StringBuilder preCheckErrors = new StringBuilder();
hostNames = ComputeUtils.getHostNamesFromFqdn(fqdnValues);
copyOfHostNames = ImmutableList.copyOf(hostNames);
List<String> existingHostNames = ComputeUtils.getHostNamesByName(getClient(), hostNames);
cluster = ComputeUtils.getCluster(name);
List<String> hostNamesInCluster = ComputeUtils.findHostNamesInCluster(cluster);
if ((cluster != null) && hostNamesInCluster.isEmpty()) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.empty.cluster.exists"));
}
if ((cluster != null) && !hostNames.containsAll(hostNamesInCluster)) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.unknown.host"));
}
if (hostNames == null || hostNames.isEmpty()) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.baremetal.hostname.required") + " ");
}
// Check for validity of host names and host Ips
for (String hostName : hostNames) {
if (!ComputeUtils.isValidHostIdentifier(hostName)) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.hostname.invalid", hostName) + " ");
}
}
if (hostNames != null && !hostNames.isEmpty() && !existingHostNames.isEmpty() && hostNamesInCluster.containsAll(existingHostNames) && (hostNames.size() == hostNamesInCluster.size())) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.host.already.in.cluster") + " ");
}
if (hostNamesInCluster != null && !hostNamesInCluster.isEmpty() && !existingHostNames.isEmpty()) {
for (String hostName : hostNamesInCluster) {
if (existingHostNames.contains(hostName)) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.hostname.already.in.cluster", hostName) + " ");
}
}
}
if (!ComputeUtils.isCapacityAvailable(getClient(), virtualPool, virtualArray, size, hostNames.size() - existingHostNames.size())) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.insufficient.storage.capacity") + " ");
}
if (!ComputeUtils.isComputePoolCapacityAvailable(getClient(), computeVirtualPool, hostNames.size() - existingHostNames.size())) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.insufficient.compute.capacity") + " ");
}
for (String existingHostName : existingHostNames) {
if (!hostNamesInCluster.contains(existingHostName)) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.hosts.exists.elsewhere", existingHostName) + " ");
}
}
ComputeVirtualPoolRestRep cvp = ComputeUtils.getComputeVirtualPool(getClient(), computeVirtualPool);
if (cvp.getServiceProfileTemplates().isEmpty()) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.service.profile.templates.null", cvp.getName()) + " ");
}
if (preCheckErrors.length() > 0) {
throw new IllegalStateException(preCheckErrors.toString() + ComputeUtils.getContextErrors(getModelClient()));
}
}
use of com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep in project coprhd-controller by CoprHD.
the class ComputeProvider method getComputeVirtualPoolOptions.
@Asset("computeVirtualPool")
public List<AssetOption> getComputeVirtualPoolOptions(AssetOptionsContext ctx) {
debug("getting compute virtual pools");
Collection<ComputeVirtualPoolRestRep> computeVirtualPools = getComputeVirtualPools(ctx);
List<AssetOption> options = Lists.newArrayList();
for (ComputeVirtualPoolRestRep value : computeVirtualPools) {
options.add(createComputeVirtualPoolOption(ctx, value));
}
AssetOptionsUtils.sortOptionsByLabel(options);
return options;
}
Aggregations