Class HostSelectionOptions
java.lang.Object
org.jenkinsci.plugins.vsphere.tools.HostSelectionOptions
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.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceTold that host selection found no host to use at the moment; seewithWaitListener(org.jenkinsci.plugins.vsphere.tools.HostSelectionOptions.Listener, boolean). -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final HostSelectionOptionsNo refinements: the original behaviour. -
Constructor Summary
ConstructorsConstructorDescriptionHostSelectionOptions(boolean requireCores, boolean requireMemory) HostSelectionOptions(boolean requireCores, boolean requireMemory, boolean requireAvailableMemory) -
Method Summary
Modifier and TypeMethodDescriptionMinimal free resources of a candidate host;HostLimits.NONEfor no limits.doubleHow 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.vCPU count the VM will end up with, if known ahead of cloning; else null.Memory size in MB the VM will end up with, if known ahead of cloning; else null.Who to tell when no host is available at the moment, or null.longHow long to wait for a host within the limits: 0 not at all, negative forever.What "most available host" means;HostWeights.DEFAULTfor the original ranking.booleanWhether the clone's default folder follows the host chosen for it.booleanTrue if a failinglisteneris only logged, rather than failing the call.booleanTrue if the deviation is above 1: any available host is chosen at random, whatever its load.booleanOnly 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.booleanOnly consider hosts with at least as many physical cores as the VM has vCPUs.booleanOnly consider hosts with at least as much physical RAM as the VM is configured with.static DoubleparseScoreDeviation(String value) 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.static LongparseWaitSeconds(String value) 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 orinfinite/forevermeans to wait for as long as it takes.static booleanResolves a tri-state call-site setting against the cloud-wide default:null(never set at the call site) inheritscloudDefault; an explicitTRUEorFALSEwins outright.static BooleantriStateFromString(String value) Inverse oftriStateToString(java.lang.Boolean): blank or anything unrecognised means unset (inherit).static ListBoxModelDrop-down for a tri-state call-site setting: inherit the cloud's default, or force yes/no.static StringtriStateToString(Boolean value) The form representation of a tri-state setting: "" for unset (inherit), else "true"/"false".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 (seeHostFolderPath), if there is such a folder.withLimits(HostLimits limits) Same options, keeping hosts with less free resources than these limits off the candidate list.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.withScoreDeviationOverride(Double scoreDeviation) AswithScoreDeviation(double), but a null (not set at the call site) keeps the current value.withVmSize(Integer vmCpus, 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.withWaitListener(HostSelectionOptions.Listener waitListener, boolean ignoreErrors) Same options, telling this listener whenever no host is available at the moment, right after that is logged.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.withWeights(HostWeights weights) Same options, ranking the candidate hosts with these weights.
-
Field Details
-
NONE
No refinements: the original behaviour.
-
-
Constructor Details
-
HostSelectionOptions
public HostSelectionOptions(boolean requireCores, boolean requireMemory) -
HostSelectionOptions
public HostSelectionOptions(boolean requireCores, boolean requireMemory, boolean requireAvailableMemory)
-
-
Method Details
-
withVmSize
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
Same options, ranking the candidate hosts with these weights. -
withLimits
Same options, keeping hosts with less free resources than these limits off the candidate list. -
withWaitSeconds
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'shostSelectionWaitNotification; it only lives as long as the call. If the listener throws, the clone/deploy fails, unlessignoreErrors, when that is only logged. -
withScoreDeviation
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
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 (seeHostFolderPath), if there is such a folder. -
isFolderFollowsHost
public boolean isFolderFollowsHost()Whether the clone's default folder follows the host chosen for it. -
withScoreDeviationOverride
AswithScoreDeviation(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 failinglisteneris only logged, rather than failing the call. -
getWaitListener
Who to tell when no host is available at the moment, or null. -
getLimits
Minimal free resources of a candidate host;HostLimits.NONEfor 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 orinfinite/forevermeans to wait for as long as it takes.- Throws:
VSphereException- if it is none of these
-
getWeights
What "most available host" means;HostWeights.DEFAULTfor the original ranking. -
getVmCpus
vCPU count the VM will end up with, if known ahead of cloning; else null. -
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
Resolves a tri-state call-site setting against the cloud-wide default:null(never set at the call site) inheritscloudDefault; an explicitTRUEorFALSEwins outright. -
triStateToString
The form representation of a tri-state setting: "" for unset (inherit), else "true"/"false". Needed because Stapler binds an empty form value to an explicitfalsefor aBooleanproperty, which would silently override the cloud's default instead of inheriting it. -
triStateFromString
Inverse oftriStateToString(java.lang.Boolean): blank or anything unrecognised means unset (inherit). -
triStateItems
Drop-down for a tri-state call-site setting: inherit the cloud's default, or force yes/no.
-