canzea 0.1.1 → 0.1.2
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/lib/audit.rb +54 -0
- data/lib/canzea/environment.rb +6 -0
- data/lib/canzea/version.rb +1 -1
- data/lib/canzea.rb +29 -15
- data/lib/commands/gen-user.rb +21 -0
- data/lib/commands/get-catalog.rb +5 -2
- data/lib/helper-run-class.rb +20 -19
- data/lib/plan-step-class.rb +35 -46
- data/lib/prepare-environment.rb +0 -1
- data/lib/template-runner.rb +0 -6
- data/lib/trace-component.rb +2 -53
- data/lib/trace-runner.rb +2 -53
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ca413ebf200c03d1699b7314804caebf821be9d3
|
4
|
+
data.tar.gz: ef0fba6fa00baf55a7b2bcb500349110869f46ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be137bad5ef7a3c27f97c78e9405108baa1a1b08ee9c9c3b03032ae6399ad492e891238c2f93e35519cdf90f4a5c3ebf913c3fd576d02286fcc8b3dffebe3d66
|
7
|
+
data.tar.gz: 68ddfe35cebc1ed98672398b53e725454482f3c00ab0fd7eeee76864fda01631969ceab3b503d5d61ecc33c5de274d6d773c6c60f8d1cf1ac31a2556a75c9170
|
data/lib/audit.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'open3'
|
3
|
+
require 'stringio'
|
4
|
+
require 'logger'
|
5
|
+
|
6
|
+
|
7
|
+
class Audit
|
8
|
+
def start (id, cmd)
|
9
|
+
self.log( id, cmd, "start", "", 0, "")
|
10
|
+
end
|
11
|
+
|
12
|
+
def complete (id, cmd, status, msecs, result)
|
13
|
+
self.log( id, cmd, "complete", status, msecs, result)
|
14
|
+
end
|
15
|
+
|
16
|
+
def status (id, cmd, status, msecs, result)
|
17
|
+
data = {
|
18
|
+
"message" => {
|
19
|
+
"id" => id,
|
20
|
+
"cmd" => cmd,
|
21
|
+
"task" => "status",
|
22
|
+
"status" => status,
|
23
|
+
"elapsed" => msecs,
|
24
|
+
"result" => result
|
25
|
+
}
|
26
|
+
}
|
27
|
+
puts data.to_json
|
28
|
+
File.open(Canzea::config[:logging_root] + '/audit.log', 'a') { |file| file.puts(data.to_json) }
|
29
|
+
end
|
30
|
+
|
31
|
+
def log (id, cmd, task, status, msecs, result)
|
32
|
+
data = {
|
33
|
+
"message" => {
|
34
|
+
"id" => id,
|
35
|
+
"cmd" => cmd,
|
36
|
+
"task" => task,
|
37
|
+
"status" => status,
|
38
|
+
"elapsed" => msecs,
|
39
|
+
"result" => result
|
40
|
+
}
|
41
|
+
}
|
42
|
+
summary = {
|
43
|
+
"message" => {
|
44
|
+
"id" => id,
|
45
|
+
"cmd" => cmd,
|
46
|
+
"task" => task,
|
47
|
+
"status" => status,
|
48
|
+
"elapsed" => msecs
|
49
|
+
}
|
50
|
+
}
|
51
|
+
puts summary.to_json
|
52
|
+
File.open(Canzea::config[:logging_root] + '/audit.log', 'a') { |file| file.puts(data.to_json) }
|
53
|
+
end
|
54
|
+
end
|
data/lib/canzea/version.rb
CHANGED
data/lib/canzea.rb
CHANGED
@@ -4,6 +4,7 @@ require 'pathname'
|
|
4
4
|
require 'git'
|
5
5
|
require "canzea/config"
|
6
6
|
require "canzea/version"
|
7
|
+
require "canzea/environment"
|
7
8
|
require "helper-run-class"
|
8
9
|
require "plan-step-class"
|
9
10
|
require "ssh-base-cmd-class"
|
@@ -11,6 +12,7 @@ require "template-runner"
|
|
11
12
|
require "commands/config-git-commit"
|
12
13
|
require "commands/get-catalog"
|
13
14
|
require "commands/remote-run"
|
15
|
+
require "commands/gen-user"
|
14
16
|
|
15
17
|
module Canzea
|
16
18
|
|
@@ -28,24 +30,24 @@ module Canzea
|
|
28
30
|
|
29
31
|
flag nil, :pwd, 'PWD'
|
30
32
|
|
31
|
-
flag nil, :run, 'Run a step'
|
32
|
-
flag nil, :helper, 'Execute a helper'
|
33
|
+
# flag nil, :run, 'Run a step'
|
34
|
+
# flag nil, :helper, 'Execute a helper'
|
33
35
|
flag nil, :remote, 'Remote execution'
|
34
36
|
flag nil, :init, 'Remote init execution'
|
35
|
-
flag nil, :enable, 'Enable the service'
|
37
|
+
# flag nil, :enable, 'Enable the service'
|
38
|
+
flag nil, :test, 'Run as a test'
|
39
|
+
flag nil, :reset, 'Refresh catalog to latest'
|
36
40
|
flag nil, :config_git_commit, 'Manage configuration files in git'
|
37
41
|
|
38
|
-
option :s, :stuff, 'specify stuff to do', argument: :required
|
39
|
-
|
40
42
|
option nil, :config, 'Config', argument: :required
|
41
43
|
|
42
44
|
option nil, :lifecycle, 'Lifecycle action [install, configure, upgrade, uninstall]', argument: :required
|
43
45
|
|
46
|
+
option nil, :util, "Utility action [gen-user, gen-cert]", argument: :required
|
44
47
|
option nil, :catalogTag, 'Specific tag of the catalog', argument: :required
|
45
48
|
option nil, :gitRoot, 'Git root', argument: :required
|
46
49
|
option nil, :role, 'Role', argument: :required
|
47
50
|
option nil, :solution, 'Solution', argument: :required
|
48
|
-
option nil, :test, 'Test', argument: :required
|
49
51
|
option nil, :task, 'Task', argument: :required
|
50
52
|
option nil, :serverBase, 'Server Base', argument: :required
|
51
53
|
option nil, :serverNumber, 'Server Number', argument: :required
|
@@ -67,30 +69,42 @@ module Canzea
|
|
67
69
|
GetCatalog.new.do(opts.fetch(:catalogTag, nil));
|
68
70
|
end
|
69
71
|
|
72
|
+
if (opts[:util])
|
73
|
+
util = opts[:util]
|
74
|
+
|
75
|
+
if (util == "gen-user")
|
76
|
+
GenUser.new.do(args[0])
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
70
80
|
if (opts[:lifecycle])
|
71
|
-
|
81
|
+
if (opts[:reset])
|
82
|
+
GetCatalog.new.do(opts.fetch(:catalogTag, nil));
|
83
|
+
end
|
72
84
|
|
73
85
|
lifecycle = opts[:lifecycle]
|
74
86
|
|
75
87
|
if lifecycle == 'install'
|
76
88
|
puts "Running install step #{opts[:role]} #{opts[:solution]}"
|
77
89
|
ps = PlanStep.new
|
78
|
-
ps.runPhaseInstall opts[:role], opts[:solution], opts
|
90
|
+
ps.runPhaseInstall opts[:role], opts[:solution], opts[:test], Integer(opts.fetch(:task, 1))
|
79
91
|
|
80
|
-
|
92
|
+
if (opts[:test] == false)
|
93
|
+
gitRoot = opts.fetch(:gitRoot, "/opt/cloud-profile")
|
81
94
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
95
|
+
# write to configure the registration of the service
|
96
|
+
if (File.exists?("#{gitRoot}/configure.sh") == false)
|
97
|
+
File.open("#{gitRoot}/configure.sh", 'a') { |file| file.puts("#!/bin/bash") }
|
98
|
+
end
|
86
99
|
|
87
|
-
|
100
|
+
File.open("#{gitRoot}/configure.sh", 'a') { |file| file.puts("canzea --enable #{ARGV.join(' ')}") }
|
101
|
+
end
|
88
102
|
end
|
89
103
|
|
90
104
|
if lifecycle == 'configure'
|
91
105
|
puts "Running configure step #{opts[:role]} #{opts[:solution]}"
|
92
106
|
ps = PlanStep.new
|
93
|
-
ps.runPhaseConfigure opts[:role], opts[:solution], opts
|
107
|
+
ps.runPhaseConfigure opts[:role], opts[:solution], opts[:test], Integer(opts.fetch(:task, 1))
|
94
108
|
end
|
95
109
|
|
96
110
|
if lifecycle == 'wire'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require "git"
|
2
|
+
require "fileutils"
|
3
|
+
require "pathname"
|
4
|
+
require "helper-run-class"
|
5
|
+
|
6
|
+
class GenUser
|
7
|
+
def do(name)
|
8
|
+
puts "Generating #{name}"
|
9
|
+
|
10
|
+
home = "/home/#{name}"
|
11
|
+
key = "general"
|
12
|
+
|
13
|
+
plans = [
|
14
|
+
{:solution => "users", :action => "add-user", :parameters => { "name" => name }},
|
15
|
+
{:solution => "users", :action => "new-key", :parameters => { "name" => name, "home" => home, "key" => key }},
|
16
|
+
]
|
17
|
+
|
18
|
+
HelperRun.new.runPlan(plans)
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
data/lib/commands/get-catalog.rb
CHANGED
@@ -5,8 +5,11 @@ require "pathname"
|
|
5
5
|
|
6
6
|
class GetCatalog
|
7
7
|
def do(tag = nil)
|
8
|
-
|
9
|
-
|
8
|
+
catalogLocation = Canzea::config[:catalog_location]
|
9
|
+
FileUtils.rm_rf catalogLocation
|
10
|
+
FileUtils.mkdir_p catalogLocation
|
11
|
+
catalogLocation = Pathname.new(catalogLocation).realpath
|
12
|
+
g = Git.clone(Canzea::config[:catalog_git], "", :path => catalogLocation)
|
10
13
|
g.branch Canzea::config[:catalog_branch]
|
11
14
|
if (tag != nil)
|
12
15
|
puts "For tag #{tag}"
|
data/lib/helper-run-class.rb
CHANGED
@@ -6,30 +6,30 @@ require "prepare-environment"
|
|
6
6
|
require "trace-runner"
|
7
7
|
|
8
8
|
class HelperRun
|
9
|
-
def
|
9
|
+
def initialize ()
|
10
|
+
@basePath = Pathname.new(Canzea::config[:catalog_location]).realpath
|
11
|
+
@log = Logger.new(Canzea::config[:logging_root] + '/plans.log')
|
12
|
+
end
|
10
13
|
|
11
|
-
|
14
|
+
def runPlan (plan)
|
15
|
+
plan.each { | plan |
|
16
|
+
puts "Running #{plan[:action]}"
|
17
|
+
self.run (plan[:solution], plan[:action], plan[:parameters])
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
def run (solution, action, parameters)
|
12
22
|
|
13
|
-
# Type can be either: ruby or shell
|
14
|
-
# type = ARGV[0]
|
15
23
|
type = "ruby"
|
16
24
|
|
17
25
|
params = JSON.parse(parameters);
|
18
|
-
# If there is context information, then merge them into the parameters before calling the helper
|
19
|
-
if (ENV.has_key?('WORK_DIR') and File.exists?ENV['WORK_DIR'] + "/context.json")
|
20
|
-
context = JSON.parse(File.read(ENV['WORK_DIR'] + "/context.json"))
|
21
|
-
context.keys.each do |key|
|
22
|
-
params[key] = context[key]
|
23
|
-
end
|
24
|
-
end
|
25
26
|
|
26
|
-
# Make sure the parameters are valid JSON
|
27
27
|
parameters = JSON.generate(params)
|
28
28
|
|
29
29
|
envPush = PrepareEnvironment.new
|
30
30
|
|
31
31
|
begin
|
32
|
-
envScript =
|
32
|
+
envScript = "#{@basePath}/helpers/#{solution}/environment.json"
|
33
33
|
if File.exist?(envScript)
|
34
34
|
log.info("Adding environment variables...")
|
35
35
|
envPush.addToEnv "#{envScript}"
|
@@ -38,16 +38,17 @@ class HelperRun
|
|
38
38
|
r = RunnerWorker.new
|
39
39
|
|
40
40
|
if (type == "ruby")
|
41
|
-
cmd = "ruby #{
|
41
|
+
cmd = "ruby #{@basePath}/helpers/#{solution}/#{action}.rb '#{parameters}'"
|
42
42
|
else
|
43
|
-
cmd = "#{
|
43
|
+
cmd = "#{@basePath}/helpers/#{solution}/#{action}.sh \"#{parameters}\""
|
44
44
|
end
|
45
45
|
r.run cmd, 1, 1, false
|
46
46
|
|
47
|
-
rescue =>
|
48
|
-
log.error(
|
49
|
-
log.error(
|
50
|
-
|
47
|
+
rescue => exception
|
48
|
+
@log.error(cmd)
|
49
|
+
@log.error(exception.to_s)
|
50
|
+
@log.error(exception.backtrace)
|
51
|
+
abort()
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
data/lib/plan-step-class.rb
CHANGED
@@ -1,82 +1,70 @@
|
|
1
1
|
require 'json'
|
2
2
|
require 'logger'
|
3
3
|
require 'trace-component'
|
4
|
+
require 'pathname'
|
4
5
|
require 'helper-run-class'
|
6
|
+
require 'prepare-environment'
|
5
7
|
|
6
8
|
class PlanStep
|
7
|
-
def
|
8
|
-
|
9
|
-
log = Logger.new(Canzea::config[:logging_root] + '/plans.log')
|
9
|
+
def initialize ()
|
10
|
+
@basePath = Pathname.new(Canzea::config[:catalog_location]).realpath
|
11
|
+
@log = Logger.new(Canzea::config[:logging_root] + '/plans.log')
|
12
|
+
end
|
10
13
|
|
11
|
-
|
14
|
+
def runPhaseInstall (role, solution, test, task)
|
12
15
|
|
13
16
|
plan = JSON.parse("{ \"plan\": [ { \"role\": \"#{role}\", \"solution\": \"#{solution}\" } ] }")
|
14
17
|
|
15
18
|
n = Worker.new
|
16
|
-
|
17
|
-
|
18
19
|
n.test ( test )
|
19
20
|
|
20
21
|
start = Integer(task)
|
21
22
|
lines = 1
|
22
23
|
|
23
|
-
cmd = "TBD"
|
24
|
-
|
25
|
-
|
26
24
|
begin
|
27
25
|
|
28
26
|
plan['plan'].each do |item|
|
29
|
-
log.info(item['solution'])
|
27
|
+
@log.info(item['solution'])
|
30
28
|
|
31
|
-
root =
|
29
|
+
root = "#{@basePath}/roles/#{item['role']}/#{item['solution']}"
|
32
30
|
if File.exist?(root) == false
|
33
31
|
puts "-- ERROR #{root} does not exist!"
|
34
32
|
raise "#{root} does not exist!"
|
35
33
|
end
|
36
34
|
|
37
|
-
cmd =
|
38
|
-
|
35
|
+
cmd = "#{@basePath}/roles/#{item['role']}/#{item['solution']}/install.sh"
|
39
36
|
if File.exist?(cmd)
|
40
37
|
lines = n.run cmd, start, lines - 1
|
41
38
|
|
42
|
-
log.info "#{ lines } lines read"
|
39
|
+
@log.info "#{ lines } lines read"
|
43
40
|
end
|
44
|
-
|
45
|
-
|
46
41
|
end
|
47
42
|
rescue => exception
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
43
|
+
@log.error(cmd)
|
44
|
+
@log.error(exception.to_s)
|
45
|
+
@log.error(exception.backtrace)
|
46
|
+
abort()
|
52
47
|
end
|
53
48
|
end
|
54
49
|
|
55
50
|
def runPhaseConfigure (role, solution, test, task)
|
56
51
|
|
57
|
-
log = Logger.new(Dir.home() + '/plans.log')
|
58
|
-
|
59
|
-
# ruby plan.rb <plan description> <test run> <start>
|
60
|
-
|
61
52
|
plan = JSON.parse("{ \"plan\": [ { \"role\": \"#{role}\", \"solution\": \"#{solution}\" } ] }")
|
62
53
|
|
63
54
|
n = Worker.new
|
64
|
-
|
65
|
-
|
66
55
|
n.test ( test )
|
67
56
|
|
68
57
|
start = Integer(task)
|
69
58
|
lines = 1
|
70
59
|
|
71
|
-
cmd = "
|
72
|
-
|
60
|
+
cmd = "undefined"
|
73
61
|
|
74
62
|
begin
|
75
63
|
|
76
64
|
plan['plan'].each do |item|
|
77
|
-
log.info(item['solution'])
|
65
|
+
@log.info(item['solution'])
|
78
66
|
|
79
|
-
root =
|
67
|
+
root = "#{@basePath}/roles/#{item['role']}/#{item['solution']}"
|
80
68
|
if File.exist?(root) == false
|
81
69
|
puts "-- ERROR #{root} does not exist!"
|
82
70
|
raise "#{root} does not exist!"
|
@@ -84,53 +72,54 @@ class PlanStep
|
|
84
72
|
|
85
73
|
# Register the service with Consul, if consul is ready
|
86
74
|
# If metadata.json exists, then use the information to register
|
87
|
-
cmd =
|
75
|
+
cmd = "#{@basePath}/roles/#{item['role']}/#{item['solution']}/metadata.json"
|
88
76
|
if File.exist?(cmd)
|
89
77
|
md = File.read(cmd)
|
90
78
|
md = JSON.parse(md)
|
91
79
|
if (md['services'].size() > 0)
|
92
80
|
svc = md['services'][0]
|
93
81
|
adef = {"listener"=>svc['listener'], "serviceName"=>svc['name'], "tags"=>{}, "port"=>svc['port']}
|
94
|
-
|
95
|
-
|
82
|
+
puts "-- Registering"
|
83
|
+
if (test == false)
|
84
|
+
h = HelperRun.new
|
85
|
+
h.run "consul", "add_service", JSON.generate(adef)
|
86
|
+
end
|
96
87
|
end
|
97
88
|
end
|
98
89
|
|
99
|
-
envScript =
|
90
|
+
envScript = "#{@basePath}/roles/#{item['role']}/#{item['solution']}/environment.json"
|
100
91
|
if File.exist?(envScript)
|
101
|
-
require_relative '../init/prepare_environment'
|
102
|
-
|
103
92
|
envPush = PrepareEnvironment.new
|
104
93
|
envPush.addToEnv "#{envScript}"
|
105
94
|
end
|
106
95
|
|
107
|
-
cmd =
|
96
|
+
cmd = "#{@basePath}/roles/#{item['role']}/#{item['solution']}/configure.sh"
|
108
97
|
if File.exist?(cmd)
|
109
98
|
lines = n.run cmd, start, lines - 1
|
110
99
|
|
111
|
-
log.info("#{ lines } lines read")
|
100
|
+
@log.info("#{ lines } lines read")
|
112
101
|
end
|
113
102
|
|
114
|
-
cmd =
|
103
|
+
cmd = "#{@basePath}/roles/#{item['role']}/#{item['solution']}/enable.sh"
|
115
104
|
if File.exist?(cmd)
|
116
105
|
lines = n.run cmd, start, lines - 1
|
117
106
|
|
118
|
-
log.info("#{ lines } lines read")
|
107
|
+
@log.info("#{ lines } lines read")
|
119
108
|
end
|
120
109
|
|
121
|
-
cmd =
|
110
|
+
cmd = "#{@basePath}/roles/#{item['role']}/#{item['solution']}/status.sh"
|
122
111
|
if File.exist?(cmd)
|
123
112
|
lines = n.run cmd, start, lines - 1, true
|
124
113
|
|
125
|
-
log.info("#{ lines } lines read")
|
114
|
+
@log.info("#{ lines } lines read")
|
126
115
|
end
|
127
116
|
|
128
117
|
end
|
129
118
|
rescue => exception
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
119
|
+
@log.error(cmd)
|
120
|
+
@log.error(exception.to_s)
|
121
|
+
@log.error(exception.backtrace)
|
122
|
+
abort()
|
134
123
|
end
|
135
124
|
end
|
136
125
|
end
|
data/lib/prepare-environment.rb
CHANGED
data/lib/template-runner.rb
CHANGED
data/lib/trace-component.rb
CHANGED
@@ -2,10 +2,9 @@ require 'json'
|
|
2
2
|
require 'open3'
|
3
3
|
require 'stringio'
|
4
4
|
require 'logger'
|
5
|
+
require 'audit'
|
6
|
+
|
5
7
|
|
6
|
-
# Optionally can specify the command to continue from
|
7
|
-
# Exit on first failure
|
8
|
-
#
|
9
8
|
def time_diff_milli(start, finish)
|
10
9
|
(finish - start) * 1000.0
|
11
10
|
end
|
@@ -20,56 +19,6 @@ def handleIO(stillOpen, ioArray, io, log)
|
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
|
-
|
24
|
-
class Audit
|
25
|
-
def start (id, cmd)
|
26
|
-
self.log( id, cmd, "start", "", 0, "")
|
27
|
-
end
|
28
|
-
|
29
|
-
def complete (id, cmd, status, msecs, result)
|
30
|
-
self.log( id, cmd, "complete", status, msecs, result)
|
31
|
-
end
|
32
|
-
|
33
|
-
def status (id, cmd, status, msecs, result)
|
34
|
-
data = {
|
35
|
-
"message" => {
|
36
|
-
"id" => id,
|
37
|
-
"cmd" => cmd,
|
38
|
-
"task" => "status",
|
39
|
-
"status" => status,
|
40
|
-
"elapsed" => msecs,
|
41
|
-
"result" => result
|
42
|
-
}
|
43
|
-
}
|
44
|
-
puts data.to_json
|
45
|
-
File.open(Canzea::config[:logging_root] + '/audit.log', 'a') { |file| file.puts(data.to_json) }
|
46
|
-
end
|
47
|
-
|
48
|
-
def log (id, cmd, task, status, msecs, result)
|
49
|
-
data = {
|
50
|
-
"message" => {
|
51
|
-
"id" => id,
|
52
|
-
"cmd" => cmd,
|
53
|
-
"task" => task,
|
54
|
-
"status" => status,
|
55
|
-
"elapsed" => msecs,
|
56
|
-
"result" => result
|
57
|
-
}
|
58
|
-
}
|
59
|
-
summary = {
|
60
|
-
"message" => {
|
61
|
-
"id" => id,
|
62
|
-
"cmd" => cmd,
|
63
|
-
"task" => task,
|
64
|
-
"status" => status,
|
65
|
-
"elapsed" => msecs
|
66
|
-
}
|
67
|
-
}
|
68
|
-
puts summary.to_json
|
69
|
-
File.open(Canzea::config[:logging_root] + '/audit.log', 'a') { |file| file.puts(data.to_json) }
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
22
|
class ManagedError < StandardError
|
74
23
|
end
|
75
24
|
|
data/lib/trace-runner.rb
CHANGED
@@ -2,10 +2,9 @@ require 'json'
|
|
2
2
|
require 'open3'
|
3
3
|
require 'stringio'
|
4
4
|
require 'logger'
|
5
|
+
require 'audit'
|
6
|
+
|
5
7
|
|
6
|
-
# Optionally can specify the command to continue from
|
7
|
-
# Exit on first failure
|
8
|
-
#
|
9
8
|
def time_diff_milli(start, finish)
|
10
9
|
(finish - start) * 1000.0
|
11
10
|
end
|
@@ -20,56 +19,6 @@ def handleIO(stillOpen, ioArray, io, log)
|
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
23
|
-
|
24
|
-
class Audit
|
25
|
-
def start (id, cmd)
|
26
|
-
self.log( id, cmd, "start", "", 0, "")
|
27
|
-
end
|
28
|
-
|
29
|
-
def complete (id, cmd, status, msecs, result)
|
30
|
-
self.log( id, cmd, "complete", status, msecs, result)
|
31
|
-
end
|
32
|
-
|
33
|
-
def status (id, cmd, status, msecs, result)
|
34
|
-
data = {
|
35
|
-
"message" => {
|
36
|
-
"id" => id,
|
37
|
-
"cmd" => cmd,
|
38
|
-
"task" => "status",
|
39
|
-
"status" => status,
|
40
|
-
"elapsed" => msecs,
|
41
|
-
"result" => result
|
42
|
-
}
|
43
|
-
}
|
44
|
-
puts data.to_json
|
45
|
-
File.open(Canzea::config[:logging_root] + '/audit.log', 'a') { |file| file.puts(data.to_json) }
|
46
|
-
end
|
47
|
-
|
48
|
-
def log (id, cmd, task, status, msecs, result)
|
49
|
-
data = {
|
50
|
-
"message" => {
|
51
|
-
"id" => id,
|
52
|
-
"cmd" => cmd,
|
53
|
-
"task" => task,
|
54
|
-
"status" => status,
|
55
|
-
"elapsed" => msecs,
|
56
|
-
"result" => result
|
57
|
-
}
|
58
|
-
}
|
59
|
-
summary = {
|
60
|
-
"message" => {
|
61
|
-
"id" => id,
|
62
|
-
"cmd" => cmd,
|
63
|
-
"task" => task,
|
64
|
-
"status" => status,
|
65
|
-
"elapsed" => msecs
|
66
|
-
}
|
67
|
-
}
|
68
|
-
puts summary.to_json
|
69
|
-
File.open(Canzea::config[:logging_root] + '/audit.log', 'a') { |file| file.puts(data.to_json) }
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
22
|
class RunnerWorker
|
74
23
|
|
75
24
|
def run(command, start, lines, statusIndicator = false )
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canzea
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Canzea Technologies
|
@@ -160,10 +160,13 @@ files:
|
|
160
160
|
- bin/setup
|
161
161
|
- canzea.gemspec
|
162
162
|
- cli.iml
|
163
|
+
- lib/audit.rb
|
163
164
|
- lib/canzea.rb
|
164
165
|
- lib/canzea/config.rb
|
166
|
+
- lib/canzea/environment.rb
|
165
167
|
- lib/canzea/version.rb
|
166
168
|
- lib/commands/config-git-commit.rb
|
169
|
+
- lib/commands/gen-user.rb
|
167
170
|
- lib/commands/get-catalog.rb
|
168
171
|
- lib/commands/remote-run.rb
|
169
172
|
- lib/helper-run-class.rb
|