提交 f1d3c50d 编写于 作者: K kohsuke

Added the setSlaves() to enable programmatic slave configuration.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@11516 71c3de6d-444a-0410-be80-ed276b4c234a
上级 8339f022
......@@ -958,6 +958,24 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node,
return Collections.unmodifiableList(slaves);
}
/**
* Updates the slave list.
*/
public void setSlaves(List<Slave> slaves) throws IOException {
this.slaves = new ArrayList<Slave>(slaves);
updateComputerList();
// label trim off
for (Iterator<Label> itr = labels.values().iterator(); itr.hasNext();) {
Label l = itr.next();
l.reset();
if(l.getNodes().isEmpty())
itr.remove();
}
save();
}
/**
* Gets the system default quiet period.
*/
......@@ -1618,6 +1636,8 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node,
public synchronized void doConfigExecutorsSubmit( StaplerRequest req, StaplerResponse rsp ) throws IOException, ServletException {
checkPermission(ADMINISTER);
BulkChange bc = new BulkChange(this);
try {
JSONObject json = req.getSubmittedForm();
numExecutors = Integer.parseInt(req.getParameter("numExecutors"));
......@@ -1626,22 +1646,11 @@ public final class Hudson extends View implements ItemGroup<TopLevelItem>, Node,
else
mode = Mode.NORMAL;
{
// update slave list
this.slaves = req.bindJSONToList(Slave.class,json.get("slaves"));
updateComputerList();
// label trim off
for (Iterator<Label> itr = labels.values().iterator(); itr.hasNext();) {
Label l = itr.next();
l.reset();
if(l.getNodes().isEmpty())
itr.remove();
}
setSlaves(req.bindJSONToList(Slave.class,json.get("slaves")));
} finally {
bc.commit();
}
save();
rsp.sendRedirect(req.getContextPath()+'/'); // go to the top page
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册