cloud66_agent 0.0.1.pre2 → 0.0.1.pre3
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.
- data/bin/cloud66_agent +12 -5
- data/lib/cloud66_agent/commands/job_end.rb +24 -0
- data/lib/cloud66_agent/commands/job_start.rb +15 -0
- data/lib/cloud66_agent/commands/pulse.rb +1 -2
- data/lib/cloud66_agent/utils/server.rb +12 -4
- data/lib/cloud66_agent/utils/version.rb +1 -1
- data/lib/cloud66_agent.rb +14 -0
- metadata +3 -1
data/bin/cloud66_agent
CHANGED
|
@@ -67,14 +67,21 @@ if !$config.is_agent_configured? && command != 'configure'
|
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
# handle commands
|
|
70
|
-
$logger.
|
|
70
|
+
$logger.info "Performing: \"#{command}\""
|
|
71
71
|
if command == "configure"
|
|
72
72
|
Cloud66Agent.configure @server_uid
|
|
73
|
-
elsif Cloud66Agent.respond_to? command
|
|
74
|
-
Cloud66Agent.send command
|
|
75
73
|
else
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
begin
|
|
75
|
+
arguments = ARGV[1..-1]
|
|
76
|
+
if arguments.empty?
|
|
77
|
+
Cloud66Agent.send command
|
|
78
|
+
else
|
|
79
|
+
Cloud66Agent.send(command, arguments)
|
|
80
|
+
end
|
|
81
|
+
rescue ArgumentError => exc
|
|
82
|
+
$logger.error "Invalid command/arguments: #{command} #{arguments}"
|
|
83
|
+
exit -1
|
|
84
|
+
end
|
|
78
85
|
end
|
|
79
86
|
exit 0
|
|
80
87
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require 'cloud66_agent/utils/server'
|
|
2
|
+
|
|
3
|
+
module Cloud66
|
|
4
|
+
module Commands
|
|
5
|
+
class JobEnd
|
|
6
|
+
def self.perform(job_uid, session_uid, results_file)
|
|
7
|
+
job_results = File.exists?(results_file) ? IO.read(results_file) : ''
|
|
8
|
+
data = {
|
|
9
|
+
session_uid: session_uid,
|
|
10
|
+
job_results: job_results
|
|
11
|
+
}
|
|
12
|
+
Utils::Server.send_job_end(job_uid, data)
|
|
13
|
+
exit 0
|
|
14
|
+
rescue => exc
|
|
15
|
+
$logger.error "job_end failed: #{exc.message}"
|
|
16
|
+
exit -1
|
|
17
|
+
ensure
|
|
18
|
+
# get rid of the old results
|
|
19
|
+
FileUtils.rm_rf(results_file) rescue nil
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require 'cloud66_agent/utils/server'
|
|
2
|
+
|
|
3
|
+
module Cloud66
|
|
4
|
+
module Commands
|
|
5
|
+
class JobStart
|
|
6
|
+
def self.perform(job_uid)
|
|
7
|
+
result = Utils::Server.send_job_start job_uid
|
|
8
|
+
exit 0
|
|
9
|
+
rescue => exc
|
|
10
|
+
$logger.error "job_start failed: #{exc.message}"
|
|
11
|
+
exit -1
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
require 'cloud66_agent/utils/vital_signs'
|
|
2
1
|
require 'cloud66_agent/utils/server'
|
|
3
2
|
|
|
4
3
|
module Cloud66
|
|
@@ -8,7 +7,7 @@ module Cloud66
|
|
|
8
7
|
Utils::Server.send_pulse
|
|
9
8
|
exit 0
|
|
10
9
|
rescue => exc
|
|
11
|
-
$logger.error "
|
|
10
|
+
$logger.error "pulse failed: #{exc.message}"
|
|
12
11
|
exit -1
|
|
13
12
|
end
|
|
14
13
|
end
|
|
@@ -8,19 +8,27 @@ module Cloud66
|
|
|
8
8
|
include HTTParty
|
|
9
9
|
|
|
10
10
|
def self.send_configure(data)
|
|
11
|
-
process(do_post('/
|
|
11
|
+
process(do_post('/server/configure.json', build_content(data)))
|
|
12
12
|
end
|
|
13
13
|
|
|
14
14
|
def self.send_pulse
|
|
15
|
-
process(do_get("/
|
|
15
|
+
process(do_get("/server/#{$config.agent_uid}/pulse.json", build_content))
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
def self.send_address(data)
|
|
19
|
-
process(do_post("/
|
|
19
|
+
process(do_post("/server/#{$config.agent_uid}/address.json", build_content(data)))
|
|
20
20
|
end
|
|
21
21
|
|
|
22
22
|
def self.send_vitals(data)
|
|
23
|
-
process(do_post("/
|
|
23
|
+
process(do_post("/server/#{$config.agent_uid}/vitals.json", build_content(data)))
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def self.send_job_start(job_uid)
|
|
27
|
+
process(do_get("/server/#{job_uid}/job_start.json", build_content))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def self.send_job_end(job_uid, data)
|
|
31
|
+
process(do_post("/server/#{job_uid}/job_end.json", build_content(data)))
|
|
24
32
|
end
|
|
25
33
|
|
|
26
34
|
private
|
data/lib/cloud66_agent.rb
CHANGED
|
@@ -17,4 +17,18 @@ class Cloud66Agent
|
|
|
17
17
|
def self.address
|
|
18
18
|
Cloud66::Commands::Address.perform
|
|
19
19
|
end
|
|
20
|
+
|
|
21
|
+
def self.job_start(args)
|
|
22
|
+
job_uid = args[0]
|
|
23
|
+
raise ArgumentError.new if job_uid.nil?
|
|
24
|
+
Cloud66::Commands::JobStart.perform job_uid
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.job_end(args)
|
|
28
|
+
job_uid = args[0]
|
|
29
|
+
session_uid = args[1]
|
|
30
|
+
results_file = args[2]
|
|
31
|
+
raise ArgumentError.new if job_uid.nil? || session_uid.nil? || results_file.nil?
|
|
32
|
+
Cloud66::Commands::JobEnd.perform(job_uid, session_uid, results_file)
|
|
33
|
+
end
|
|
20
34
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cloud66_agent
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.1.
|
|
4
|
+
version: 0.0.1.pre3
|
|
5
5
|
prerelease: 6
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -61,6 +61,8 @@ files:
|
|
|
61
61
|
- lib/cloud66_agent.rb
|
|
62
62
|
- lib/cloud66_agent/commands/address.rb
|
|
63
63
|
- lib/cloud66_agent/commands/configure.rb
|
|
64
|
+
- lib/cloud66_agent/commands/job_end.rb
|
|
65
|
+
- lib/cloud66_agent/commands/job_start.rb
|
|
64
66
|
- lib/cloud66_agent/commands/pulse.rb
|
|
65
67
|
- lib/cloud66_agent/commands/vitals.rb
|
|
66
68
|
- lib/cloud66_agent/plugins/backup.rb
|