Examples of CannotTranslateException


Examples of org.nimbustools.api.repr.CannotTranslateException

     */
    protected VM getVM(InstanceResource resource)
            throws CannotTranslateException {
       
        if (resource == null) {
            throw new CannotTranslateException("resource is missing");
        }

        VM vm = this.dataConvert.getVM(resource);
       
        if(VMConstants.LIFE_CYCLE_SPOT.equals(vm.getLifeCycle())){
View Full Code Here

Examples of org.nimbustools.api.repr.CannotTranslateException

    public UsedAndReservedTime_Type getUsedAndReserved(Usage usage)
            throws CannotTranslateException {

        if (usage == null) {
            throw new CannotTranslateException("usage is missing");
        }

        final UsedAndReservedTime_Type ret = new UsedAndReservedTime_Type();

        // exceeds 6 million years of usage?
        final long reserved = usage.getReservedMinutes();
        if (reserved > Integer.MAX_VALUE) {
            throw new CannotTranslateException(
                    "Reserved time exceeds maximum integer size");
        }
        ret.setReservedTime(CommonUtil.minutesToDuration((int)reserved));

        // exceeds 6 million years of usage?
        final long elapsed = usage.getElapsedMinutes();
        if (elapsed > Integer.MAX_VALUE) {
            throw new CannotTranslateException(
                    "Elapsed time exceeds maximum integer size");
        }
        ret.setUsedTime(CommonUtil.minutesToDuration((int)elapsed));

        return ret;
View Full Code Here

Examples of org.nimbustools.api.repr.CannotTranslateException

    public _CreateRequest getCreateRequest(WorkspaceCreateRequest_Type wsreq)
            throws CannotTranslateException {
       
        if (wsreq == null) {
            throw new CannotTranslateException("wsreq may not be null");
        }

        final _CreateRequest req = this.repr._newCreateRequest();
        final VirtualWorkspace_Type vw = wsreq.getMetadata();
       
        final URI name = vw.getName();
        if (name != null) {
            req.setName(name.toString());
        }

        // -------------------------------------------------------------
        // Weed out the needed items:
        // -------------------------------------------------------------

        final Definition def = vw.getDefinition();
        if (def == null) {
            throw new CannotTranslateException(
                    "create request definition may not be missing");
        }

        final VirtualNetwork_Type net;
       
        final Logistics log = vw.getLogistics();
        if (log == null) {
            net = null;
        } else {
            net = log.getNetworking();
        }

        final CustomizeTask_Type[] customizes;

        final OptionalParameters_Type optional = wsreq.getOptionalParameters();
        if (optional != null) {
            customizes = optional.getFilewrite();
            req.setMdUserData(optional.getMdServerUserdata());
            req.setCredential(optional.getCredentialToCopy());
        } else {
            customizes = null;
        }

        // Boolean object can be null for conversion like this (null==false)
        final boolean ensDone =
                Boolean.TRUE.equals(wsreq.getEnsembleDone());
        final boolean partOfEnsemble =
                Boolean.TRUE.equals(wsreq.getPartOfEnsemble());
        final EndpointReferenceType ensembleEPR = wsreq.getEnsembleEPR();

        // it'd be interesting to not require this and use all defaults but
        // it is currently required:
        final WorkspaceDeployment_Type dep = wsreq.getResourceRequest();
        if (dep == null) {
            throw new CannotTranslateException(
                    "create request deployment may not be missing");
        }

        final PostShutdown_Type post = dep.getPostShutdown();

        // -------------------------------------------------------------
        // Translate:
        // -------------------------------------------------------------

        this.trdef.translateDefinitionRelated(req, def, post);
        this.trra.translateResourceRelated(req, dep);
        if (net != null) {
            this.trnet.translateNetworkingRelated(req, net);
        }

        if (customizes != null && customizes.length > 0) {
            final CustomizationRequest[] crs =
                    new CustomizationRequest[customizes.length];
            for (int i = 0; i < customizes.length; i++) {
                final _CustomizationRequest cr =
                        this.repr._newCustomizationRequest();
                cr.setContent(customizes[i].getContent());
                cr.setPathOnVM(customizes[i].getPathOnVM());
                crs[i] = cr;
            }
            req.setCustomizationRequests(crs);
        }

        req.setCoScheduleMember(partOfEnsemble);
        req.setCoScheduleDone(ensDone);
        if (ensembleEPR != null) {
            try {
                req.setCoScheduleID(EnsembleUtil.getResourceID(ensembleEPR));
            } catch (Exception e) {
                throw new CannotTranslateException(e.getMessage(), e);
            }
        }
       
        return req;
    }
View Full Code Here

Examples of org.nimbustools.api.repr.CannotTranslateException

    public CreatedWorkspace_Type[] getCreatedWorkspaces(VM[] vms)
            throws CannotTranslateException {
       
        if (vms == null || vms.length == 0) {
            throw new CannotTranslateException("no VMs in RM response");
        }

        final CreatedWorkspace_Type[] created =
                new CreatedWorkspace_Type[vms.length];
View Full Code Here

Examples of org.nimbustools.api.repr.CannotTranslateException

        final _NIC[] nics = new _NIC[wsnics.length];

        for (int i = 0; i < wsnics.length; i++) {
            final Nic_Type wsnic = wsnics[i];
            if (wsnic == null) {
                throw new CannotTranslateException(
                        "WS nic in request list was missing?");
            }
            nics[i] = this.translateNIC(wsnic);
        }
       
View Full Code Here

Examples of org.nimbustools.api.repr.CannotTranslateException

        nic.setMAC(wsnic.getMAC());
        nic.setName(wsnic.getName());

        final IPConfig_Type ipconfig = wsnic.getIpConfig();
        if (ipconfig == null) {
            throw new CannotTranslateException(
                        "IPConfig_Type in nic request was missing?");
        }

        final String method =
                (String) acqMethodMap.get(ipconfig.getAcquisitionMethod());
        if (method == null) {
            throw new CannotTranslateException("unrecognized acquisition " +
                    "type (IPConfig_TypeAcquisitionMethod enumeration)");
        }

        nic.setAcquisitionMethod(method);
View Full Code Here

Examples of org.nimbustools.api.repr.CannotTranslateException

        final String dn = caller.getIdentity();
        try {
            return this.imageLocator.getImageLocation(dn, vmname);
        } catch (Exception e) {
            throw new CannotTranslateException(e.getMessage(), e);
        }
    }
View Full Code Here

Examples of org.nimbustools.api.repr.CannotTranslateException

            throws CannotTranslateException   
    {
        final String dn = caller.getIdentity();
        if (dn == null)
        {
            throw new CannotTranslateException("Cannot construct file " +
                    "request without owner hash/ID, the file(s) location is " +
                    "based on it");
        }
        // todo: look at RA and construct blankspace request
        //return new VMFile[]{this.getRootFile(imageID, ownerID)};
        VMFile [] vma = new VMFile[1];
       
       // vma[0].
        final _VMFile file = this.repr._newVMFile();
        file.setRootFile(true);
        file.setDiskPerms(VMFile.DISKPERMS_ReadWrite);

        // must convert to scp url
        // look up image id
        try
        {
            String urlStr;
            if(imageID.indexOf("cumulus://") == 0)
            {
                urlStr = imageID;
            }
            else
            {
                urlStr = getImageLocation(caller, imageID) + "/" + imageID;
            }
            file.setMountAs(this.rootFileMountAs);
            URI imageURI = new URI(urlStr);
            file.setURI(imageURI);
            vma[0] = file;
            return vma;
        }
        catch(Exception ex)
        {
            throw new CannotTranslateException(ex);
        }               
    }
View Full Code Here

Examples of org.nimbustools.api.repr.CannotTranslateException

        String                          keyName;

        final String dn = caller.getIdentity();
        if (dn == null)
        {
            throw new CannotTranslateException("Cannot construct file " +
                    "request without owner hash/ID, the file(s) location is " +
                    "based on it");
        }

        try
View Full Code Here

Examples of org.nimbustools.api.repr.CannotTranslateException

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

        final Requirements_Type requires = def.getRequirements();
        if (requires == null) {
            throw new CannotTranslateException(
                    "Requirements_Type may not be missing");
        }

        this.translateRequirement_Type(req, requires);

        final DiskCollection_Type disks = def.getDiskCollection();
        if (disks == null) {
            throw new CannotTranslateException(
                    "DiskCollection_Type may not be missing");
        }

        this.translateDiskCollection_Type(req, disks);

        if (post != null) {
            final URI unpropTarget = post.getRootPartitionUnpropagationTarget();
            if (unpropTarget != null) {
                final VMFile[] vmFiles = req.getVMFiles();
                if (vmFiles == null) {
                    throw new CannotTranslateException(
                            "expecting files to be translated already");
                }
                for (int i = 0; i < vmFiles.length; i++) {
                    if (!(vmFiles[i] instanceof _VMFile)) {
                        throw new CannotTranslateException(
                            "expecting writable VMFile");
                    }

                    final _VMFile file = (_VMFile)vmFiles[i];
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.