Package org.nimbustools.api.repr

Examples of org.nimbustools.api.repr.CannotTranslateException


    public State getState(InstanceResource resource)
            throws CannotTranslateException {

        if (resource == null) {
            throw new CannotTranslateException("no resource?");
        }

        final int num = resource.getState();

        final String stateStr;
        if (num >= STATE_CORRUPTED_GENERIC && num <= STATE_LAST_LEGAL) {
            stateStr = State.STATE_Corrupted;
        } else {
            stateStr = (String) statusMap.get(new Integer(num));
        }

        if (stateStr == null) {
            throw new CannotTranslateException("state string is required");
        }

        final _State state = this.repr._newState();
        state.setState(stateStr);
        state.setProblem(resource.getStateThrowable()); // can be null
View Full Code Here


    // TODO: move to sane network representation
    // need for this will go away as we migrate
    public NIC[] getNICs(VirtualMachine vm) throws CannotTranslateException {

        if (vm == null) {
            throw new CannotTranslateException("no vm?");
        }

        final String network = vm.getNetwork();

        if (network == null) {
            throw new CannotTranslateException("no network?");
        }

        return getNICs(network);
    }
View Full Code Here

    public ResourceAllocation getRA(VirtualMachine vm)

            throws CannotTranslateException {
       
        if (vm == null) {
            throw new CannotTranslateException("null VirtualMachine?");
        }

        final _ResourceAllocation ra = this.repr._newResourceAllocation();

        final VirtualMachineDeployment dep = vm.getDeployment();
View Full Code Here

    public Schedule getSchedule(InstanceResource resource)

            throws CannotTranslateException {

        if (resource == null) {
            throw new CannotTranslateException("no resource?");
        }

        final _Schedule schedule = this.repr._newSchedule();

        schedule.setDestructionTime(resource.getTerminationTime());
        schedule.setStartTime(resource.getStartTime());

        final VirtualMachine vm = resource.getVM();
        if (vm == null) {
            throw new CannotTranslateException("null VirtualMachine?");
        }
        final VirtualMachineDeployment dep = vm.getDeployment();
        if (dep == null) {
            throw new CannotTranslateException("null deployment information?");
        }
        schedule.setDurationSeconds(dep.getMinDuration());

        return schedule;
    }
View Full Code Here

    public VMFile[] getStorage(VirtualMachine vm)
            throws CannotTranslateException {

        if (vm == null) {
            throw new CannotTranslateException("null VirtualMachine?");
        }

        final VirtualMachinePartition[] partitions = vm.getPartitions();
        if (partitions == null || partitions.length == 0) {
            return EMPTY_VM_FILES;
View Full Code Here

    // will switch over to using natively, they are basically identical.
    public VMFile getOneFile(VirtualMachinePartition part)
            throws CannotTranslateException {

        if (part == null) {
            throw new CannotTranslateException("null partition");
        }

        final _VMFile vmFile = this.repr._newVMFile();

        vmFile.setRootFile(part.isRootdisk());
        if (part.isReadwrite()) {
            vmFile.setDiskPerms(VMFile.DISKPERMS_ReadWrite);
        } else {
            vmFile.setDiskPerms(VMFile.DISKPERMS_ReadOnly);
        }
        vmFile.setMountAs(part.getImagemount());

        final int size = part.getBlankspace();
        if (size > 0) {
            vmFile.setBlankSpaceSize(size);
            vmFile.setBlankSpaceName(null); // unknown
        }

        try {
            final String unpropTargetStr = part.getAlternateUnpropTarget();
            if (unpropTargetStr != null) {
                vmFile.setUnpropURI(new URI(unpropTargetStr));
            }
            vmFile.setURI(new URI(part.getImage()));
        } catch (URISyntaxException e) {
            throw new CannotTranslateException(e.getMessage(), e);
        }

        return vmFile;
    }
View Full Code Here

    public Usage getUsage(ElapsedAndReservedMinutes earm)

            throws CannotTranslateException {

        if (earm == null) {
            throw new CannotTranslateException("no usage information");
        }

        final _Usage usage = this.repr._newUsage();
        usage.setElapsedMinutes(earm.getElapsed());
        usage.setReservedMinutes(earm.getReserved());
View Full Code Here

    public Caller getCreator(InstanceResource resource)

            throws CannotTranslateException {
       
        if (resource == null) {
            throw new CannotTranslateException("no resource?");
        }

        final String creatorID = resource.getCreatorID();

        if (creatorID == null) {
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.