提交 77f1242d 编写于 作者: D Daniel Beck 提交者: Oleg Nenashev

Move cloud configuration out of Configure System (#4339)

* Move cloud configuration out of Configure System

* Update display name

* Add section header back
上级 8a2f7614
package jenkins.model;
import hudson.Extension;
import hudson.RestrictedSince;
import hudson.model.Descriptor;
import hudson.model.RootAction;
import hudson.slaves.Cloud;
import hudson.util.FormApply;
import net.sf.json.JSONObject;
import org.jenkinsci.Symbol;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.verb.POST;
import javax.annotation.CheckForNull;
import javax.servlet.ServletException;
import java.io.IOException;
/**
* Adds the {@link Cloud} configuration to the system config page.
* Provides a configuration form for {@link Jenkins#clouds}.
*
* <p>
* This object just acts as a proxy to configure {@link Jenkins#clouds}
*
* @author Kohsuke Kawaguchi
* Has been overhauled in Jenkins 2.XXX to no longer contribute to Configure System, but be a standalone form.
*/
@Extension(ordinal=-100) @Symbol("cloud") // historically this was placed at the very end of the configuration page
public class GlobalCloudConfiguration extends GlobalConfiguration {
@Extension
@Symbol("cloud")
@Restricted(NoExternalUse.class)
@RestrictedSince("TODO")
public class GlobalCloudConfiguration implements RootAction {
@CheckForNull
@Override
public String getIconFileName() {
return null;
}
@CheckForNull
@Override
public boolean configure(StaplerRequest req, JSONObject json) throws FormException {
try {
Jenkins.get().clouds.rebuildHetero(req,json, Cloud.all(), "cloud");
return true;
} catch (IOException e) {
throw new FormException(e,"clouds");
}
public String getDisplayName() {
return Messages.GlobalCloudConfiguration_DisplayName();
}
@Override
public String getUrlName() {
return "configureClouds";
}
@POST
public void doConfigure(StaplerRequest req, StaplerResponse rsp) throws Descriptor.FormException, IOException, ServletException {
Jenkins.get().checkPermission(Jenkins.ADMINISTER);
JSONObject json = req.getSubmittedForm();
Jenkins.get().clouds.rebuildHetero(req,json, Cloud.all(), "cloud");
FormApply.success(req.getContextPath() + "/manage").generateResponse(req, rsp, null);
}
}
......@@ -34,7 +34,8 @@ THE SOFTWARE.
<l:task href="${rootURL}/" icon="icon-up icon-md" title="${%Back to Dashboard}"/>
<l:task href="${rootURL}/manage" icon="icon-gear2 icon-md" permission="${app.ADMINISTER}" title="${%Manage Jenkins}"/>
<l:task href="new" icon="icon-new-computer icon-md" permission="${createPermission}" title="${%New Node}"/>
<l:task href="configure" icon="icon-gear2 icon-md" permission="${app.ADMINISTER}" title="${%Configure}"/>
<l:task href="${rootURL}/configureClouds" icon="icon-health-40to59 icon-md" permission="${app.ADMINISTER}" title="${%Configure Clouds}"/>
<l:task href="configure" icon="icon-gear2 icon-md" permission="${app.ADMINISTER}" title="${%Node Monitoring}"/>
</l:tasks>
<t:queue items="${app.queue.items}" />
<t:executors />
......
......@@ -50,7 +50,7 @@ CliLink.Description=Access/manage Jenkins from your shell, or from your script.
ConsoleLink.DisplayName=Script Console
ConsoleLink.Description=Executes arbitrary script for administration/trouble-shooting/diagnostics.
NodesLink.DisplayName=Manage Nodes
NodesLink.DisplayName=Manage Nodes and Clouds
NodesLink.Description=Add, remove, control and monitor the various nodes that Jenkins runs jobs on.
ShutdownLink.DisplayName_prepare=Prepare for Shutdown
......
package jenkins.model.GlobalCloudConfiguration
import hudson.slaves.Cloud
def f=namespace(lib.FormTagLib)
def clouds = Cloud.all()
if (!clouds.isEmpty()) {
f.section(title:_("Cloud")) {
f.block {
f.hetero_list(name:"cloud", hasHeader:true, descriptors:Cloud.all(), items:app.clouds,
addCaption:_("Add a new cloud"), deleteCaption:_("Delete cloud"))
}
}
}
package jenkins.model.GlobalCloudConfiguration
import hudson.slaves.Cloud
def f = namespace(lib.FormTagLib)
def l = namespace(lib.LayoutTagLib)
def st = namespace("jelly:stapler")
l.layout(norefresh:true, permission:app.ADMINISTER, title:my.displayName) {
l.side_panel {
l.tasks {
l.task(icon:"icon-up icon-md", href:rootURL+'/', title:_("Back to Dashboard"))
l.task(icon:"icon-gear2 icon-md", href:"${rootURL}/computer/", title:_("Manage Nodes"))
}
}
l.main_panel {
h1 {
l.icon(class: 'icon-health-40to59 icon-xlg')
// TODO more appropriate icon
text(my.displayName)
}
def clouds = Cloud.all()
if (!clouds.isEmpty()) {
p()
div(class:"behavior-loading", _("LOADING"))
f.form(method:"post",name:"config",action:"configure") {
f.block {
f.hetero_list(name:"cloud", hasHeader:true, descriptors:Cloud.all(), items:app.clouds,
addCaption:_("Add a new cloud"), deleteCaption:_("Delete cloud"))
}
f.bottomButtonBar {
f.submit(value:_("Save"))
f.apply(value:_("Apply"))
}
}
st.adjunct(includes: "lib.form.confirm")
} else {
p {
_("There are no cloud implementations for dynamically allocated agents installed.")
a(href: rootURL + "/pluginManager/available") {
_("Go to plugin manager.")
}
}
}
}
}
package jenkins.model.Jenkins
import hudson.slaves.Cloud
// TODO remove this once it's been long enough that users got used to this.
def f = namespace(lib.FormTagLib)
def clouds = Cloud.all()
if (!clouds.isEmpty()) {
f.section(title: _("Cloud")) {
f.block {
div(class: 'alert alert-info') {
raw(_("note", rootURL))
}
}
}
}
note=The cloud configuration has moved to <a href="{0}/configureClouds">a separate configuration page</a>.
......@@ -52,6 +52,8 @@ THE SOFTWARE.
</f:rowSet>
</j:forEach>
<st:include page="_cloud-note.jelly"/>
<f:bottomButtonBar>
<f:submit value="${%Save}" />
<f:apply />
......
......@@ -74,3 +74,5 @@ BuildDiscarderProperty.displayName=Discard old builds
EnforceSlaveAgentPortAdministrativeMonitor.displayName=Enforce TCP Agent Port
CLI.disable-job.shortDescription=Disables a job.
CLI.enable-job.shortDescription=Enables a job.
GlobalCloudConfiguration.DisplayName=Configure Clouds
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册