Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.22</version>
<version>2.29</version>
</parent>

<artifactId>vsphere-cloud</artifactId>
Expand Down Expand Up @@ -32,14 +32,14 @@
<comments>A business-friendly OSS license</comments>
</license>
</licenses>

<scm>
<connection>scm:git:https://github.com/jenkinsci/vsphere-cloud-plugin.git</connection>
<developerConnection>scm:git:https://git@github.com/jenkinsci/vsphere-cloud-plugin.git</developerConnection>
<url>https://github.com/jenkinsci/vsphere-cloud-plugin</url>
<tag>HEAD</tag>
</scm>
</scm>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
Expand All @@ -58,7 +58,7 @@
<url>http://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

<dependencies>
<dependency>
<groupId>org.kohsuke.stapler</groupId>
Expand Down Expand Up @@ -106,7 +106,7 @@
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<configuration>
<disabledTestInjection>true</disabledTestInjection>
<disabledTestInjection>false</disabledTestInjection>
</configuration>
</plugin>
<plugin>
Expand Down
72 changes: 42 additions & 30 deletions src/main/java/org/jenkinsci/plugins/vSphereCloudLauncher.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package org.jenkinsci.plugins;

import hudson.Util;
Expand Down Expand Up @@ -66,20 +62,30 @@ public vSphereCloudLauncher(ComputerLauncher launcher,
this.waitForVMTools = waitForVMTools;
this.snapName = snapName;
this.launchDelay = Util.tryParseNumber(launchDelay, 60).intValue();
if ("Shutdown".equals(idleOption)) {
idleAction = MACHINE_ACTION.SHUTDOWN;
} else if ("Shutdown and Revert".equals(idleOption)) {
idleAction = MACHINE_ACTION.REVERT;
} else if ("Revert and Restart".equals(idleOption)) {
idleAction = MACHINE_ACTION.REVERT_AND_RESTART;
} else if ("Revert and Reset".equals(idleOption)) {
idleAction = MACHINE_ACTION.REVERT_AND_RESET;
} else if ("Reset".equals(idleOption)) {
idleAction = MACHINE_ACTION.RESET;
} else if ("Suspend".equals(idleOption)) {
idleAction = MACHINE_ACTION.SUSPEND;
} else {
if (null == idleOption) {
idleAction = MACHINE_ACTION.NOTHING;
} else switch (idleOption) {
case "Shutdown":
idleAction = MACHINE_ACTION.SHUTDOWN;
break;
case "Shutdown and Revert":
idleAction = MACHINE_ACTION.REVERT;
break;
case "Revert and Restart":
idleAction = MACHINE_ACTION.REVERT_AND_RESTART;
break;
case "Revert and Reset":
idleAction = MACHINE_ACTION.REVERT_AND_RESET;
break;
case "Reset":
idleAction = MACHINE_ACTION.RESET;
break;
case "Suspend":
idleAction = MACHINE_ACTION.SUSPEND;
break;
default:
idleAction = MACHINE_ACTION.NOTHING;
break;
}
this.LimitedTestRunCount = Util.tryParseNumber(LimitedTestRunCount, 0).intValue();
}
Expand Down Expand Up @@ -336,19 +342,25 @@ public synchronized void afterDisconnect(SlaveComputer slaveComputer, TaskListen
case NOTHING:
break;
}
if (localIdle == MACHINE_ACTION.REVERT) {
revertVM(vm, vsC, slaveComputer, taskListener);
} else if (localIdle == MACHINE_ACTION.REVERT_AND_RESTART) {
revertVM(vm, vsC, slaveComputer, taskListener);
if (power == VirtualMachinePowerState.poweredOn) {
// Some time is needed for the VMWare Tools to reactivate
Thread.sleep(60000);
shutdownVM(vm, slaveComputer, taskListener);
}
powerOnVM(vm, slaveComputer, taskListener);
} else if (localIdle == MACHINE_ACTION.REVERT_AND_RESET) {
revertVM(vm, vsC, slaveComputer, taskListener);
resetVM(vm, slaveComputer, taskListener);
switch (localIdle) {
case REVERT:
revertVM(vm, vsC, slaveComputer, taskListener);
break;
case REVERT_AND_RESTART:
revertVM(vm, vsC, slaveComputer, taskListener);
if (power == VirtualMachinePowerState.poweredOn) {
// Some time is needed for the VMWare Tools to reactivate
Thread.sleep(60000);
shutdownVM(vm, slaveComputer, taskListener);
}
powerOnVM(vm, slaveComputer, taskListener);
break;
case REVERT_AND_RESET:
revertVM(vm, vsC, slaveComputer, taskListener);
resetVM(vm, slaveComputer, taskListener);
break;
default:
break;
}
} else {
// VM is already powered down.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
package org.jenkinsci.plugins.vsphere.builders;

import hudson.*;
import hudson.Extension;
import hudson.model.AbstractBuild;
import hudson.model.BuildListener;
import hudson.model.Run;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ private boolean hasFiniteCapacity() {

private double calcFullness() {
final int maxToProvision = calcMaxToProvision();
return ((double) calcCurrentCommitment()) / (double) maxToProvision;
return calcCurrentCommitment() / (double) maxToProvision;
}

boolean hasCapacityForMore() {
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/index.jelly
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<!--
This view is used to render the installed plugins page.
-->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form">
<table width="100%">
<st:include page="config.jelly" class="${descriptor.clazz}"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="${%Name of this Cloud}" field="vsDescription">
<f:textbox/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt">
<j:if test="${it.launchSupported and it.offline and !it.temporarilyOffline}">
<j:choose>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout"
xmlns:t="/lib/hudson" xmlns:f="/lib/form">

<f:entry title="${%vSphere Cloud Instance}" field="vsDescription">
<select class="setting-input" name="vsDescription" value="${it.vsDescription}" >
<option>Select a vSphere Cloud instance...</option>
Expand All @@ -18,7 +19,7 @@
<f:entry title="${%Snapshot Name}" field="snapName">
<f:textbox />
</f:entry>

<f:validateButton title="${%Test VM Connection}" progress="${%Testing...}" method="testConnection" with="vsDescription,vmName,snapName"/>

<f:entry title="${%Description}" help="/help/system-config/master-slave/description.html">
Expand Down Expand Up @@ -48,7 +49,7 @@
description="${%Wait for VMTools in the VM to start up.}" >
<f:checkbox />
</f:entry>

<f:entry title="${%Delay between launch and boot complete}" field="launchDelay"
description="${%How many seconds between the VM being brought back to life before Jenkins can connect and bring it online as a slave.}" >
<f:textbox default="60" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<table width="100%">
<f:entry title="${%Clone Name Prefix}" field="cloneNamePrefix">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="${%Idle Timeout}" field="idleMinutes">
<f:number default="2"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ limitations under the License.

<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
<f:entry title="${%Server}" field="serverName">
<f:select />
<f:select />
</f:entry>
<f:entry>
<f:dropdownDescriptorSelector title="${%vSphere Action}" field="buildStep" descriptors="${descriptor.buildSteps}" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="${%Idle Timeout}" field="idleMinutes">
<f:number default="5"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:c="/lib/credentials">
<table width="100%">
<f:entry title="${%Property Name}" field="name">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<?jelly escape-by-default='true'?>

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="${%SourceName}" field="sourceName">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<?jelly escape-by-default='true'?>

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="${%VM}" field="vm">
<f:textbox />
</f:entry>
<f:entry title="${%Force}" field="force">
<f:checkbox />
</f:entry>
<f:validateButton title="${%Check Data}" progress="${%Testing...}" method="testData" with="serverName,vm,description"/>
<f:entry title="${%VM}" field="vm">
<f:textbox />
</f:entry>

<f:entry title="${%Force}" field="force">
<f:checkbox />
</f:entry>

<f:validateButton title="${%Check Data}" progress="${%Testing...}" method="testData" with="serverName,vm,description"/>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<?jelly escape-by-default='true'?>

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="${%Template}" field="template">
<f:textbox />
</f:entry>

<f:entry title="${%Cluster}" field="cluster">
<f:textbox />
</f:entry>
<f:entry title="${%Template}" field="template">
<f:textbox />
</f:entry>

<f:entry title="${%Resource Pool}" field="resourcePool">
<f:textbox />
</f:entry>
<f:entry title="${%Cluster}" field="cluster">
<f:textbox />
</f:entry>

<f:validateButton title="${%Check Data}" progress="${%Testing...}" method="testData" with="serverName,template,resourcePool,cluster"/>
<f:entry title="${%Resource Pool}" field="resourcePool">
<f:textbox />
</f:entry>

<f:validateButton title="${%Check Data}" progress="${%Testing...}" method="testData" with="serverName,template,resourcePool,cluster"/>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<?jelly escape-by-default='true'?>

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="${%VM}" field="vm">
<f:textbox />
</f:entry>
<f:entry title="${%Fail on null?}" field="failOnNoExist">
<f:checkbox />
</f:entry>
<f:validateButton title="${%Check Data}" progress="${%Testing...}" method="testData" with="serverName,vm"/>
<f:entry title="${%VM}" field="vm">
<f:textbox />
</f:entry>

<f:entry title="${%Fail on null?}" field="failOnNoExist">
<f:checkbox />
</f:entry>

<f:validateButton title="${%Check Data}" progress="${%Testing...}" method="testData" with="serverName,vm"/>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,24 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<?jelly escape-by-default='true'?>

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="${%VM}" field="vm">
<f:textbox />
</f:entry>
<f:entry title="${%Snapshot Name}" field="snapshotName">
<f:textbox />
</f:entry>
<f:entry title="${%Consolidate disks?}" field="consolidate">
<f:checkbox />
</f:entry>
<f:entry title="${%Fail on null?}" field="failOnNoExist">
<f:checkbox />
</f:entry>
<f:validateButton title="${%Check Data}" progress="${%Testing...}" method="testData" with="serverName,vm,snapshotName"/>
<f:entry title="${%VM}" field="vm">
<f:textbox />
</f:entry>

<f:entry title="${%Snapshot Name}" field="snapshotName">
<f:textbox />
</f:entry>

<f:entry title="${%Consolidate disks?}" field="consolidate">
<f:checkbox />
</f:entry>

<f:entry title="${%Fail on null?}" field="failOnNoExist">
<f:checkbox />
</f:entry>

<f:validateButton title="${%Check Data}" progress="${%Testing...}" method="testData" with="serverName,vm,snapshotName"/>
</j:jelly>
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<?jelly escape-by-default='true'?>

<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<f:entry title="${%Template}" field="template">
Expand Down
Loading