use of com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep in project coprhd-controller by CoprHD.
the class AddBareMetalHostToClusterService 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 = BlockStorageUtils.getCluster(clusterId);
List<String> hostNamesInCluster = ComputeUtils.findHostNamesInCluster(cluster);
if (cluster == null) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.no.cluster.exists"));
}
acquireClusterLock(cluster);
if (hostNames == null || hostNames.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) + " ");
}
}
if (hostNamesInCluster != null && !hostNamesInCluster.isEmpty() && !existingHostNames.isEmpty() && hostNamesInCluster.containsAll(existingHostNames)) {
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 CreateComputeClusterService 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 = ComputeUtils.getCluster(name);
List<String> hostNamesInCluster = ComputeUtils.findHostNamesInCluster(cluster);
if ((cluster != null) && hostNamesInCluster.isEmpty()) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.empty.cluster.exists"));
}
// and also inform it to the user
if ((cluster != null) && !hostNames.containsAll(hostNamesInCluster)) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.unknown.host"));
}
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
// TODO why do we take only the first NTP server? Check
String[] ntpServerList = ntpServer.split(",");
String validServer = null;
for (String ntpServerx : ntpServerList) {
if (ComputeUtils.isValidHostIdentifier(ntpServerx.trim())) {
validServer = ntpServerx.trim();
// TODO the break should be moved inside the 'if'
}
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) + " ");
}
}
if (vcenterId != null && datacenterId == null) {
preCheckErrors.append(ExecutionUtils.getMessage("compute.cluster.datacenter.id.null") + " ");
}
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 ComputeVirtualPools method elements.
public static void elements(String id) {
addReferenceData();
ComputeVirtualPoolRestRep computeVirtualPool = ComputeVirtualPoolUtils.getComputeVirtualPool(id);
ComputeVirtualPoolElementDataTable dataTable = new ComputeVirtualPoolElementDataTable();
render("@listElements", computeVirtualPool, dataTable);
}
use of com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep in project coprhd-controller by CoprHD.
the class ComputeVirtualPools method computeVirtualPoolDetails.
public static void computeVirtualPoolDetails(String id) {
ComputeVirtualPoolRestRep computeVirtualPool = ComputeVirtualPoolUtils.getComputeVirtualPool(id);
if (computeVirtualPool == null) {
error(MessagesUtils.get(UNKNOWN, id));
}
List<NamedRelatedResourceRep> temps = computeVirtualPool.getServiceProfileTemplates();
List<RelatedResourceRep> varrays = computeVirtualPool.getVirtualArrays();
StringBuilder selectedTemplatesBuilder = new StringBuilder();
for (RelatedResourceRep varray : varrays) {
List<ComputeSystemRestRep> arrayComputes = VirtualArrayUtils.getComputeSystems(varray.getId());
for (ComputeSystemRestRep acomp : arrayComputes) {
for (NamedRelatedResourceRep spt : acomp.getServiceProfileTemplates()) {
if (CollectionUtils.isNotEmpty(temps)) {
for (NamedRelatedResourceRep template : temps) {
if (spt.getId().equals(template.getId())) {
selectedTemplatesBuilder.append(acomp.getName()).append(" - ").append(template.getName()).append(", ");
}
}
}
}
}
}
String selectedTemplatesString = StringUtils.stripEnd(selectedTemplatesBuilder.toString(), ", ");
render(computeVirtualPool, selectedTemplatesString);
}
use of com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep in project coprhd-controller by CoprHD.
the class ComputeVirtualPools method listComputePoolElements.
public static void listComputePoolElements(String id) {
List<ComputeVirtualElementInfo> results = Lists.newArrayList();
List<ComputeElementRestRep> allComputeElements = (List<ComputeElementRestRep>) ComputeSystemUtils.getAllComputeElements();
ComputeVirtualPoolRestRep computePool = ComputeVirtualPoolUtils.getComputeVirtualPool(id);
List<RelatedResourceRep> matchedElements = computePool.getMatchedComputeElements();
for (RelatedResourceRep poolElement : matchedElements) {
for (ComputeElementRestRep element : allComputeElements) {
if (element.getId().equals(poolElement.getId())) {
results.add(new ComputeVirtualElementInfo(element, computePool.getName(), (String) "No Name yet"));
break;
}
}
}
renderJSON(DataTablesSupport.createJSON(results, params));
}
Aggregations