Package com.cloud.stack.models

Examples of com.cloud.stack.models.CloudStackInfoResponse


     * @param request
     * @return
     */
    public EC2Volume deleteVolume(EC2Volume request) {
        try {
            CloudStackInfoResponse resp = getApi().deleteVolume(request.getId());
            if (resp != null) {
                request.setState("deleted");
            }
        } catch (Exception e) {
            logger.error("EC2 DeleteVolume - ", e);
View Full Code Here


            for (EC2TagTypeId resourceType : resourceTypeSet) {
                String cloudStackResourceType = mapToCloudStackResourceType(resourceType.getResourceType());
                List<String> resourceIdList = new ArrayList<String>();
                for (String resourceId : resourceType.getResourceIds())
                    resourceIdList.add(resourceId);
                CloudStackInfoResponse resp = new CloudStackInfoResponse();
                if (operation.equalsIgnoreCase("create"))
                    resp = getApi().createTags(cloudStackResourceType, resourceIdList, resourceTagList);
                else if (operation.equalsIgnoreCase("delete"))
                    resp = getApi().deleteTags(cloudStackResourceType, resourceIdList, resourceTagList);
                else
                    throw new EC2ServiceException(ServerError.InternalError, "Unknown operation.");
                if (resp.getSuccess() == false)
                    return false;
            }
            return true;
        } catch (Exception e) {
            logger.error("EC2 Create/Delete Tags - ", e);
View Full Code Here

   * @param groupName
   * @return
   */
  public boolean deleteSecurityGroup(String groupName) {
    try {
      CloudStackInfoResponse resp = getApi().deleteSecurityGroup(null, null, null, groupName);
      if (resp != null) {
        return resp.getSuccess();
      }
      return false;
    } catch( Exception e ) {
      logger.error( "EC2 DeleteSecurityGroup - ", e);
      throw new EC2ServiceException(ServerError.InternalError, e.getMessage());
View Full Code Here

      }

      if (null == ruleId)
        throw new EC2ServiceException(ClientError.InvalidGroup_NotFound, "Cannot find matching ruleid.");

      CloudStackInfoResponse resp = getApi().revokeSecurityGroupIngress(ruleId);
      if (resp != null && resp.getId() != null) {
        return resp.getSuccess();
      }
      return false;
    } catch( Exception e ) {
      logger.error( "EC2 revokeSecurityGroupIngress" + " - " + e.getMessage());
      throw new EC2ServiceException(ServerError.InternalError, e.getMessage());
View Full Code Here

   * @return
   */
  public boolean deleteSnapshot(String snapshotId) {
    try {
     
      CloudStackInfoResponse resp = getApi().deleteSnapshot(snapshotId);
      if(resp != null) {
          return resp.getSuccess();
      }

      return false;
    } catch(Exception e) {
      logger.error( "EC2 DeleteSnapshot - ", e);
View Full Code Here

   *
   * @param request
   * @return
   */
  public boolean modifyImageAttribute(EC2ModifyImageAttribute request) {
        CloudStackInfoResponse updateTemplatePermissions = null;
      try {
          // reset case
          if (request.getReset() != null) {
              updateTemplatePermissions = getApi().updateTemplatePermissions(request.getImageId(), null, null,
                      null, null, "reset");
          }

          // add users
          List<String> addedUsers = request.getAddedUsers();
          if (addedUsers != null && ! addedUsers.isEmpty()) {
              String accounts = new String();
              for (String usr : addedUsers) {
                  accounts = accounts + "," + usr;
              }
              updateTemplatePermissions = getApi().updateTemplatePermissions(request.getImageId(), accounts, null,
                      null, null, "add");
          }
         
          // remove users
          List<String> removedUsers = request.getRemovedUsers();
          if (removedUsers != null && ! removedUsers.isEmpty()) {
              String accounts = new String();
              for (String usr : removedUsers) {
                  accounts = accounts + "," + usr;
              }
              updateTemplatePermissions = getApi().updateTemplatePermissions(request.getImageId(), accounts, null,
                      null, null, "remove");
          }
         
          // Make public
          if (request.getIsPublic() != null) {
              updateTemplatePermissions = getApi().updateTemplatePermissions(request.getImageId(), null, null,
                      null, request.getIsPublic(), null);
          }
        } catch (Exception e) {
            logger.error( "EC2 ModifyImage - ", e);
            throw new EC2ServiceException(ServerError.InternalError, e.getMessage());
        }
      // Unfortunately, the error is thrown before we parse the response text returned from CS, so this error
      // handling is unnecessary.
      if (updateTemplatePermissions != null) {
          if (updateTemplatePermissions.getSuccess() != true) {
              throw new EC2ServiceException(ServerError.InternalError, updateTemplatePermissions.getDisplayText());
          }
          return updateTemplatePermissions.getSuccess();
      } else
          return false;
  }
View Full Code Here

   * @param request
   * @return
   */
  public boolean deleteKeyPair( EC2DeleteKeyPair request ) {
    try {
      CloudStackInfoResponse resp = getApi().deleteSSHKeyPair(request.getKeyName(), null, null);
      if (resp == null) {
        throw new Exception("Ivalid CloudStack API response");
      }

      return resp.getSuccess();
    } catch(Exception e) {
      logger.error("EC2 DeleteKeyPair - ", e);
      throw new EC2ServiceException(ServerError.InternalError, e.getMessage());
    }
  }
View Full Code Here

   * @return
   */
  public boolean releaseAddress(EC2ReleaseAddress request) {
    try {
      CloudStackIpAddress cloudIp = getApi().listPublicIpAddresses(null, null, null, null, null, request.getPublicIp(), null, null, null).get(0);
      CloudStackInfoResponse resp = getApi().disassociateIpAddress(cloudIp.getId());
      if (resp != null) {
        return resp.getSuccess();
      }
    } catch(Exception e) {
      logger.error("EC2 ReleaseAddress - ", e);
      throw new EC2ServiceException(ServerError.InternalError, e.getMessage());
    }
View Full Code Here

  public boolean associateAddress( EC2AssociateAddress request ) {
    try {
      CloudStackIpAddress cloudIp = getApi().listPublicIpAddresses(null, null, null, null, null, request.getPublicIp(), null, null, null).get(0);
      CloudStackUserVm cloudVm = getApi().listVirtualMachines(null, null, null, null, null, null, request.getInstanceId(), null, null, null, null, null, null, null, null).get(0);

      CloudStackInfoResponse resp = getApi().enableStaticNat(cloudIp.getId(), cloudVm.getId());
      if (resp != null) {
        return resp.getSuccess();
      }
    } catch(Exception e) {
      logger.error( "EC2 AssociateAddress - ", e);
      throw new EC2ServiceException(ServerError.InternalError, e.getMessage() != null ? e.getMessage() : "An unexpected error occurred.");
    }
View Full Code Here

   * @return
   */
  public boolean disassociateAddress( EC2DisassociateAddress request ) {
    try {
      CloudStackIpAddress cloudIp = getApi().listPublicIpAddresses(null, null, null, null, null, request.getPublicIp(), null, null, null).get(0);
      CloudStackInfoResponse resp = getApi().disassociateIpAddress(cloudIp.getId());
      if (resp != null) {
        return resp.getSuccess();
      }
    } catch(Exception e) {
      logger.error( "EC2 DisassociateAddress - ", e);
      throw new EC2ServiceException(ServerError.InternalError, e.getMessage() != null ? e.getMessage() : "An unexpected error occurred.");
    }
View Full Code Here

TOP

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

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.