hudson.plugins.ec2
Class EC2Cloud

java.lang.Object
  extended by hudson.model.AbstractModelObject
      extended by hudson.slaves.Cloud
          extended by hudson.plugins.ec2.EC2Cloud
All Implemented Interfaces:
hudson.ExtensionPoint, hudson.model.Describable<hudson.slaves.Cloud>, hudson.model.ModelObject, hudson.search.SearchableModelObject, hudson.search.SearchItem, hudson.security.AccessControlled
Direct Known Subclasses:
AmazonEC2Cloud, Eucalyptus

public abstract class EC2Cloud
extends hudson.slaves.Cloud

Hudson's view of EC2.

Author:
Kohsuke Kawaguchi

Nested Class Summary
static class EC2Cloud.DescriptorImpl
           
 
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
hudson.ExtensionPoint.LegacyInstancesAreScopedToHudson
 
Field Summary
static String DEFAULT_EC2_HOST
           
static String EC2_URL_HOST
           
 int instanceCap
          Upper bound on how many instances we may provision.
 
Fields inherited from class hudson.slaves.Cloud
ALL, name, PROVISION
 
Constructor Summary
protected EC2Cloud(String id, String accessId, String secretKey, String privateKey, String instanceCapStr, List<SlaveTemplate> templates)
           
 
Method Summary
 URL buildPresignedURL(String path)
          Computes the presigned URL for the given S3 resource.
 boolean canProvision(hudson.model.Label label)
           
static URL checkEndPoint(String url)
           
 com.amazonaws.services.ec2.AmazonEC2 connect()
          Connects to EC2 and returns AmazonEC2, which can then be used to communicate with EC2.
static com.amazonaws.services.ec2.AmazonEC2 connect(String accessId, hudson.util.Secret secretKey, URL endpoint)
          Connect to an EC2 instance.
static com.amazonaws.services.ec2.AmazonEC2 connect(String accessId, String secretKey, URL endpoint)
          Connect to an EC2 instance.
static String convertHostName(String ec2HostName)
          Convert a configured hostname like 'us-east-1' to a FQDN or ip address
static Integer convertPort(String ec2Port)
          Convert a user entered string into a port number "" -> -1 to indicate default based on SSL setting
 int countCurrentEC2Slaves()
          Counts the number of instances in EC2 currently running.
 void doAttach(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, String id)
          Debug command to attach to a running instance.
 void doProvision(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, String ami)
           
static EC2Cloud get()
          Gets the first EC2Cloud instance configured in the current Hudson, or null if no such thing exists.
 String getAccessId()
           
abstract  URL getEc2EndpointUrl()
           
 String getInstanceCapStr()
           
 com.amazonaws.services.ec2.model.KeyPair getKeyPair()
          Gets the KeyPairInfo used for the launch.
 hudson.plugins.ec2.EC2PrivateKey getPrivateKey()
           
abstract  URL getS3EndpointUrl()
           
 String getSecretKey()
           
 SlaveTemplate getTemplate(hudson.model.Label label)
          Gets SlaveTemplate that has the matching Label.
 SlaveTemplate getTemplate(String ami)
           
 List<SlaveTemplate> getTemplates()
           
 Collection<hudson.slaves.NodeProvisioner.PlannedNode> provision(hudson.model.Label label, int excessWorkload)
           
protected  Object readResolve()
           
 
Methods inherited from class hudson.slaves.Cloud
all, checkPermission, getACL, getDescriptor, getDisplayName, getSearchUrl, hasPermission
 
Methods inherited from class hudson.model.AbstractModelObject
getConfiguredHudsonProperty, getSearch, getSearchIndex, getSearchName, makeSearchIndex, requirePOST, sendError, sendError, sendError, sendError, sendError
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_EC2_HOST

public static final String DEFAULT_EC2_HOST
See Also:
Constant Field Values

EC2_URL_HOST

public static final String EC2_URL_HOST
See Also:
Constant Field Values

instanceCap

public final int instanceCap
Upper bound on how many instances we may provision.

Constructor Detail

EC2Cloud

protected EC2Cloud(String id,
                   String accessId,
                   String secretKey,
                   String privateKey,
                   String instanceCapStr,
                   List<SlaveTemplate> templates)
