rundeck 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/CHANGELOG.md +2 -0
- data/lib/rundeck/api.rb +1 -1
- data/lib/rundeck/client.rb +2 -1
- data/lib/rundeck/client/execution.rb +17 -22
- data/lib/rundeck/client/job.rb +3 -2
- data/lib/rundeck/client/project.rb +84 -0
- data/lib/rundeck/objectified_hash.rb +7 -1
- data/lib/rundeck/version.rb +1 -1
- data/rundeck.gemspec +1 -0
- data/spec/cassettes/12/create_project_invalid.yml +43 -0
- data/spec/cassettes/12/create_project_json.yml +55 -0
- data/spec/cassettes/12/create_project_xml.yml +58 -0
- data/spec/cassettes/12/delete_project_invalid.yml +41 -0
- data/spec/cassettes/12/delete_project_valid.yml +32 -0
- data/spec/cassettes/12/project_invalid.yml +41 -0
- data/spec/cassettes/12/project_valid.yml +55 -0
- data/spec/cassettes/12/projects.yml +44 -0
- data/spec/rundeck/client/execution_spec.rb +128 -89
- data/spec/rundeck/client/job_spec.rb +14 -8
- data/spec/rundeck/client/project_spec.rb +117 -0
- data/spec/rundeck/objectified_hash_spec.rb +16 -0
- data/spec/rundeck/request_spec.rb +1 -1
- data/spec/rundeck_spec.rb +1 -1
- data/spec/support/helpers.rb +36 -20
- metadata +36 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 31730efc03d57ef39d030de2aaec177f44d26a4e
|
4
|
+
data.tar.gz: 193d25852a20e7a351760d90e4a9a311e1ed3210
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7c0324e4bff89cbc319ad93c102c16927bb76928bd5be58f70679d570eb19d8a87f2ba895f6e2c9e2515d5da23193c065cbfce3d18661b18d85adefd952b8ae3
|
7
|
+
data.tar.gz: 564b902d2ed2f4771495809585e32899d088ed7e289c6219cdbb9fab34d04d77e3efffb958668d34d51e414b6a850ca9af95e60311fe2914b5be701368f9dd3c
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
ADDED
data/lib/rundeck/api.rb
CHANGED
@@ -9,7 +9,7 @@ module Rundeck
|
|
9
9
|
def initialize(options = {})
|
10
10
|
options = Rundeck.options.merge(options)
|
11
11
|
Configuration::VALID_OPTIONS_KEYS.each do |key|
|
12
|
-
send("#{key}=", options[key])
|
12
|
+
send("#{key}=", options[key]) if options.key?(key)
|
13
13
|
end
|
14
14
|
set_request_defaults @endpoint, @api_token
|
15
15
|
end
|
data/lib/rundeck/client.rb
CHANGED
@@ -54,6 +54,7 @@ module Rundeck
|
|
54
54
|
include Execution
|
55
55
|
include Job
|
56
56
|
include Key
|
57
|
+
include Project
|
57
58
|
|
58
59
|
# Turn a hash into an object for easy accessibility.
|
59
60
|
#
|
@@ -68,7 +69,7 @@ module Rundeck
|
|
68
69
|
if result.is_a?(Hash)
|
69
70
|
ObjectifiedHash.new(result)
|
70
71
|
elsif result.is_a?(Array)
|
71
|
-
result.map
|
72
|
+
result.map { |e| ObjectifiedHash.new(e) }
|
72
73
|
elsif result.nil?
|
73
74
|
nil
|
74
75
|
else
|
@@ -2,6 +2,12 @@ module Rundeck
|
|
2
2
|
class Client
|
3
3
|
# Defines methods related to executions.
|
4
4
|
module Execution
|
5
|
+
def project_options_query(project, options)
|
6
|
+
options[:query] = {} if options[:query].nil?
|
7
|
+
options[:query]['project'] = project
|
8
|
+
options
|
9
|
+
end
|
10
|
+
|
5
11
|
# Execute a job
|
6
12
|
#
|
7
13
|
# @!macro has_optional_params
|
@@ -19,7 +25,7 @@ module Rundeck
|
|
19
25
|
# @return [Rundeck::ObjectifiedHash]
|
20
26
|
# @!macro exceptions
|
21
27
|
def execute_job(id, options = {})
|
22
|
-
objectify post("/job/#{id}/executions", options)['result']['executions']
|
28
|
+
objectify post("/job/#{id}/executions", options)['result']['executions']
|
23
29
|
end
|
24
30
|
alias_method :run_job, :execute_job
|
25
31
|
|
@@ -39,7 +45,7 @@ module Rundeck
|
|
39
45
|
# @return [Rundeck::ObjectifiedHash]
|
40
46
|
# @!macro exceptions
|
41
47
|
def job_executions(id, options = {})
|
42
|
-
r = get("/job/#{id}/executions", options)['result']['executions']
|
48
|
+
r = get("/job/#{id}/executions", options)['result']['executions']
|
43
49
|
objectify r
|
44
50
|
end
|
45
51
|
|
@@ -55,21 +61,12 @@ module Rundeck
|
|
55
61
|
#
|
56
62
|
# @param [String] project List running executions from this project
|
57
63
|
# @!macro options
|
58
|
-
# @return [
|
59
|
-
# @return [Rundeck::ObjectifiedHash] if a single running job execution
|
60
|
-
# @return [Array<Rundeck::ObjectifiedHash>] if multiple running job executions
|
64
|
+
# @return [Rundeck::ObjectifiedHash]
|
61
65
|
# @!macro exceptions
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
#
|
67
|
-
# if objectify(r['result']['executions']).count != '0'
|
68
|
-
# objectify r['result']['executions']['execution']
|
69
|
-
# else
|
70
|
-
# nil
|
71
|
-
# end
|
72
|
-
# end
|
66
|
+
def running_job_executions(project, options = {})
|
67
|
+
options = project_options_query(project, options)
|
68
|
+
objectify get('/executions/running', options)['result']['executions']
|
69
|
+
end
|
73
70
|
|
74
71
|
# Delete all executions for a specific job
|
75
72
|
#
|
@@ -175,12 +172,10 @@ module Rundeck
|
|
175
172
|
#
|
176
173
|
# @see http://rundeck.org/docs/api/index.html#execution-query
|
177
174
|
# Rundeck API documentation for 'GET /api/12/executions'
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
# objectify get('/executions', options)['result']
|
183
|
-
# end
|
175
|
+
def execution_query(project, options = {})
|
176
|
+
options = project_options_query(project, options)
|
177
|
+
objectify get('/executions', options)['result']['executions']
|
178
|
+
end
|
184
179
|
|
185
180
|
# def execution_output()
|
186
181
|
#
|
data/lib/rundeck/client/job.rb
CHANGED
@@ -12,12 +12,13 @@ module Rundeck
|
|
12
12
|
# @return [Array<Rundeck::ObjectifiedHash>]
|
13
13
|
# @!macro exceptions
|
14
14
|
def jobs(project, options = {})
|
15
|
-
objectify get("/project/#{project}/jobs", options)['jobs']
|
15
|
+
objectify get("/project/#{project}/jobs", options)['jobs']
|
16
16
|
end
|
17
17
|
|
18
18
|
# Gets a single job by id
|
19
19
|
#
|
20
|
-
# @example
|
20
|
+
# @example
|
21
|
+
# Rundeck.job('c07518ef-b697-4792-9a59-5b4f08855b67')
|
21
22
|
#
|
22
23
|
# @param [String] id Job id
|
23
24
|
# @!macro options
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module Rundeck
|
2
|
+
class Client
|
3
|
+
# Defines methods related to projects.
|
4
|
+
module Project
|
5
|
+
# Get all projects
|
6
|
+
#
|
7
|
+
# @see http://rundeck.org/docs/api/index.html#listing-projects
|
8
|
+
# Rundeck API documentation for 'GET /api/1/projects' endpoint
|
9
|
+
#
|
10
|
+
# @example
|
11
|
+
# Rundeck.projects
|
12
|
+
#
|
13
|
+
# @!macro options
|
14
|
+
# @return [Rundeck::ObjectifiedHash]
|
15
|
+
# @!macro exceptions
|
16
|
+
def projects(options = {})
|
17
|
+
objectify get('/projects', options)['projects']
|
18
|
+
end
|
19
|
+
|
20
|
+
# Create a project
|
21
|
+
#
|
22
|
+
# @see http://rundeck.org/docs/api/index.html#project-creation
|
23
|
+
# Rundeck API documentation for 'POST /api/11/projects' endpoint
|
24
|
+
#
|
25
|
+
# @example
|
26
|
+
# @TODO: Example
|
27
|
+
#
|
28
|
+
# @param [String] content The job definition(s) as yaml or xml
|
29
|
+
# @param [String] format The project creation format. 'json|xml',
|
30
|
+
# defaults to 'json'
|
31
|
+
# @!macro options
|
32
|
+
# @return [Rundeck::ObjectifiedHash]
|
33
|
+
# @!macro exceptions
|
34
|
+
def create_project(content, format = 'json', options = {})
|
35
|
+
options[:headers] = {} if options[:headers].nil?
|
36
|
+
options[:headers] = if format == 'json'
|
37
|
+
options[:headers].merge!(
|
38
|
+
'Content-Type' => 'application/json')
|
39
|
+
elsif format == 'xml'
|
40
|
+
options[:headers].merge!(
|
41
|
+
'Content-Type' => 'application/xml')
|
42
|
+
else
|
43
|
+
fail Error::InvalidAttributes,
|
44
|
+
'format must be json or xml'
|
45
|
+
end
|
46
|
+
options[:body] = content
|
47
|
+
|
48
|
+
objectify post('/projects', options)['project']
|
49
|
+
end
|
50
|
+
|
51
|
+
# Get a project by name
|
52
|
+
#
|
53
|
+
# @see http://rundeck.org/docs/api/index.html#getting-project-info
|
54
|
+
# Rundeck API documentation for 'GET /api/1/project/[NAME]' endpoint
|
55
|
+
#
|
56
|
+
# @example
|
57
|
+
# Rundeck.project('anvils')
|
58
|
+
#
|
59
|
+
# @param [String] name The project name
|
60
|
+
# @!macro options
|
61
|
+
# @return [Rundeck::ObjectifiedHash]
|
62
|
+
# @!macro exceptions
|
63
|
+
def project(name, options = {})
|
64
|
+
objectify get("/project/#{name}", options)['project']
|
65
|
+
end
|
66
|
+
|
67
|
+
# Delete a project
|
68
|
+
#
|
69
|
+
# @see http://rundeck.org/docs/api/index.html#project-deletion
|
70
|
+
# Rundeck API documentation for 'DELETE /api/11/project/[NAME]' endpoint
|
71
|
+
#
|
72
|
+
# @example
|
73
|
+
# Rundeck.delete_project('my_project')
|
74
|
+
#
|
75
|
+
# @param [String] name The project name
|
76
|
+
# @!macro options
|
77
|
+
# @return nil
|
78
|
+
# @!macro exceptions
|
79
|
+
def delete_project(name, options = {})
|
80
|
+
objectify delete("/project/#{name}", options)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -5,7 +5,13 @@ module Rundeck
|
|
5
5
|
def initialize(hash)
|
6
6
|
@hash = hash
|
7
7
|
@data = hash.each_with_object({}) do |(key, value), data|
|
8
|
-
value =
|
8
|
+
value = if value.is_a?(Hash)
|
9
|
+
ObjectifiedHash.new(value)
|
10
|
+
elsif value.is_a?(Array)
|
11
|
+
value.map { |e| ObjectifiedHash.new(e) }
|
12
|
+
else
|
13
|
+
value
|
14
|
+
end
|
9
15
|
data[key.to_s.downcase] = value
|
10
16
|
data
|
11
17
|
end
|
data/lib/rundeck/version.rb
CHANGED
data/rundeck.gemspec
CHANGED
@@ -28,6 +28,7 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency 'rspec', '~> 3.1.0'
|
29
29
|
spec.add_development_dependency 'rspec-core', '~> 3.1.2'
|
30
30
|
spec.add_development_dependency 'rspec-its', '~> 1.0.0'
|
31
|
+
spec.add_development_dependency 'rubocop'
|
31
32
|
spec.add_development_dependency 'webmock'
|
32
33
|
spec.add_development_dependency 'codeclimate-test-reporter'
|
33
34
|
spec.add_development_dependency 'guard-rspec', '~> 4.3.0'
|
@@ -0,0 +1,43 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://192.168.50.2:4440/api/12/projects
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{ "name": "anvils" }'
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
X-Rundeck-Auth-Token:
|
13
|
+
- cmJQYoy9EAsSd0905yNjKDNGs0ESIwEd
|
14
|
+
Accept:
|
15
|
+
- application/xml
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 409
|
19
|
+
message: Conflict
|
20
|
+
headers:
|
21
|
+
Set-Cookie:
|
22
|
+
- JSESSIONID=urdzotmxs4xr1i958fa3gzya0;Path=/
|
23
|
+
Expires:
|
24
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
25
|
+
Content-Type:
|
26
|
+
- text/xml;charset=UTF-8
|
27
|
+
X-Rundeck-Api-Version:
|
28
|
+
- '12'
|
29
|
+
Transfer-Encoding:
|
30
|
+
- chunked
|
31
|
+
Server:
|
32
|
+
- Jetty(7.6.0.v20120127)
|
33
|
+
body:
|
34
|
+
encoding: UTF-8
|
35
|
+
string: |-
|
36
|
+
<result error='true' apiversion='12'>
|
37
|
+
<error code='api.error.item.alreadyexists'>
|
38
|
+
<message>project already exists: anvils</message>
|
39
|
+
</error>
|
40
|
+
</result>
|
41
|
+
http_version:
|
42
|
+
recorded_at: Mon, 03 Nov 2014 18:56:26 GMT
|
43
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,55 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://192.168.50.2:4440/api/12/projects
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: '{ "name": "json_project" }'
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
X-Rundeck-Auth-Token:
|
13
|
+
- cmJQYoy9EAsSd0905yNjKDNGs0ESIwEd
|
14
|
+
Accept:
|
15
|
+
- application/xml
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 201
|
19
|
+
message: Created
|
20
|
+
headers:
|
21
|
+
Set-Cookie:
|
22
|
+
- JSESSIONID=mtleb8x2y6qpqxb2a3vdup22;Path=/
|
23
|
+
Expires:
|
24
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
25
|
+
X-Rundeck-Api-Xml-Response-Wrapper:
|
26
|
+
- 'false'
|
27
|
+
Content-Type:
|
28
|
+
- application/xml;charset=UTF-8
|
29
|
+
X-Rundeck-Api-Version:
|
30
|
+
- '12'
|
31
|
+
Transfer-Encoding:
|
32
|
+
- chunked
|
33
|
+
Server:
|
34
|
+
- Jetty(7.6.0.v20120127)
|
35
|
+
body:
|
36
|
+
encoding: UTF-8
|
37
|
+
string: |-
|
38
|
+
<project url='http://192.168.50.2:4440/api/12/project/json_project'>
|
39
|
+
<name>json_project</name>
|
40
|
+
<description></description>
|
41
|
+
<config>
|
42
|
+
<property key='project.name' value='json_project' />
|
43
|
+
<property key='project.ssh-authentication' value='privateKey' />
|
44
|
+
<property key='service.NodeExecutor.default.provider' value='jsch-ssh' />
|
45
|
+
<property key='resources.source.1.config.includeServerNode' value='true' />
|
46
|
+
<property key='resources.source.1.config.generateFileAutomatically' value='true' />
|
47
|
+
<property key='resources.source.1.config.file' value='/var/rundeck/projects/json_project/etc/resources.xml' />
|
48
|
+
<property key='project.ssh-keypath' value='/var/lib/rundeck/.ssh/id_rsa' />
|
49
|
+
<property key='service.FileCopier.default.provider' value='jsch-scp' />
|
50
|
+
<property key='resources.source.1.type' value='file' />
|
51
|
+
</config>
|
52
|
+
</project>
|
53
|
+
http_version:
|
54
|
+
recorded_at: Mon, 03 Nov 2014 18:50:21 GMT
|
55
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,58 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: http://192.168.50.2:4440/api/12/projects
|
6
|
+
body:
|
7
|
+
encoding: UTF-8
|
8
|
+
string: |
|
9
|
+
<project>
|
10
|
+
<name>xml_project</name>
|
11
|
+
</project>
|
12
|
+
headers:
|
13
|
+
Content-Type:
|
14
|
+
- application/xml
|
15
|
+
X-Rundeck-Auth-Token:
|
16
|
+
- cmJQYoy9EAsSd0905yNjKDNGs0ESIwEd
|
17
|
+
Accept:
|
18
|
+
- application/xml
|
19
|
+
response:
|
20
|
+
status:
|
21
|
+
code: 201
|
22
|
+
message: Created
|
23
|
+
headers:
|
24
|
+
Set-Cookie:
|
25
|
+
- JSESSIONID=1bj2k8scmc7jvll68akb8nm9s;Path=/
|
26
|
+
Expires:
|
27
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
28
|
+
X-Rundeck-Api-Xml-Response-Wrapper:
|
29
|
+
- 'false'
|
30
|
+
Content-Type:
|
31
|
+
- application/xml;charset=UTF-8
|
32
|
+
X-Rundeck-Api-Version:
|
33
|
+
- '12'
|
34
|
+
Transfer-Encoding:
|
35
|
+
- chunked
|
36
|
+
Server:
|
37
|
+
- Jetty(7.6.0.v20120127)
|
38
|
+
body:
|
39
|
+
encoding: UTF-8
|
40
|
+
string: |-
|
41
|
+
<project url='http://192.168.50.2:4440/api/12/project/xml_project'>
|
42
|
+
<name>xml_project</name>
|
43
|
+
<description></description>
|
44
|
+
<config>
|
45
|
+
<property key='project.name' value='xml_project' />
|
46
|
+
<property key='project.ssh-authentication' value='privateKey' />
|
47
|
+
<property key='service.NodeExecutor.default.provider' value='jsch-ssh' />
|
48
|
+
<property key='resources.source.1.config.includeServerNode' value='true' />
|
49
|
+
<property key='resources.source.1.config.generateFileAutomatically' value='true' />
|
50
|
+
<property key='resources.source.1.config.file' value='/var/rundeck/projects/xml_project/etc/resources.xml' />
|
51
|
+
<property key='project.ssh-keypath' value='/var/lib/rundeck/.ssh/id_rsa' />
|
52
|
+
<property key='service.FileCopier.default.provider' value='jsch-scp' />
|
53
|
+
<property key='resources.source.1.type' value='file' />
|
54
|
+
</config>
|
55
|
+
</project>
|
56
|
+
http_version:
|
57
|
+
recorded_at: Mon, 03 Nov 2014 18:51:06 GMT
|
58
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,41 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: delete
|
5
|
+
uri: http://192.168.50.2:4440/api/12/project/project1
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
X-Rundeck-Auth-Token:
|
11
|
+
- cmJQYoy9EAsSd0905yNjKDNGs0ESIwEd
|
12
|
+
Accept:
|
13
|
+
- application/xml
|
14
|
+
response:
|
15
|
+
status:
|
16
|
+
code: 404
|
17
|
+
message: Not Found
|
18
|
+
headers:
|
19
|
+
Set-Cookie:
|
20
|
+
- JSESSIONID=1x1jz735m5pf41dyllrj4dbj9h;Path=/
|
21
|
+
Expires:
|
22
|
+
- Thu, 01 Jan 1970 00:00:00 GMT
|
23
|
+
Content-Type:
|
24
|
+
- text/xml;charset=UTF-8
|
25
|
+
X-Rundeck-Api-Version:
|
26
|
+
- '12'
|
27
|
+
Transfer-Encoding:
|
28
|
+
- chunked
|
29
|
+
Server:
|
30
|
+
- Jetty(7.6.0.v20120127)
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: |-
|
34
|
+
<result error='true' apiversion='12'>
|
35
|
+
<error code='api.error.item.doesnotexist'>
|
36
|
+
<message>Project does not exist: project1</message>
|
37
|
+
</error>
|
38
|
+
</result>
|
39
|
+
http_version:
|
40
|
+
recorded_at: Sun, 02 Nov 2014 18:46:21 GMT
|
41
|
+
recorded_with: VCR 2.9.3
|