Skip to content

Commit

Permalink
getting to 0 commits behind master
Browse files Browse the repository at this point in the history
  • Loading branch information
ghost1874 committed Jan 25, 2016
1 parent 2610fad commit 7f2772c
Show file tree
Hide file tree
Showing 9 changed files with 93 additions and 63 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -7,7 +7,7 @@
</parent>

<artifactId>vsphere-cloud</artifactId>
<version>2.9-SNAPSHOT</version>
<version>2.10-SNAPSHOT</version>
<packaging>hpi</packaging>
<name>vSphere Plugin</name>
<description>Integrates Jenkins with a vSphere server</description>
Expand Down
Expand Up @@ -80,9 +80,10 @@ public class vSphereCloudSlaveTemplate implements Describable<vSphereCloudSlaveT
private final String targetHost;
private final String credentialsId;
private final List<? extends NodeProperty<?>> nodeProperties;
boolean POWER_ON = true;

private transient Set<LabelAtom> labelSet;
protected transient vSphereCloud parent;
protected transient vSphereCloud parent;

@DataBoundConstructor
public vSphereCloudSlaveTemplate(final String cloneNamePrefix,
Expand Down Expand Up @@ -246,7 +247,7 @@ public vSphereCloudProvisionedSlave provision(TaskListener listener) throws VSph
final UUID cloneUUID = UUID.randomUUID();
final String cloneName = this.cloneNamePrefix + "_" + cloneUUID;

vSphere.cloneVm(cloneName, this.masterImageName, this.linkedClone, this.resourcePool, this.cluster, this.datastore, logger);
vSphere.cloneVm(cloneName, this.masterImageName, this.linkedClone, this.resourcePool, this.cluster, this.datastore, POWER_ON, logger);

final String ip = vSphere.getIp(vSphere.getVmByName(cloneName), 1000);
final SSHLauncher sshLauncher = new SSHLauncher(ip, 0, credentialsId, null, null, null, null, this.launchDelay, 3, 60);
Expand Down
11 changes: 9 additions & 2 deletions src/main/java/org/jenkinsci/plugins/vsphere/builders/Clone.java
Expand Up @@ -44,16 +44,18 @@ public class Clone extends VSphereBuildStep {
private final String resourcePool;
private final String cluster;
private final String datastore;
private final boolean powerOn;

@DataBoundConstructor
public Clone(String sourceName, String clone, boolean linkedClone,
String resourcePool, String cluster, String datastore) throws VSphereException {
String resourcePool, String cluster, String datastore, boolean powerOn) throws VSphereException {
this.sourceName = sourceName;
this.clone = clone;
this.linkedClone = linkedClone;
this.resourcePool=resourcePool;
this.cluster=cluster;
this.datastore=datastore;
this.powerOn=powerOn;
}

public String getSourceName() {
Expand All @@ -80,6 +82,11 @@ public String getDatastore() {
return datastore;
}

public boolean isPowerOn() {
return powerOn;
}


public boolean perform(final AbstractBuild<?, ?> build, final Launcher launcher, final BuildListener listener) throws VSphereException {
return cloneFromSource(build, launcher, listener);
//TODO throw AbortException instead of returning value
Expand All @@ -102,7 +109,7 @@ private boolean cloneFromSource(final AbstractBuild<?, ?> build, final Launcher
expandedResourcePool = env.expand(resourcePool);

vsphere.cloneVm(expandedClone, expandedSource, linkedClone, expandedResourcePool, expandedCluster,
expandedDatastore, jLogger);
expandedDatastore, powerOn, jLogger);
VSphereLogger.vsLogger(jLogger, "\""+expandedClone+"\" successfully cloned!");

return true;
Expand Down
12 changes: 9 additions & 3 deletions src/main/java/org/jenkinsci/plugins/vsphere/builders/Deploy.java
Expand Up @@ -44,16 +44,18 @@ public class Deploy extends VSphereBuildStep {
private final String resourcePool;
private final String cluster;
private final String datastore;
private final boolean powerOn;

@DataBoundConstructor
public Deploy(String template, String clone, boolean linkedClone,
String resourcePool, String cluster, String datastore) throws VSphereException {
String resourcePool, String cluster, String datastore, boolean powerOn) throws VSphereException {
this.template = template;
this.clone = clone;
this.linkedClone = linkedClone;
this.resourcePool=resourcePool;
this.cluster=cluster;
this.datastore=datastore;
this.powerOn=powerOn;
}

public String getTemplate() {
Expand All @@ -80,6 +82,10 @@ public String getDatastore() {
return datastore;
}

public boolean isPowerOn() {
return powerOn;
}

public boolean perform(final AbstractBuild<?, ?> build, final Launcher launcher, final BuildListener listener) throws VSphereException {
return deployFromTemplate(build, launcher, listener);
//TODO throw AbortException instead of returning value
Expand Down Expand Up @@ -108,7 +114,7 @@ private boolean deployFromTemplate(final AbstractBuild<?, ?> build, final Launch
resourcePoolName = env.expand(resourcePool);
}

vsphere.deployVm(expandedClone, expandedTemplate, linkedClone, resourcePoolName, expandedCluster, expandedDatastore, jLogger);
vsphere.deployVm(expandedClone, expandedTemplate, linkedClone, resourcePoolName, expandedCluster, expandedDatastore, powerOn, jLogger);
VSphereLogger.vsLogger(jLogger, "\""+expandedClone+"\" successfully deployed!");

return true;
Expand Down Expand Up @@ -170,7 +176,7 @@ public FormValidation doTestData(@QueryParameter String serverName,
if (template.indexOf('$') >= 0)
return FormValidation.warning(Messages.validation_buildParameter("template"));

VirtualMachine vm = vsphere.getVmByName(template);
VirtualMachine vm = vsphere.getVmByName(template);
if (vm == null)
return FormValidation.error(Messages.validation_notFound("template"));

Expand Down
11 changes: 6 additions & 5 deletions src/main/java/org/jenkinsci/plugins/vsphere/tools/VSphere.java
Expand Up @@ -107,10 +107,10 @@ public static String vSphereOutput(String msg){
* @param datastoreName - Datastore to use
* @throws VSphereException
*/
public void deployVm(String cloneName, String sourceName, boolean linkedClone, String resourcePoolName, String cluster, String datastoreName, PrintStream jLogger) throws VSphereException {
public void deployVm(String cloneName, String sourceName, boolean linkedClone, String resourcePoolName, String cluster, String datastoreName, boolean powerOn, PrintStream jLogger) throws VSphereException {
boolean DO_NOT_USE_SNAPSHOTS = false;
logMessage(jLogger, "Deploying new vm \""+ cloneName + "\" from template \""+sourceName+"\"");
cloneOrDeployVm(cloneName, sourceName, linkedClone, resourcePoolName, cluster, datastoreName, DO_NOT_USE_SNAPSHOTS, jLogger);
cloneOrDeployVm(cloneName, sourceName, linkedClone, resourcePoolName, cluster, datastoreName, DO_NOT_USE_SNAPSHOTS, powerOn, jLogger);
}

/**
Expand All @@ -124,13 +124,13 @@ public void deployVm(String cloneName, String sourceName, boolean linkedClone, S
* @param datastoreName - Datastore to use
* @throws VSphereException
*/
public void cloneVm(String cloneName, String sourceName, boolean linkedClone, String resourcePoolName, String cluster, String datastoreName, PrintStream jLogger) throws VSphereException {
public void cloneVm(String cloneName, String sourceName, boolean linkedClone, String resourcePoolName, String cluster, String datastoreName, boolean powerOn, PrintStream jLogger) throws VSphereException {
boolean DO_USE_SNAPSHOTS = true;
logMessage(jLogger, "Creating a shallow clone of \""+ sourceName + "\" to \""+cloneName+"\"");
cloneOrDeployVm(cloneName, sourceName, linkedClone, resourcePoolName, cluster, datastoreName, DO_USE_SNAPSHOTS, jLogger);
cloneOrDeployVm(cloneName, sourceName, linkedClone, resourcePoolName, cluster, datastoreName, DO_USE_SNAPSHOTS, powerOn, jLogger);
}

private void cloneOrDeployVm(String cloneName, String sourceName, boolean linkedClone, String resourcePoolName, String cluster, String datastoreName, boolean useSnapshot, PrintStream jLogger) throws VSphereException {
private void cloneOrDeployVm(String cloneName, String sourceName, boolean linkedClone, String resourcePoolName, String cluster, String datastoreName, boolean useSnapshot, boolean powerOn, PrintStream jLogger) throws VSphereException {
try{
VirtualMachine sourceVm = getVmByName(sourceName);

Expand All @@ -146,6 +146,7 @@ private void cloneOrDeployVm(String cloneName, String sourceName, boolean linked

VirtualMachineCloneSpec cloneSpec = createCloneSpec(rel);
cloneSpec.setTemplate(false);
cloneSpec.powerOn = powerOn;

if (useSnapshot) {
//TODO add config to allow state of VM or snapshot
Expand Down
Expand Up @@ -15,29 +15,33 @@ limitations under the License.
-->

<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">
<f:textbox />
</f:entry>

<f:entry title="${%Clone}" field="clone">
<f:textbox />
</f:entry>

<f:entry title="${%Linked Clone?}" field="linkedClone">
<f:checkbox />
</f:entry>

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

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

<f:entry title="${%Datastore}" field="datastore">
<f:textbox />
</f:entry>

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

<f:entry title="${%Clone}" field="clone">
<f:textbox />
</f:entry>

<f:entry title="${%Linked Clone?}" field="linkedClone">
<f:checkbox />
</f:entry>

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

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

<f:entry title="${%Datastore}" field="datastore">
<f:textbox />
</f:entry>

<f:entry title="${%Power on?}" field="powerOn">
<f:checkbox />
</f:entry>

<f:validateButton title="${%Check Data}" progress="${%Testing...}" method="testData" with="serverName,sourceName,clone,resourcePool,cluster"/>
</j:jelly>
@@ -0,0 +1,3 @@
<div>
Specifies whether or not the new VirtualMachine should be powered on after creation.
</div>
Expand Up @@ -15,29 +15,34 @@ limitations under the License.
-->

<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="${%Clone}" field="clone">
<f:textbox />
</f:entry>

<f:entry title="${%Linked Clone?}" field="linkedClone">
<f:checkbox />
</f:entry>

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

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

<f:entry title="${%Datastore}" field="datastore">
<f:textbox />
</f:entry>

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

<f:entry title="${%Clone}" field="clone">
<f:textbox />
</f:entry>

<f:entry title="${%Linked Clone?}" field="linkedClone">
<f:checkbox />
</f:entry>

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

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

<f:entry title="${%Datastore}" field="datastore">
<f:textbox />
</f:entry>

<f:entry title="${%Power on?}" field="powerOn">
<f:checkbox />
</f:entry>


<f:validateButton title="${%Check Data}" progress="${%Testing...}" method="testData" with="serverName,template,clone,resourcePool,cluster"/>
</j:jelly>
@@ -0,0 +1,3 @@
<div>
Specifies whether or not the new VirtualMachine should be powered on after creation.
</div>

0 comments on commit 7f2772c

Please sign in to comment.