Skip to content

Commit 619f3c7

Browse files
committed
plugin and core support
1 parent 588cc7f commit 619f3c7

File tree

9 files changed

+189
-4
lines changed

9 files changed

+189
-4
lines changed

core/src/main/java/com/dtolabs/rundeck/core/execution/ExecutionContext.java

+6-1
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
import com.dtolabs.rundeck.core.common.NodesSelector;
3030
import com.dtolabs.rundeck.core.jobs.JobService;
3131
import com.dtolabs.rundeck.core.common.OrchestratorConfig;
32+
import com.dtolabs.rundeck.core.nodes.ProjectNodeService;
3233
import com.dtolabs.rundeck.core.storage.StorageTree;
33-
import com.dtolabs.rundeck.plugins.orchestrator.OrchestratorPlugin;
3434

3535
import java.io.File;
3636
import java.util.Map;
@@ -67,6 +67,11 @@ public interface ExecutionContext {
6767
*/
6868
public JobService getJobService();
6969

70+
/**
71+
* @return the job service
72+
*/
73+
public ProjectNodeService getNodeService();
74+
7075
/**
7176
* @return username
7277
*/

core/src/main/java/com/dtolabs/rundeck/core/execution/ExecutionContextImpl.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@
3636
import com.dtolabs.rundeck.core.execution.workflow.StepExecutionContext;
3737
import com.dtolabs.rundeck.core.execution.workflow.steps.node.NodeExecutionContext;
3838
import com.dtolabs.rundeck.core.jobs.JobService;
39+
import com.dtolabs.rundeck.core.nodes.ProjectNodeService;
3940
import com.dtolabs.rundeck.core.storage.StorageTree;
40-
import com.dtolabs.rundeck.plugins.orchestrator.OrchestratorPlugin;
4141

4242
import java.io.File;
4343
import java.util.ArrayList;
@@ -73,6 +73,7 @@ public class ExecutionContextImpl implements ExecutionContext, StepExecutionCont
7373
private List<Integer> stepContext;
7474
private StorageTree storageTree;
7575
private JobService jobService;
76+
private ProjectNodeService nodeService;
7677
private FlowControl flowControl;
7778

7879
private OrchestratorConfig orchestrator;
@@ -152,6 +153,7 @@ public Builder(final ExecutionContext original) {
152153
ctx.nodeRankOrderAscending = original.isNodeRankOrderAscending();
153154
ctx.storageTree = original.getStorageTree();
154155
ctx.jobService = original.getJobService();
156+
ctx.nodeService = original.getNodeService();
155157
ctx.orchestrator = original.getOrchestrator();
156158
if(original instanceof NodeExecutionContext){
157159
NodeExecutionContext original1 = (NodeExecutionContext) original;
@@ -170,6 +172,11 @@ public Builder jobService(JobService jobService) {
170172
return this;
171173
}
172174

175+
public Builder nodeService(ProjectNodeService nodeService) {
176+
ctx.nodeService=nodeService;
177+
return this;
178+
}
179+
173180
public Builder(final StepExecutionContext original) {
174181
this((ExecutionContext) original);
175182
if (null != original) {
@@ -414,6 +421,11 @@ public JobService getJobService() {
414421
return jobService;
415422
}
416423

424+
@Override
425+
public ProjectNodeService getNodeService(){
426+
return nodeService;
427+
}
428+
417429

418430
@Override
419431
public OrchestratorConfig getOrchestrator() {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package com.dtolabs.rundeck.core.nodes;
2+
3+
/*
4+
* Copyright 2016 SimplifyOps, Inc. (http://simplifyops.com)
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import com.dtolabs.rundeck.core.common.IProjectNodes;
20+
21+
/**
22+
* Service for interact with nodes.
23+
*/
24+
public interface ProjectNodeService {
25+
26+
27+
/**
28+
* Expire cache and refresh node list
29+
*
30+
* @param project Project name
31+
*/
32+
void refreshProjectNodes(final String project);
33+
34+
IProjectNodes getNodes(final String name);
35+
}
+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Copyright 2016 SimplifyOps, Inc. (http://simplifyops.com)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
ext.pluginClassNames = 'org.rundeck.plugin.nodes.NodeRefreshWorkflowStep'
18+
ext.pluginName = 'Node Refresh Plugin'
19+
ext.pluginDescription = 'Force refresh node list'
20+
21+
jar {
22+
manifest {
23+
attributes 'Rundeck-Plugin-Classnames': pluginClassNames
24+
attributes 'Rundeck-Plugin-Name': pluginName
25+
attributes 'Rundeck-Plugin-Description': pluginDescription
26+
}
27+
}
28+
29+
task createPom << {
30+
pom {
31+
project {
32+
artifactId 'rundeck-source-refresh-plugin'
33+
groupId project.group
34+
inceptionYear '2015'
35+
packaging 'jar'
36+
version version
37+
name "Node Refresh Plugin"
38+
url 'http://rundeck.org'
39+
licenses {
40+
license {
41+
name 'The Apache Software License, Version 2.0'
42+
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
43+
distribution 'repo'
44+
}
45+
}
46+
parent{
47+
groupId project.group
48+
artifactId "rundeck-bundled-plugins"
49+
version(version)
50+
}
51+
build{
52+
plugins{
53+
plugin{
54+
groupId 'org.apache.maven.plugins'
55+
artifactId 'maven-jar-plugin'
56+
version '2.3.2'
57+
configuration{
58+
archive{
59+
manifestEntries{
60+
'Rundeck-Plugin-Classnames'(pluginClassNames)
61+
'Rundeck-Plugin-Version'(rundeckPluginVersion)
62+
'Rundeck-Plugin-Archive'('true')
63+
'Rundeck-Plugin-File-Version'(version)
64+
}
65+
}
66+
}
67+
}
68+
}
69+
}
70+
}
71+
}.writeTo("pom.xml")
72+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/*
2+
* Copyright 2016 SimplifyOps, Inc. (http://simplifyops.com)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.rundeck.plugin.nodes;
18+
19+
import com.dtolabs.rundeck.core.common.INodeSet;
20+
import com.dtolabs.rundeck.core.common.IProjectNodes;
21+
import com.dtolabs.rundeck.core.execution.workflow.steps.StepException;
22+
import com.dtolabs.rundeck.core.plugins.Plugin;
23+
import com.dtolabs.rundeck.plugins.ServiceNameConstants;
24+
import com.dtolabs.rundeck.plugins.descriptions.PluginDescription;
25+
import com.dtolabs.rundeck.plugins.descriptions.PluginProperty;
26+
import com.dtolabs.rundeck.plugins.step.PluginStepContext;
27+
import com.dtolabs.rundeck.plugins.step.StepPlugin;
28+
29+
import java.util.Map;
30+
31+
32+
@Plugin(name = NodeRefreshWorkflowStep.PROVIDER_NAME, service = ServiceNameConstants.WorkflowStep)
33+
@PluginDescription(title = "Force refresh node list",
34+
description = "Force refresh node list.\n")
35+
36+
37+
public class NodeRefreshWorkflowStep implements StepPlugin {
38+
39+
public static final String PROVIDER_NAME = "source-refresh-plugin";
40+
41+
42+
@Override
43+
public void executeStep(PluginStepContext context, Map<String, Object> configuration) throws StepException {
44+
context.getExecutionContext().getNodeService().refreshProjectNodes(context.getFrameworkProject());
45+
IProjectNodes nodes = context.getExecutionContext().getNodeService().getNodes(context.getFrameworkProject());
46+
INodeSet set = nodes.getNodeSet();
47+
}
48+
49+
50+
}

rundeckapp/build.gradle

+2-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ dependencies {
8080
project(':plugins:flow-control-plugin'),
8181
project(':plugins:jasypt-encryption-plugin'),
8282
project(':plugins:orchestrator-plugin'),
83-
project(':plugins:git-plugin')
83+
project(':plugins:git-plugin'),
84+
project(':plugins:source-refresh-plugin')
8485
}
8586

8687
task copyPluginLibs(dependsOn: configurations.pluginFiles)<< {

rundeckapp/grails-app/services/rundeck/services/ExecutionService.groovy

+2
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ class ExecutionService implements ApplicationContextAware, StepExecutor, NodeSte
9797
def logFileStorageService
9898
MessageSource messageSource
9999
def jobStateService
100+
def nodeService
100101
def grailsApplication
101102
def configurationService
102103
def grailsEvents
@@ -1184,6 +1185,7 @@ class ExecutionService implements ApplicationContextAware, StepExecutor, NodeSte
11841185
.frameworkProject(execMap.project)
11851186
.storageTree(storageService.storageTreeWithContext(authContext))
11861187
.jobService(jobStateService.jobServiceWithAuthContext(authContext))
1188+
.nodeService(nodeService.nodeService())
11871189
.user(userName)
11881190
.nodeSelector(nodeselector)
11891191
.nodes(nodeSet)

rundeckapp/grails-app/services/rundeck/services/NodeService.groovy

+8-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import com.dtolabs.rundeck.core.common.IProjectNodes
2121
import com.dtolabs.rundeck.core.common.IProjectNodesFactory
2222
import com.dtolabs.rundeck.core.common.IRundeckProjectConfig
2323
import com.dtolabs.rundeck.core.common.ProjectNodeSupport
24+
import com.dtolabs.rundeck.core.nodes.ProjectNodeService
2425
import com.dtolabs.rundeck.core.plugins.configuration.Property
2526
import com.dtolabs.rundeck.core.resources.SourceFactory
2627
import com.dtolabs.rundeck.plugins.util.PropertyBuilder
@@ -41,7 +42,7 @@ import java.util.concurrent.TimeUnit
4142
/**
4243
* Provides asynchronous loading and caching of nodesets for projects
4344
*/
44-
class NodeService implements InitializingBean, RundeckProjectConfigurable,IProjectNodesFactory {
45+
class NodeService implements InitializingBean, RundeckProjectConfigurable,IProjectNodesFactory, ProjectNodeService {
4546
public static final String PROJECT_NODECACHE_DELAY = 'project.nodeCache.delay'
4647
public static final String PROJECT_NODECACHE_ENABLED = 'project.nodeCache.enabled'
4748
static transactional = false
@@ -283,4 +284,10 @@ class NodeService implements InitializingBean, RundeckProjectConfigurable,IProje
283284
}
284285
result
285286
}
287+
288+
289+
ProjectNodeService nodeService() {
290+
return this
291+
}
292+
286293
}

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ include 'core',
2626
'plugins:stub-plugin',
2727
'plugins:copyfile-plugin',
2828
'plugins:job-state-plugin',
29+
'plugins:source-refresh-plugin',
2930
'plugins:flow-control-plugin',
3031
'plugins:jasypt-encryption-plugin',
3132
'plugins:orchestrator-plugin',

0 commit comments

Comments
 (0)