Package jenkins.plugins.jclouds.compute
Class JCloudsSlave
- java.lang.Object
-
- hudson.model.AbstractModelObject
-
- hudson.model.Node
-
- hudson.model.Slave
-
- hudson.slaves.AbstractCloudSlave
-
- jenkins.plugins.jclouds.compute.JCloudsSlave
-
- All Implemented Interfaces:
ExtensionPoint
,Describable<Node>
,ModelObject
,ReconfigurableDescribable<Node>
,Saveable
,SearchableModelObject
,SearchItem
,AccessControlled
,Serializable
,OnMaster
,org.jenkinsci.plugins.cloudstats.TrackedItem
public class JCloudsSlave extends AbstractCloudSlave implements org.jenkinsci.plugins.cloudstats.TrackedItem
Jenkins Slave node - managed by JClouds.- Author:
- Vijay Kiran
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
JCloudsSlave.JCloudsSlaveDescriptor
-
Nested classes/interfaces inherited from class hudson.model.Slave
Slave.JnlpJar, Slave.SlaveDescriptor
-
Nested classes/interfaces inherited from class hudson.model.Node
Node.InternalComputerListener, Node.Mode
-
Nested classes/interfaces inherited from interface hudson.ExtensionPoint
ExtensionPoint.LegacyInstancesAreScopedToHudson
-
-
Field Summary
Fields Modifier and Type Field Description boolean
stopOnTerminate
-
Fields inherited from class hudson.model.Node
holdOffLaunchUntilSave, SKIP_BUILD_CHECK_ON_FLYWEIGHTS
-
-
Constructor Summary
Constructors Constructor Description JCloudsSlave(String cloudName, String name, String nodeDescription, String remoteFS, String numExecutors, Node.Mode mode, String labelString, ComputerLauncher launcher, RetentionStrategy retentionStrategy, List<? extends NodeProperty<?>> nodeProperties, boolean stopOnTerminate, Integer overrideRetentionTime, String user, String password, String privateKey, boolean authSudo, String jvmOptions, boolean waitPhoneHome, int waitPhoneHomeTimeout, String credentialsId, String preferredAddress, boolean useJnlp, boolean jnlpProvisioning, String jnlpProvisioningNonce)
JCloudsSlave(String cloudName, String fsRoot, NodeMetadata metadata, String labelString, String description, String numExecutors, boolean stopOnTerminate, Integer overrideRetentionTime, String jvmOptions, boolean waitPhoneHome, int waitPhoneHomeTimeout, String credentialsId, Node.Mode mode, String preferredAddress, boolean useJnlp, boolean jnlpProvisioning, String jnlpProvisioningNonce)
Constructs a new slave from JCloud's NodeMetadataJCloudsSlave(org.jenkinsci.plugins.cloudstats.ProvisioningActivity.Id provisioningId, String cloudName, String fsRoot, NodeMetadata metadata, String labelString, String description, String numExecutors, boolean stopOnTerminate, Integer overrideRetentionTime, String jvmOptions, boolean waitPhoneHome, int waitPhoneHomeTimeout, String credentialsId, Node.Mode mode, String preferredAddress, boolean useJnlp, boolean jnlpProvisioning, String jnlpProvisioningNonce)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
_terminate(TaskListener listener)
Destroy the node.AbstractCloudComputer<JCloudsSlave>
createComputer()
String
getCloudName()
Get the JClouds profile identifier for the Cloud associated with this slave.LoginCredentials
getCredentials()
Get Jclouds LoginCredentials associated with this Slave.String
getCredentialsId()
org.jenkinsci.plugins.cloudstats.ProvisioningActivity.Id
getId()
boolean
getJnlpProvisioning()
String
getJnlpProvisioningNonce()
String
getJvmOptions()
Get Jclouds Custom JVM Options associated with this Slave.NodeMetadata
getNodeMetaData()
Get Jclouds NodeMetadata associated with this Slave.String
getPreferredAddress()
int
getRetentionTime()
Get the retention time for this slave, defaulting to the parent cloud's if not set.boolean
getUseJnlp()
String
handleJnlpProvisioning(String hash)
Handles JNLP provisioning request from slave.boolean
isPendingDelete()
boolean
isWaitPhoneHome()
void
publishJnlpMetaData()
Publishes JNLP metadata to the virtual machine.protected Object
readResolve()
void
setJnlpProvisioningNonce(String value)
void
setOverrideRetentionTime(Integer value)
void
setPendingDelete(boolean pendingDelete)
void
setWaitPhoneHome(boolean value)
void
waitForPhoneHome(PrintStream logger)
-
Methods inherited from class hudson.slaves.AbstractCloudSlave
terminate
-
Methods inherited from class hudson.model.Slave
createLauncher, equals, getClockDifferenceCallable, getComputer, getDescriptor, getLabelString, getLauncher, getMode, getNodeDescription, getNodeName, getNodeProperties, getNumExecutors, getRemoteFS, getRetentionStrategy, getRootPath, getUserId, getWorkspaceFor, getWorkspaceRoot, hashCode, setLabelString, setLauncher, setMode, setNodeDescription, setNodeName, setNodeProperties, setNumExecutors, setRetentionStrategy, setUserId, toString
-
Methods inherited from class hudson.model.Node
canTake, canTake, createPath, getACL, getAssignedLabels, getChannel, getClockDifference, getDisplayName, getFileSystemProvisioner, getLabelCloud, getNodeProperty, getNodeProperty, getNodePropertyDescriptors, getSearchUrl, getSelfLabel, isAcceptingTasks, isHoldOffLaunchUntilSave, reconfigure, save, toComputer
-
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, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface hudson.security.AccessControlled
checkAnyPermission, checkPermission, hasAnyPermission, hasPermission, hasPermission, hasPermission2
-
-
-
-
Constructor Detail
-
JCloudsSlave
@DataBoundConstructor public JCloudsSlave(String cloudName, String name, String nodeDescription, String remoteFS, String numExecutors, Node.Mode mode, String labelString, ComputerLauncher launcher, RetentionStrategy retentionStrategy, List<? extends NodeProperty<?>> nodeProperties, boolean stopOnTerminate, Integer overrideRetentionTime, String user, String password, String privateKey, boolean authSudo, String jvmOptions, boolean waitPhoneHome, int waitPhoneHomeTimeout, String credentialsId, String preferredAddress, boolean useJnlp, boolean jnlpProvisioning, String jnlpProvisioningNonce) throws Descriptor.FormException, IOException
- Throws:
Descriptor.FormException
IOException
-
JCloudsSlave
public JCloudsSlave(String cloudName, String fsRoot, NodeMetadata metadata, String labelString, String description, String numExecutors, boolean stopOnTerminate, Integer overrideRetentionTime, String jvmOptions, boolean waitPhoneHome, int waitPhoneHomeTimeout, String credentialsId, Node.Mode mode, String preferredAddress, boolean useJnlp, boolean jnlpProvisioning, String jnlpProvisioningNonce) throws IOException, Descriptor.FormException
Constructs a new slave from JCloud's NodeMetadata- Parameters:
cloudName
- - the name of the cloud that's provisioning this slave.fsRoot
- - Location of Jenkins root (homedir) on the slave.metadata
- - JCloudsNodeMetadatalabelString
- - Label(s) for this slave.description
- - Description of this slave.numExecutors
- - Number of executors for this slave.stopOnTerminate
- - iftrue
, suspend the slave rather than terminating it.overrideRetentionTime
- - Retention time to use specifically for this slave, overriding the cloud default.jvmOptions
- - Custom options for lauching the JVM on the slave.waitPhoneHome
- - iftrue
, delay initial SSH connect until slave has "phoned home" back to jenkins.waitPhoneHomeTimeout
- - Timeout in minutes util giving up waiting for the "phone home" POST.credentialsId
- - Id of the credentials in Jenkin's global credentials database.mode
- - Jenkins usage mode for this nodepreferredAddress
- - The preferred Address expression to connect touseJnlp
- - iftrue
, the final ssh connection attempt will be skipped.jnlpProvisioning
- - iftrue
, enables JNLP provisioning.jnlpProvisioningNonce
- - nonce, used to authenticate provisioning requests via JnlpProvisionWebHook.- Throws:
IOException
- if an error occurs.Descriptor.FormException
- if the form does not validate.
-
JCloudsSlave
public JCloudsSlave(org.jenkinsci.plugins.cloudstats.ProvisioningActivity.Id provisioningId, String cloudName, String fsRoot, NodeMetadata metadata, String labelString, String description, String numExecutors, boolean stopOnTerminate, Integer overrideRetentionTime, String jvmOptions, boolean waitPhoneHome, int waitPhoneHomeTimeout, String credentialsId, Node.Mode mode, String preferredAddress, boolean useJnlp, boolean jnlpProvisioning, String jnlpProvisioningNonce) throws IOException, Descriptor.FormException
- Throws:
IOException
Descriptor.FormException
-
-
Method Detail
-
readResolve
protected Object readResolve()
- Overrides:
readResolve
in classSlave
-
handleJnlpProvisioning
public String handleJnlpProvisioning(@NonNull String hash)
Handles JNLP provisioning request from slave.- Parameters:
hash
- The authentication hash, provided in the client's request- Returns:
- The parameters for establishing a Jnlp connection as JSON response. An empty string, if the provided hash is incorrect.
-
publishJnlpMetaData
public void publishJnlpMetaData()
Publishes JNLP metadata to the virtual machine.
-
getNodeMetaData
public NodeMetadata getNodeMetaData()
Get Jclouds NodeMetadata associated with this Slave.- Returns:
NodeMetadata
-
getJvmOptions
public String getJvmOptions()
Get Jclouds Custom JVM Options associated with this Slave.- Returns:
- jvmOptions
-
getPreferredAddress
public String getPreferredAddress()
-
getJnlpProvisioning
public boolean getJnlpProvisioning()
-
getUseJnlp
public boolean getUseJnlp()
-
getJnlpProvisioningNonce
public String getJnlpProvisioningNonce()
-
getCredentials
public LoginCredentials getCredentials()
Get Jclouds LoginCredentials associated with this Slave.If Jclouds doesn't provide credentials, use stored ones.
- Returns:
LoginCredentials
-
setOverrideRetentionTime
public void setOverrideRetentionTime(Integer value)
-
getRetentionTime
public int getRetentionTime()
Get the retention time for this slave, defaulting to the parent cloud's if not set. Sometime parent cloud cannot be determined (returns Null as I see), in which case this method will return default value set in CloudInstanceDefaults.- Returns:
- overrideTime
- See Also:
CloudInstanceDefaults.DEFAULT_INSTANCE_RETENTION_TIME_IN_MINUTES
-
getCloudName
public String getCloudName()
Get the JClouds profile identifier for the Cloud associated with this slave.- Returns:
- cloudName
-
isPendingDelete
public boolean isPendingDelete()
-
setPendingDelete
public void setPendingDelete(boolean pendingDelete)
-
isWaitPhoneHome
public boolean isWaitPhoneHome()
-
setWaitPhoneHome
public void setWaitPhoneHome(boolean value)
-
setJnlpProvisioningNonce
public void setJnlpProvisioningNonce(String value)
-
getCredentialsId
public String getCredentialsId()
-
createComputer
public AbstractCloudComputer<JCloudsSlave> createComputer()
- Specified by:
createComputer
in classAbstractCloudSlave
-
getId
@Nullable public org.jenkinsci.plugins.cloudstats.ProvisioningActivity.Id getId()
- Specified by:
getId
in interfaceorg.jenkinsci.plugins.cloudstats.TrackedItem
-
_terminate
protected void _terminate(TaskListener listener) throws IOException, InterruptedException
Destroy the node. If stopOnTerminate istrue
, callsComputeService.suspendNode(java.lang.String)
, otherwiseComputeService.destroyNode(java.lang.String)
.- Specified by:
_terminate
in classAbstractCloudSlave
- Throws:
IOException
InterruptedException
-
waitForPhoneHome
public void waitForPhoneHome(PrintStream logger) throws InterruptedException
- Throws:
InterruptedException
-
-