Skip to content

Commit

Permalink
Replace the f:slave-mode node with a dropdown menu so we can save the…
Browse files Browse the repository at this point in the history
… usageMode parameter [FIXED JENKINS-42037]
  • Loading branch information
clguiman committed Mar 16, 2017
1 parent 35fdce1 commit 039c5ac
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 5 deletions.
Expand Up @@ -93,7 +93,7 @@ public enum ImageReferenceType {

private final int noOfParallelJobs;

private final Node.Mode useAgentAlwaysIfAvail;
private Node.Mode usageMode;

private final boolean shutdownOnIdle;

Expand Down Expand Up @@ -153,7 +153,7 @@ public AzureVMAgentTemplate(
final String virtualMachineSize,
final String storageAccountName,
final String noOfParallelJobs,
final Node.Mode useAgentAlwaysIfAvail,
final String usageMode,
final String imageReferenceType,
final String image,
final String osType,
Expand Down Expand Up @@ -189,7 +189,7 @@ public AzureVMAgentTemplate(
} else {
this.noOfParallelJobs = Integer.parseInt(noOfParallelJobs);
}
this.useAgentAlwaysIfAvail = useAgentAlwaysIfAvail;
setUsageMode(usageMode);
this.imageReferenceType = imageReferenceType;
this.image = image;
this.osType = osType;
Expand Down Expand Up @@ -256,7 +256,22 @@ public void setStorageAccountName(final String storageAccountName) {
}

public Node.Mode getUseAgentAlwaysIfAvail() {
return useAgentAlwaysIfAvail;
return (usageMode == null) ? Node.Mode.NORMAL : usageMode;
}

public String getUsageMode() {
return getUseAgentAlwaysIfAvail().getDescription();
}

public void setUsageMode(final String mode) {
Node.Mode val = Node.Mode.NORMAL;
for(Node.Mode m : hudson.Functions.getNodeModes()) {
if (mode.equalsIgnoreCase(m.getDescription())) {
val = m;
break;
}
}
this.usageMode = val;
}

public boolean isShutdownOnIdle() {
Expand Down Expand Up @@ -539,6 +554,14 @@ public ListBoxModel doFillLocationItems(

return model;
}

public ListBoxModel doFillUsageModeItems() throws IOException, ServletException {
ListBoxModel model = new ListBoxModel();
for(Node.Mode m : hudson.Functions.getNodeModes()) {
model.add(m.getDescription());
}
return model;
}

public ListBoxModel doFillAgentLaunchMethodItems() {
ListBoxModel model = new ListBoxModel();
Expand Down
Expand Up @@ -34,7 +34,9 @@
<f:checkbox/>
</f:entry>

<f:slave-mode name="useAgentAlwaysIfAvail" node="${instance}" help="/plugin/azure-vm-agents/help-slaveMode.html" default="EXCLUSIVE"/>
<f:entry title="${%Usage}" field="usageMode" help="/plugin/azure-vm-agents/help-slaveMode.html" >
<f:select />
</f:entry>
</f:section>

<f:section title="${%Image_Configuration}">
Expand Down

0 comments on commit 039c5ac

Please sign in to comment.