Method Detail

getEc2EndpointUrl

public abstract URL getEc2EndpointUrl()
                               throws IOException
Throws:
IOException

getS3EndpointUrl

public abstract URL getS3EndpointUrl()
                              throws IOException
Throws:
IOException

readResolve

protected Object readResolve()

getAccessId

public String getAccessId()

getSecretKey

public String getSecretKey()

getPrivateKey

public hudson.plugins.ec2.EC2PrivateKey getPrivateKey()

getInstanceCapStr

public String getInstanceCapStr()

getTemplates

public List<SlaveTemplate> getTemplates()

getTemplate

public SlaveTemplate getTemplate(String ami)

getTemplate

public SlaveTemplate getTemplate(hudson.model.Label label)
Gets SlaveTemplate that has the matching Label.


getKeyPair

public com.amazonaws.services.ec2.model.KeyPair getKeyPair()
                                                    throws com.amazonaws.AmazonClientException,
                                                           IOException
Gets the KeyPairInfo used for the launch.

Throws:
com.amazonaws.AmazonClientException
IOException

countCurrentEC2Slaves

public int countCurrentEC2Slaves()
                          throws com.amazonaws.AmazonClientException
Counts the number of instances in EC2 currently running.

This includes those instances that may be started outside Hudson.

Throws:
com.amazonaws.AmazonClientException

doAttach

public void doAttach(org.kohsuke.stapler.StaplerRequest req,
                     org.kohsuke.stapler.StaplerResponse rsp,
                     @QueryParameter
                     String id)
              throws javax.servlet.ServletException,
                     IOException,
                     com.amazonaws.AmazonClientException
Debug command to attach to a running instance.

Throws:
javax.servlet.ServletException
IOException
com.amazonaws.AmazonClientException

doProvision

public void doProvision(org.kohsuke.stapler.StaplerRequest req,
                        org.kohsuke.stapler.StaplerResponse rsp,
                        @QueryParameter
                        String ami)
                 throws javax.servlet.ServletException,
                        IOException
Throws:
javax.servlet.ServletException
IOException

provision

public Collection<hudson.slaves.NodeProvisioner.PlannedNode> provision(hudson.model.Label label,
                                                                       int excessWorkload)
Specified by:
provision in class hudson.slaves.Cloud

canProvision

public boolean canProvision(hudson.model.Label label)
Specified by:
canProvision in class hudson.slaves.Cloud

get

public static EC2Cloud get()
Gets the first EC2Cloud instance configured in the current Hudson, or null if no such thing exists.


connect

public com.amazonaws.services.ec2.AmazonEC2 connect()
                                             throws com.amazonaws.AmazonClientException
Connects to EC2 and returns AmazonEC2, which can then be used to communicate with EC2.

Throws:
com.amazonaws.AmazonClientException

connect

public static com.amazonaws.services.ec2.AmazonEC2 connect(String accessId,
                                                           String secretKey,
                                                           URL endpoint)
Connect to an EC2 instance.

Returns:
AmazonEC2 client

connect

public static com.amazonaws.services.ec2.AmazonEC2 connect(String accessId,
                                                           hudson.util.Secret secretKey,
                                                           URL endpoint)
Connect to an EC2 instance.

Returns:
AmazonEC2 client

convertHostName

public static String convertHostName(String ec2HostName)
Convert a configured hostname like 'us-east-1' to a FQDN or ip address


convertPort

public static Integer convertPort(String ec2Port)
Convert a user entered string into a port number "" -> -1 to indicate default based on SSL setting


buildPresignedURL

public URL buildPresignedURL(String path)
                      throws IOException,
                             com.amazonaws.AmazonClientException
Computes the presigned URL for the given S3 resource.

Parameters:
path - String like "/bucketName/folder/folder/abc.txt" that represents the resource to request.
Throws:
IOException
com.amazonaws.AmazonClientException

checkEndPoint

public static URL checkEndPoint(String url)
                         throws hudson.util.FormValidation
Throws:
hudson.util.FormValidation


Copyright © 2004-2012 Hudson. All Rights Reserved.