Class HostSelectionOptions

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

public final class HostSelectionOptions extends Object
Optional refinements for automatic host selection (see VSphereHostSelection), already resolved from cloud-level defaults and call-site overrides, so VSphere only has to apply them.
  • Field Details

  • Constructor Details

    • HostSelectionOptions

      public HostSelectionOptions(boolean requireCores, boolean requireMemory)
    • HostSelectionOptions

      public HostSelectionOptions(boolean requireCores, boolean requireMemory, boolean requireAvailableMemory)
  • Method Details

    • withVmSize

      public HostSelectionOptions withVmSize(@CheckForNull Integer vmCpus, @CheckForNull Long vmMemoryMB)
      Same options, but telling the host size checks to compare against this vCPU count and memory size (null: unknown, use the source VM's) instead of the source VM's own - for VMs that are known to be resized right after being cloned.
    • withWeights

      public HostSelectionOptions withWeights(@CheckForNull HostWeights weights)
      Same options, ranking the candidate hosts with these weights.
    • withLimits

      public HostSelectionOptions withLimits(@CheckForNull HostLimits limits)
      Same options, keeping hosts with less free resources than these limits off the candidate list.
    • withWaitSeconds

      public HostSelectionOptions withWaitSeconds(long waitSeconds)
      Same options, but if the limits (or nothing else) leave no host, wait up to this many seconds for one to free up: 0 does not wait, a negative number (VSphereHostSelection.WAIT_FOREVER) waits for as long as it takes.
    • withWaitListener

      public HostSelectionOptions withWaitListener(@CheckForNull HostSelectionOptions.Listener waitListener, boolean ignoreErrors)
      Same options, telling this listener whenever no host is available at the moment, right after that is logged. For a pipeline's hostSelectionWaitNotification; it only lives as long as the call. If the listener throws, the clone/deploy fails, unless ignoreErrors, when that is only logged.
    • withScoreDeviation

      public HostSelectionOptions withScoreDeviation(double scoreDeviation)
      Same options, choosing at random among the hosts scoring within this fraction (0..1) of the best one; a negative number always takes the single top host.
    • withFolderFollowsHost

      public HostSelectionOptions withFolderFollowsHost(boolean folderFollowsHost)
      Same options, but if no folder is given for the clone, put it in the folder of its source with the source's host name replaced by the name of the host chosen for the clone (see HostFolderPath), if there is such a folder.
    • isFolderFollowsHost

      public boolean isFolderFollowsHost()
      Whether the clone's default folder follows the host chosen for it.
    • withScoreDeviationOverride

      public HostSelectionOptions withScoreDeviationOverride(@CheckForNull Double scoreDeviation)
      As withScoreDeviation(double), but a null (not set at the call site) keeps the current value.
    • getScoreDeviation

      public double getScoreDeviation()
      How far below the best score a host may be and still be a candidate for the final random pick: 0 (the default) only equally scored ones, up to 1 for all that have a score; above 1: any available host at random, including those with no usage statistics; negative: always the single top host.
    • isPickAnyHostAtRandom

      public boolean isPickAnyHostAtRandom()
      True if the deviation is above 1: any available host is chosen at random, whatever its load.
    • parseScoreDeviation

      @CheckForNull public static Double parseScoreDeviation(@CheckForNull String value) throws VSphereException
      Parses a call site's own deviation, already variable-expanded: blank means not set (null, inherit the cloud's); else a number, where anything below 0 means always the top host and anything above 1 any available host at random.
      Throws:
      VSphereException - if it is not a number
    • isIgnoreWaitListenerErrors

      public boolean isIgnoreWaitListenerErrors()
      True if a failing listener is only logged, rather than failing the call.
    • getWaitListener

      @CheckForNull public HostSelectionOptions.Listener getWaitListener()
      Who to tell when no host is available at the moment, or null.
    • getLimits

      public HostLimits getLimits()
      Minimal free resources of a candidate host; HostLimits.NONE for no limits.
    • getWaitSeconds

      public long getWaitSeconds()
      How long to wait for a host within the limits: 0 not at all, negative forever.
    • parseWaitSeconds

      @CheckForNull public static Long parseWaitSeconds(@CheckForNull String value) throws VSphereException
      Parses a call site's own wait time, already variable-expanded: blank means not set (null, inherit the cloud's); a whole number of seconds, where a negative one or infinite/forever means to wait for as long as it takes.
      Throws:
      VSphereException - if it is none of these
    • getWeights

      public HostWeights getWeights()
      What "most available host" means; HostWeights.DEFAULT for the original ranking.
    • getVmCpus

      @CheckForNull public Integer getVmCpus()
      vCPU count the VM will end up with, if known ahead of cloning; else null.
    • getVmMemoryMB

      @CheckForNull public Long getVmMemoryMB()
      Memory size in MB the VM will end up with, if known ahead of cloning; else null.
    • isRequireCores

      public boolean isRequireCores()
      Only consider hosts with at least as many physical cores as the VM has vCPUs.
    • isRequireAvailableMemory

      public boolean isRequireAvailableMemory()
      Only consider hosts that currently have at least as much memory free as the VM is configured with, so the new VM does not push the host into swapping.
    • isRequireMemory

      public boolean isRequireMemory()
      Only consider hosts with at least as much physical RAM as the VM is configured with.
    • resolve

      public static boolean resolve(boolean cloudDefault, @CheckForNull Boolean override)
      Resolves a tri-state call-site setting against the cloud-wide default: null (never set at the call site) inherits cloudDefault; an explicit TRUE or FALSE wins outright.
    • triStateToString

      public static String triStateToString(@CheckForNull Boolean value)
      The form representation of a tri-state setting: "" for unset (inherit), else "true"/"false". Needed because Stapler binds an empty form value to an explicit false for a Boolean property, which would silently override the cloud's default instead of inheriting it.
    • triStateFromString

      @CheckForNull public static Boolean triStateFromString(@CheckForNull String value)
      Inverse of triStateToString(java.lang.Boolean): blank or anything unrecognised means unset (inherit).
    • triStateItems

      public static ListBoxModel triStateItems()
      Drop-down for a tri-state call-site setting: inherit the cloud's default, or force yes/no.