Interface ElasticInstanceManager
- All Superinterfaces:
ElasticAgentTunnelPorts
- All Known Implementing Classes:
ElasticInstanceManagerImpl
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addElasticLogEntry
(org.apache.log4j.Logger log, String logEntry) Deprecated.void
addElasticLogEntry
(org.apache.logging.log4j.Logger log, String logEntry) boolean
cancelSpotRequests
(@NotNull com.atlassian.aws.AWSAccount awsAccount) Cancel spot instance requests.void
ensureLoginKeyPairExists
(com.atlassian.aws.AWSAccount awsAccount, String keyPair) Ensures that a key pair, named "elasticbamboo", has been defined in the configured AWS account.Returns all elastic instances in aSetMultimap
, keyed by theElasticImageConfiguration
Returns all elastic instances.@NotNull Set<com.atlassian.aws.ec2.EC2InstanceType>
Returns the name of the security group used to indicate that this instance belongs to Bamboo.Retrieve activity logs@Nullable RemoteElasticInstance
getElasticRemoteAgentByInstanceId
(String instanceId) Retrieve elastic instance of the given ID.@NotNull List<RemoteElasticInstance>
Retrieve a readonly list of any currently existing EC2 instances@NotNull List<RemoteElasticInstance>
@NotNull List<RemoteElasticInstance>
getElasticRemoteAgentsByConfiguration
(@NotNull ElasticImageConfiguration elasticImageConfiguration) @NotNull String
getInstanceLogs
(@NotNull String instanceId) Fetch console output of a running EC2 instance.@NotNull List<RemoteElasticInstance>
Returns those elastic instances that have already started but their agents have not yet connected to the bamboo server.@NotNull List<RemoteElasticInstance>
Returns the elastic instances which have been requested but not yet identified.@NotNull List<RemoteElasticInstance>
Return the elastic instances which have been identified but not started up yet, i.e.int
Return how many license spots are currently being occupied by elastic instances (pending and running)boolean
boolean
isInstanceKnown
(@NotNull String instanceId) Checks if an AWS instance with the given ID exists and is managed by this Bamboo server.newElasticAgent
(RemoteElasticInstanceListener listener, com.atlassian.aws.AWSAccount awsAccount, AgentManager agentManager, ElasticImageConfiguration elasticImageConfiguration, com.atlassian.aws.ec2.InstanceLaunchConfigurationBuilder instanceLaunchConfigurationBuilder) void
onInstanceIdentified
(@NotNull RemoteElasticInstance remoteElasticInstance) Tell the manager that the instance is up and runningvoid
onInstanceRunning
(@NotNull RemoteElasticInstance remoteElasticInstance) Invoked when the instance enters the 'running' statevoid
registerElasticAgentStopped
(@NotNull RemoteElasticInstance instance) Remove and EC2 instance from the "currently Running maprestoreElasticAgent
(@NotNull ElasticAgentDefinition elasticAgentDefinition, @Nullable ElasticTunnelDefinition elasticTunnelDefinition, @NotNull com.amazonaws.services.ec2.model.Instance instance, @NotNull RemoteElasticInstanceListener listener, @NotNull com.atlassian.aws.AWSAccount awsAccount, @NotNull AgentManager agentManager, @NotNull com.atlassian.aws.ec2.InstanceLaunchConfigurationBuilder instanceLaunchConfigurationBuilder) After Bamboo server restart, reconnect to elastic agent.boolean
validateAwsCredentials
(com.atlassian.aws.ec2.awssdk.AwsSupportConstants.Region region, com.atlassian.aws.credentials.AWSCredentials awsCredentials, ErrorCollection errorCollection) Validate supplied AWS credentials.boolean
validateAwsCredentials
(com.atlassian.aws.ec2.awssdk.AwsSupportConstants.Region region, String awsAccessID, String awsSecretKey, ErrorCollection errorCollection) Deprecated.since 8.2 usevalidateAwsCredentials(AwsSupportConstants.Region, AWSCredentials, ErrorCollection)
instead.Methods inherited from interface com.atlassian.bamboo.agent.elastic.tunnel.ElasticAgentTunnelPorts
getAgentSideHttpPort, getAgentSideJmsPort, getTunnelPort
-
Field Details
-
DEFAULT_INSTANCE_TYPE_32
static final com.atlassian.aws.ec2.EC2InstanceType DEFAULT_INSTANCE_TYPE_32 -
DEFAULT_INSTANCE_TYPE_64
static final com.atlassian.aws.ec2.EC2InstanceType DEFAULT_INSTANCE_TYPE_64 -
DEFAULT_PRODUCT_FOR_LINUX_PLATFORM
- See Also:
-
DEFAULT_PRODUCT_FOR_WINDOWS_PLATFORM
- See Also:
-
ELASTIC_BAMBOO_SECURITY_GROUP
-
ELASTIC_BAMBOO_KEY_PAIR
-
ELASTIC_BAMBOO_KEY_PAIR_FILE
-
-
Method Details
-
newElasticAgent
RemoteElasticInstance newElasticAgent(RemoteElasticInstanceListener listener, com.atlassian.aws.AWSAccount awsAccount, AgentManager agentManager, ElasticImageConfiguration elasticImageConfiguration, com.atlassian.aws.ec2.InstanceLaunchConfigurationBuilder instanceLaunchConfigurationBuilder) throws NoSuchAlgorithmException, KeyManagementException, IOException, CertificateException, UnrecoverableKeyException, KeyStoreException -
restoreElasticAgent
RemoteElasticInstance restoreElasticAgent(@NotNull @NotNull ElasticAgentDefinition elasticAgentDefinition, @Nullable @Nullable ElasticTunnelDefinition elasticTunnelDefinition, @NotNull @NotNull com.amazonaws.services.ec2.model.Instance instance, @NotNull @NotNull RemoteElasticInstanceListener listener, @NotNull @NotNull com.atlassian.aws.AWSAccount awsAccount, @NotNull @NotNull AgentManager agentManager, @NotNull @NotNull com.atlassian.aws.ec2.InstanceLaunchConfigurationBuilder instanceLaunchConfigurationBuilder) throws Exception After Bamboo server restart, reconnect to elastic agent.- Throws:
Exception
- Since:
- 5.10
-
ensureLoginKeyPairExists
void ensureLoginKeyPairExists(com.atlassian.aws.AWSAccount awsAccount, String keyPair) throws com.atlassian.aws.AWSException Ensures that a key pair, named "elasticbamboo", has been defined in the configured AWS account.
- Parameters:
awsAccount
- that should contain the key pairkeyPair
-- Throws:
com.atlassian.aws.AWSException
- if there is a problem communicating with EC2.
-
validateAwsCredentials
@Deprecated boolean validateAwsCredentials(com.atlassian.aws.ec2.awssdk.AwsSupportConstants.Region region, String awsAccessID, String awsSecretKey, ErrorCollection errorCollection) Deprecated.since 8.2 usevalidateAwsCredentials(AwsSupportConstants.Region, AWSCredentials, ErrorCollection)
instead.Validate a set of supplied AWS credentials.
- Parameters:
awsAccessID
- The Access ID of the Amazon Web Services AccountawsSecretKey
- The Secret Key of the Amazon Web Services AccounterrorCollection
- AnErrorCollection
to which validation errors should be added, ornull
if validation errors are not required.- Returns:
true
if the supplied credentials are successfully validated;false
otherwise.
-
validateAwsCredentials
boolean validateAwsCredentials(com.atlassian.aws.ec2.awssdk.AwsSupportConstants.Region region, com.atlassian.aws.credentials.AWSCredentials awsCredentials, ErrorCollection errorCollection) Validate supplied AWS credentials.
- Parameters:
awsCredentials
- Amazon Web Services Account credentialserrorCollection
- AnErrorCollection
to which validation errors should be added, ornull
if validation errors are not required.- Returns:
true
if the supplied credentials are successfully validated;false
otherwise.
-
getElasticRemoteAgents
Retrieve a readonly list of any currently existing EC2 instances- Returns:
- List of
RemoteElasticInstance
-
getRequestedElasticRemoteAgents
Returns the elastic instances which have been requested but not yet identified.- Returns:
- List of elastic instances which have been requested but not yet started up yet..
-
getStartingElasticInstances
Return the elastic instances which have been identified but not started up yet, i.e. those instances that are IDENTIFIED pending to move to RUNNING state. The list does not include those instances that have been requested but not yet identified.- Returns:
- List of elastic instances which have been requested and identified but not yet started up yet..
-
getAllElasticRemoteAgents
List<RemoteElasticInstance> getAllElasticRemoteAgents()Returns all elastic instances. It includes requested agents as well as active agents- Returns:
-
getInstancesWithStartingAgents
Returns those elastic instances that have already started but their agents have not yet connected to the bamboo server. Once the elastic instance is started it launches a bamboo agents that connects to the bamboo server. There is a period of time when the instance has already started (and therefore it is not returned bygetRequestedElasticRemoteAgents()
) but the agent on the instance has not yet connected to the bamboo server. Elastic instances in such state are returned by this method and the list is a subset of the list returned bygetElasticRemoteAgents()
.- Returns:
- List of
RemoteElasticInstance
-
getAllElasticAgentsAsMap
SetMultimap<ElasticImageConfiguration,RemoteElasticInstance> getAllElasticAgentsAsMap()Returns all elastic instances in aSetMultimap
, keyed by theElasticImageConfiguration
- Returns:
-
getTotalNumElasticRemoteAgents
int getTotalNumElasticRemoteAgents()Return how many license spots are currently being occupied by elastic instances (pending and running)- Returns:
- Number of license slots currently occupied by elastic instances (pending and running).
-
getElasticRemoteAgentByInstanceId
Retrieve elastic instance of the given ID.- Parameters:
instanceId
- of the instance- Returns:
- the elastic remote agent specific to the provided instance id
-
registerElasticAgentStopped
Remove and EC2 instance from the "currently Running map- Parameters:
instance
- - the one to be deleted from the map
-
onInstanceIdentified
Tell the manager that the instance is up and running- Parameters:
remoteElasticInstance
- the instance identified
-
onInstanceRunning
Invoked when the instance enters the 'running' state- Parameters:
remoteElasticInstance
- the instance that entered running state
-
addElasticLogEntry
-
addElasticLogEntry
Deprecated.since 9.3 useaddElasticLogEntry(Logger, String)
-
getElasticAgentLogs
Retrieve activity logs- Returns:
- a copy of the current elastic agent logs
-
isElasticSupportEnabled
boolean isElasticSupportEnabled()- Returns:
- true, if elastic support is turned on
-
getAllowedInstanceTypes
- Returns:
- Set of allowed instance types.
-
getElasticRemoteAgentsByConfiguration
@NotNull @NotNull List<RemoteElasticInstance> getElasticRemoteAgentsByConfiguration(@NotNull @NotNull ElasticImageConfiguration elasticImageConfiguration) -
getElasticRemoteAgentsByConfiguration
-
cancelSpotRequests
boolean cancelSpotRequests(@NotNull @NotNull com.atlassian.aws.AWSAccount awsAccount) Cancel spot instance requests.- Parameters:
awsAccount
- account- Returns:
- true if at least one request was found and cancelled
-
getInstanceLogs
@NotNull @NotNull String getInstanceLogs(@NotNull @NotNull String instanceId) throws com.atlassian.aws.AWSException Fetch console output of a running EC2 instance.- Parameters:
instanceId
- id of the instance- Returns:
- Logs from the instance, empty string if no logs were available.
- Throws:
com.atlassian.aws.AWSException
- if an error occurs while fetching the console output
-
isInstanceKnown
Checks if an AWS instance with the given ID exists and is managed by this Bamboo server.- Parameters:
instanceId
- id of the instance- Returns:
- true, if the instance exists and is managed by this Bamboo server
-
getBambooControlTag
String getBambooControlTag()Returns the name of the security group used to indicate that this instance belongs to Bamboo.
-
addElasticLogEntry(Logger, String)