Class vSphereCloud

All Implemented Interfaces:
ExtensionPoint, Describable<Cloud>, ModelObject, SearchableModelObject, SearchItem, AccessControlled, ModelObjectWithContextMenu

public class vSphereCloud extends Cloud
Author:
Admin
  • Field Details

    • DEFAULT_CLOUD_NAME

      public static final String DEFAULT_CLOUD_NAME
      Name used by every cloud of this type before names were made unique, and the fallback when no usable description exists.
      See Also:
  • Constructor Details

  • Method Details

    • Log

      public static void Log(String format, Object... args)
      Logs an Level.INFO message (created with String.format(String, Object...)).
    • Log

      public static void Log(Throwable ex, String format, Object... args)
      Logs an Level.SEVERE message (created with String.format(String, Object...)) and a Throwable with stacktrace.
    • Log

      public static void Log(TaskListener listener, String format, Object... args)
      Logs a Level.INFO message (created with String.format(String, Object...)).
    • Log

      public static void Log(TaskListener listener, Throwable ex, String format, Object... args)
      Logs a Level.SEVERE message (created with String.format(String, Object...)) and a Throwable (with stacktrace).
    • Log

      public static void Log(Slave slave, String format, Object... args)
      Logs a Level.INFO message (created with String.format(String, Object...)), prefixed by the Slave name.
    • Log

      public static void Log(Slave slave, Throwable ex, String format, Object... args)
      Logs a Level.SEVERE message (created with String.format(String, Object...)) and a Throwable (with stacktrace), prefixed by the Slave name.
    • Log

      public static void Log(Slave slave, TaskListener listener, String format, Object... args)
      Logs a Level.INFO message (created with String.format(String, Object...)), prefixed by the Slave name.
    • Log

      public static void Log(Slave slave, TaskListener listener, Throwable ex, String format, Object... args)
      Logs a Level.SEVERE message (created with String.format(String, Object...)) and a Throwable (with stacktrace), prefixed by the Slave name.
    • Log

      public static void Log(SlaveComputer slave, TaskListener listener, String format, Object... args)
      Logs a Level.INFO message (created with String.format(String, Object...)), prefixed by the SlaveComputer name.
    • Log

      public static void Log(SlaveComputer slave, TaskListener listener, Throwable ex, String format, Object... args)
      Logs a Level.SEVERE message (created with String.format(String, Object...)) and a Throwable (with stacktrace), prefixed by the SlaveComputer name.
    • deriveCloudName

      public static String deriveCloudName(@CheckForNull String description, Set<String> taken)
      Derives a URL/ID-safe Cloud.name from a cloud's description, unique among taken (the result is not added to it): unsafe characters become '-', and "-2", "-3", ... is appended on collision. Falls back to DEFAULT_CLOUD_NAME for an empty description.
    • setName

      @DataBoundSetter public void setName(@CheckForNull String name)
      Sets the Jenkins-level cloud ID (the name in config.xml and in /manage/cloud/<name>/). This is an implementation detail: the config form shows it read-only and only submits it back so that reconfiguring a cloud keeps its identity. Blank values are ignored, leaving the name derived from the description.
    • getDisplayName

      public String getDisplayName()
      Shown in the list of clouds: the type, then the user-chosen name of this cloud.
      Specified by:
      getDisplayName in interface ModelObject
      Overrides:
      getDisplayName in class Cloud
    • readResolve

      public Object readResolve() throws IOException
      Throws:
      IOException
    • getMaxOnlineSlaves

      public int getMaxOnlineSlaves()
    • getInstanceCap

      public int getInstanceCap()
    • getUseNoDelayProvisioner

      public boolean getUseNoDelayProvisioner()
    • getTemplates

      public List<? extends vSphereCloudSlaveTemplate> getTemplates()
    • isUseConnectionPool

      public boolean isUseConnectionPool()
    • setUseConnectionPool

      @DataBoundSetter public void setUseConnectionPool(boolean useConnectionPool)
    • getPoolHealthCheckIntervalSecs

      public int getPoolHealthCheckIntervalSecs()
    • setPoolHealthCheckIntervalSecs

      @DataBoundSetter public void setPoolHealthCheckIntervalSecs(int poolHealthCheckIntervalSecs)
    • getSessionMaxAgeSecs

      public int getSessionMaxAgeSecs()
    • setSessionMaxAgeSecs

      @DataBoundSetter public void setSessionMaxAgeSecs(int sessionMaxAgeSecs)
    • getSessionMaxUses

      public int getSessionMaxUses()
    • setSessionMaxUses

      @DataBoundSetter public void setSessionMaxUses(int sessionMaxUses)
    • getPoolIdleTimeoutSecs

      public int getPoolIdleTimeoutSecs()
    • setPoolIdleTimeoutSecs

      @DataBoundSetter public void setPoolIdleTimeoutSecs(int poolIdleTimeoutSecs)
    • isMaintenanceMode

      public boolean isMaintenanceMode()
    • setMaintenanceMode

      @DataBoundSetter public void setMaintenanceMode(boolean maintenanceMode)
    • getMaintenanceMessage

      public String getMaintenanceMessage()
    • setMaintenanceMessage

      @DataBoundSetter public void setMaintenanceMessage(String maintenanceMessage)
    • getHostSelectionMode

      public String getHostSelectionMode()
      Default hostSelectionMode for templates/build-steps that leave their own blank.
    • setHostSelectionMode

      @DataBoundSetter public void setHostSelectionMode(String hostSelectionMode)
    • getHostSelectionCandidates

      public Set<String> getHostSelectionCandidates()
      Default hostSelectionCandidates for templates/build-steps that leave their own unset.
    • setHostSelectionCandidates

      @DataBoundSetter public void setHostSelectionCandidates(Collection<String> hostSelectionCandidates)
    • hostSelectionOptions

      public static HostSelectionOptions hostSelectionOptions(@CheckForNull vSphereCloud cloud, @CheckForNull Boolean requireCores, @CheckForNull Boolean requireMemory)
      Resolves the host selection refinements for one call site: the cloud's own defaults (or none, if there is no cloud), overridden by whatever the call site set explicitly.
    • hostSelectionOptions

      public static HostSelectionOptions hostSelectionOptions(@CheckForNull vSphereCloud cloud, @CheckForNull Boolean requireCores, @CheckForNull Boolean requireMemory, @CheckForNull Boolean requireAvailableMemory)
      As above, also for the "enough memory free right now" requirement.
    • hostSelectionOptions

      public static HostSelectionOptions hostSelectionOptions(@CheckForNull vSphereCloud cloud, @CheckForNull Boolean requireCores, @CheckForNull Boolean requireMemory, @CheckForNull Boolean requireAvailableMemory, @CheckForNull HostWeights weightsOverride)
      As above, also with the host weights a call site set for itself: if weightsOverride is not null it replaces the cloud's weights as a whole, else the cloud's apply.
    • getHostSelectionCandidatesAsString

      public String getHostSelectionCandidatesAsString()
      For the classic config UI textbox, and pipeline/JCasC callers that prefer a plain string.
    • setHostSelectionCandidatesAsString

      @DataBoundSetter public void setHostSelectionCandidatesAsString(String hostSelectionCandidatesCsv)
    • getHostWeightFreeCpuMhz

      public int getHostWeightFreeCpuMhz()
    • setHostWeightFreeCpuMhz

      @DataBoundSetter public void setHostWeightFreeCpuMhz(int hostWeightFreeCpuMhz)
      Weight of a host's free CPU, in MHz (absolute), when ranking hosts; 0 = ignore.
    • getHostWeightFreeCpuPercent

      public int getHostWeightFreeCpuPercent()
    • setHostWeightFreeCpuPercent

      @DataBoundSetter public void setHostWeightFreeCpuPercent(int hostWeightFreeCpuPercent)
      Weight of a host's free CPU as a share of its capacity (relative), when ranking hosts; 0 = ignore.
    • getHostWeightFreeMemoryMB

      public int getHostWeightFreeMemoryMB()
    • setHostWeightFreeMemoryMB

      @DataBoundSetter public void setHostWeightFreeMemoryMB(int hostWeightFreeMemoryMB)
      Weight of a host's free memory, in MB (absolute), when ranking hosts; 0 = ignore.
    • getHostWeightFreeMemoryPercent

      public int getHostWeightFreeMemoryPercent()
    • setHostWeightFreeMemoryPercent

      @DataBoundSetter public void setHostWeightFreeMemoryPercent(int hostWeightFreeMemoryPercent)
      Weight of a host's free memory as a share of its capacity (relative), when ranking hosts; 0 = ignore.
    • hostWeights

      public HostWeights hostWeights()
      The four weights as one value; HostWeights.DEFAULT if none is set.
    • isHostSelectionRequireCores

      public boolean isHostSelectionRequireCores()
      Opt-in: only consider hosts with at least as many physical CPU cores as the VM has vCPUs. Off by default (oversubscribed sites). Default for every template/build-step using this cloud; each can override it either way.
    • setHostSelectionRequireCores

      @DataBoundSetter public void setHostSelectionRequireCores(boolean hostSelectionRequireCores)
    • isHostSelectionRequireMemory

      public boolean isHostSelectionRequireMemory()
      Opt-in: only consider hosts with at least as much physical RAM as the VM is configured with. Off by default (oversubscribed sites). Default for every template/build-step using this cloud; each can override it either way.
    • setHostSelectionRequireMemory

      @DataBoundSetter public void setHostSelectionRequireMemory(boolean hostSelectionRequireMemory)
    • isHostSelectionRequireAvailableMemory

      public boolean isHostSelectionRequireAvailableMemory()
      Opt-in: only consider hosts that currently have at least as much memory free as the VM is configured with, so the new VM does not get swapped by the hypervisor. Default for every template/build-step using this cloud; each can override it either way.
    • setHostSelectionRequireAvailableMemory

      @DataBoundSetter public void setHostSelectionRequireAvailableMemory(boolean hostSelectionRequireAvailableMemory)
    • getPassword

      @CheckForNull public String getPassword()
    • getUsername

      @CheckForNull public String getUsername()
    • getVsDescription

      public String getVsDescription()
    • getVsHost

      @CheckForNull public String getVsHost()
    • getAllowUntrustedCertificate

      public boolean getAllowUntrustedCertificate()
    • getVsConnectionConfig

      @CheckForNull public VSphereConnectionConfig getVsConnectionConfig()
    • getHash

      public final int getHash()
    • vSphereInstance

      public VSphere vSphereInstance() throws VSphereException
      Throws:
      VSphereException
    • waitWhileInMaintenanceMode

      public void waitWhileInMaintenanceMode(TaskListener listener) throws InterruptedException
      If this cloud (or whichever vSphereCloud instance now holds its configuration - Jenkins constructs a brand-new Cloud instance on every reconfiguration rather than mutating the existing one, see resolveCurrentInstance()) is in maintenance mode, logs the configured message to listener and blocks the calling thread, polling every MAINTENANCE_POLL_INTERVAL_MS, until maintenance mode is turned off. Returns immediately if the cloud is not currently in maintenance mode.
      Throws:
      InterruptedException
    • canProvision

      public boolean canProvision(Label label)
      Overrides:
      canProvision in class Cloud
    • provision

      public Collection<NodeProvisioner.PlannedNode> provision(Label label, int excessWorkload)
      Overrides:
      provision in class Cloud
    • preProvisionNodes

      @Restricted(org.kohsuke.accmod.restrictions.NoExternalUse.class) public void preProvisionNodes(vSphereCloudSlaveTemplate template)
      Pre-provisions nodes per template to save time on a VM boot.
      Parameters:
      template -
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • canMarkVMOnline

      public Boolean canMarkVMOnline(String slaveName, String vmName)
    • markVMOnline

      public Boolean markVMOnline(String slaveName, String vmName)
    • markVMOffline

      public void markVMOffline(String slaveName, String vmName)
    • findAllVsphereClouds

      public static List<vSphereCloud> findAllVsphereClouds(String jobName)
    • findAllVsphereCloudNames

      public static List<String> findAllVsphereCloudNames()
    • getDescriptor

      public vSphereCloud.DescriptorImpl getDescriptor()
      Specified by:
      getDescriptor in interface Describable<Cloud>
      Overrides:
      getDescriptor in class Cloud