Package org.nimbustools.api.services.rm

Examples of org.nimbustools.api.services.rm.ResourceRequestDeniedException


        }

        final int maxGroupSize = this.globals.getMaximumGroupSize();
        // zero means infinite
        if (maxGroupSize > 0 && vms.length > maxGroupSize) {
            throw new ResourceRequestDeniedException(
                        "request number of VMs (" + vms.length + ")" +
                                " exceeds the maximum permitted (" + maxGroupSize +
                                    " instances per group)");
        }
View Full Code Here


            throws ResourceRequestDeniedException {

        final int needed;
        final int len = macPrefix.length();
        switch (len) {
            case 0: throw new ResourceRequestDeniedException("prefix length 0?");
            case 1:  needed = 11; break;
            case 2:  needed = 10; break;
            case 3:  needed = 10; break;
            case 4:  needed = 9break;
            case 5:  needed = 8break;
            case 6:  needed = 8break;
            case 7:  needed = 7break;
            case 8:  needed = 6break;
            case 9:  needed = 6break;
            case 10: needed = 5break;
            case 11: needed = 4break;
            case 12: needed = 4break;
            case 13: needed = 3break;
            case 14: needed = 2break;
            case 15: needed = 2break;
            case 16: needed = 1break;
            case 17: needed = 0break;
            default: throw new ResourceRequestDeniedException("prefix length >17?");
        }

        if (needed == 0) {
            logger.warn("prefix is full MAC address, conflict detection OFF");
            return macPrefix;
        }

        synchronized (list_lock) {

            final String result;
            if (needed < 4) {
                // slow, but tries every single permutation
                result = _pickNewSerially(macs, macPrefix, needed);
            } else {
                // Faster.  Does not get at every single permutation but is very
                // unlikely to fail when address range is 16^4 or higher
                result = _pickNewWithRandomComponent(macs, macPrefix, needed);
            }

            if (result == null) {
                throw new ResourceRequestDeniedException(
                        "no unique MAC address is available");
            } else {
                macs.add(result);
                return result;
            }
View Full Code Here

        while (true) {

            if (count >= limit) {
                // Even at lowest allowable limit (~65000), this is very
                // unlikely to ever occur.
                throw new ResourceRequestDeniedException(
                    "Search limit reached (" + count +
                    ") looking for MAC to assign.  Please inform developers.");
            }

            String attempt = appendRandomCharacter(macPrefix);
View Full Code Here

            return; // *** EARLY RETURN ***
        }

        if (vm.getVmm() != null) {
            if (!vmm.equals(vm.getVmm())) {
                throw new ResourceRequestDeniedException(
                    "incorrect VMM");
            }
        }

        final String[] versions = this.globals.getVmmVersions();
        if (versions != null) {
            final String fromReq = vm.getVmmVersion();
            if (fromReq != null) {
                boolean found = false;
                for (int i = 0; i < versions.length; i++) {
                    if (versions[i].equals(fromReq)) {
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    throw new ResourceRequestDeniedException(
                                                    "unsupported VMM version");
                }
            }
        }

View Full Code Here

        final int requestedSecs = dep.getMinDuration();
        if (requestedSecs == VirtualMachineDeployment.NOTSET) {
            dep.setMinDuration(defaultSecs);
        } else if (requestedSecs > maxSecs) {
                // client visible message:
                throw new ResourceRequestDeniedException(
                        "request duration (" + requestedSecs + " seconds)" +
                                " exceeds the maximum allowed (" + maxSecs +
                                " seconds)");
        }
    }
View Full Code Here

            return; // *** EARLY RETURN ***
        }

        final VirtualMachineDeployment dep = vm.getDeployment();
        if (dep == null) {
            throw new ResourceRequestDeniedException(
                            "no CPU architecture description (no dep)");
        }

        final String requestedArch = dep.getCPUArchitecture();
        if (requestedArch == null) {
            throw new ResourceRequestDeniedException(
                            "no CPU architecture description (no dep.arch)");
        }

        List archList = Arrays.asList(allowedCPUArchitectures);

        if (!archList.contains(requestedArch)) {

            StringBuilder sb = new StringBuilder();
            boolean first = true;
            for (int i=0; i < allowedCPUArchitectures.length ; i++) {
                if (first) {
                    first = false;
                }
                else {
                    sb.append(", ");
                }
                sb.append(allowedCPUArchitectures[i]);
            }
            final String allArchitectures = sb.toString();

            throw new ResourceRequestDeniedException(
                    "incorrect CPU architecture, only '" + allArchitectures +
                            "' supported, you requested '" + requestedArch + "'");
        }
    }
