Package org.nimbustools.api.repr

Examples of org.nimbustools.api.repr.CannotTranslateException


            throw new IllegalArgumentException("requires may not be null");
        }

        final CPUArchitecture_Type arch = requires.getCPUArchitecture();
        if (arch == null) {
            throw new CannotTranslateException(
                    "CPUArchitecture_Type may not be missing");
        }

        final ProcessorArchitectureEnumeration archEnum =
                                        arch.getCPUArchitectureName();
        if (archEnum == null) {
            throw new CannotTranslateException(
                    "ProcessorArchitectureEnumeration may not be missing");
        }

        final String archStr = (String) archMap.get(archEnum);
        if (archStr == null) {
            throw new CannotTranslateException(
                    "ProcessorArchitectureEnumeration contains " +
                            "unrecognized value '" + archEnum.toString() + "'");
        }

        ResourceAllocation ra = req.getRequestedRA();
        if (ra == null) {
            ra = this.repr._newResourceAllocation();
            req.setRequestedRA(ra);
        }
        if (!(ra instanceof _ResourceAllocation)) {
            throw new CannotTranslateException(
                    "expecting writable ResourceAllocation");
        }
        ((_ResourceAllocation)ra).setArchitecture(archStr);

        final VMM_Type vmm = requires.getVMM();
View Full Code Here


        this.serializationUnsupported(disks);

        final BoundDisk_Type rootdisk = disks.getRootVBD();
        if (rootdisk == null) {
            throw new CannotTranslateException(
                    "root disk/partition description may not be missing");
        }

        final ArrayList files = new ArrayList(8);
        files.add(this.translateRootFile(rootdisk));
View Full Code Here

        if (disks == null) {
            throw new IllegalArgumentException("disks may not be null");
        }
        if (disks.getRAM() != null) {
            throw new CannotTranslateException(
                    "VWS API does not support serialized images as input yet");
        }
        if (disks.getSwap() != null) {
            throw new CannotTranslateException(
                    "VWS API does not support serialized images as input yet");
        }
    }
View Full Code Here

        file.setBlankSpaceName(null);
        file.setBlankSpaceSize(-1);

        final URI uri = bd.getLocation();
        if (uri == null) {
            throw new CannotTranslateException("a disk is missing location");
        }

        file.setURI(this.convertURI(uri));

        final String mountAs = bd.getMountAs();
        if (mountAs == null) {
            throw new CannotTranslateException("a disk is missing mountAs");
        }
        file.setMountAs(mountAs);

        final DiskPermissions_Type perms = bd.getPermissions();

        if (perms == null) {
            file.setDiskPerms(VMFile.DISKPERMS_ReadWrite);
        } else if (perms.equals(DiskPermissions_Type.ReadOnly)) {
            file.setDiskPerms(VMFile.DISKPERMS_ReadOnly);
        } else if (perms.equals(DiskPermissions_Type.ReadWrite)) {
            file.setDiskPerms(VMFile.DISKPERMS_ReadWrite);
        } else {
            throw new CannotTranslateException(
                    "unknown disk permission: '" + perms + "'");
        }

        return file;
    }
View Full Code Here

        file.setRootFile(false);
        file.setURI(null);

        final String name = bd.getPartitionName();
        if (name == null) {
            throw new CannotTranslateException(
                    "a blank disk description is missing PartitionName");
        }
        file.setBlankSpaceName(name);

        final String mountAs = bd.getMountAs();
        if (mountAs == null) {
            throw new CannotTranslateException(
                    "a blank disk description is missing mountAs");
        }
        file.setMountAs(mountAs);

        // setBlankSpaceSize is needed, but will get set in resource allocation
View Full Code Here

    public java.net.URI convertURI(URI axisURI)
            throws CannotTranslateException {
        try {
            return axisURI == null ? null : new java.net.URI(axisURI.toString());
        } catch (URISyntaxException e) {
            throw new CannotTranslateException(e.getMessage(), e);
        }
    }
