gadabout 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/gadabout.rb +2 -0
- data/lib/gadabout/DSL/artifact.rb +23 -0
- data/lib/gadabout/DSL/base.rb +48 -0
- data/lib/gadabout/DSL/constraint.rb +23 -0
- data/lib/gadabout/DSL/job.rb +79 -0
- data/lib/gadabout/DSL/log_config.rb +18 -0
- data/lib/gadabout/DSL/network.rb +23 -0
- data/lib/gadabout/DSL/periodic.rb +28 -0
- data/lib/gadabout/DSL/resources.rb +37 -0
- data/lib/gadabout/DSL/restart_policy.rb +28 -0
- data/lib/gadabout/DSL/task.rb +83 -0
- data/lib/gadabout/DSL/task_group.rb +50 -0
- data/lib/gadabout/client.rb +222 -0
- data/lib/gadabout/dsl.rb +21 -0
- data/lib/gadabout/node.rb +0 -0
- data/lib/gadabout/version.rb +3 -0
- metadata +87 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a61995683057c5d17cf6fa25c95ae6281c2b5a46
|
4
|
+
data.tar.gz: da865c43635aff5d6df83e75f6304650b9f243db
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 29edbbc64f9ea3e7e8420bdd111611d668b1f7c2ec99400c10e8e37bb107d56d8f6356389b612d09bacb075dc2f2aed0a98e77347e27f902f734881b76ece535
|
7
|
+
data.tar.gz: cace848fa7a00644f4f5e484b5c676ad30b0b32c30d6e3b2a0d59ca7db227b8cc2e8361dc36ccc4121a48666503a1349ef676d87849fb048a6f87770c245b8b9
|
data/lib/gadabout.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Gadabout
|
2
|
+
module DSL
|
3
|
+
class Artifact < Base
|
4
|
+
def initialize
|
5
|
+
@getter_source = nil
|
6
|
+
@relative_dest = nil
|
7
|
+
@getter_options = {}
|
8
|
+
end
|
9
|
+
|
10
|
+
def source(source)
|
11
|
+
@getter_source = source
|
12
|
+
end
|
13
|
+
|
14
|
+
def relative_dest(relative_dest)
|
15
|
+
@relative_dest = relative_dest
|
16
|
+
end
|
17
|
+
|
18
|
+
def option(key, value)
|
19
|
+
@getter_options[key] = value
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Gadabout
|
2
|
+
module DSL
|
3
|
+
class Base
|
4
|
+
def initialize
|
5
|
+
end
|
6
|
+
|
7
|
+
def to_h
|
8
|
+
map = {}
|
9
|
+
|
10
|
+
self.instance_variables.each do |var|
|
11
|
+
val = instance_variable_get(var)
|
12
|
+
|
13
|
+
next if val.nil?
|
14
|
+
if val.instance_of? Array
|
15
|
+
next if val.empty?
|
16
|
+
end
|
17
|
+
|
18
|
+
unless [String, Fixnum, Hash, Array, TrueClass, FalseClass].include? val.class
|
19
|
+
val = val.to_h
|
20
|
+
else
|
21
|
+
# Check within Arrays and Hashes for other incomprehensibles
|
22
|
+
if val.instance_of? Array
|
23
|
+
val.map! do |i|
|
24
|
+
unless [String, Fixnum, Hash, Array, TrueClass, FalseClass].include? i.class
|
25
|
+
i.to_h
|
26
|
+
else
|
27
|
+
i
|
28
|
+
end
|
29
|
+
end
|
30
|
+
elsif val.instance_of? Hash
|
31
|
+
val.each_pair do |k,v|
|
32
|
+
unless [String, Fixnum, Hash, Array, TrueClass, FalseClass].include? v.class
|
33
|
+
val[k] = v.to_h
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
# Convert keys from ruby instance_var to Hashicorp JSON-syntax key
|
40
|
+
hashivar = var[1..-1].to_s.split('_').map{ |w| w.capitalize }.join('')
|
41
|
+
map[hashivar] = val
|
42
|
+
end
|
43
|
+
|
44
|
+
return map
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Gadabout
|
2
|
+
module DSL
|
3
|
+
class Constraint < Base
|
4
|
+
def initialize
|
5
|
+
@l_target = nil
|
6
|
+
@r_target = nil
|
7
|
+
@operator = nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def l_target(l_target)
|
11
|
+
@l_target = l_target
|
12
|
+
end
|
13
|
+
|
14
|
+
def r_target(r_target)
|
15
|
+
@r_target = r_target
|
16
|
+
end
|
17
|
+
|
18
|
+
def operator(operator)
|
19
|
+
@operator = operator
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
3
|
+
module Gadabout
|
4
|
+
module DSL
|
5
|
+
class Job < Base
|
6
|
+
def initialize(&block)
|
7
|
+
@name = nil
|
8
|
+
@task_groups = []
|
9
|
+
@constraints = []
|
10
|
+
@all_at_once = false
|
11
|
+
@meta = {}
|
12
|
+
@periodic = nil
|
13
|
+
@priority = 50
|
14
|
+
@region = "global"
|
15
|
+
@type = "service"
|
16
|
+
@update = nil
|
17
|
+
@datacenters = []
|
18
|
+
|
19
|
+
instance_eval &block if block_given?
|
20
|
+
|
21
|
+
spec = { Job: self.to_h }
|
22
|
+
|
23
|
+
puts JSON.pretty_generate(spec)
|
24
|
+
end
|
25
|
+
|
26
|
+
def task_group(&block)
|
27
|
+
tg = TaskGroup.new
|
28
|
+
|
29
|
+
tg.instance_eval &block
|
30
|
+
|
31
|
+
@task_groups << tg
|
32
|
+
end
|
33
|
+
|
34
|
+
def constraint(&block)
|
35
|
+
c = Constraint.new
|
36
|
+
|
37
|
+
c.instance_eval &block
|
38
|
+
|
39
|
+
@constraints << c
|
40
|
+
end
|
41
|
+
|
42
|
+
def periodic
|
43
|
+
p = Periodic.new
|
44
|
+
|
45
|
+
p.instance_eval &block
|
46
|
+
|
47
|
+
@periodic = p
|
48
|
+
end
|
49
|
+
|
50
|
+
def meta(key, value)
|
51
|
+
@meta[key] = value
|
52
|
+
end
|
53
|
+
|
54
|
+
def name(name)
|
55
|
+
@name = name
|
56
|
+
end
|
57
|
+
|
58
|
+
def region(region)
|
59
|
+
@region = region
|
60
|
+
end
|
61
|
+
|
62
|
+
def type(type)
|
63
|
+
@type = type
|
64
|
+
end
|
65
|
+
|
66
|
+
def priority(priority)
|
67
|
+
@priority = priority
|
68
|
+
end
|
69
|
+
|
70
|
+
def all_at_once(all_at_once)
|
71
|
+
@all_at_once = all_at_once
|
72
|
+
end
|
73
|
+
|
74
|
+
def datacenters(*datacenters)
|
75
|
+
@datacenters = datacenters
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Gadabout
|
2
|
+
module DSL
|
3
|
+
class LogConfig < Base
|
4
|
+
def initialize
|
5
|
+
@max_files = nil
|
6
|
+
@max_file_size_m_b = nil
|
7
|
+
end
|
8
|
+
|
9
|
+
def max_files(max_files)
|
10
|
+
@max_files = max_files
|
11
|
+
end
|
12
|
+
|
13
|
+
def max_file_size(max_file_size)
|
14
|
+
@max_file_size_m_b = max_file_size
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Gadabout
|
2
|
+
module DSL
|
3
|
+
class Network < Base
|
4
|
+
def initialize
|
5
|
+
@reserved_ports = []
|
6
|
+
@dynamic_ports = []
|
7
|
+
@m_bits = nil
|
8
|
+
end
|
9
|
+
|
10
|
+
def reserved_port(label, port)
|
11
|
+
@reserved_ports << {label: label, value: port}
|
12
|
+
end
|
13
|
+
|
14
|
+
def dynamic_port(label)
|
15
|
+
@dynamic_ports << {label: label}
|
16
|
+
end
|
17
|
+
|
18
|
+
def mbits(m_bits)
|
19
|
+
@m_bits = m_bits
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Gadabout
|
2
|
+
module DSL
|
3
|
+
class Periodic < Base
|
4
|
+
def initialize
|
5
|
+
@enabled = nil
|
6
|
+
@spec = nil
|
7
|
+
@spec_type = nil
|
8
|
+
@prohibit_overlap = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def enabled(enabled)
|
12
|
+
@enabled = enabled
|
13
|
+
end
|
14
|
+
|
15
|
+
def prohibit_overlap(prohibit_overlap)
|
16
|
+
@prohibit_overlap = prohibit_overlap
|
17
|
+
end
|
18
|
+
|
19
|
+
def spec_type(spec_type)
|
20
|
+
@spec_type = spec_type
|
21
|
+
end
|
22
|
+
|
23
|
+
def spec(spec)
|
24
|
+
@spec = spec
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Gadabout
|
2
|
+
module DSL
|
3
|
+
class Resources < Base
|
4
|
+
def initialize
|
5
|
+
@cpu = nil
|
6
|
+
@disk_m_b = nil
|
7
|
+
@iops = nil
|
8
|
+
@memory_m_b = nil
|
9
|
+
@networks = []
|
10
|
+
end
|
11
|
+
|
12
|
+
def network(&block)
|
13
|
+
n = Network.new
|
14
|
+
|
15
|
+
n.instance_eval &block
|
16
|
+
|
17
|
+
@networks << n
|
18
|
+
end
|
19
|
+
|
20
|
+
def cpu(cpu)
|
21
|
+
@cpu = cpu
|
22
|
+
end
|
23
|
+
|
24
|
+
def memory(memory)
|
25
|
+
@memory_m_b = memory
|
26
|
+
end
|
27
|
+
|
28
|
+
def iops(iops)
|
29
|
+
@iops = iops
|
30
|
+
end
|
31
|
+
|
32
|
+
def disk(disk)
|
33
|
+
@disk_m_b = disk
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Gadabout
|
2
|
+
module DSL
|
3
|
+
class RestartPolicy < Base
|
4
|
+
def initialize
|
5
|
+
@attempts = nil
|
6
|
+
@interval = nil
|
7
|
+
@delay = nil
|
8
|
+
@mode = nil
|
9
|
+
end
|
10
|
+
|
11
|
+
def attempts(attempts)
|
12
|
+
@attempts = attempts
|
13
|
+
end
|
14
|
+
|
15
|
+
def interval(interval)
|
16
|
+
@interval = interval
|
17
|
+
end
|
18
|
+
|
19
|
+
def delay(delay)
|
20
|
+
@delay = delay
|
21
|
+
end
|
22
|
+
|
23
|
+
def mode(mode)
|
24
|
+
@mode = mode
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Gadabout
|
2
|
+
module DSL
|
3
|
+
class Task < Base
|
4
|
+
def initialize
|
5
|
+
@artifacts = []
|
6
|
+
@config = {}
|
7
|
+
@name = nil
|
8
|
+
@constraints = []
|
9
|
+
@driver = nil
|
10
|
+
@env = {}
|
11
|
+
@meta = {}
|
12
|
+
@resources = nil
|
13
|
+
@kill_timeout = nil
|
14
|
+
@log_config = nil
|
15
|
+
@user = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
def constraint(&block)
|
19
|
+
c = Constraint.new
|
20
|
+
|
21
|
+
c.instance_eval &block
|
22
|
+
|
23
|
+
@constraints << c
|
24
|
+
end
|
25
|
+
|
26
|
+
def artifact(&block)
|
27
|
+
a = Artifact.new
|
28
|
+
|
29
|
+
a.instance_eval &block
|
30
|
+
|
31
|
+
@artifacts << a
|
32
|
+
end
|
33
|
+
|
34
|
+
def log_config(&block)
|
35
|
+
lc = LogConfig.new
|
36
|
+
|
37
|
+
lc.instance_eval &block
|
38
|
+
|
39
|
+
@log_config = lc
|
40
|
+
end
|
41
|
+
|
42
|
+
def resources(&block)
|
43
|
+
r = Resources.new
|
44
|
+
|
45
|
+
r.instance_eval &block
|
46
|
+
|
47
|
+
@resources = r
|
48
|
+
end
|
49
|
+
|
50
|
+
def meta(key, value)
|
51
|
+
@meta[key] = value
|
52
|
+
end
|
53
|
+
|
54
|
+
def env(key, value)
|
55
|
+
@env[key] = value
|
56
|
+
end
|
57
|
+
|
58
|
+
def name(name)
|
59
|
+
@name = name
|
60
|
+
end
|
61
|
+
|
62
|
+
def config(key, value)
|
63
|
+
@config[key] = value
|
64
|
+
end
|
65
|
+
|
66
|
+
def name(name)
|
67
|
+
@name = name
|
68
|
+
end
|
69
|
+
|
70
|
+
def user(user)
|
71
|
+
@user = user
|
72
|
+
end
|
73
|
+
|
74
|
+
def driver(driver)
|
75
|
+
@driver = driver
|
76
|
+
end
|
77
|
+
|
78
|
+
def kill_timeout(kill_timeout)
|
79
|
+
@kill_timeout = kill_timeout
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Gadabout
|
2
|
+
module DSL
|
3
|
+
class TaskGroup < Base
|
4
|
+
def initialize
|
5
|
+
@constraints = []
|
6
|
+
@count = 0
|
7
|
+
@meta = {}
|
8
|
+
@name = nil
|
9
|
+
@restart_policy = nil
|
10
|
+
@tasks = []
|
11
|
+
end
|
12
|
+
|
13
|
+
def task(&block)
|
14
|
+
t = Task.new
|
15
|
+
|
16
|
+
t.instance_eval &block
|
17
|
+
|
18
|
+
@tasks << t
|
19
|
+
end
|
20
|
+
|
21
|
+
def constraint(&block)
|
22
|
+
c = Constraint.new
|
23
|
+
|
24
|
+
c.instance_eval &block
|
25
|
+
|
26
|
+
@constraints << c
|
27
|
+
end
|
28
|
+
|
29
|
+
def restart_policy(&block)
|
30
|
+
rp = RestartPolicy.new
|
31
|
+
|
32
|
+
rp.instance_eval &block
|
33
|
+
|
34
|
+
@restart_policy = rp
|
35
|
+
end
|
36
|
+
|
37
|
+
def meta(key, value)
|
38
|
+
@meta[key] = value
|
39
|
+
end
|
40
|
+
|
41
|
+
def name(name)
|
42
|
+
@name = name
|
43
|
+
end
|
44
|
+
|
45
|
+
def count(count)
|
46
|
+
@count = count
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,222 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'rest-client'
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Gadabout
|
6
|
+
|
7
|
+
API_VERSION = "/v1"
|
8
|
+
|
9
|
+
class Client
|
10
|
+
|
11
|
+
def initialize(host="localhost", port=4646)
|
12
|
+
@rest = RestClient::Resource.new(URI::HTTP.build({:host => host, :port => port, :path => API_VERSION}))
|
13
|
+
end
|
14
|
+
|
15
|
+
#GET /v1/jobs
|
16
|
+
def jobs(opts={})
|
17
|
+
valid_opts?(opts,["prefix"])
|
18
|
+
path = "/jobs"
|
19
|
+
return get(path, opts)
|
20
|
+
end
|
21
|
+
|
22
|
+
#GET /v1/job
|
23
|
+
def job(id)
|
24
|
+
path = File.join("/job", id)
|
25
|
+
return get(path)
|
26
|
+
end
|
27
|
+
|
28
|
+
#GET /v1/job/<ID>/evaluations
|
29
|
+
def job_evaluatons(id)
|
30
|
+
path = File.join("/job", id, "/evaluations")
|
31
|
+
return get(path)
|
32
|
+
end
|
33
|
+
|
34
|
+
#GET /v1/job/<ID>/allocations
|
35
|
+
def job_allocations(id)
|
36
|
+
path = File.join("/job", id, "/allocations")
|
37
|
+
return get(path)
|
38
|
+
end
|
39
|
+
|
40
|
+
#PUT/POST /v1/job
|
41
|
+
def force_job_evaluation(id)
|
42
|
+
path = File.join("/job", id, "/evaluate")
|
43
|
+
return put(path)
|
44
|
+
end
|
45
|
+
|
46
|
+
#PUT/POST /v1/job
|
47
|
+
def force_periodic_job(id)
|
48
|
+
path = File.join("/job", id, "/periodic/force")
|
49
|
+
return put(path)
|
50
|
+
end
|
51
|
+
|
52
|
+
#PUT/POST /v1/job
|
53
|
+
def register_job(spec)
|
54
|
+
path = "/job"
|
55
|
+
return put(path, nil, spec)
|
56
|
+
end
|
57
|
+
|
58
|
+
#PUT/POST /v1/job
|
59
|
+
def update_job(id, spec)
|
60
|
+
path = File.join("/job", id)
|
61
|
+
return put(path, nil, spec)
|
62
|
+
end
|
63
|
+
|
64
|
+
#DELETE /v1/job
|
65
|
+
def delete_job(id)
|
66
|
+
path = File.join("/job", id)
|
67
|
+
return delete(path)
|
68
|
+
end
|
69
|
+
|
70
|
+
#GET /v1/nodes
|
71
|
+
def nodes(opts={})
|
72
|
+
valid_opts?(opts,["prefix"])
|
73
|
+
path = "/nodes"
|
74
|
+
return get(path, opts)
|
75
|
+
end
|
76
|
+
|
77
|
+
#GET /v1/node/<ID>
|
78
|
+
def node(id)
|
79
|
+
path = File.join("/node", id)
|
80
|
+
return get(path)
|
81
|
+
end
|
82
|
+
|
83
|
+
#GET /v1/node/<ID>/allocations
|
84
|
+
def node_allocations(id)
|
85
|
+
path = File.join("job", id, "allocations")
|
86
|
+
return get(path)
|
87
|
+
end
|
88
|
+
|
89
|
+
#PUT/POST /v1/node/<ID>/evaluate
|
90
|
+
def create_evaluation(id)
|
91
|
+
path = File.join("/node", id, "/evaluate")
|
92
|
+
return put(path)
|
93
|
+
end
|
94
|
+
|
95
|
+
def drain(id, enable)
|
96
|
+
path = File.join("/node", id, "/drain")
|
97
|
+
return put(path, {:enable => enable})
|
98
|
+
end
|
99
|
+
|
100
|
+
#GET /v1/allocations
|
101
|
+
def allocations(opts = {})
|
102
|
+
valid_opts?(opts, ['prefix'])
|
103
|
+
path = "/allocations"
|
104
|
+
return get(path, opts)
|
105
|
+
end
|
106
|
+
|
107
|
+
#GET /v1/allocation/<ID>
|
108
|
+
def allocation(id)
|
109
|
+
path = File.join("/allocation", id)
|
110
|
+
return get(path)
|
111
|
+
end
|
112
|
+
|
113
|
+
#GET /v1/evaluations
|
114
|
+
def evaluations(opts = {})
|
115
|
+
valid_opts?(opts, ['prefix'])
|
116
|
+
path = "/evaluations"
|
117
|
+
return get(path, opts)
|
118
|
+
end
|
119
|
+
|
120
|
+
#GET /v1/evaluation/<ID>
|
121
|
+
def evaluation(id)
|
122
|
+
path = File.join("/evaluation", id)
|
123
|
+
return get(path)
|
124
|
+
end
|
125
|
+
|
126
|
+
#GET /v1/evaluation/<ID>/allocations
|
127
|
+
def evaluation_allocations(id)
|
128
|
+
path = File.join("/evaluation", id, 'allocations')
|
129
|
+
return get(path)
|
130
|
+
end
|
131
|
+
|
132
|
+
#GET /v1/agent/self
|
133
|
+
def agent_info
|
134
|
+
path = "/agent/self"
|
135
|
+
return get(path)
|
136
|
+
end
|
137
|
+
|
138
|
+
#PUT/POST /v1/agent/join
|
139
|
+
def agent_join(addresses)
|
140
|
+
path = "/agent/join"
|
141
|
+
return put(path, {:address => addresses})
|
142
|
+
end
|
143
|
+
|
144
|
+
#GET /v1/agent/members
|
145
|
+
def members
|
146
|
+
path = "/agent/members"
|
147
|
+
return get(path)
|
148
|
+
end
|
149
|
+
|
150
|
+
#PUT/POST /v1/agent/force-leave
|
151
|
+
def force_leave(node)
|
152
|
+
path = "/agent/force-leave"
|
153
|
+
return put(path, {:node => node})
|
154
|
+
end
|
155
|
+
|
156
|
+
#GET /v1/agent/servers
|
157
|
+
def servers
|
158
|
+
path = "/agent/servers"
|
159
|
+
return get(path)
|
160
|
+
end
|
161
|
+
|
162
|
+
#PUT/POST /v1/agent/servers
|
163
|
+
def update_servers(addresses)
|
164
|
+
path = "/agent/servers"
|
165
|
+
return put(path, {:address => addresses})
|
166
|
+
end
|
167
|
+
|
168
|
+
#GET /v1/client/fs/ls
|
169
|
+
def client_ls(allocation, path)
|
170
|
+
path = File.join("/client/fs/ls", allocation)
|
171
|
+
return get(path, {:path => path})
|
172
|
+
end
|
173
|
+
|
174
|
+
#GET /v1/client/fs/cat
|
175
|
+
def client_cat(allocation, path)
|
176
|
+
path = File.join("/client/fs/cat", allocation)
|
177
|
+
return get(path, {:path => path})
|
178
|
+
end
|
179
|
+
|
180
|
+
#GET /v1/client/fs/stat
|
181
|
+
def client_stat(allocation, path)
|
182
|
+
path = File.join("/client/fs/cat", allocation)
|
183
|
+
return get(path, {:path => path})
|
184
|
+
end
|
185
|
+
|
186
|
+
private
|
187
|
+
|
188
|
+
def get(path, params = {})
|
189
|
+
begin
|
190
|
+
resp = @rest[path].get(:params => params)
|
191
|
+
rescue StandardError => e
|
192
|
+
raise "Error whilst making HTTP GET request to the Nomad Agent at #{path}: #{e.response}"
|
193
|
+
end
|
194
|
+
|
195
|
+
return JSON.parse(resp)
|
196
|
+
end
|
197
|
+
|
198
|
+
def put(path, params = {}, body = '')
|
199
|
+
begin
|
200
|
+
resp = @rest[path].put(body, :params => params)
|
201
|
+
rescue StandardError => e
|
202
|
+
raise "Error whilst making HTTP PUT request to the Nomad Agent at #{path}: #{e.response}"
|
203
|
+
end
|
204
|
+
|
205
|
+
return JSON.parse(resp)
|
206
|
+
end
|
207
|
+
|
208
|
+
def delete(path, params = {})
|
209
|
+
begin
|
210
|
+
resp = @rest[path].delete(:params => params)
|
211
|
+
rescue StandardError => e
|
212
|
+
raise "Error whilst making HTTP DELETE request to the Nomad Agent at #{path}: #{e.response}"
|
213
|
+
end
|
214
|
+
|
215
|
+
return JSON.parse(resp)
|
216
|
+
end
|
217
|
+
|
218
|
+
def valid_opts?(opts, valid)
|
219
|
+
raise "Invalid options. Supported: #{valid}" unless opts.keys.reject{ |k| valid.include? k }.empty?
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
data/lib/gadabout/dsl.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'gadabout/dsl/base'
|
2
|
+
require 'gadabout/dsl/job'
|
3
|
+
require 'gadabout/dsl/constraint'
|
4
|
+
require 'gadabout/dsl/task_group'
|
5
|
+
require 'gadabout/dsl/task'
|
6
|
+
require 'gadabout/dsl/log_config'
|
7
|
+
require 'gadabout/dsl/restart_policy'
|
8
|
+
require 'gadabout/dsl/resources'
|
9
|
+
require 'gadabout/dsl/artifact'
|
10
|
+
require 'gadabout/dsl/network'
|
11
|
+
require 'gadabout/dsl/periodic'
|
12
|
+
|
13
|
+
module Gadabout
|
14
|
+
module DSL
|
15
|
+
def job(&block)
|
16
|
+
Gadabout::DSL::Job.new &block
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
include Gadabout::DSL
|
File without changes
|
metadata
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: gadabout
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josh McGhee
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-05-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.19'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.19'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rest-client
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.8'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.8'
|
41
|
+
description: A swiss army knife gem for the Hashicorp Nomad job scheduler
|
42
|
+
email:
|
43
|
+
- joshpmcghee@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- lib/gadabout.rb
|
49
|
+
- lib/gadabout/DSL/artifact.rb
|
50
|
+
- lib/gadabout/DSL/base.rb
|
51
|
+
- lib/gadabout/DSL/constraint.rb
|
52
|
+
- lib/gadabout/DSL/job.rb
|
53
|
+
- lib/gadabout/DSL/log_config.rb
|
54
|
+
- lib/gadabout/DSL/network.rb
|
55
|
+
- lib/gadabout/DSL/periodic.rb
|
56
|
+
- lib/gadabout/DSL/resources.rb
|
57
|
+
- lib/gadabout/DSL/restart_policy.rb
|
58
|
+
- lib/gadabout/DSL/task.rb
|
59
|
+
- lib/gadabout/DSL/task_group.rb
|
60
|
+
- lib/gadabout/client.rb
|
61
|
+
- lib/gadabout/dsl.rb
|
62
|
+
- lib/gadabout/node.rb
|
63
|
+
- lib/gadabout/version.rb
|
64
|
+
homepage: https://github.com//gadabout
|
65
|
+
licenses: []
|
66
|
+
metadata: {}
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
requirements: []
|
82
|
+
rubyforge_project:
|
83
|
+
rubygems_version: 2.5.1
|
84
|
+
signing_key:
|
85
|
+
specification_version: 4
|
86
|
+
summary: A swiss army knife gem for the Hashicorp Nomad job scheduler
|
87
|
+
test_files: []
|