Package org.nimbustools.api.repr

Examples of org.nimbustools.api.repr.CannotTranslateException


            //TODO: support ranges and Exact_Type[]
            final Exact_Type exact_blank =
                    entry.getIndividualDiskSpace().getExact(0);
            if (exact_blank == null) {
                throw new CannotTranslateException(
                        "missing blankspace space specification");
            }

            // casting double
            final int space = (int) exact_blank.get_value();

            final String blankPartitionName = entry.getPartitionName();
            if (blankPartitionName == null) {
                throw new CannotTranslateException(
                        "missing blankspace name");
            }

            final Set keys = blankStorageRequests.keySet();
            if (keys.contains(blankPartitionName)) {
                throw new CannotTranslateException(
                        "blank space partition name '" + blankPartitionName +
                                "' is present more than once");
            }

            blankStorageRequests.put(blankPartitionName, new Integer(space));
        }

        for (int i = 0; i < files.length; i++) {

            if (!(files[i] instanceof _VMFile)) {
                throw new CannotTranslateException("expecting writable VMFile");
            }

            final _VMFile file =
                    (_VMFile)files[i];
            if (file == null) {
                continue;
            }

            final String name = file.getBlankSpaceName();
            if (name == null) {
                continue;
            }

            final Integer size = (Integer) blankStorageRequests.get(name);
            if (size == null) {
                throw new CannotTranslateException("blank space listed in" +
                        "definition but no matching blank storage request " +
                        "is in deployment request");
            }

            final int space = size.intValue();

            if (space < 1) {
                throw new CannotTranslateException(
                        "blank space request is for under 1 MB");
            }

            file.setBlankSpaceSize(space);

            // remove to mark 'used' so we can check at the end for extras
            blankStorageRequests.remove(name);
        }

        // check for any unused
        if (!blankStorageRequests.isEmpty()) {
            throw new CannotTranslateException("there are blank space " +
                    "requests in request that do not have a partition " +
                    "name match in the workspace definition");
        }
    }
View Full Code Here


                    userDetailsService.loadUserByDn(dn);

            return user.getAccessID();

        } catch (DataAccessException e) {
            throw new CannotTranslateException(
                    "Unable to resolve DN to an accessID",e);
        } catch (UsernameNotFoundException e) {
            throw new CannotTranslateException(
                    "Unable to resolve DN to an accessID",e);
        }
    }
