@QueryParameter String hostname)
throws IOException, FormException {
// bypass the regular security check
SecurityContextHolder.getContext().setAuthentication(ACL.SYSTEM);
try {
final Jenkins jenkins = Jenkins.getInstance();
if (defaultPrefix != null && !defaultPrefix.isEmpty()) {
name = defaultPrefix + "-" + name;
}
if (description == null) {
description = "";
}
labels = defaultLabels + " " + Util.fixNull(labels);
DynaSlave slave = new DynaSlave(name, "Dynamic slave at " + hostname + ": " + description,
remoteFsRoot, String.valueOf(executors), labels, hostname, defaultRemoteSlaveUser,
defaultBaseLauncherCommand, defaultIdleTerminationMinutes);
synchronized (jenkins) {
Node n = jenkins.getNode(name);
if (n != null) jenkins.removeNode(n);
jenkins.addNode(slave);
}
} catch (FormException e) {
LOG.log(Level.WARNING, "Unable to create dynaslave:", e);
} finally {