Package hudson.plugins.ec2
Class EC2Cloud
- java.lang.Object
-
- hudson.model.AbstractModelObject
-
- hudson.model.Actionable
-
- hudson.slaves.Cloud
-
- hudson.plugins.ec2.EC2Cloud
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<Cloud>
,ModelObject
,SearchableModelObject
,SearchItem
,AccessControlled
,ModelObjectWithContextMenu
- Direct Known Subclasses:
AmazonEC2Cloud
,Eucalyptus
public abstract class EC2Cloud extends Cloud
Hudson's view of EC2.- Author:
- Kohsuke Kawaguchi
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
EC2Cloud.DescriptorImpl
static class
EC2Cloud.EC2ConnectionUpdater
-
Nested classes/interfaces inherited from class hudson.slaves.Cloud
Cloud.CloudState
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
Nested classes/interfaces inherited from interface jenkins.model.ModelObjectWithContextMenu
ModelObjectWithContextMenu.ContextMenu, ModelObjectWithContextMenu.ContextMenuVisibility, ModelObjectWithContextMenu.MenuItem, ModelObjectWithContextMenu.MenuItemType
-
-
Field Summary
Fields Modifier and Type Field Description static String
AWS_CN_URL_HOST
static String
AWS_URL_HOST
static String
DEFAULT_EC2_ENDPOINT
static String
DEFAULT_EC2_HOST
static String
EC2_REQUEST_EXPIRED_ERROR_CODE
static String
EC2_SLAVE_TYPE_DEMAND
static String
EC2_SLAVE_TYPE_SPOT
-
Constructor Summary
Constructors Modifier Constructor Description protected
EC2Cloud(String name, boolean useInstanceProfileForCredentials, String credentialsId, String privateKey, String sshKeysCredentialsId, String instanceCapStr, List<? extends SlaveTemplate> templates, String roleArn, String roleSessionName)
protected
EC2Cloud(String id, boolean useInstanceProfileForCredentials, String credentialsId, String privateKey, String instanceCapStr, List<? extends SlaveTemplate> templates, String roleArn, String roleSessionName)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
addTemplate(SlaveTemplate newTemplate)
URL
buildPresignedURL(String path)
Computes the presigned URL for the given S3 resource.boolean
canProvision(Label label)
static URL
checkEndPoint(String url)
com.amazonaws.services.ec2.AmazonEC2
connect()
Connects to EC2 and returnsAmazonEC2
, which can then be used to communicate with EC2.static String
convertHostName(String ec2HostName)
Convert a configured hostname like 'us-east-1' to a FQDN or ip addressstatic Integer
convertPort(String ec2Port)
Convert a user entered string into a port number "" -> -1 to indicate default based on SSL settingstatic com.amazonaws.ClientConfiguration
createClientConfiguration(String host)
protected com.amazonaws.auth.AWSCredentialsProvider
createCredentialsProvider()
static com.amazonaws.auth.AWSCredentialsProvider
createCredentialsProvider(boolean useInstanceProfileForCredentials, String credentialsId)
static com.amazonaws.auth.AWSCredentialsProvider
createCredentialsProvider(boolean useInstanceProfileForCredentials, String credentialsId, String roleArn, String roleSessionName, String region)
void
doAttach(org.kohsuke.stapler.StaplerRequest req, org.kohsuke.stapler.StaplerResponse rsp, String id)
Debug command to attach to a running instance.org.kohsuke.stapler.HttpResponse
doProvision(String template)
static String
getAwsPartitionHostForService(String region, String service)
Returns the DNS endpoint for a AWS service based on region providedString
getCredentialsId()
abstract URL
getEc2EndpointUrl()
int
getInstanceCap()
String
getInstanceCapStr()
com.amazonaws.services.ec2.model.KeyPair
getKeyPair()
Gets theKeyPairInfo
used for the launch.EC2PrivateKey
getPrivateKey()
Deprecated.String
getRoleArn()
String
getRoleSessionName()
abstract URL
getS3EndpointUrl()
static String
getSlaveTypeTagValue(String slaveType, String templateDescription)
String
getSshKeysCredentialsId()
SlaveTemplate
getTemplate(Label label)
Deprecated.SlaveTemplate
getTemplate(String template)
List<SlaveTemplate>
getTemplates()
Collection<SlaveTemplate>
getTemplates(Label label)
Gets list ofSlaveTemplate
that matchesLabel
.boolean
isUseInstanceProfileForCredentials()
static void
log(Logger logger, Level level, TaskListener listener, String message)
static void
log(Logger logger, Level level, TaskListener listener, String message, Throwable exception)
Collection<NodeProvisioner.PlannedNode>
provision(Label label, int excessWorkload)
void
provision(SlaveTemplate t, int number)
protected Object
readResolve()
EC2PrivateKey
resolvePrivateKey()
-
Methods inherited from class hudson.slaves.Cloud
all, canProvision, doConfigSubmit, doDoDelete, getACL, getDescriptor, getDisplayName, getIcon, getIconAltText, getIconClassName, getSearchUrl, getUrl, provision, reconfigure, registerPermissions
-
Methods inherited from class hudson.model.Actionable
addAction, addOrReplaceAction, doContextMenu, getAction, getAction, getActions, getActions, getAllActions, getDynamic, removeAction, removeActions, replaceAction, replaceActions
-
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
-
Methods inherited from interface hudson.security.AccessControlled
checkAnyPermission, checkPermission, hasAnyPermission, hasPermission, hasPermission, hasPermission2
-
-
-
-
Field Detail
-
DEFAULT_EC2_HOST
public static final String DEFAULT_EC2_HOST
- See Also:
- Constant Field Values
-
DEFAULT_EC2_ENDPOINT
public static final String DEFAULT_EC2_ENDPOINT
- See Also:
- Constant Field Values
-
AWS_URL_HOST
public static final String AWS_URL_HOST
- See Also:
- Constant Field Values
-
AWS_CN_URL_HOST
public static final String AWS_CN_URL_HOST
- See Also:
- Constant Field Values
-
EC2_SLAVE_TYPE_SPOT
public static final String EC2_SLAVE_TYPE_SPOT
- See Also:
- Constant Field Values
-
EC2_SLAVE_TYPE_DEMAND
public static final String EC2_SLAVE_TYPE_DEMAND
- See Also:
- Constant Field Values
-
EC2_REQUEST_EXPIRED_ERROR_CODE
public static final String EC2_REQUEST_EXPIRED_ERROR_CODE
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
EC2Cloud
protected EC2Cloud(String name, boolean useInstanceProfileForCredentials, String credentialsId, String privateKey, String sshKeysCredentialsId, String instanceCapStr, List<? extends SlaveTemplate> templates, String roleArn, String roleSessionName)
-
EC2Cloud
@Deprecated protected EC2Cloud(String id, boolean useInstanceProfileForCredentials, String credentialsId, String privateKey, String instanceCapStr, List<? extends SlaveTemplate> templates, String roleArn, String roleSessionName)
Deprecated.
-
-
Method Detail
-
resolvePrivateKey
@CheckForNull public EC2PrivateKey resolvePrivateKey()
-
getEc2EndpointUrl
public abstract URL getEc2EndpointUrl() throws IOException
- Throws:
IOException
-
getS3EndpointUrl
public abstract URL getS3EndpointUrl() throws IOException
- Throws:
IOException
-
addTemplate
public void addTemplate(SlaveTemplate newTemplate) throws Exception
- Throws:
Exception
-
readResolve
protected Object readResolve()
-
isUseInstanceProfileForCredentials
public boolean isUseInstanceProfileForCredentials()
-
getRoleArn
public String getRoleArn()
-
getRoleSessionName
public String getRoleSessionName()
-
getCredentialsId
public String getCredentialsId()
-
getSshKeysCredentialsId
@CheckForNull public String getSshKeysCredentialsId()
-
getPrivateKey
@Deprecated public EC2PrivateKey getPrivateKey()
Deprecated.
-
getInstanceCapStr
public String getInstanceCapStr()
-
getInstanceCap
public int getInstanceCap()
-
getTemplates
public List<SlaveTemplate> getTemplates()
-
getTemplate
@CheckForNull public SlaveTemplate getTemplate(String template)
-
getTemplate
@Deprecated public SlaveTemplate getTemplate(Label label)
Deprecated.GetsSlaveTemplate
that has the matchingLabel
.
-
getTemplates
public Collection<SlaveTemplate> getTemplates(Label label)
Gets list ofSlaveTemplate
that matchesLabel
.
-
getKeyPair
@CheckForNull public com.amazonaws.services.ec2.model.KeyPair getKeyPair() throws com.amazonaws.AmazonClientException, IOException
Gets theKeyPairInfo
used for the launch.- Throws:
com.amazonaws.AmazonClientException
IOException
-
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 org.kohsuke.stapler.HttpResponse doProvision(@QueryParameter String template) throws javax.servlet.ServletException, IOException
- Throws:
javax.servlet.ServletException
IOException
-
provision
public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload)
-
provision
public void provision(SlaveTemplate t, int number)
-
canProvision
public boolean canProvision(Label label)
- Overrides:
canProvision
in classCloud
-
createCredentialsProvider
protected com.amazonaws.auth.AWSCredentialsProvider createCredentialsProvider()
-
getSlaveTypeTagValue
public static String getSlaveTypeTagValue(String slaveType, String templateDescription)
-
createCredentialsProvider
public static com.amazonaws.auth.AWSCredentialsProvider createCredentialsProvider(boolean useInstanceProfileForCredentials, String credentialsId)
-
createCredentialsProvider
public static com.amazonaws.auth.AWSCredentialsProvider createCredentialsProvider(boolean useInstanceProfileForCredentials, String credentialsId, String roleArn, String roleSessionName, String region)
-
connect
public com.amazonaws.services.ec2.AmazonEC2 connect() throws com.amazonaws.AmazonClientException
Connects to EC2 and returnsAmazonEC2
, which can then be used to communicate with EC2.- Throws:
com.amazonaws.AmazonClientException
-
createClientConfiguration
public static com.amazonaws.ClientConfiguration createClientConfiguration(String host)
-
getAwsPartitionHostForService
public static String getAwsPartitionHostForService(String region, String service)
Returns the DNS endpoint for a AWS service based on region provided
-
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 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:
com.amazonaws.AmazonClientException
-
checkEndPoint
public static URL checkEndPoint(String url) throws FormValidation
- Throws:
FormValidation
-
log
public static void log(Logger logger, Level level, TaskListener listener, String message)
-
log
public static void log(Logger logger, Level level, TaskListener listener, String message, Throwable exception)
-
-