Package io.jenkins.plugins.kubevirt
Class KubeVirtTemplate
java.lang.Object
io.jenkins.plugins.kubevirt.KubeVirtTemplate
- All Implemented Interfaces:
Describable<KubeVirtTemplate>,Saveable
KubeVirt VM Template configuration.
Defines the settings for provisioning virtual machine agents.
-
Nested Class Summary
Nested Classes -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionKubeVirtTemplate(String id, String name, String labels, KubeVirtDiskSource diskSource, String diskSize, String accessMode, String cpu, String memory, String cpuLimit, String memoryLimit, String connectionType, String sshCredentialsId, String sshPort, String remoteFS, String javaPath, String cloudInitId, String idleMinutes, String instanceCap, String provisioningTimeoutMinutes, String maxProvisionAttempts, boolean injectTmpDiskConfig, String orphanGracePeriodMinutes, String cloudInitWaitSeconds) KubeVirtTemplate(String id, String name, String labels, String diskSourceType, String image, String dataSourceNamespace, String dataSourceName, String diskSize, String accessMode, String cpu, String memory, String cpuLimit, String memoryLimit, String connectionType, String sshCredentialsId, String sshPort, String remoteFS, String javaPath, String cloudInitId, String idleMinutes, String instanceCap, String provisioningTimeoutMinutes, String maxProvisionAttempts, boolean injectTmpDiskConfig, String orphanGracePeriodMinutes, String cloudInitWaitSeconds) -
Method Summary
Modifier and TypeMethodDescriptionbooleancanProvision(Label label) org.kohsuke.stapler.HttpResponsedoConfigSubmit(org.kohsuke.stapler.StaplerRequest2 req, VMTemplateGroup owner) Saves the template configuration via the UI.org.kohsuke.stapler.HttpResponsedoDoDelete(VMTemplateGroup owner) Deletes the template via the UI.intConsecutive failures allowed before cancelling queued builds (retries + 1).Resolves and returns the cloud-init content from the configured config file.intGets the maximum time to wait for cloud-init to complete SSH setup.getCpu()intGets the effective instance cap for provisioning logic.getId()Gets the unique ID of this template.intGets the idle timeout in minutes before the agent is terminated.getImage()intGets the instance cap as configured (for UI binding).Gets the manage permission for this template.intGets the number of extra VM provisioning tries after the first failure.getName()intGets the orphan grace period in minutes.intGets the VM provisioning timeout in minutes.intReturns the Kubernetes storage class used for VM disks, ornullto use the cluster default.booleanChecks if the current user has permission to manage templates.booleanbooleanbooleanbooleanbooleanbooleanGets whether to inject /tmp disk configuration into cloud-init.booleanprotected Objectvoidsave()Empty implementation of Saveable interface.voidsetStorageClass(String storageClass) Sets the Kubernetes storage class used for VM disks.
-
Constructor Details
-
KubeVirtTemplate
public KubeVirtTemplate(String id, String name, String labels, String diskSourceType, String image, String dataSourceNamespace, String dataSourceName, String diskSize, String accessMode, String cpu, String memory, String cpuLimit, String memoryLimit, String connectionType, String sshCredentialsId, String sshPort, String remoteFS, String javaPath, String cloudInitId, String idleMinutes, String instanceCap, String provisioningTimeoutMinutes, String maxProvisionAttempts, boolean injectTmpDiskConfig, String orphanGracePeriodMinutes, String cloudInitWaitSeconds) -
KubeVirtTemplate
@DataBoundConstructor public KubeVirtTemplate(String id, String name, String labels, KubeVirtDiskSource diskSource, String diskSize, String accessMode, String cpu, String memory, String cpuLimit, String memoryLimit, String connectionType, String sshCredentialsId, String sshPort, String remoteFS, String javaPath, String cloudInitId, String idleMinutes, String instanceCap, String provisioningTimeoutMinutes, String maxProvisionAttempts, boolean injectTmpDiskConfig, String orphanGracePeriodMinutes, String cloudInitWaitSeconds)
-
-
Method Details
-
getName
-
getLabels
-
getDiskSource
-
getDiskSourceType
-
isContainerDisk
public boolean isContainerDisk() -
isDataSource
public boolean isDataSource() -
isDataSourceImport
public boolean isDataSourceImport() -
getImage
-
getDataSourceNamespace
-
getDataSourceName
-
getDiskSize
-
getAccessMode
-
getStorageClass
Returns the Kubernetes storage class used for VM disks, ornullto use the cluster default. -
setStorageClass
Sets the Kubernetes storage class used for VM disks.Leading and trailing whitespace is removed so UI and JCasC values are normalized consistently. An empty value preserves the existing cluster-default behavior.
- Parameters:
storageClass- Kubernetes storage class name, or an empty value to use the cluster default
-
getCpu
-
getMemory
-
getCpuLimit
-
getMemoryLimit
-
getConnectionType
-
isDirectSsh
public boolean isDirectSsh() -
isVirtctlSsh
public boolean isVirtctlSsh() -
getSshCredentialsId
-
getSshPort
public int getSshPort() -
getRemoteFS
-
getJavaPath
-
getCloudInitId
-
getCloudInitContent
Resolves and returns the cloud-init content from the configured config file.- Returns:
- The cloud-init content, or null if not configured or empty
-
getIdleMinutes
public int getIdleMinutes()Gets the idle timeout in minutes before the agent is terminated. A value of 0 means the VM will be disposed immediately after the first build completes. Returns the default value (10 minutes) for old configurations that don't have this field.- Returns:
- The idle timeout in minutes (0 or greater)
-
getInstanceCap
public int getInstanceCap()Gets the instance cap as configured (for UI binding). Returns the raw value: 0 means unlimited, positive number means that limit.- Returns:
- The configured instance cap value
-
getEffectiveInstanceCap
public int getEffectiveInstanceCap()Gets the effective instance cap for provisioning logic. ReturnsKubeVirtConfiguration.UNLIMITED_CAPACITYif set to 0 (unlimited).- Returns:
- The effective instance cap, or UNLIMITED_CAPACITY if no limit
-
getProvisioningTimeoutMinutes
public int getProvisioningTimeoutMinutes()Gets the VM provisioning timeout in minutes. This is the maximum time to wait for the VM to be ready and get an IP address. Returns the default value (15 minutes) for old configurations that don't have this field.- Returns:
- The provisioning timeout in minutes (1 or greater)
-
getMaxProvisionAttempts
public int getMaxProvisionAttempts()Gets the number of extra VM provisioning tries after the first failure. Queued builds waiting for this template's label are cancelled once the retry budget is exhausted.- Returns:
-1for unlimited retries,0for no retries, or a positive retry count
-
hasUnlimitedProvisionRetries
public boolean hasUnlimitedProvisionRetries()- Returns:
trueif provisioning may be retried indefinitely
-
getAllowedProvisionFailures
public int getAllowedProvisionFailures()Consecutive failures allowed before cancelling queued builds (retries + 1). Only meaningful when retries are limited.- Returns:
- the failure budget, at least 1 when retries are limited
-
getCloudInitWaitSeconds
public int getCloudInitWaitSeconds()Gets the maximum time to wait for cloud-init to complete SSH setup. Used by virtctl SSH to poll for sshd before attempting agent connection.- Returns:
- The cloud-init wait timeout in seconds (1 or greater)
-
isInjectTmpDiskConfig
public boolean isInjectTmpDiskConfig()Gets whether to inject /tmp disk configuration into cloud-init. When enabled, a 10Gi ephemeral disk is attached and mounted at /tmp via cloud-init runcmd. This provides faster /tmp storage for build operations.- Returns:
- true if /tmp disk configuration should be injected
-
getOrphanGracePeriodMinutes
public int getOrphanGracePeriodMinutes()Gets the orphan grace period in minutes. A VM without a registered Jenkins agent will not be considered orphaned until it has existed for at least this many minutes. This allows time for VM boot, cloud-init, and agent registration.- Returns:
- The orphan grace period in minutes (1 or greater)
-
canProvision
-
getId
Gets the unique ID of this template.- Returns:
- the template ID
-
hasManagePermission
@Restricted(org.kohsuke.accmod.restrictions.DoNotUse.class) public boolean hasManagePermission()Checks if the current user has permission to manage templates.- Returns:
- true if the user has manage permission
-
getManagePermission
Gets the manage permission for this template.- Returns:
- the permission required to manage templates
-
doDoDelete
@POST public org.kohsuke.stapler.HttpResponse doDoDelete(@AncestorInPath VMTemplateGroup owner) throws IOException Deletes the template via the UI.- Throws:
IOException
-
doConfigSubmit
@POST public org.kohsuke.stapler.HttpResponse doConfigSubmit(org.kohsuke.stapler.StaplerRequest2 req, @AncestorInPath VMTemplateGroup owner) throws IOException, jakarta.servlet.ServletException, Descriptor.FormException Saves the template configuration via the UI.- Throws:
IOExceptionjakarta.servlet.ServletExceptionDescriptor.FormException
-
save
public void save()Empty implementation of Saveable interface. -
getDescriptor
- Specified by:
getDescriptorin interfaceDescribable<KubeVirtTemplate>
-
readResolve
-