Class: OrchestratorClient
- Inherits:
-
Object
- Object
- OrchestratorClient
show all
- Defined in:
- lib/orchestrator_client.rb,
lib/orchestrator_client/version.rb
Defined Under Namespace
Classes: ApiError, BadResponse, Command, Config, ConfigError, Job, Jobs
Constant Summary
collapse
- VERSION =
'0.5.1'.freeze
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(overrides, load_files = false) ⇒ OrchestratorClient
Returns a new instance of OrchestratorClient.
17
18
19
20
21
|
# File 'lib/orchestrator_client.rb', line 17
def initialize(overrides, load_files=false)
@config = Config.new(overrides, load_files)
@config.validate
@http = create_http(config.root_url)
end
|
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
14
15
16
|
# File 'lib/orchestrator_client.rb', line 14
def config
@config
end
|
#http ⇒ Object
Returns the value of attribute http.
15
16
17
|
# File 'lib/orchestrator_client.rb', line 15
def http
@http
end
|
Instance Method Details
#create_http(root_url) ⇒ Object
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/orchestrator_client.rb', line 23
def create_http(root_url)
Faraday.new(url: root_url) do |f|
f.['Content-Type'] = 'application/json'
f.['X-Authentication'] = config.token
f.['User-Agent'] = config['User-Agent']
f.ssl['ca_file'] = config['cacert']
f.ssl['version'] = :TLSv1_2
if !!File::ALT_SEPARATOR
f.adapter :net_http
else
f.adapter :net_http_persistent, pool_size: 5 do |http|
http.idle_timeout = 30
http.read_timeout = config['read-timeout'] if config['read-timeout']
end
end
end
end
|
#new_job(options, type = :deploy) ⇒ Object
70
71
72
|
# File 'lib/orchestrator_client.rb', line 70
def new_job(options, type = :deploy)
OrchestratorClient::Job.new(self, options, type)
end
|
#post(location, body) ⇒ Object
52
53
54
55
56
57
58
59
60
|
# File 'lib/orchestrator_client.rb', line 52
def post(location, body)
res = http.post(location, body.to_json)
unless Set.new([202, 200]).include? res.status
raise OrchestratorClient::ApiError.make_error_from_response(res)
end
JSON.parse(res.body)
end
|
#root ⇒ Object
86
87
88
|
# File 'lib/orchestrator_client.rb', line 86
def root
get(url)
end
|
#run_task(options) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/orchestrator_client.rb', line 74
def run_task(options)
if options[:plan_job] || options['plan_job']
type = :plan_task
else
type = :task
end
job = OrchestratorClient::Job.new(self, options, type)
job.start
job.wait
job.nodes['items']
end
|