Class VmSize

java.lang.Object
org.jenkinsci.plugins.vsphere.tools.VmSize

public final class VmSize extends Object
The optional CPU and memory settings a VM is to be created with, in the same operation that creates it, instead of being reconfigured afterwards. The properties mean the same as those of the ReconfigureCpu and ReconfigureMemory steps; a null one keeps the source's.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final VmSize
    Nothing set: the VM keeps the source's CPU and memory configuration.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    applyTo(com.vmware.vim25.VirtualMachineConfigSpec spec)
    Puts the settings that are set into a configuration spec, leaving the others untouched.
    For logging: what the VM will be created with.
    Cores per socket, or null to keep the source's.
    Number of vCPUs (as ReconfigureCpu's cpuCores), or null to keep the source's.
    CPU reservation in MHz (as ReconfigureCpu's cpuLimitMHz), or null for none.
    Memory size in MB (as ReconfigureMemory's memorySize), or null to keep the source's.
    boolean
     
    static VmSize
    of(String cpuCores, String coresPerSocket, String cpuLimitMHz, String memorySize)
    Builds a size from the (already variable-expanded) text of the four settings; each may be null or blank, meaning "keep the source's".
    static Integer
    Parses an optional, already variable-expanded positive whole number.
    void
    validateAgainstSource(Integer sourceCpus, Integer sourceCoresPerSocket)
    vCenter refuses a vCPU count that is not a multiple of the cores per socket.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • NONE

      public static final VmSize NONE
      Nothing set: the VM keeps the source's CPU and memory configuration.
  • Method Details

    • of

      public static VmSize of(@CheckForNull String cpuCores, @CheckForNull String coresPerSocket, @CheckForNull String cpuLimitMHz, @CheckForNull String memorySize) throws VSphereException
      Builds a size from the (already variable-expanded) text of the four settings; each may be null or blank, meaning "keep the source's".
      Throws:
      VSphereException - if a setting is given but is not a positive whole number
    • parseOptionalPositive

      @CheckForNull public static Integer parseOptionalPositive(String what, @CheckForNull String value) throws VSphereException
      Parses an optional, already variable-expanded positive whole number.
      Parameters:
      what - name of the setting for the error message
      Returns:
      the number, or null if value is null or blank (meaning: keep the source's)
      Throws:
      VSphereException - if it is set but is not a positive whole number
    • getCpuCores

      @CheckForNull public Integer getCpuCores()
      Number of vCPUs (as ReconfigureCpu's cpuCores), or null to keep the source's.
    • getCoresPerSocket

      @CheckForNull public Integer getCoresPerSocket()
      Cores per socket, or null to keep the source's.
    • getCpuLimitMHz

      @CheckForNull public Integer getCpuLimitMHz()
      CPU reservation in MHz (as ReconfigureCpu's cpuLimitMHz), or null for none.
    • getMemorySize

      @CheckForNull public Integer getMemorySize()
      Memory size in MB (as ReconfigureMemory's memorySize), or null to keep the source's.
    • isEmpty

      public boolean isEmpty()
    • validateAgainstSource

      public void validateAgainstSource(@CheckForNull Integer sourceCpus, @CheckForNull Integer sourceCoresPerSocket) throws VSphereException
      vCenter refuses a vCPU count that is not a multiple of the cores per socket. Checks that with what the VM will end up with: the settings here, else the source's.
      Throws:
      VSphereException - if they do not fit together
    • applyTo

      public void applyTo(com.vmware.vim25.VirtualMachineConfigSpec spec)
      Puts the settings that are set into a configuration spec, leaving the others untouched.
    • describe

      public String describe()
      For logging: what the VM will be created with.