Package com.cloud.bridge.service.core.ec2

Examples of com.cloud.bridge.service.core.ec2.EC2DescribeImageAttribute


        DescribeImagesResponse EC2response = EC2SoapServiceImpl.toDescribeImagesResponse(engine.describeImages(EC2request));
        serializeResponse(response, EC2response);
    }

    private void describeImageAttribute(HttpServletRequest request, HttpServletResponse response) throws ADBException, XMLStreamException, IOException {
        EC2DescribeImageAttribute ec2request = new EC2DescribeImageAttribute();

        String[] imageId = request.getParameterValues("ImageId");
        if (imageId != null && imageId.length > 0)
            ec2request.setImageId(imageId[0]);
        else {
            throw new EC2ServiceException(ClientError.MissingParamter, "Missing required parameter - ImageId");
        }

        String[] attribute = request.getParameterValues("Attribute");
        if (attribute != null && attribute.length > 0) {
            if (attribute[0].equalsIgnoreCase("description"))
                ec2request.setAttribute(ImageAttribute.description);
            else if (attribute[0].equalsIgnoreCase("launchPermission"))
                ec2request.setAttribute(ImageAttribute.launchPermission);
            else {
                throw new EC2ServiceException(ClientError.InvalidParameterValue, "Only values supported for paramter Attribute are - Description/LaunchPermission");
            }
        } else {
            throw new EC2ServiceException(ClientError.MissingParamter, "Missing required parameter - Attribute");
View Full Code Here


    /**
     * This only supports a query about description.
     */
    public DescribeImageAttributeResponse describeImageAttribute(DescribeImageAttribute describeImageAttribute) {
        EC2DescribeImageAttribute request = new EC2DescribeImageAttribute();
        DescribeImageAttributeType diat = describeImageAttribute.getDescribeImageAttribute();
        DescribeImageAttributesGroup diag = diat.getDescribeImageAttributesGroup();
        EmptyElementType description = diag.getDescription();
        EmptyElementType launchPermission = diag.getLaunchPermission();

        if (null != description) {
            request.setImageId(diat.getImageId());
            request.setAttribute(ImageAttribute.description);
            return toDescribeImageAttributeResponse(engine.describeImageAttribute(request));
        } else if (launchPermission != null) {
            request.setImageId(diat.getImageId());
            request.setAttribute(ImageAttribute.launchPermission);
            return toDescribeImageAttributeResponse(engine.describeImageAttribute(request));
        } else
            throw new EC2ServiceException(ClientError.Unsupported, "Unsupported - only description or launchPermission supported");
    }
View Full Code Here

  /**
   * This only supports a query about description.
   */
    public DescribeImageAttributeResponse describeImageAttribute(DescribeImageAttribute describeImageAttribute) {
        EC2DescribeImageAttribute request = new EC2DescribeImageAttribute();
        DescribeImageAttributeType diat = describeImageAttribute.getDescribeImageAttribute();
        DescribeImageAttributesGroup diag = diat.getDescribeImageAttributesGroup();
        EmptyElementType description = diag.getDescription();
        EmptyElementType launchPermission = diag.getLaunchPermission();

        if ( null != description ) {
             request.setImageId(diat.getImageId());
             request.setAttribute(ImageAttribute.description);
             return toDescribeImageAttributeResponse( engine.describeImageAttribute( request ));
        }else if(launchPermission != null){
           request.setImageId(diat.getImageId());
           request.setAttribute(ImageAttribute.launchPermission);
           return toDescribeImageAttributeResponse( engine.describeImageAttribute( request ));
        }
        else throw new EC2ServiceException( ClientError.Unsupported, "Unsupported - only description or launchPermission supported" );
    }
View Full Code Here

        serializeResponse(response, EC2response);
    }

    private void describeImageAttribute( HttpServletRequest request, HttpServletResponse response )
            throws ADBException, XMLStreamException, IOException {
        EC2DescribeImageAttribute ec2request = new EC2DescribeImageAttribute();

        String[] imageId = request.getParameterValues( "ImageId" );
        if (imageId != null && imageId.length > 0)
            ec2request.setImageId(imageId[0]);
        else {
            throw new EC2ServiceException( ClientError.MissingParamter, "Missing required parameter - ImageId");
        }

        String[] attribute = request.getParameterValues( "Attribute" );
        if (attribute != null && attribute.length > 0) {
            if (attribute[0].equalsIgnoreCase("description"))
                ec2request.setAttribute(ImageAttribute.description);
            else if (attribute[0].equalsIgnoreCase("launchPermission"))
                ec2request.setAttribute(ImageAttribute.launchPermission);
            else {
              throw new EC2ServiceException( ClientError.InvalidParameterValue,
                        "Only values supported for paramter Attribute are - Description/LaunchPermission");
            }
        } else {
View Full Code Here

  /**
   * This only supports a query about description.
   */
    public DescribeImageAttributeResponse describeImageAttribute(DescribeImageAttribute describeImageAttribute) {
        EC2DescribeImageAttribute request = new EC2DescribeImageAttribute();
        DescribeImageAttributeType diat = describeImageAttribute.getDescribeImageAttribute();
        DescribeImageAttributesGroup diag = diat.getDescribeImageAttributesGroup();
        EmptyElementType description = diag.getDescription();
        EmptyElementType launchPermission = diag.getLaunchPermission();

        if ( null != description ) {
             request.setImageId(diat.getImageId());
             request.setAttribute(ImageAttribute.description);
             return toDescribeImageAttributeResponse( engine.describeImageAttribute( request ));
        }else if(launchPermission != null){
           request.setImageId(diat.getImageId());
           request.setAttribute(ImageAttribute.launchPermission);
           return toDescribeImageAttributeResponse( engine.describeImageAttribute( request ));
        }
        else throw new EC2ServiceException( ClientError.Unsupported, "Unsupported - only description or launchPermission supported" );
    }
View Full Code Here

        serializeResponse(response, EC2response);
    }

    private void describeImageAttribute( HttpServletRequest request, HttpServletResponse response )
            throws ADBException, XMLStreamException, IOException {
        EC2DescribeImageAttribute ec2request = new EC2DescribeImageAttribute();

        String[] imageId = request.getParameterValues( "ImageId" );
        if (imageId != null && imageId.length > 0)
            ec2request.setImageId(imageId[0]);
        else {
            response.sendError(530, "Missing ImageId parameter");
            return;
        }

        String[] attribute = request.getParameterValues( "Attribute" );
        if (attribute != null && attribute.length > 0) {
            if (attribute[0].equalsIgnoreCase("description"))
                ec2request.setAttribute(ImageAttribute.description);
            else if (attribute[0].equalsIgnoreCase("launchPermission"))
                ec2request.setAttribute(ImageAttribute.launchPermission);
            else {
                response.sendError(501, "Unsupported Attribute - description and launchPermission supported" );
                return;
            }
        } else {
View Full Code Here

        else throw new EC2ServiceException( ClientError.Unsupported, "Unsupported - only description or launchPermission supported" );
    }


  public DescribeImagesResponse describeImages(DescribeImages describeImages) {
    EC2DescribeImages  request = new EC2DescribeImages();
    DescribeImagesType dit     = describeImages.getDescribeImages();
   
    // -> toEC2DescribeImages
      DescribeImagesExecutableBySetType param1 = dit.getExecutableBySet();
      if (null != param1) {
          DescribeImagesExecutableByType[] items1  = param1.getItem();
          if (null != items1) {
            for( int i=0; i < items1.length; i++ ) request.addExecutableBySet( items1[i].getUser());
          }
      }
    DescribeImagesInfoType param2 = dit.getImagesSet();
    if (null != param2) {
        DescribeImagesItemType[] items2 = param2.getItem();
        if (null != items2) { 
            for( int i=0; i < items2.length; i++ ) request.addImageSet( items2[i].getImageId());
        }
    }
    DescribeImagesOwnersType param3 = dit.getOwnersSet();
    if (null != param3) {
        DescribeImagesOwnerType[] items3 = param3.getItem();
        if (null != items3) { 
          for( int i=0; i < items3.length; i++ ) request.addOwnersSet( items3[i].getOwner());
        }
    }   
        FilterSetType fst = dit.getFilterSet();
        if ( fst != null) {
            request.setFilterSet(toImageFilterSet(fst));
        }
    return toDescribeImagesResponse( engine.describeImages( request ));
  }
View Full Code Here

        }
    return toDescribeImagesResponse( engine.describeImages( request ));
  }

  public DescribeInstanceAttributeResponse describeInstanceAttribute(DescribeInstanceAttribute describeInstanceAttribute) {
      EC2DescribeInstances  request = new EC2DescribeInstances();
      DescribeInstanceAttributeType diat = describeInstanceAttribute.getDescribeInstanceAttribute();
      DescribeInstanceAttributesGroup diag = diat.getDescribeInstanceAttributesGroup();
      EmptyElementType instanceType = diag.getInstanceType();
   
      // -> toEC2DescribeInstances
           if (null != instanceType) {
                   request.addInstanceId( diat.getInstanceId());
        return toDescribeInstanceAttributeResponse( engine.describeInstances( request ));
      }
           throw new EC2ServiceException( ClientError.Unsupported, "Unsupported - only instanceType supported");
  }
View Full Code Here

  }

 
  public DescribeInstancesResponse describeInstances( DescribeInstances describeInstances )
  {
    EC2DescribeInstances  request = new EC2DescribeInstances();
    DescribeInstancesType dit     = describeInstances.getDescribeInstances();
    FilterSetType fst = dit.getFilterSet();

    // -> toEC2DescribeInstances
    DescribeInstancesInfoType   diit  = dit.getInstancesSet();
    DescribeInstancesItemType[] items = diit.getItem();
    if (null != items) {  // -> can be empty
      for( int i=0; i < items.length; i++ ) request.addInstanceId( items[i].getInstanceId());
    }

        if (null != fst)
            request = toInstanceFilterSet( request, fst );
View Full Code Here

        return response;
    }

  public DescribeKeyPairsResponse describeKeyPairs(DescribeKeyPairs describeKeyPairs) {
   
    EC2DescribeKeyPairs ec2Request = new EC2DescribeKeyPairs();

    // multiple keynames may be provided
    DescribeKeyPairsInfoType kset = describeKeyPairs.getDescribeKeyPairs().getKeySet();
    if (kset != null) {
      DescribeKeyPairsItemType[] keyPairKeys = kset.getItem();
      if (keyPairKeys != null) {
        for (DescribeKeyPairsItemType key : keyPairKeys) {
          ec2Request.addKeyName(key.getKeyName());
        }
      }
    }
   
    // multiple filters may be provided
    FilterSetType fset = describeKeyPairs.getDescribeKeyPairs().getFilterSet();
    if (fset != null) {
      ec2Request.setKeyFilterSet(toKeyPairFilterSet(fset));
    }
   
    return toDescribeKeyPairs(engine.describeKeyPairs(ec2Request));
  }
View Full Code Here

TOP

Related Classes of com.cloud.bridge.service.core.ec2.EC2DescribeImageAttribute

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.