提交 5b007aab 编写于 作者: R Ryan Campbell 提交者: Nicolas De Loof

Added new hudson.model.Computer.CREATE permission to limit who can create new slaves.

上级 bf08281f
......@@ -108,6 +108,8 @@ Upcoming changes</a>
<li class=bug>
Fixed an occasional NPE when running Maven jobs
(<a href="https://issues.jenkins-ci.org/browse/JENKINS-9822">issue 9822</a>)
<li class=rfe>
Added a new hudson.model.Computer.CREATE permission to limit who can create new slaves.
</ul>
<h3><a name=v1.421>What's new in 1.421</a> (2011/07/17)</h3>
<ul class=image>
......
......@@ -1146,6 +1146,7 @@ public /*transient*/ abstract class Computer extends Actionable implements Acces
*/
public static final Permission CONFIGURE = new Permission(PERMISSIONS,"Configure", Messages._Computer_ConfigurePermission_Description(), Permission.CONFIGURE, PermissionScope.COMPUTER);
public static final Permission DELETE = new Permission(PERMISSIONS,"Delete", Messages._Computer_DeletePermission_Description(), Permission.DELETE, PermissionScope.COMPUTER);
public static final Permission CREATE = new Permission(PERMISSIONS,"Create", Messages._Computer_CreatePermission_Description(), Permission.CREATE);
private static final Logger LOGGER = Logger.getLogger(Computer.class.getName());
}
......@@ -210,7 +210,7 @@ public final class ComputerSet extends AbstractModelObject {
@QueryParameter String name, @QueryParameter String mode,
@QueryParameter String from ) throws IOException, ServletException {
final Jenkins app = Jenkins.getInstance();
app.checkPermission(Jenkins.ADMINISTER); // TODO: new permission?
app.checkPermission(Computer.CREATE);
if(mode!=null && mode.equals("copy")) {
name = checkName(name);
......@@ -254,7 +254,7 @@ public final class ComputerSet extends AbstractModelObject {
@QueryParameter String name,
@QueryParameter String type ) throws IOException, ServletException, FormException {
final Jenkins app = Jenkins.getInstance();
app.checkPermission(Jenkins.ADMINISTER); // TODO: new permission?
app.checkPermission(Computer.CREATE);
checkName(name);
Node result = NodeDescriptor.all().find(type).newInstance(req, req.getSubmittedForm());
......@@ -286,7 +286,7 @@ public final class ComputerSet extends AbstractModelObject {
* Makes sure that the given name is good as a slave name.
*/
public FormValidation doCheckName(@QueryParameter String value) throws IOException, ServletException {
Jenkins.getInstance().checkPermission(Jenkins.ADMINISTER);
Jenkins.getInstance().checkPermission(Computer.CREATE);
if(Util.fixEmpty(value)==null)
return FormValidation.ok();
......
......@@ -28,7 +28,7 @@ THE SOFTWARE.
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout"
xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<l:layout norefresh="true" permission="${app.ADMINISTER}">
<l:layout norefresh="true" permission="${it.CREATE}">
<st:include page="sidepanel.jelly"/>
<l:main-panel>
<f:form method="post" action="doCreateItem">
......
......@@ -31,7 +31,8 @@ THE SOFTWARE.
-->
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:s="/lib/form">
<l:layout norefresh="true" permission="${app.ADMINISTER}">
<j:getStatic var="createPermission" className="hudson.model.Computer" field="CREATE"/>
<l:layout norefresh="true" permission="${createPermission}">
<st:include page="sidepanel.jelly" />
<l:main-panel>
<j:invokeStatic var="slaves" className="hudson.slaves.NodeDescriptor" method="allInstantiable" />
......
......@@ -29,10 +29,11 @@ THE SOFTWARE.
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:s="/lib/form">
<l:header />
<l:side-panel>
<j:getStatic var="createPermission" className="hudson.model.Computer" field="CREATE"/>
<l:tasks>
<l:task icon="images/24x24/up.png" href="${rootURL}/" title="${%Back to Dashboard}" />
<l:task icon="images/24x24/setting.png" href="${rootURL}/manage" title="${%Manage Jenkins}" permission="${app.ADMINISTER}" />
<l:task icon="images/24x24/new-computer.png" href="new" title="${%New Node}" permission="${app.ADMINISTER}" />
<l:task icon="images/24x24/new-computer.png" href="new" title="${%New Node}" permission="${createPermission}" />
<l:task icon="images/24x24/setting.png" href="configure" title="${%Configure}" permission="${app.ADMINISTER}" />
</l:tasks>
<t:queue items="${app.queue.items}" />
......
......@@ -91,6 +91,7 @@ Computer.NoSuchSlaveExists=No such slave "{0}" exists. Did you mean "{1}"?
Computer.Permissions.Title=Slave
Computer.ConfigurePermission.Description=This permission allows users to configure slaves.
Computer.DeletePermission.Description=This permission allows users to delete existing slaves.
Computer.CreatePermission.Description=This permission allows users to create slaves.
Computer.BadChannel=Slave node offline or not a remote channel (such as master node).
ComputerSet.NoSuchSlave=No such slave: {0}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册