Index: src/main/java/hudson/plugins/libvirt/VirtualMachineLauncher.java =================================================================== --- src/main/java/hudson/plugins/libvirt/VirtualMachineLauncher.java (revision 36607) +++ src/main/java/hudson/plugins/libvirt/VirtualMachineLauncher.java (working copy) @@ -28,6 +28,7 @@ import hudson.slaves.Cloud; import java.io.IOException; +import java.lang.Boolean; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -43,14 +44,17 @@ private transient VirtualMachine virtualMachine; private String hypervisorDescription; private String virtualMachineName; + private Boolean overrideLaunchSupported; private static final int WAIT_TIME = 60000; @DataBoundConstructor - public VirtualMachineLauncher(ComputerLauncher delegate, String hypervisorDescription, String virtualMachineName) { + public VirtualMachineLauncher(ComputerLauncher delegate, String hypervisorDescription, + String virtualMachineName, Boolean overrideLaunchSupported) { super(); this.delegate = delegate; this.virtualMachineName = virtualMachineName; this.hypervisorDescription = hypervisorDescription; + this.overrideLaunchSupported = overrideLaunchSupported; buildVirtualMachine(); } @@ -82,9 +86,22 @@ return virtualMachine; } - @Override + public Boolean getOverrideLaunchSupported() { + return overrideLaunchSupported; + } + + public void setOverrideLaunchSupported(Boolean overrideLaunchSupported) { + this.overrideLaunchSupported = overrideLaunchSupported; + } + + @Override public boolean isLaunchSupported() { - return delegate.isLaunchSupported(); + if (overrideLaunchSupported == null) + return delegate.isLaunchSupported(); + else { + LOGGER.log(Level.INFO, "Launch support is overriden to always return: " + overrideLaunchSupported); + return overrideLaunchSupported; + } } @Override @@ -165,6 +182,7 @@ @Extension public static final Descriptor DESCRIPTOR = new Descriptor() { + private Boolean overrideLaunchSupported; private String hypervisorDescription; private String virtualMachineName; private ComputerLauncher delegate; @@ -173,6 +191,10 @@ return "Virtual Machine Launcher"; } + public Boolean getOverrideLaunchSupported() { + return overrideLaunchSupported; + } + public String getHypervisorDescription() { return hypervisorDescription; } Index: src/main/java/hudson/plugins/libvirt/VirtualMachineSlave.java =================================================================== --- src/main/java/hudson/plugins/libvirt/VirtualMachineSlave.java (revision 36607) +++ src/main/java/hudson/plugins/libvirt/VirtualMachineSlave.java (working copy) @@ -33,6 +33,7 @@ import java.util.List; import java.util.ArrayList; import java.util.logging.Logger; +import java.util.logging.Level; import java.io.IOException; import org.kohsuke.stapler.DataBoundConstructor; @@ -47,11 +48,11 @@ public VirtualMachineSlave(String name, String nodeDescription, String remoteFS, String numExecutors, Mode mode, String labelString, VirtualMachineLauncher launcher, ComputerLauncher delegateLauncher, RetentionStrategy retentionStrategy, List> nodeProperties, - String hypervisorDescription, String virtualMachineName) - throws - Descriptor.FormException, IOException { + String hypervisorDescription, String virtualMachineName, boolean launchSupportForced) + throws Descriptor.FormException, IOException { super(name, nodeDescription, remoteFS, Util.tryParseNumber(numExecutors, 1).intValue(), mode, labelString, - launcher == null ? new VirtualMachineLauncher(delegateLauncher, hypervisorDescription, virtualMachineName) : launcher, + launcher == null ? new VirtualMachineLauncher(delegateLauncher, hypervisorDescription, + virtualMachineName, launchSupportForced ? Boolean.TRUE : null) : launcher, retentionStrategy, nodeProperties); this.hypervisorDescription = hypervisorDescription; this.virtualMachineName = virtualMachineName; @@ -65,6 +66,15 @@ return virtualMachineName; } + public boolean isLaunchSupportForced() { + return ((VirtualMachineLauncher) getLauncher()).getOverrideLaunchSupported() == Boolean.TRUE; + } + + public void setLaunchSupportForced(boolean slaveLaunchesOnBootup) { + ((VirtualMachineLauncher) getLauncher()). + setOverrideLaunchSupported(slaveLaunchesOnBootup ? Boolean.TRUE : null); + } + public ComputerLauncher getDelegateLauncher() { return ((VirtualMachineLauncher) getLauncher()).getDelegate(); } @@ -76,6 +86,7 @@ private String hypervisorDescription; private String virtualMachineName; + private boolean launchSupportForced = true; public DescriptorImpl() { load(); @@ -132,6 +143,9 @@ public String getVirtualMachineName() { return virtualMachineName; } - - } + + public boolean isLaunchSupportForced() { + return launchSupportForced; + } + } } Index: src/main/resources/hudson/plugins/libvirt/VirtualMachineSlave/configure-entries.jelly =================================================================== --- src/main/resources/hudson/plugins/libvirt/VirtualMachineSlave/configure-entries.jelly (revision 36607) +++ src/main/resources/hudson/plugins/libvirt/VirtualMachineSlave/configure-entries.jelly (working copy) @@ -43,22 +43,28 @@ - - - + + - + + + + + + +

+ Ticking this box, instructs Hudson that starting this VM should always + be supported even if the selected secondary launch method does not offer automatic + connection between the slave and the master (e.g. JNLP). +

+

+ Use this option when you connected the VM using JNLP and installed it as service or + startup script. +

+ \ No newline at end of file