Package org.nimbustools.api.repr

Examples of org.nimbustools.api.repr.CannotTranslateException


        final String pubNet = this.networks.getManagerPublicNetworkName();
        final String privNet = this.networks.getManagerPrivateNetworkName();

        if (pubNet == null || privNet == null) {
            throw new CannotTranslateException("Illegal Networks " +
                    "implementation, null network mapping");
        }

        final NIC[] nics;

        /* Check that when one of public and private is set, they are both set */
        if (publicNetworkName != null && !publicNetworkName.trim().equals("")) {
            if (privateNetworkName == null || privateNetworkName.trim().equals("")) {
                throw new CannotTranslateException("Illegal Networks " +
                        "implementation, public network set but null private network mapping");
            }
        }
        if (privateNetworkName != null && !privateNetworkName.trim().equals("")) {
            if (publicNetworkName == null || publicNetworkName.trim().equals("")) {
                throw new CannotTranslateException("Illegal Networks " +
                        "implementation, private network set but null public network mapping");
            }
        }

        if (publicNetworkName != null && !publicNetworkName.trim().equals("")) {
View Full Code Here


    protected NIC oneRequestedNIC(String networkName, String nicName)
            throws CannotTranslateException {
       
        if (networkName == null) {
            throw new CannotTranslateException("networkName is missing");
        }
        final _NIC nic = this.repr._newNIC();
        nic.setAcquisitionMethod(NIC.ACQUISITION_AllocateAndConfigure);
        nic.setNetworkName(networkName);
        nic.setName(nicName);
View Full Code Here

        }

        final NIC[] nics = vm.getNics();
        if (nics == null || nics.length == 0) {
            // zero NICs not supported by this interface
            throw new CannotTranslateException("NICs are missing");
        }

        if (nics.length != 1 && nics.length != 2) {
            throw new CannotTranslateException("Can only handle one or two " +
                    "assigned NICs, but were given " + nics.length +
                    " for vm id-" + vm.getID());
        }

        if (nics.length == 1 && nics[0] == null) {
            throw new CannotTranslateException("NIC[] value is missing");
        }

        if (nics.length == 2 && nics[1] == null) {
            throw new CannotTranslateException("NIC[] value is missing");
        }

        final String netName = nics[0].getNetworkName();
        if (netName == null) {
            throw new CannotTranslateException("NIC in vm id-" +
                    vm.getID() + " is missing network name");
        }

        final String hostname = nics[0].getHostname();
        if (hostname == null) {
            throw new CannotTranslateException("NIC in vm id-" +
                    vm.getID() + " is missing hostname");
        }

        final String ipAddress = nics[0].getIpAddress();
        if (ipAddress == null) {
            throw new CannotTranslateException("NIC in vm id-" +
                    vm.getID() + " is missing IP address");
        }

        final String netName2;
        final String hostname2;
        final String ipAddress2;
        if (nics.length == 2) {
            netName2 = nics[1].getNetworkName();
            if (netName2 == null) {
                throw new CannotTranslateException("NIC in vm id-" +
                        vm.getID() + " is missing network name");
            }

            hostname2 = nics[1].getHostname();
            if (hostname2 == null) {
                throw new CannotTranslateException("NIC in vm id-" +
                        vm.getID() + " is missing hostname");
            }

            ipAddress2 = nics[1].getIpAddress();
            if (ipAddress2 == null) {
                throw new CannotTranslateException("NIC in vm id-" +
                        vm.getID() + " is missing IP address");
            }
        } else {
            netName2 = null;
            hostname2 = null;
            ipAddress2 = null;
        }

        String privateAssignedHostname = null;
        String publicAssignedHostname = null;
        String privateAssignedIp = null;
        String publicAssignedIp = null;

        if (netName2 != null) {
            logger.info("Using networks " + netName + " and " + netName2);
        } else {
            logger.info("Using network " + netName);
        }
        if (this.networks.isPrivateNetwork(netName)) {
            riit.setPrivateDnsName(hostname);
            riit.setPrivateIpAddress(ipAddress);
            privateAssignedHostname = hostname;
            privateAssignedIp = ipAddress;
        } else if (this.networks.isPublicNetwork(netName)) {
            riit.setDnsName(hostname);
            riit.setIpAddress(ipAddress);
            publicAssignedHostname = hostname;
            publicAssignedIp = ipAddress;
        } else {
            throw new CannotTranslateException("Unknown network was " +
                    "assigned: '" + netName + "'");
        }

        if (nics.length == 2) {
            if (this.networks.isPrivateNetwork(netName2)) {
                if (privateAssignedHostname != null) {
                    // if public and private are set to be the same, that means
                    // request ONE nic and make it appear to be two in remote
                    // interface
                    throw new CannotTranslateException("Won't support " +
                            "real NICs from duplicate networks yet");
                }
                riit.setPrivateDnsName(hostname2);
                riit.setPrivateIpAddress(ipAddress2);
                privateAssignedHostname = hostname2;
                privateAssignedIp = ipAddress2;
            } else if (this.networks.isPublicNetwork(netName2)) {
                if (publicAssignedHostname != null) {
                    // if public and private are set to be the same, that means
                    // request ONE nic and make it appear to be two in remote
                    // interface
                    throw new CannotTranslateException("Won't support " +
                            "real NICs from duplicate networks yet");
                }
                riit.setDnsName(hostname2);
                riit.setIpAddress(ipAddress2);
                publicAssignedHostname = hostname2;
                publicAssignedIp = ipAddress2;
            } else {
                throw new CannotTranslateException("Unknown network was " +
                        "assigned: '" + netName2 + "'");
            }
        }

        if (this.networks.getManagerPublicNetworkName().equals(
                this.networks.getManagerPrivateNetworkName())) {

            if (publicAssignedHostname != null && privateAssignedHostname != null) {
                // if public and private are set to be the same, that means
                // request ONE nic and make it appear to be two in remote
                // interface
                throw new CannotTranslateException("Won't support " +
                            "real NICs from duplicate networks yet");
            }

            if (publicAssignedHostname != null) {
                riit.setPrivateDnsName(publicAssignedHostname);
View Full Code Here

    }

    public String getOwnerID(Caller caller) throws CannotTranslateException {

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

        final String id = caller.getIdentity();
        if (id == null) {
            throw new CannotTranslateException("missing caller identity");
        }

        if (!HashUtil.isInitialized()) {
            throw new CannotTranslateException("hashing algorithm failed to initialize");
        }

        try {
            return HashUtil.hashDN(id);
        } catch (NoSuchAlgorithmException e) {
            throw new CannotTranslateException(e.getMessage(), e);
        }
    }
View Full Code Here

        if (instanceIDs != null && instanceIDs.length > 0) {
            scopedQuery = true;
            for (int i = 0; i < instanceIDs.length; i++) {
                final String instanceID = instanceIDs[i];
                if (!this.validity.isValidInstanceID(instanceID)) {
                    throw new CannotTranslateException(
                            "invalid instance ID in query: " + instanceID);
                }
            }
        }
View Full Code Here

    protected ReservationInfoType[] getAllReservations(VM[] vms,
                                                       String ownerID)
            throws CannotTranslateException {

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

        final List riits = new LinkedList();
        // assuming sorting will resolve any orphans
        final Hashtable sorted = this.sort(vms);
View Full Code Here

                                                        String[] instanceIDs,
                                                        String ownerID)
            throws CannotTranslateException {

        if (instanceIDs == null || instanceIDs.length == 0) {
            throw new CannotTranslateException(
                    "instanceIDs is empty or missing");
        }

        // translate the requests elastic IDs into manager instance IDs
        final String[] mgrIDs = new String[instanceIDs.length];
View Full Code Here

                                                    List vms,
                                                    String ownerID)
            throws CannotTranslateException {

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

        if (ownerID == null) {
            throw new CannotTranslateException("ownerID is missing");
        }
       
        if (vms == null) {
            throw new CannotTranslateException("vms are missing");
        }

        final RunningInstancesItemType[] riits =
                new RunningInstancesItemType[vms.size()];

        final Iterator iter = vms.iterator();
        int idx = 0;
        while (iter.hasNext()) {
            final VM vm = (VM) iter.next();
            final String elasticID;
            try {
                elasticID = this.ids.managerInstanceToElasticInstance(vm.getID());
            } catch (Exception e) {
                throw new CannotTranslateException(e.getMessage(), e);
            }
            riits[idx] = this.getInstanceItemType(vm, elasticID);
            idx += 1;
        }
View Full Code Here

    protected RunningInstancesItemType getInstanceItemType(VM vm,
                                                           String elasticID)
            throws CannotTranslateException {

        if (vm == null) {
            throw new CannotTranslateException("vm may not be null");
        }
        if (elasticID == null) {
            throw new IllegalArgumentException("elasticID may not be null");
        }
View Full Code Here

    }   
   
    public Calendar getLaunchTime(VM vm) throws CannotTranslateException {

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

        final Schedule schedule = vm.getSchedule();
        if (schedule == null) {
            throw new CannotTranslateException("schedule is missing");
        }

        return schedule.getStartTime();
    }
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.