View Full Code Here

    // -------------------------------------------------------------------------

    public CurrentState getCurrentState(VM vm) throws CannotTranslateException {
       
        if (vm == null) {
            throw new CannotTranslateException("vm may not be null");
        }

        final State state = vm.getState();
        if (state == null) {
            throw new CannotTranslateException("state may not be null");
        }


        final CurrentState_Enumeration stateEnum =
                (CurrentState_Enumeration) statusMap.get(state.getState());

        if (stateEnum == null) {
            throw new CannotTranslateException(
                    "do not recognize VM state '" + state.getState() + "'");
        }

        final CurrentState ret = new CurrentState();
        ret.setState(stateEnum);
View Full Code Here

    // -------------------------------------------------------------------------

    public Logistics getLogistics(VM vm) throws CannotTranslateException {

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

        final NIC[] nics = vm.getNics();
        if (nics == null || nics.length == 0) {
            return new Logistics(); // *** EARLY RETURN ***
 
View Full Code Here

            final IPConfig_TypeAcquisitionMethod method =
                    (IPConfig_TypeAcquisitionMethod)
                            acqMethodMap.get(nic.getAcquisitionMethod());
            if (method == null) {
                throw new CannotTranslateException(
                        "do not recognize acquisition method '" +
                                nic.getAcquisitionMethod() + "'");
            }
            ip.setAcquisitionMethod(method);
View Full Code Here

    public Schedule_Type getSchedule_Type(VM vm)
            throws CannotTranslateException {

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

        final Schedule_Type t_sched = new Schedule_Type();

        final Schedule sched = vm.getSchedule();
View Full Code Here

    // missing: support for Storage_Type, Bandwidth_Type
    public ResourceAllocation_Type getResourceAllocation_Type(VM vm)
            throws CannotTranslateException {

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

        final ResourceAllocation_Type alloc = new ResourceAllocation_Type();

        final ResourceAllocation ra = vm.getResourceAllocation();
View Full Code Here

        ProcessorArchitectureEnumeration arch = null;
        if (raArch != null) {
            arch = (ProcessorArchitectureEnumeration) archMap.get(raArch);
            if (arch == null) {
                throw new CannotTranslateException("do not recognize given " +
                        "CPU architecture '" + raArch + "'");
            }
        }

        final int raSpeed = ra.getIndCpuSpeed();
View Full Code Here

   
    public SpotInstanceRequestSetItemType translateSpotInfo(
                                    SpotRequestInfo result) throws Exception {

        if (result == null) {
            throw new CannotTranslateException("spot request info is missing");
        }
       
        Integer instanceCount = result.getInstanceCount();
        if (instanceCount == null || instanceCount == 0) {
            throw new CannotTranslateException("instance count is empty?");
        }       

        final String groupid = result.getGroupID();

        if (groupid == null && instanceCount != 1) {
            throw new CannotTranslateException("expecting a groupID if " +
                    "more than one VM was created");
        }
       
        String instID = null;
        String resID = null;
View Full Code Here

                                                     Caller caller,
                                                     String sshKeyName)
            throws Exception {

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

        final VM[] vms = result.getVMs();
        if (vms == null || vms.length == 0) {
            throw new CannotTranslateException("creation result is empty?");
        }

        if (result.getCoscheduledID() != null) {
            throw new CannotTranslateException("not expecting " +
                    "coscheduling ID in any cases yet");
        }

        final String groupid = result.getGroupID();

        if (groupid == null && vms.length != 1) {
            throw new CannotTranslateException("expecting a groupID if " +
                    "more than one VM was created");
        }

        final String vmidWhenJustOne;
        final String resID;
        // these mappings may exist already, for secondary idempotent launches
        if (groupid == null) {
            vmidWhenJustOne = vms[0].getID();
            resID = this.ids.getOrNewInstanceReservationID(vmidWhenJustOne, sshKeyName);
        } else {
            vmidWhenJustOne = null;
            resID = this.ids.getOrNewGroupReservationID(groupid);
        }

        final RunningInstancesSetType rist = new RunningInstancesSetType();
        final RunningInstancesItemType[] riits =
                new RunningInstancesItemType[vms.length];

        final String msg = "New reservation ID '" + resID + "' for ";
        final StringBuffer buf = new StringBuffer(msg);
        if (vmidWhenJustOne == null) {
            buf.append("VM group '").append(groupid);
        } else {
            buf.append("single VM '").append(vmidWhenJustOne);
        }
        buf.append("'.  Members:");

        for (int i = 0; i < vms.length; i++) {
            final VM vm = vms[i];
            final String id = vm.getID();
            if (id == null) {
                throw new CannotTranslateException("VM has no ID");
            }
            final String instID;
            if (vmidWhenJustOne != null) {
                // mapping already created:
                instID = this.ids.managerInstanceToElasticInstance(vmidWhenJustOne);
            } else {
                // this mapping may exist already, for secondary idempotent launches
                instID = this.ids.getOrNewInstanceID(vm.getID(), resID, sshKeyName);
            }

            if (i != 0) {
                buf.append(",");
            }
            buf.append(" id-").append(id)
               .append("='").append(instID).append("'");

            riits[i] = this.getOneCreatedVM(vm, instID, resID, sshKeyName);
        }

        logger.info(buf.toString());

        final RunInstancesResponseType ret = new RunInstancesResponseType();
        ret.setGroupSet(getGroupStub());
        final String ownerID = this.container.getOwnerID(caller);
        if (ownerID == null) {
            throw new CannotTranslateException("Cannot find owner ID");
        }
        ret.setOwnerId(ownerID);
        ret.setReservationId(resID);
        rist.setItem(riits);
        ret.setInstancesSet(rist);
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.