Search in sources :

Example 6 with ComputeVirtualPoolRestRep

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;
}
Also used : ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) AssetDependencies(com.emc.sa.asset.annotation.AssetDependencies) Asset(com.emc.sa.asset.annotation.Asset)

Example 7 with ComputeVirtualPoolRestRep

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

Example 8 with ComputeVirtualPoolRestRep

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

Example 9 with ComputeVirtualPoolRestRep

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

Example 10 with ComputeVirtualPoolRestRep

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;
}
Also used : ComputeVirtualPoolRestRep(com.emc.storageos.model.vpool.ComputeVirtualPoolRestRep) AssetOption(com.emc.vipr.model.catalog.AssetOption) Asset(com.emc.sa.asset.annotation.Asset)

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