Package com.cloud.stack.models

Examples of com.cloud.stack.models.CloudStackAccount


            return;
        }

        // validate account is admin level
        try {
            CloudStackAccount currentAccount = ServiceProvider.getInstance().getEC2Engine().getCurrentAccount();

            if (currentAccount.getAccountType() != 1) {
                logger.debug("SetOfferMapping called by non-admin user!");
                response.setStatus(500);
                endResponse(response, "Permission denied for non-admin user to setOfferMapping!");
                return;
            }
View Full Code Here


            return;
        }

        // validate account is admin level
        try {
            CloudStackAccount currentAccount = ServiceProvider.getInstance().getEC2Engine().getCurrentAccount();

            if (currentAccount.getAccountType() != 1) {
                logger.debug("deleteOfferMapping called by non-admin user!");
                response.setStatus(500);
                endResponse(response, "Permission denied for non-admin user to deleteOfferMapping!");
                return;
            }
View Full Code Here

        return;
        }
     
      // validate account is admin level
      try {
          CloudStackAccount currentAccount = ServiceProvider.getInstance().getEC2Engine().getCurrentAccount();
         
          if (currentAccount.getAccountType() != 1) {
              logger.debug("SetOfferMapping called by non-admin user!");
              response.setStatus(500);
              endResponse(response, "Permission denied for non-admin user to setOfferMapping!");
              return;
          }
View Full Code Here

        return;
        }
     
      // validate account is admin level
      try {
            CloudStackAccount currentAccount = ServiceProvider.getInstance().getEC2Engine().getCurrentAccount();
           
            if (currentAccount.getAccountType() != 1) {
                logger.debug("deleteOfferMapping called by non-admin user!");
                response.setStatus(500);
                endResponse(response, "Permission denied for non-admin user to deleteOfferMapping!");
                return;
            }
View Full Code Here

   * @return
   */
  public EC2CreateImageResponse registerImage(EC2RegisterImage request)
  {
    try {
        CloudStackAccount caller = getCurrentAccount();
      if (null == request.getFormat()   || null == request.getName() || null == request.getOsTypeName() ||
          null == request.getLocation() || null == request.getZoneName())
        throw new EC2ServiceException(ServerError.InternalError, "Missing parameter - location/architecture/name");

      List<CloudStackTemplate> templates = getApi().registerTemplate((request.getDescription() == null ? request.getName() : request.getDescription()),
View Full Code Here

   * @param request
   * @return
   */
  public EC2DescribeAvailabilityZonesResponse handleRequest(EC2DescribeAvailabilityZones request) { 
    try {
        CloudStackAccount caller = getCurrentAccount();
       
      return listZones(request.getZoneSet(), null);

    } catch( EC2ServiceException error ) {
      logger.error( "EC2 DescribeAvailabilityZones - ", error);
View Full Code Here

   * @return
   */
  public EC2Volume createVolume( EC2CreateVolume request ) {
    try {
       
        CloudStackAccount caller = getCurrentAccount();
      // -> put either snapshotid or diskofferingid on the request
      String snapshotId = request.getSnapshotId();
      Long size = request.getSize();
      String diskOfferingId = null;

View Full Code Here

    int createInstances    = 0;
    int canCreateInstances = -1;
    int countCreated       = 0;

    try {
        CloudStackAccount caller = getCurrentAccount();
       
      // ugly...
      canCreateInstances = calculateAllowedInstances();
      if (-1 == canCreateInstances) canCreateInstances = request.getMaxCount();
View Full Code Here

   *         the user can create.
   */
  private int calculateAllowedInstances() throws Exception {   
    int maxAllowed = -1;
   
    CloudStackAccount ourAccount = getCurrentAccount();
   
    if (ourAccount == null) {
        // This should never happen, but
        // we will return -99999 if this happens...
        return -99999;
    }
   
    // if accountType is Admin == 1, then let's return -1
    if (ourAccount.getAccountType() == 1) return -1;
   
    // -> get the user limits on instances
    // "0" represents instances: 
    // http://download.cloud.com/releases/2.2.0/api_2.2.8/user/listResourceLimits.html
    List<CloudStackResourceLimit> limits = getApi().listResourceLimits(null, null, null, null, "0");
View Full Code Here

   * @return
   * @throws Exception
   */
  private CloudStackNetwork getNetworksWithoutSecurityGroupEnabled(String zoneId) throws Exception {
    // grab current account
    CloudStackAccount caller = getCurrentAccount();
   
    //check if account has any networks in the system
    List<CloudStackNetwork> networks = getApi().listNetworks(caller.getName(), caller.getDomainId(), null, true, null, null, null, null, null, zoneId);
      
    //listRequired offerings in the system - the network created from this offering has to be specified in deployVm command
    List<CloudStackNetworkOffering> reuquiredOfferings = getApi().listNetworkOfferings("Required", null, null, null, true,  null, null, null, null, null, zoneId);
    if (reuquiredOfferings != null && !reuquiredOfferings.isEmpty()) {
        if (networks != null && !networks.isEmpty()) {
            //pick up the first required network from the network list
            for (CloudStackNetwork network : networks)  {
                    for (CloudStackNetworkOffering requiredOffering : reuquiredOfferings) {
                        logger.debug("[reqd/virtual} offering: " + requiredOffering.getId() + " network " + network.getNetworkOfferingId());
                        if (network.getNetworkOfferingId().equals(requiredOffering.getId())) {
                            return network;
                        }               
                    }
                }
        } else {
            //create new network and return it
            return createDefaultGuestNetwork(zoneId, reuquiredOfferings.get(0), caller);
        }
    } else {
        //find all optional network offerings in the system
          List<CloudStackNetworkOffering> optionalOfferings = getApi().listNetworkOfferings("Optional", null, null, null, true, null, null, null, null, null, zoneId);
          if (optionalOfferings != null && !optionalOfferings.isEmpty()) {
              if (networks != null && !networks.isEmpty()) {
                  for (CloudStackNetwork network : networks) {
                      for (CloudStackNetworkOffering optionalOffering : optionalOfferings) {
                          logger.debug("[optional] offering: " + optionalOffering.getId() + " network " + network.getNetworkOfferingId());
                          if (network.getNetworkOfferingId().equals(optionalOffering.getId())) {
                              return network;
                          }
                      }
                  }
              }
          }
    }
   
    // if we get this far and haven't returned already return an error
    throw new EC2ServiceException(ServerError.InternalError, "Unable to find an appropriate network for account " + caller.getName());
  }
View Full Code Here

TOP

Related Classes of com.cloud.stack.models.CloudStackAccount

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.