Class Cloud
- java.lang.Object
-
- hudson.model.AbstractModelObject
-
- hudson.model.Actionable
-
- hudson.slaves.Cloud
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<Cloud>
,ModelObject
,SearchableModelObject
,SearchItem
,AccessControlled
,ModelObjectWithContextMenu
- Direct Known Subclasses:
AbstractCloudImpl
public abstract class Cloud extends Actionable implements ExtensionPoint, Describable<Cloud>, AccessControlled
CreatesNode
s to dynamically expand/shrink the agents attached to Hudson.Put another way, this class encapsulates different communication protocols needed to start a new agent programmatically.
Notes for implementers
Automatically delete idle agents
Nodes provisioned from a cloud do not automatically get released just because it's created fromCloud
. Doing so requires a use ofRetentionStrategy
. Instantiate yourSlave
subtype with something likeCloudSlaveRetentionStrategy
so that it gets automatically deleted after some idle time.Freeing an external resource when an agent is removed
Whether you do auto scale-down or not, you often want to release an external resource tied to a cloud-allocated agent when it is removed.To do this, have your
Slave
subtype remember the necessary handle (such as EC2 instance ID) as a field. Such fields need to survive the user-initiated re-configuration ofSlave
, so you'll need to expose it in yourSlave
configure-entries.jelly
and read it back in throughDataBoundConstructor
.You then implement your own
Computer
subtype, overrideSlave.createComputer()
, and instantiate your ownComputer
subtype with this handle information.Finally, override
Computer.onRemoved()
and use the handle to talk to the "cloud" and de-allocate the resource (such as shutting down a virtual machine.)Computer
needs to own this handle information because by the time this happens, aSlave
object is already long gone.Views
Since version 2.64, Jenkins clouds are visualized in UI. Implementations can providetop
ormain
view to be presented at the top of the page or at the bottom respectively. In the middle, actions have theirsummary
views displayed. Actions further contribute tosidepanel
withbox
views. All mentioned views are optional to preserve backward compatibility.- Author:
- Kohsuke Kawaguchi
- See Also:
NodeProvisioner
,AbstractCloudImpl
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Cloud.CloudState
Parameter object forCloud
.-
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 DescriptorList<Cloud>
ALL
String
name
Uniquely identifies thisCloud
instance among other instances inJenkins.clouds
.static Permission
PROVISION
Permission constant to control mutation operations onCloud
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static DescriptorExtensionList<Cloud,Descriptor<Cloud>>
all()
Returns all the registeredCloud
descriptors.boolean
canProvision(Label label)
Deprecated.UsecanProvision(CloudState)
instead.boolean
canProvision(Cloud.CloudState state)
Returns true if this cloud is capable of provisioning new nodes for the given label.ACL
getACL()
Obtains the ACL associated with this object.Descriptor<Cloud>
getDescriptor()
Gets the descriptor for this instance.String
getDisplayName()
String
getSearchUrl()
Returns the URL of this item relative to the parentSearchItem
.String
getUrl()
Get URL of the cloud.Collection<NodeProvisioner.PlannedNode>
provision(Label label, int excessWorkload)
Deprecated.Useprovision(CloudState, int)
instead.Collection<NodeProvisioner.PlannedNode>
provision(Cloud.CloudState state, int excessWorkload)
Provisions newNode
s from this cloud.static void
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
-
name
public final String name
Uniquely identifies thisCloud
instance among other instances inJenkins.clouds
. This is expected to be short ID-like string that does not contain any character unsafe as variable name or URL path token.
-
ALL
@Deprecated public static final DescriptorList<Cloud> ALL
All registeredCloud
implementations.
-
PROVISION
public static final Permission PROVISION
Permission constant to control mutation operations onCloud
. This includes provisioning a new node, as well as removing it.
-
-
Constructor Detail
-
Cloud
protected Cloud(String name)
-
-
Method Detail
-
getDisplayName
public String getDisplayName()
- Specified by:
getDisplayName
in interfaceModelObject
-
getUrl
@NonNull public String getUrl()
Get URL of the cloud.- Returns:
- Jenkins relative URL.
- Since:
- 2.64
-
getSearchUrl
@NonNull public String getSearchUrl()
Description copied from interface:SearchItem
Returns the URL of this item relative to the parentSearchItem
.- Specified by:
getSearchUrl
in interfaceSearchItem
- Returns:
- URL like "foo" or "foo/bar". The path can end with '/'. The path that starts with '/' will be interpreted as the absolute path (within the context path of Jenkins.)
-
getACL
public ACL getACL()
Description copied from interface:AccessControlled
Obtains the ACL associated with this object.- Specified by:
getACL
in interfaceAccessControlled
- Returns:
- never null.
-
provision
@Deprecated public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload)
Deprecated.Useprovision(CloudState, int)
instead.Provisions newNode
s from this cloud.NodeProvisioner
performs a trend analysis on the load, and when it determines that it really needs to bring up additional nodes, this method is invoked.The implementation of this method asynchronously starts node provisioning.
- Parameters:
label
- The label that indicates what kind of nodes are needed now. Newly launched node needs to have this label. Only thoseLabel
s that this instance returned true from thecanProvision(Label)
method will be passed here. This parameter is null if Hudson needs to provision a newNode
for jobs that don't have any tie to any label.excessWorkload
- Number of total executors needed to meet the current demand. Always ≥ 1. For example, if this is 3, the implementation should launch 3 agents with 1 executor each, or 1 agent with 3 executors, etc.- Returns:
NodeProvisioner.PlannedNode
s that represent asynchronousNode
provisioning operations. Can be empty but must not be null.NodeProvisioner
will be responsible for adding the resultingNode
s into Hudson viaJenkins.addNode(Node)
, so aCloud
implementation just needs to returnNodeProvisioner.PlannedNode
s that each contain an object that implementsFuture
. When theFuture
has completed its work,Future.get()
will be called to obtain the provisionedNode
object.
-
provision
public Collection<NodeProvisioner.PlannedNode> provision(Cloud.CloudState state, int excessWorkload)
Provisions newNode
s from this cloud.NodeProvisioner
performs a trend analysis on the load, and when it determines that it really needs to bring up additional nodes, this method is invoked.The implementation of this method asynchronously starts node provisioning.
- Parameters:
state
- the current state.excessWorkload
- Number of total executors needed to meet the current demand. Always ≥ 1. For example, if this is 3, the implementation should launch 3 agents with 1 executor each, or 1 agent with 3 executors, etc.- Returns:
NodeProvisioner.PlannedNode
s that represent asynchronousNode
provisioning operations. Can be empty but must not be null.NodeProvisioner
will be responsible for adding the resultingNode
s into Hudson viaJenkins.addNode(Node)
, so aCloud
implementation just needs to returnNodeProvisioner.PlannedNode
s that each contain an object that implementsFuture
. When theFuture
has completed its work,Future.get()
will be called to obtain the provisionedNode
object.
-
canProvision
@Deprecated public boolean canProvision(Label label)
Deprecated.UsecanProvision(CloudState)
instead.Returns true if this cloud is capable of provisioning new nodes for the given label.
-
canProvision
public boolean canProvision(Cloud.CloudState state)
Returns true if this cloud is capable of provisioning new nodes for the given label.
-
getDescriptor
public Descriptor<Cloud> getDescriptor()
Description copied from interface:Describable
Gets the descriptor for this instance.Descriptor
is a singleton for every concreteDescribable
implementation, so ifa.getClass() == b.getClass()
then by defaulta.getDescriptor() == b.getDescriptor()
as well. (In rare cases a single implementation class may be used for instances with distinct descriptors.)- Specified by:
getDescriptor
in interfaceDescribable<Cloud>
-
all
public static DescriptorExtensionList<Cloud,Descriptor<Cloud>> all()
Returns all the registeredCloud
descriptors.
-
registerPermissions
@Initializer(before=SYSTEM_CONFIG_LOADED) @Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public static void registerPermissions()
-
-