Package org.nimbustools.api.services.rm

Examples of org.nimbustools.api.services.rm.CreationException


                    vm.getName() + "', setting default";
            logger.debug(dbg);
            vm.setKernel(null);           
        } else if (!uri.getScheme().equals("file")) {
            // not supporting propagating kernels currently
            throw new CreationException("supplied, non-default kernel " +
                    "cannot currently be a remote file");
        } else {
            final String image = uri.toASCIIString();
            logger.trace("found kernel image: '" + image + "'");
            vm.setKernel(image);
View Full Code Here


    public void consume(VirtualMachine vm,
                        VMFile[] vmFiles)
            throws CreationException, ResourceRequestDeniedException {

        if (vmFiles == null || vmFiles.length == 0) {
            throw new CreationException("VM file description(s) missing");
        }

        final String vmName = vm.getName();

        boolean seenRootDisk = false;
       
        final boolean propagationEnabled = this.globals.isPropagateEnabled();
       
        final ArrayList partitions = new ArrayList(8);

        for (int i = 0; i < vmFiles.length; i++) {
           
            final VMFile file = vmFiles[i];
            if (file == null) {
                throw new CreationException(
                        "vmFile[] contents may not be null (index " + i + ")");
            }

            if (file.isRootFile()) {

                if (seenRootDisk) {
                    throw new CreationException("more than one root disk?");
                } else {
                    seenRootDisk = true;
                }

                // TODO:
View Full Code Here

        if (!propagationEnabled && !local) {
            final String err = "cannot propagate: supplied image '" +
                    uri.toASCIIString() + "' is not specified with " +
                    "file:// and propagation is disabled";
            throw new CreationException(err);
        }

        if (propagationEnabled && http) {
            boolean foundHost = false;

            String[] allowedHosts = this.globals.getAllowedHttpHosts();
            for (String allowedHost : allowedHosts) {
                //convert glob to regex
                allowedHost = allowedHost.trim();
                allowedHost = allowedHost.replaceAll("\\.", "\\\\\\.");
                allowedHost = allowedHost.replaceAll("\\*", "\\.\\*");

                if (uri.getHost().matches(allowedHost)) {
                    foundHost = true;
                }
            }

            if (!foundHost) {
                final String err = "cannot propagate: supplied image is from '" +
                    uri.getHost() + "' which is not in allowed.http.hosts";
                throw new CreationException(err);
            }
        }

        final VirtualMachinePartition partition = new VirtualMachinePartition();

View Full Code Here

        if (!uri.getScheme().equals("file")) {
            final String err = "request for '" + vmName + "' contains " +
                    "partition that is not root disk or a blank space " +
                    "creation request but it is not a cache reference " +
                    "(currently no propagate support for these)";
            throw new CreationException(err);
        }

        partition.setImage(uri.toASCIIString());
        partition.setImagemount(file.getMountAs());
        partition.setRootdisk(false);
View Full Code Here

            throws CreationException {

        if (megabytes < 1) {
            final String err = "blank space request under 1 megabyte in " +
                    "request for '" + vmName + "'";
            throw new CreationException(err);
        }

        final VirtualMachinePartition partition = new VirtualMachinePartition();
        partition.setPropRequired(false);
        partition.setUnPropRequired(false);
View Full Code Here

        final ArrayList nicnames = new ArrayList(nics.length);
        for (int i = 0; i < nics.length; i++) {
            final NIC nic = nics[i];
            final String name = nic.getName();
            if (nicnames.contains(name)) {
                throw new CreationException("You can not specify multiple " +
                        "NICs with the same name");
            }
            nicnames.add(name);
        }
View Full Code Here

            if (failure instanceof ResourceRequestDeniedException) {
                throw (ResourceRequestDeniedException) failure;
            } else if (failure instanceof CreationException) {
                throw (CreationException) failure;
            } else {
                throw new CreationException("Unknown problem while " +
                        "processing networking", failure);
            }
        }

        logger.error("Problem with network validations or reservations, " +
View Full Code Here

        if (failure instanceof CreationException) {
            toThrow = failure;
        } else if (failure instanceof ResourceRequestDeniedException) {
            toThrow = failure;
        } else {
            toThrow = new CreationException("", failure);
        }

        if (bailed < 1) {

            // love it
View Full Code Here

        net.append(XenUtil.WC_FIELD_SEPARATOR);

        final String clientProvidedMAC = nic.getMAC();
        if (clientProvidedMAC != null
                && clientProvidedMAC.trim().length() > 0) {
            throw new CreationException("no security policy in place for " +
                    "client MAC specification, this is disabled, resubmit " +
                    "without specific MAC requirement");
        }

        final String method = nic.getAcquisitionMethod();
        if (method == null) {
            throw new CreationException("no network method specification");
        }

        if (method.equals(NIC.ACQUISITION_AcceptAndConfigure)
                || method.equals(NIC.ACQUISITION_Advisory)) {

            // todo: verify IP syntax here to identify a problem earlier
            // (workspace_control will validate)
            // (e.g., xml constraints don't check for >255 )

            // TODO: move to authorization check section
            if (!staticIPAllowed) {
                throw new ResourceRequestDeniedException("request for " +
                        "non-allocate networking method is denied");
            }

            if (nic.getIpAddress() == null
                    || nic.getBroadcast() == null
                    || nic.getNetmask() == null) {
               
                final String err = "acquisition method '" + method + "' " +
                        "requires at least IP, broadcast, and netmask settings";
                throw new CreationException(err);
            }

            final String newMac = this.networkAdapter.newMAC();
            if (newMac == null) {
                net.append("ANY");
            } else {
                net.append(newMac);
            }
            net.append(XenUtil.WC_FIELD_SEPARATOR);

            //only handling bridged
            net.append("Bridged");
            net.append(XenUtil.WC_FIELD_SEPARATOR);

            net.append(method);
            net.append(XenUtil.WC_FIELD_SEPARATOR);

            // broadcast, gateway, and netmask can be null
            net.append(nic.getIpAddress()).
                append(XenUtil.WC_FIELD_SEPARATOR).
                append(nic.getGateway()).
                append(XenUtil.WC_FIELD_SEPARATOR).
                append(nic.getBroadcast()).
                append(XenUtil.WC_FIELD_SEPARATOR).
                append(nic.getNetmask()).
                append(XenUtil.WC_FIELD_SEPARATOR).
                append("null").
                append(XenUtil.WC_FIELD_SEPARATOR).
                append("null").
                append(XenUtil.WC_FIELD_SEPARATOR).
                append("null").
                append(XenUtil.WC_FIELD_SEPARATOR).
                append("null").
                append(XenUtil.WC_FIELD_SEPARATOR).
                append("null").
                append(XenUtil.WC_FIELD_SEPARATOR).
                append("null");

        } else if (method.equals(NIC.ACQUISITION_AllocateAndConfigure)) {

            //todo: once default association is configurable, there
            //  will also be an option to disallow defaults.
            // association being null means this
            //if (association == null) {
            //    throw errorBind("noAllocate");
            //}

            if (nic.getIpAddress() != null ||
                nic.getHostname()  != null ||
                nic.getBroadcast() != null ||
                nic.getGateway()   != null ||
                nic.getNetmask()   != null ||
                nic.getNetwork()   != null) {

                final String err = "no specific NIC network settings should " +
                        "be specified for acquisition method '" + method + "'";
                throw new CreationException(err);
            }

            int vmid = -1; // for logging
            if (vm != null) {
                final Integer integer = vm.getID();
                if (integer != null) {
                    vmid = integer.intValue();
                }
            }

            final Object[] entryAndDns =
                    this.networkAdapter.getNextEntry(association, vmid);

            if (entryAndDns == null || entryAndDns[0] == null) {
                // can't happen here, exception already thrown, but this is here
                // for clarity (and code analysis tools)
                final String err = "network '" + association
                        + "' is not currently available";
                logger.error(err);
                throw new ResourceRequestDeniedException(err);
            }

            final AssociationEntry entry = (AssociationEntry) entryAndDns[0];

            final String assignedMAC = entry.getMac();
            if (assignedMAC == null) {
                net.append("ANY");
            } else {
                net.append(assignedMAC);
            }
            net.append(XenUtil.WC_FIELD_SEPARATOR);

            //only handling bridged
            net.append("Bridged");
            net.append(XenUtil.WC_FIELD_SEPARATOR);

            net.append(method);
            net.append(XenUtil.WC_FIELD_SEPARATOR);

            net.append(entry.getIpAddress()).
                append(XenUtil.WC_FIELD_SEPARATOR).
                append(entry.getGateway()).
                append(XenUtil.WC_FIELD_SEPARATOR).
                append(entry.getBroadcast()).
                append(XenUtil.WC_FIELD_SEPARATOR).
                append(entry.getSubnetMask()).
                append(XenUtil.WC_FIELD_SEPARATOR).
                append(entryAndDns[1]).
                append(XenUtil.WC_FIELD_SEPARATOR).
                append(entry.getHostname()).
                append(XenUtil.WC_FIELD_SEPARATOR);

            // cert paths, old implementation
            net.append("null").
                append(XenUtil.WC_FIELD_SEPARATOR).
                append("null").
                append(XenUtil.WC_FIELD_SEPARATOR).
                append("null").
                append(XenUtil.WC_FIELD_SEPARATOR).
                append("null");

        } else {

            // todo: or just leave it up to the implementation?
            throw new CreationException("network method '" + method +
                    "' is not supported");
        }

        return net;
    }
View Full Code Here

                final String err = "requested shutdown state 'normal' is " +
                        "disabled, this site does not allow unpropagation " +
                        "from VMM nodes after the running time has expired. " +
                        "Use 'trash' instead and invoke unpropagation " +
                        "manually before running time has expired.";
                throw new CreationException(err);
            }

        } else if (CreateRequest.SHUTDOWN_TYPE_SERIALIZE.equals(shutdownRequest)) {

            // If this was implemented, !UnPropagateAfterRunningTimeEnabled
            // would also apply
            final String err = "requested shutdown state 'serialized' can " +
                    "not be accomplished, serialization is not supported";
            throw new CreationException(err);

        } else if (CreateRequest.SHUTDOWN_TYPE_TRASH.equals(shutdownRequest)) {

            dep.setRequestedShutdown(WorkspaceConstants.DEFAULT_SHUTDOWN_TRASH);

        } else {
            throw new CreationException("unknown shutdown type '" +
                    shutdownRequest + "'");
        }
       
    }
View Full Code Here

TOP

Related Classes of org.nimbustools.api.services.rm.CreationException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.