View Full Code Here

        final Hashtable associations;
        try {
            associations = db.currentAssociations();
        } catch (WorkspaceDatabaseException e) {
            logger.fatal(e.getMessage(), e);
            throw new ResourceRequestDeniedException(
                    "internal error, db problem");
        }
       
        final Object[] entryAndDns = nextAssociationEntry(name,
                                                          associations);

        final AssociationEntry entry;
        if (entryAndDns == null || entryAndDns[0] == null) {
            final String err = "network '" + name
                        + "' is not currently available";
            logger.error(err);
            throw new ResourceRequestDeniedException(err);
        } else {
            entry = (AssociationEntry) entryAndDns[0];
            logger.debug("entry picked = " + entry);
        }

        try {
            db.replaceAssociationEntry(name, entry);
        } catch (WorkspaceDatabaseException e) {
            logger.fatal(e.getMessage(), e);
            throw new ResourceRequestDeniedException(
                    "internal error, db problem");
        }

        if (eventLog) {
            logger.info(Lager.ev(vmid) + "'" + name + "' network " +
View Full Code Here

        final Association assoc = (Association)associations.get(name);
        if (assoc == null) {
            final String err = "'" + name + "' is not a valid network name";
            logger.error(err);
            throw new ResourceRequestDeniedException(err);
        }

        final List entries = assoc.getEntries();
        if (entries == null || entries.isEmpty()) {
            return null; // *** EARLY RETURN ***
 
View Full Code Here

                String perms = "";
                long size = 0;

                if(fileIds[0] < 0)
                {
                    throw new ResourceRequestDeniedException("The bucket name " + bucketName + " was not found.");
                }               
                if(fileIds[1] < 0 && write)
                {
                    String pubPerms = perms + authDB.getPermissionsPublic(fileIds[0]);
                    perms = authDB.getPermissions(fileIds[0], canUser) + pubPerms;
                    int ndx = perms.indexOf('w');
                    if(ndx < 0)
                    {
                        throw new ResourceRequestDeniedException("user " + userId + " does not have write access the bucket " + url);
                    }
                }               
                else if(fileIds[1] < 0)
                {                                                                                                
                    throw new ResourceRequestDeniedException("the object " + objectName + " was not found.");
                }
                else
                {
                    String pubPerms = perms + authDB.getPermissionsPublic(fileIds[1]);
                    perms = authDB.getPermissions(fileIds[1], canUser) + pubPerms;
                    int ndx = perms.indexOf('r');
                    if(ndx < 0)
                    {
                        throw new ResourceRequestDeniedException("user " + userId + " canonical ID " + canUser + " does not have read access to " + url);
                    }
                    size = authDB.getFileSize(fileIds[1]);
                    if(write)
                    {
                        ndx = perms.indexOf('w');
                        if(ndx < 0)
                        {
                            throw new ResourceRequestDeniedException("user " + userId + " does not have write access to " + url);
                        }
                    }
                }
                if(write)
                {
                    // expected size is only zero when replacing the original file.  in this case we assume it will
                    // fit
                    if(expectedSize != 0)
                    {
                        // deduct the size of the file that already exists from the expected size.  it
                        // is ok if it goes negative
                        long canFitSize = expectedSize - size;
                        boolean quota = authDB.canStore(canFitSize, canUser, schemeType);
                        if (!quota)
                        {
                            throw new ResourceRequestDeniedException("You do not have enough storage space for the new image.  Please free up some storage and try again");
                        }
                    }                   
                }
                return size;
            }
            catch(AuthzDBException wsdbex)
            {
                logger.error("iternal db problem", wsdbex);
                throw new AuthorizationException("Internal problem with the data base " + wsdbex.toString());
            }
        }
        else if (scheme.equals("file"))
        {
            return 0;
        }
        else if (this.schemePassthrough)
        {
            return 0;
        }
        else
        {
            throw new ResourceRequestDeniedException("scheme of: " + scheme + " is not supported.");
        }
    }
View Full Code Here

        }

        logger.error("NOT IN ANY GROUP: '" + callerDN + "'");

        // administrator put DN in grid-mapfile but not in a group...
        throw new ResourceRequestDeniedException(NO_POLICIES_MESSAGE);
    }
View Full Code Here

TOP

Related Classes of org.nimbustools.api.services.rm.ResourceRequestDeniedException

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.