View Full Code Here

     */
    public EndpointReferenceType getEPR(String id)
            throws CannotTranslateException {

        if (id == null) {
            throw new CannotTranslateException("id may not be null");
        }

        try {
            final String addr = this.baseURL + this.serviceName;
            final ResourceKey key =
                    new SimpleResourceKey(this.keyTypeName, id);
            return AddressingUtils.createEndpointReference(addr, key);
        } catch (Exception e) {
            throw new CannotTranslateException(e.getMessage(), e);
        }
    }
View Full Code Here

        if (dep == null) {
            throw new IllegalArgumentException("dep may not be null");
        }

        if (!(req.getRequestedRA() instanceof _ResourceAllocation)) {
            throw new CannotTranslateException(
                    "expecting writable ResourceAllocation");
        }

        _ResourceAllocation ra = (_ResourceAllocation) req.getRequestedRA();
        if (ra == null) {
            ra = this.repr._newResourceAllocation();
            req.setRequestedRA(ra);
        }

        final _Schedule sched = this.repr._newSchedule();
        if (dep.getDeploymentTime() != null) {
            final int requestedSecs;
            try {
                requestedSecs = CommonUtil.durationToSeconds(
                            dep.getDeploymentTime().getMinDuration());
            } catch (InvalidDurationException e) {
                throw new CannotTranslateException(e.getMessage(), e);
            }
            sched.setDurationSeconds(requestedSecs);
        }
        req.setRequestedSchedule(sched);

        ra.setNodeNumber(dep.getNodeNumber());
       
        // handled elsewhere: dep.getPostShutdown();

        final ShutdownMechanism_Type shutdownMech = dep.getShutdownMechanism();
        if (shutdownMech == null) {
            req.setShutdownType(CreateRequest.SHUTDOWN_TYPE_NORMAL);
        } else {
            final String type = (String) shutdownMap.get(shutdownMech);
            if (type == null) {
                throw new CannotTranslateException("unknown shutdown " +
                        "mechanism '" + shutdownMech.toString() + "'");
            } else {
                req.setShutdownType(type);
            }
        }

        final InitialState_Type initialState = dep.getInitialState();
        if (initialState == null) {
            req.setInitialStateRequest(CreateRequest.INITIAL_STATE_RUNNING);
        } else {
            final String state = (String) initialStateMap.get(initialState);
            if (state == null) {
                throw new CannotTranslateException("unknown initial " +
                        "state '" + initialState.toString() + "'");
            } else {
                req.setInitialStateRequest(state);
            }
        }

        final ResourceAllocation_Type wsra = dep.getResourceAllocation();
        if (wsra == null) {
            throw new CannotTranslateException(
                    "ResourceAllocation_Type may not be missing");
        }

        ra.setMemory(this.getMemoryMB(wsra));
        ra.setIndCpuCount(this.getCPUCount(wsra));

        boolean noFiles = false;
        final VMFile[] files = req.getVMFiles();
        if (files == null || files.length == 0) {
            noFiles = true;
        }

        final Storage_Type storage = wsra.getStorage();
        if (storage != null) {

            final Entry[] entries = storage.getEntry();
            if (entries != null && entries.length > 0) {

                if (noFiles) {
                    throw new CannotTranslateException("Cannot examine " +
                        "storage requests without previous file consumption");
                }

                this.consumeEntries(entries, files);
            }
View Full Code Here

            throw new IllegalArgumentException("wsra may not be null");
        }

        final RangeValue_Type memory =  wsra.getIndividualPhysicalMemory();
        if (memory == null) {
            throw new CannotTranslateException("no memory request");
        }

        //TODO: support ranges and Exact_Type[]
        final Exact_Type exact_mem = memory.getExact(0);
        if (exact_mem == null) {
            throw new CannotTranslateException("no exact memory request");
        }

        // casting double
        return (int) exact_mem.get_value();
    }
View Full Code Here

        }

        //TODO: support ranges and Exact_Type[]
        final Exact_Type exact_cores = cores.getExact(0);
        if (exact_cores == null) {
            throw new CannotTranslateException("no exact multi core CPU request");
        }

        // casting double
        return (int) exact_cores.get_value();
    }
View Full Code Here

TOP

Related Classes of org.nimbustools.api.repr.CannotTranslateException

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.