Search in sources :

Example 11 with ComputeVirtualPoolRestRep

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()));
    }
}
Also used : ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep)

Example 12 with ComputeVirtualPoolRestRep

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()));
    }
}
Also used : ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep)

Example 13 with ComputeVirtualPoolRestRep

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);
}
Also used : ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep) ComputeVirtualPoolElementDataTable(models.datatable.ComputeVirtualPoolElementDataTable)

Example 14 with ComputeVirtualPoolRestRep

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);
}
Also used : ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) ComputeSystemRestRep(com.emc.storageos.model.compute.ComputeSystemRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep)

Example 15 with ComputeVirtualPoolRestRep

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));
}
Also used : ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep) NamedRelatedResourceRep(com.emc.storageos.model.NamedRelatedResourceRep) RelatedResourceRep(com.emc.storageos.model.RelatedResourceRep) List(java.util.List) ArrayList(java.util.ArrayList) ComputeElementRestRep(com.emc.storageos.model.compute.ComputeElementRestRep) ComputeVirtualElementInfo(models.datatable.ComputeVirtualPoolElementDataTable.ComputeVirtualElementInfo)

Aggregations

ComputeVirtualPoolRestRep (com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep)16 NamedRelatedResourceRep (com.emc.storageos.model.NamedRelatedResourceRep)5 RelatedResourceRep (com.emc.storageos.model.RelatedResourceRep)3 Asset (com.emc.sa.asset.annotation.Asset)2 ComputeSystemRestRep (com.emc.storageos.model.compute.ComputeSystemRestRep)2 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)2 ViPRException (com.emc.vipr.client.exceptions.ViPRException)2 AssetOption (com.emc.vipr.model.catalog.AssetOption)2 Common.flashException (controllers.Common.flashException)2 URI (java.net.URI)2 HashSet (java.util.HashSet)2 ComputeVirtualPoolElementDataTable (models.datatable.ComputeVirtualPoolElementDataTable)2 AssetDependencies (com.emc.sa.asset.annotation.AssetDependencies)1 UCSServiceProfileTemplate (com.emc.storageos.db.client.model.UCSServiceProfileTemplate)1 ComputeElementRestRep (com.emc.storageos.model.compute.ComputeElementRestRep)1 VirtualArrayCreateParam (com.emc.storageos.model.varray.VirtualArrayCreateParam)1 VirtualArrayRestRep (com.emc.storageos.model.varray.VirtualArrayRestRep)1 ComputeVirtualPoolCreateParam (com.emc.storageos.model.vpool.ComputeVirtualPoolCreateParam)1 ComputeVirtualPoolList (com.emc.storageos.model.vpool.ComputeVirtualPoolList)1 ComputeVirtualPoolUpdateParam (com.emc.storageos.model.vpool.ComputeVirtualPoolUpdateParam)1