Class KubeVirtTemplate

java.lang.Object
io.jenkins.plugins.kubevirt.KubeVirtTemplate
All Implemented Interfaces:
Describable<KubeVirtTemplate>, Saveable

public class KubeVirtTemplate extends Object implements Describable<KubeVirtTemplate>, Saveable
KubeVirt VM Template configuration. Defines the settings for provisioning virtual machine agents.
  • Constructor Details

  • Method Details

    • getName

      public String getName()
    • getLabels

      public String getLabels()
    • getDiskSource

      public KubeVirtDiskSource getDiskSource()
    • getDiskSourceType

      public String getDiskSourceType()
    • isContainerDisk

      public boolean isContainerDisk()
    • isDataSource

      public boolean isDataSource()
    • isDataSourceImport

      public boolean isDataSourceImport()
    • getImage

      public String getImage()
    • getDataSourceNamespace

      public String getDataSourceNamespace()
    • getDataSourceName

      public String getDataSourceName()
    • getDiskSize

      public String getDiskSize()
    • getAccessMode

      public String getAccessMode()
    • getStorageClass

      @CheckForNull public String getStorageClass()
      Returns the Kubernetes storage class used for VM disks, or null to use the cluster default.
    • setStorageClass

      @DataBoundSetter public void setStorageClass(@CheckForNull String storageClass)
      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

      public String getCpu()
    • getMemory

      public String getMemory()
    • getCpuLimit

      public String getCpuLimit()
    • getMemoryLimit

      public String getMemoryLimit()
    • getConnectionType

      public String getConnectionType()
    • isDirectSsh

      public boolean isDirectSsh()
    • isVirtctlSsh

      public boolean isVirtctlSsh()
    • getSshCredentialsId

      public String getSshCredentialsId()
    • getSshPort

      public int getSshPort()
    • getRemoteFS

      public String getRemoteFS()
    • getJavaPath

      public String getJavaPath()
    • getCloudInitId

      @CheckForNull public String getCloudInitId()
    • getCloudInitContent

      @CheckForNull public String 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. Returns KubeVirtConfiguration.UNLIMITED_CAPACITY if 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:
      -1 for unlimited retries, 0 for no retries, or a positive retry count
    • hasUnlimitedProvisionRetries

      public boolean hasUnlimitedProvisionRetries()
      Returns:
      true if 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

      public boolean canProvision(Label label)
    • getId

      @NonNull public String 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

      public 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:
      IOException
      jakarta.servlet.ServletException
      Descriptor.FormException
    • save

      public void save()
      Empty implementation of Saveable interface.
      Specified by:
      save in interface Saveable
    • getDescriptor

      public Descriptor<KubeVirtTemplate> getDescriptor()
      Specified by:
      getDescriptor in interface Describable<KubeVirtTemplate>
    • readResolve

      protected Object readResolve()