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
 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(java.lang.String id, java.lang.String accessId, java.lang.String secretKey, java.lang.String privateKey, java.lang.String instanceCapStr, java.util.List<SlaveTemplate> templates)
           
 
Method Summary
protected  org.jets3t.service.Jets3tProperties buildJets3tProperties(java.net.URL s3)
          Builds the connection parameters for S3.
 java.net.URL buildPresignedURL(java.lang.String path)
          Computes the presigned URL for the given S3 resource.
 boolean canProvision(hudson.model.Label label)
           
static java.net.URL checkEndPoint(java.lang.String url)
           
 com.xerox.amazonws.ec2.Jec2 connect()
          Connects to EC2 and returns Jec2, which can then be used to communicate with EC2.
static com.xerox.amazonws.ec2.Jec2 connect(java.lang.String accessId, hudson.util.Secret secretKey, java.net.URL endpoint)
          Connect to an EC2 instance.
static com.xerox.amazonws.ec2.Jec2 connect(java.lang.String accessId, java.lang.String secretKey, java.net.URL endpoint)
          Connect to an EC2 instance.
 org.jets3t.service.S3Service connectS3()
          Connects to S3 and returns S3Service.
static java.lang.String convertHostName(java.lang.String ec2HostName)
          Convert a configured hostname like 'us-east-1' to a FQDN or ip address
static java.lang.Integer convertPort(java.lang.String ec2Port)
          Convert a user entered string into a port number "" -> -1 to indicate default based on SSL setting
static java.lang.String convertS3HostName(java.lang.String s3HostName)
          Convert a configured s3 endpoint to a FQDN or ip address
 int countCurrentEC2Slaves()
          Counts the number of instances in EC2 currently running.
 void doAttach(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, java.lang.String id)
          Debug command to attach to a running instance.
 void doProvision(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, java.lang.String ami)
           
static EC2Cloud get()
          Gets the first EC2Cloud instance configured in the current Hudson, or null if no such thing exists.
 java.lang.String getAccessId()
           
abstract  java.net.URL getEc2EndpointUrl()
           
 java.lang.String getInstanceCapStr()
           
 com.xerox.amazonws.ec2.KeyPairInfo getKeyPair()
          Gets the KeyPairInfo used for the launch.
 hudson.plugins.ec2.EC2PrivateKey getPrivateKey()
           
abstract  java.net.URL getS3EndpointUrl()
           
 java.lang.String getSecretKey()
           
 SlaveTemplate getTemplate(hudson.model.Label label)
          Gets SlaveTemplate that has the matching Label.
 SlaveTemplate getTemplate(java.lang.String ami)
           
 java.util.List<SlaveTemplate> getTemplates()
           
 java.util.Collection<hudson.slaves.NodeProvisioner.PlannedNode> provision(hudson.model.Label label, int excessWorkload)
           
protected  java.lang.Object readResolve()
           
 
Methods inherited from class hudson.slaves.Cloud
all, checkPermission, getACL, getDescriptor, getDisplayName, getSearchUrl, hasPermission
 
Methods inherited from class hudson.model.AbstractModelObject
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

instanceCap

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

Constructor Detail

EC2Cloud

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

getEc2EndpointUrl

public abstract java.net.URL getEc2EndpointUrl()
                                        throws java.io.IOException
Throws:
java.io.IOException

getS3EndpointUrl

public abstract java.net.URL getS3EndpointUrl()
                                       throws java.io.IOException
Throws:
java.io.IOException

readResolve

protected java.lang.Object readResolve()

getAccessId

public java.lang.String getAccessId()

getSecretKey

public java.lang.String getSecretKey()

getPrivateKey

public hudson.plugins.ec2.EC2PrivateKey getPrivateKey()

getInstanceCapStr

public java.lang.String getInstanceCapStr()

getTemplates

public java.util.List<SlaveTemplate> getTemplates()

getTemplate

public SlaveTemplate getTemplate(java.lang.String ami)

getTemplate

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


getKeyPair

public com.xerox.amazonws.ec2.KeyPairInfo getKeyPair()
                                              throws com.xerox.amazonws.ec2.EC2Exception,
                                                     java.io.IOException
Gets the KeyPairInfo used for the launch.

Throws:
com.xerox.amazonws.ec2.EC2Exception
java.io.IOException

countCurrentEC2Slaves

public int countCurrentEC2Slaves()
                          throws com.xerox.amazonws.ec2.EC2Exception
Counts the number of instances in EC2 currently running.

This includes those instances that may be started outside Hudson.

Throws:
com.xerox.amazonws.ec2.EC2Exception

doAttach

public void doAttach(org.kohsuke.stapler.StaplerRequest req,
                     org.kohsuke.stapler.StaplerResponse rsp,
                     @QueryParameter
                     java.lang.String id)
              throws javax.servlet.ServletException,
                     java.io.IOException,
                     com.xerox.amazonws.ec2.EC2Exception
Debug command to attach to a running instance.

Throws:
javax.servlet.ServletException
java.io.IOException
com.xerox.amazonws.ec2.EC2Exception

doProvision

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

provision

public java.util.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.xerox.amazonws.ec2.Jec2 connect()
                                    throws com.xerox.amazonws.ec2.EC2Exception
Connects to EC2 and returns Jec2, which can then be used to communicate with EC2.

Throws:
com.xerox.amazonws.ec2.EC2Exception

connect

public static com.xerox.amazonws.ec2.Jec2 connect(java.lang.String accessId,
                                                  java.lang.String secretKey,
                                                  java.net.URL endpoint)
Connect to an EC2 instance.

Returns:
Jec2

connect

public static com.xerox.amazonws.ec2.Jec2 connect(java.lang.String accessId,
                                                  hudson.util.Secret secretKey,
                                                  java.net.URL endpoint)
Connect to an EC2 instance.

Returns:
Jec2

convertHostName

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


convertS3HostName

public static java.lang.String convertS3HostName(java.lang.String s3HostName)
Convert a configured s3 endpoint to a FQDN or ip address


convertPort

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


connectS3

public org.jets3t.service.S3Service connectS3()
                                       throws org.jets3t.service.S3ServiceException,
                                              java.io.IOException
Connects to S3 and returns S3Service.

Throws:
org.jets3t.service.S3ServiceException
java.io.IOException

buildJets3tProperties

protected org.jets3t.service.Jets3tProperties buildJets3tProperties(java.net.URL s3)
Builds the connection parameters for S3.


buildPresignedURL

public java.net.URL buildPresignedURL(java.lang.String path)
                               throws java.io.IOException,
                                      org.jets3t.service.S3ServiceException
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:
java.io.IOException
org.jets3t.service.S3ServiceException

checkEndPoint

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


Copyright © 2010. All Rights Reserved.