Skip to content

Commit 8ce559a

Browse files
committed
VSphere.java: move logging from cloneVm() and deployVm() wrappers to cloneOrDeployVm() implementation
Signed-off-by: Jim Klimov <[email protected]>
1 parent 26db2ff commit 8ce559a

File tree

1 file changed

+14
-2
lines changed
  • src/main/java/org/jenkinsci/plugins/vsphere/tools

1 file changed

+14
-2
lines changed

src/main/java/org/jenkinsci/plugins/vsphere/tools/VSphere.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ public void deployVm(String cloneName, String sourceName, boolean linkedClone, S
147147
final boolean useCurrentSnapshotIsFALSE = false;
148148
final String namedSnapshotIsNULL = null;
149149
final Map<String, String> extraConfigParameters = null;
150-
logMessage(jLogger, "Deploying new vm \""+ cloneName + "\" from template \""+sourceName+"\"");
151150
cloneOrDeployVm(cloneName, sourceName, linkedClone, resourcePoolName, cluster, datastoreName, folderName, useCurrentSnapshotIsFALSE, namedSnapshotIsNULL, powerOn, extraConfigParameters, customizationSpec, jLogger);
152151
}
153152

@@ -170,7 +169,6 @@ public void cloneVm(String cloneName, String sourceName, boolean linkedClone, St
170169
final boolean useCurrentSnapshotIsTRUE = true;
171170
final String namedSnapshotIsNULL = null;
172171
final Map<String, String> extraConfigParameters = null;
173-
logMessage(jLogger, "Creating a " + (linkedClone?"shallow":"deep") + " clone of \"" + sourceName + "\" to \"" + cloneName + "\"");
174172
cloneOrDeployVm(cloneName, sourceName, linkedClone, resourcePoolName, cluster, datastoreName, folderName, useCurrentSnapshotIsTRUE, namedSnapshotIsNULL, powerOn, extraConfigParameters, customizationSpec, jLogger);
175173
}
176174

@@ -220,6 +218,20 @@ public void cloneVm(String cloneName, String sourceName, boolean linkedClone, St
220218
* if anything goes wrong.
221219
*/
222220
public void cloneOrDeployVm(String cloneName, String sourceName, boolean linkedClone, String resourcePoolName, String cluster, String datastoreName, String folderName, boolean useCurrentSnapshot, final String namedSnapshot, boolean powerOn, Map<String, String> extraConfigParameters, String customizationSpec, PrintStream jLogger) throws VSphereException {
221+
if (namedSnapshot == null && extraConfigParameters == null) {
222+
// NOTE: This "if" clause may be superfluous - just that previously
223+
// this message was only logged by cloneVm() or deployVm()... so for
224+
// least surprise and unexpected noise in the logs, effectively kept
225+
// so for upgraded plugins.
226+
if (useCurrentSnapshot) {
227+
// Called from cloneVm() above.
228+
logMessage(jLogger, "Creating a " + (linkedClone ? "shallow" : "deep") + " clone of \"" + sourceName + "\" to \"" + cloneName + "\"");
229+
} else {
230+
// Called from deployVm() above.
231+
logMessage(jLogger, "Deploying new vm \""+ cloneName + "\" from template \""+sourceName+"\"");
232+
}
233+
}
234+
223235
try {
224236
final VirtualMachine sourceVm = getVmByName(sourceName);
225237
if (sourceVm==null) {

0 commit comments

Comments
 (0)