-
-
Notifications
You must be signed in to change notification settings - Fork 103
Minor fixes for adding timeOutInSeconds to Clone and Deploy by MarcelMue #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
95b0fbd
e6c6be0
cafd43a
a09b93b
b7625c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -42,6 +42,8 @@ | |
|
|
||
| public class Clone extends VSphereBuildStep { | ||
|
|
||
| private final Integer TIMEOUT_DEFAULT = 60; | ||
|
|
||
| private final String sourceName; | ||
| private final String clone; | ||
| private final boolean linkedClone; | ||
|
|
@@ -51,12 +53,13 @@ public class Clone extends VSphereBuildStep { | |
| private final String folder; | ||
| private final String customizationSpec; | ||
| private final boolean powerOn; | ||
| private final Integer timeoutInSeconds; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that, unless we want to store a null/empty timeoutInSeconds field, this should be "int". Personally I think it'd be simpler to have this as an int, and have the get method also return an int.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah sorry, I'm pretty new to all this code so bear with me a bit. I like the idea of keeping everything except the constructor as int so I'll do that.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm only just one step ahead of you at present - it's a "learning experience" for both of us :-) I've just been reading https://wiki.jenkins.io/display/JENKINS/Hint+on+retaining+backward+compatibility and that's reminded me that, when Jenkins loads the configuration off disk, it doesn't actually call the constructor at all. I'm not familiar with what this code did before there was a timeout - did it wait "forever"? If so, I'd suggest that this is what the default behavior should be as, that way, existing customers will see no difference, but can decide to take advantage of the new flexibility if they choose to. (I do apologize - I was expecting this part to be way simpler than it's turning out to be!) |
||
| private String IP; | ||
|
|
||
| @DataBoundConstructor | ||
| public Clone(String sourceName, String clone, boolean linkedClone, | ||
| String resourcePool, String cluster, String datastore, String folder, | ||
| boolean powerOn, String customizationSpec) throws VSphereException { | ||
| boolean powerOn, Integer timeoutInSeconds, String customizationSpec) throws VSphereException { | ||
| this.sourceName = sourceName; | ||
| this.clone = clone; | ||
| this.linkedClone = linkedClone; | ||
|
|
@@ -66,6 +69,12 @@ public Clone(String sourceName, String clone, boolean linkedClone, | |
| this.folder=folder; | ||
| this.customizationSpec=customizationSpec; | ||
| this.powerOn=powerOn; | ||
| if (timeoutInSeconds != null) { | ||
| this.timeoutInSeconds = timeoutInSeconds; | ||
| } | ||
| else { | ||
| this.timeoutInSeconds = TIMEOUT_DEFAULT; | ||
| } | ||
| } | ||
|
|
||
| public String getSourceName() { | ||
|
|
@@ -103,6 +112,10 @@ public String getCustomizationSpec() { | |
| public boolean isPowerOn() { | ||
| return powerOn; | ||
| } | ||
|
|
||
| public Integer getTimeoutInSeconds() { | ||
| return timeoutInSeconds; | ||
| } | ||
|
|
||
| @Override | ||
| public void perform(@Nonnull Run<?, ?> run, @Nonnull FilePath filePath, @Nonnull Launcher launcher, @Nonnull TaskListener listener) throws InterruptedException, IOException { | ||
|
|
@@ -168,8 +181,8 @@ private boolean cloneFromSource(final Run<?, ?> run, final Launcher launcher, fi | |
| vsphere.cloneVm(expandedClone, expandedSource, linkedClone, expandedResourcePool, expandedCluster, | ||
| expandedDatastore, expandedFolder, powerOn, expandedCustomizationSpec, jLogger); | ||
| if (powerOn) { | ||
| VSphereLogger.vsLogger(jLogger,"Powering on VM..."); | ||
| IP = vsphere.getIp(vsphere.getVmByName(expandedClone), 60); | ||
| VSphereLogger.vsLogger(jLogger, "Powering on VM \""+expandedClone+"\" for the next "+timeoutInSeconds+" seconds."); | ||
| IP = vsphere.getIp(vsphere.getVmByName(expandedClone), timeoutInSeconds); | ||
| } | ||
| VSphereLogger.vsLogger(jLogger, "\""+expandedClone+"\" successfully cloned " + (powerOn ? "and powered on" : "") + "!"); | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, Integer should be int - this one isn't nullable.
(Sorry, I should have spotted this earlier)