oxidized 0.25.1 → 0.26.0
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 +30 -9
- data/.rubocop_todo.yml +16 -637
- data/.travis.yml +2 -3
- data/CHANGELOG.md +14 -0
- data/Dockerfile +7 -5
- data/README.md +18 -14
- data/Rakefile +2 -2
- data/bin/console +1 -1
- data/bin/oxidized +2 -2
- data/docs/Configuration.md +6 -0
- data/docs/Model-Notes/README.md +1 -0
- data/docs/Model-Notes/SmartAX-Huawei.md +35 -0
- data/docs/Supported-OS-Types.md +12 -0
- data/extra/nagios_check_failing_nodes.rb +1 -1
- data/extra/rest_client.rb +6 -8
- data/extra/syslog.rb +33 -33
- data/lib/oxidized/cli.rb +25 -26
- data/lib/oxidized/config.rb +9 -9
- data/lib/oxidized/config/vars.rb +3 -7
- data/lib/oxidized/core.rb +4 -7
- data/lib/oxidized/hook.rb +16 -17
- data/lib/oxidized/hook/awssns.rb +4 -4
- data/lib/oxidized/hook/exec.rb +16 -20
- data/lib/oxidized/hook/githubrepo.rb +8 -14
- data/lib/oxidized/hook/noophook.rb +1 -1
- data/lib/oxidized/hook/xmppdiff.rb +1 -1
- data/lib/oxidized/input/cli.rb +12 -12
- data/lib/oxidized/input/ftp.rb +8 -8
- data/lib/oxidized/input/http.rb +37 -14
- data/lib/oxidized/input/input.rb +6 -6
- data/lib/oxidized/input/ssh.rb +31 -31
- data/lib/oxidized/input/telnet.rb +24 -24
- data/lib/oxidized/input/tftp.rb +9 -10
- data/lib/oxidized/jobs.rb +7 -7
- data/lib/oxidized/manager.rb +13 -13
- data/lib/oxidized/model/acos.rb +2 -2
- data/lib/oxidized/model/aireos.rb +3 -3
- data/lib/oxidized/model/aos7.rb +1 -1
- data/lib/oxidized/model/aosw.rb +12 -14
- data/lib/oxidized/model/apc_aos.rb +1 -1
- data/lib/oxidized/model/aricentiss.rb +6 -8
- data/lib/oxidized/model/asa.rb +1 -1
- data/lib/oxidized/model/audiocodesmp.rb +28 -0
- data/lib/oxidized/model/awplus.rb +9 -9
- data/lib/oxidized/model/boss.rb +1 -1
- data/lib/oxidized/model/ciscosmb.rb +1 -1
- data/lib/oxidized/model/ciscovpn3k.rb +11 -0
- data/lib/oxidized/model/comware.rb +1 -1
- data/lib/oxidized/model/cumulus.rb +3 -1
- data/lib/oxidized/model/dellx.rb +5 -5
- data/lib/oxidized/model/edgeos.rb +1 -1
- data/lib/oxidized/model/edgeswitch.rb +1 -1
- data/lib/oxidized/model/fabricos.rb +1 -1
- data/lib/oxidized/model/fortios.rb +5 -5
- data/lib/oxidized/model/ftos.rb +1 -1
- data/lib/oxidized/model/gcombnps.rb +7 -7
- data/lib/oxidized/model/grandstream.rb +9 -0
- data/lib/oxidized/model/hatteras.rb +8 -8
- data/lib/oxidized/model/ios.rb +22 -40
- data/lib/oxidized/model/ironware.rb +1 -1
- data/lib/oxidized/model/junos.rb +1 -1
- data/lib/oxidized/model/mlnxos.rb +1 -1
- data/lib/oxidized/model/model.rb +32 -38
- data/lib/oxidized/model/netgearxs716.rb +23 -0
- data/lib/oxidized/model/netonix.rb +1 -1
- data/lib/oxidized/model/netscaler.rb +1 -1
- data/lib/oxidized/model/nos.rb +2 -2
- data/lib/oxidized/model/nxos.rb +1 -1
- data/lib/oxidized/model/openbsd.rb +3 -2
- data/lib/oxidized/model/outputs.rb +4 -4
- data/lib/oxidized/model/planet.rb +4 -4
- data/lib/oxidized/model/powerconnect.rb +8 -8
- data/lib/oxidized/model/procurve.rb +2 -1
- data/lib/oxidized/model/quantaos.rb +3 -3
- data/lib/oxidized/model/raisecom.rb +19 -0
- data/lib/oxidized/model/siklu.rb +1 -1
- data/lib/oxidized/model/slxos.rb +1 -1
- data/lib/oxidized/model/smartax.rb +25 -0
- data/lib/oxidized/model/sros.rb +4 -4
- data/lib/oxidized/model/tdre.rb +30 -0
- data/lib/oxidized/model/tmos.rb +3 -0
- data/lib/oxidized/model/trango.rb +17 -37
- data/lib/oxidized/model/voltaire.rb +1 -1
- data/lib/oxidized/model/voss.rb +1 -1
- data/lib/oxidized/model/vyatta.rb +1 -1
- data/lib/oxidized/model/xos.rb +1 -1
- data/lib/oxidized/model/zhoneolt.rb +1 -1
- data/lib/oxidized/node.rb +42 -46
- data/lib/oxidized/node/stats.rb +6 -6
- data/lib/oxidized/nodes.rb +42 -42
- data/lib/oxidized/output/file.rb +16 -20
- data/lib/oxidized/output/git.rb +68 -78
- data/lib/oxidized/output/gitcrypt.rb +77 -91
- data/lib/oxidized/output/http.rb +17 -19
- data/lib/oxidized/output/output.rb +1 -1
- data/lib/oxidized/source/csv.rb +3 -3
- data/lib/oxidized/source/http.rb +11 -14
- data/lib/oxidized/source/source.rb +3 -3
- data/lib/oxidized/source/sql.rb +16 -18
- data/lib/oxidized/string.rb +10 -10
- data/lib/oxidized/version.rb +4 -4
- data/lib/oxidized/worker.rb +15 -15
- data/oxidized.gemspec +6 -9
- metadata +32 -25
data/lib/oxidized/cli.rb
CHANGED
|
@@ -2,15 +2,16 @@ module Oxidized
|
|
|
2
2
|
class CLI
|
|
3
3
|
require 'slop'
|
|
4
4
|
require 'oxidized'
|
|
5
|
+
require 'English'
|
|
5
6
|
|
|
6
7
|
def run
|
|
7
8
|
check_pid
|
|
8
9
|
Process.daemon if @opts[:daemonize]
|
|
9
10
|
write_pid
|
|
10
11
|
begin
|
|
11
|
-
Oxidized.logger.info "Oxidized starting, running as pid #{
|
|
12
|
+
Oxidized.logger.info "Oxidized starting, running as pid #{$PROCESS_ID}"
|
|
12
13
|
Oxidized.new
|
|
13
|
-
rescue => error
|
|
14
|
+
rescue StandardError => error
|
|
14
15
|
crash error
|
|
15
16
|
raise
|
|
16
17
|
end
|
|
@@ -27,9 +28,9 @@ module Oxidized
|
|
|
27
28
|
@pidfile = File.expand_path(Oxidized.config.pid)
|
|
28
29
|
end
|
|
29
30
|
|
|
30
|
-
def crash
|
|
31
|
+
def crash(error)
|
|
31
32
|
Oxidized.logger.fatal "Oxidized crashed, crashfile written in #{Config::Crash}"
|
|
32
|
-
open Config::Crash, 'w' do |file|
|
|
33
|
+
File.open Config::Crash, 'w' do |file|
|
|
33
34
|
file.puts '-' * 50
|
|
34
35
|
file.puts Time.now.utc
|
|
35
36
|
file.puts error.message + ' [' + error.class.to_s + ']'
|
|
@@ -40,7 +41,7 @@ module Oxidized
|
|
|
40
41
|
end
|
|
41
42
|
|
|
42
43
|
def parse_opts
|
|
43
|
-
opts = Slop.new(:
|
|
44
|
+
opts = Slop.new(help: true) do
|
|
44
45
|
on 'd', 'debug', 'turn on debugging'
|
|
45
46
|
on 'daemonize', 'Daemonize/fork the process'
|
|
46
47
|
on 'show-exhaustive-config', 'output entire configuration, including defaults' do
|
|
@@ -56,43 +57,41 @@ module Oxidized
|
|
|
56
57
|
[opts.parse!, opts]
|
|
57
58
|
end
|
|
58
59
|
|
|
59
|
-
|
|
60
|
-
@pidfile
|
|
61
|
-
end
|
|
60
|
+
attr_reader :pidfile
|
|
62
61
|
|
|
63
62
|
def pidfile?
|
|
64
63
|
!!pidfile
|
|
65
64
|
end
|
|
66
65
|
|
|
67
66
|
def write_pid
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
67
|
+
return unless pidfile?
|
|
68
|
+
|
|
69
|
+
begin
|
|
70
|
+
File.open(pidfile, ::File::CREAT | ::File::EXCL | ::File::WRONLY) { |f| f.write(Process.pid.to_s) }
|
|
71
|
+
at_exit { File.delete(pidfile) if File.exist?(pidfile) }
|
|
72
|
+
rescue Errno::EEXIST
|
|
73
|
+
check_pid
|
|
74
|
+
retry
|
|
76
75
|
end
|
|
77
76
|
end
|
|
78
77
|
|
|
79
78
|
def check_pid
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
79
|
+
return unless pidfile?
|
|
80
|
+
|
|
81
|
+
case pid_status(pidfile)
|
|
82
|
+
when :running, :not_owned
|
|
83
|
+
puts "A server is already running. Check #{pidfile}"
|
|
84
|
+
exit(1)
|
|
85
|
+
when :dead
|
|
86
|
+
File.delete(pidfile)
|
|
88
87
|
end
|
|
89
88
|
end
|
|
90
89
|
|
|
91
90
|
def pid_status(pidfile)
|
|
92
|
-
return :exited unless File.
|
|
91
|
+
return :exited unless File.exist?(pidfile)
|
|
93
92
|
|
|
94
93
|
pid = ::File.read(pidfile).to_i
|
|
95
|
-
return :dead if pid
|
|
94
|
+
return :dead if pid.zero?
|
|
96
95
|
|
|
97
96
|
Process.kill(0, pid)
|
|
98
97
|
:running
|
data/lib/oxidized/config.rb
CHANGED
|
@@ -4,13 +4,13 @@ module Oxidized
|
|
|
4
4
|
class InvalidConfig < OxidizedError; end
|
|
5
5
|
class Config
|
|
6
6
|
Root = ENV['OXIDIZED_HOME'] || File.join(ENV['HOME'], '.config', 'oxidized')
|
|
7
|
-
Crash = File.join Root, 'crash'
|
|
8
|
-
Log = File.join Root, 'logs'
|
|
9
|
-
InputDir = File.join Directory, %w
|
|
10
|
-
OutputDir = File.join Directory, %w
|
|
11
|
-
ModelDir = File.join Directory, %w
|
|
12
|
-
SourceDir = File.join Directory, %w
|
|
13
|
-
HookDir = File.join Directory, %w
|
|
7
|
+
Crash = File.join(ENV['OXIDIZED_LOGS'] || Root, 'crash')
|
|
8
|
+
Log = File.join(ENV['OXIDIZED_LOGS'] || Root, 'logs')
|
|
9
|
+
InputDir = File.join Directory, %w[lib oxidized input]
|
|
10
|
+
OutputDir = File.join Directory, %w[lib oxidized output]
|
|
11
|
+
ModelDir = File.join Directory, %w[lib oxidized model]
|
|
12
|
+
SourceDir = File.join Directory, %w[lib oxidized source]
|
|
13
|
+
HookDir = File.join Directory, %w[lib oxidized hook]
|
|
14
14
|
Sleep = 1
|
|
15
15
|
|
|
16
16
|
def self.load(cmd_opts = {})
|
|
@@ -49,13 +49,13 @@ module Oxidized
|
|
|
49
49
|
asetus.default.source.default = 'csv' # csv, sql
|
|
50
50
|
|
|
51
51
|
asetus.default.model_map = {
|
|
52
|
-
'cisco' => 'ios',
|
|
53
52
|
'juniper' => 'junos',
|
|
53
|
+
'cisco' => 'ios'
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
begin
|
|
57
57
|
asetus.load # load system+user configs, merge to Config.cfg
|
|
58
|
-
rescue => error
|
|
58
|
+
rescue StandardError => error
|
|
59
59
|
raise InvalidConfig, "Error loading config: #{error.message}"
|
|
60
60
|
end
|
|
61
61
|
|
data/lib/oxidized/config/vars.rb
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
1
|
module Oxidized::Config::Vars
|
|
2
2
|
# convenience method for accessing node, group or global level user variables
|
|
3
3
|
# nil values will be ignored
|
|
4
|
-
def vars
|
|
4
|
+
def vars(name)
|
|
5
5
|
r = @node.vars[name] unless @node.vars.nil?
|
|
6
6
|
if Oxidized.config.groups.has_key?(@node.group)
|
|
7
|
-
if Oxidized.config.groups[@node.group].vars.has_key?(name.to_s)
|
|
8
|
-
r ||= Oxidized.config.groups[@node.group].vars[name.to_s]
|
|
9
|
-
end
|
|
7
|
+
r ||= Oxidized.config.groups[@node.group].vars[name.to_s] if Oxidized.config.groups[@node.group].vars.has_key?(name.to_s)
|
|
10
8
|
end
|
|
11
9
|
if Oxidized.config.models.has_key?(@node.model.class.name.to_s.downcase)
|
|
12
|
-
if Oxidized.config.models[@node.model.class.name.to_s.downcase].vars.has_key?(name.to_s)
|
|
13
|
-
r ||= Oxidized.config.models[@node.model.class.name.to_s.downcase].vars[name.to_s]
|
|
14
|
-
end
|
|
10
|
+
r ||= Oxidized.config.models[@node.model.class.name.to_s.downcase].vars[name.to_s] if Oxidized.config.models[@node.model.class.name.to_s.downcase].vars.has_key?(name.to_s)
|
|
15
11
|
end
|
|
16
12
|
r ||= Oxidized.config.vars[name.to_s] if Oxidized.config.vars.has_key?(name.to_s)
|
|
17
13
|
r
|
data/lib/oxidized/core.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module Oxidized
|
|
2
2
|
class << self
|
|
3
|
-
def new
|
|
3
|
+
def new(*args)
|
|
4
4
|
Core.new args
|
|
5
5
|
end
|
|
6
6
|
end
|
|
@@ -8,11 +8,11 @@ module Oxidized
|
|
|
8
8
|
class Core
|
|
9
9
|
class NoNodesFound < OxidizedError; end
|
|
10
10
|
|
|
11
|
-
def initialize
|
|
11
|
+
def initialize(_args)
|
|
12
12
|
Oxidized.mgr = Manager.new
|
|
13
13
|
Oxidized.Hooks = HookManager.from_config(Oxidized.config)
|
|
14
14
|
nodes = Nodes.new
|
|
15
|
-
raise NoNodesFound, 'source returns no usable nodes' if nodes.size
|
|
15
|
+
raise NoNodesFound, 'source returns no usable nodes' if nodes.size.zero?
|
|
16
16
|
|
|
17
17
|
@worker = Worker.new nodes
|
|
18
18
|
trap('HUP') { nodes.load }
|
|
@@ -33,10 +33,7 @@ module Oxidized
|
|
|
33
33
|
|
|
34
34
|
def run
|
|
35
35
|
Oxidized.logger.debug "lib/oxidized/core.rb: Starting the worker..."
|
|
36
|
-
while
|
|
37
|
-
@worker.work
|
|
38
|
-
sleep Config::Sleep
|
|
39
|
-
end
|
|
36
|
+
@worker.work while sleep Config::Sleep
|
|
40
37
|
end
|
|
41
38
|
end
|
|
42
39
|
end
|
data/lib/oxidized/hook.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
module Oxidized
|
|
2
2
|
class HookManager
|
|
3
3
|
class << self
|
|
4
|
-
def from_config
|
|
4
|
+
def from_config(cfg)
|
|
5
5
|
mgr = new
|
|
6
6
|
cfg.hooks.each do |name, h_cfg|
|
|
7
7
|
h_cfg.events.each do |event|
|
|
@@ -17,27 +17,27 @@ module Oxidized
|
|
|
17
17
|
class HookContext < OpenStruct; end
|
|
18
18
|
|
|
19
19
|
# RegisteredHook is a container for a Hook instance
|
|
20
|
-
|
|
20
|
+
RegisteredHook = Struct.new(:name, :hook)
|
|
21
21
|
|
|
22
|
-
Events = [
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
]
|
|
22
|
+
Events = %i[
|
|
23
|
+
node_success
|
|
24
|
+
node_fail
|
|
25
|
+
post_store
|
|
26
|
+
nodes_done
|
|
27
|
+
].freeze
|
|
28
28
|
attr_reader :registered_hooks
|
|
29
29
|
|
|
30
30
|
def initialize
|
|
31
31
|
@registered_hooks = Hash.new { |h, k| h[k] = [] }
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
def register
|
|
34
|
+
def register(event, name, hook_type, cfg)
|
|
35
35
|
unless Events.include? event
|
|
36
36
|
raise ArgumentError,
|
|
37
37
|
"unknown event #{event}, available: #{Events.join ','}"
|
|
38
38
|
end
|
|
39
39
|
|
|
40
|
-
Oxidized.mgr.add_hook(hook_type)
|
|
40
|
+
Oxidized.mgr.add_hook(hook_type) || raise("cannot load hook '#{hook_type}', not found")
|
|
41
41
|
begin
|
|
42
42
|
hook = Oxidized.mgr.hook.fetch(hook_type).new
|
|
43
43
|
rescue KeyError
|
|
@@ -50,15 +50,15 @@ module Oxidized
|
|
|
50
50
|
Oxidized.logger.debug "Hook #{name.inspect} registered #{hook.class} for event #{event.inspect}"
|
|
51
51
|
end
|
|
52
52
|
|
|
53
|
-
def handle
|
|
53
|
+
def handle(event, ctx_params = {})
|
|
54
54
|
ctx = HookContext.new ctx_params
|
|
55
55
|
ctx.event = event
|
|
56
56
|
|
|
57
57
|
@registered_hooks[event].each do |r_hook|
|
|
58
58
|
begin
|
|
59
59
|
r_hook.hook.run_hook ctx
|
|
60
|
-
rescue => e
|
|
61
|
-
Oxidized.logger.error "Hook #{r_hook.name} (#{r_hook.hook}) failed "
|
|
60
|
+
rescue StandardError => e
|
|
61
|
+
Oxidized.logger.error "Hook #{r_hook.name} (#{r_hook.hook}) failed " \
|
|
62
62
|
"(#{e.inspect}) for event #{event.inspect}"
|
|
63
63
|
end
|
|
64
64
|
end
|
|
@@ -69,15 +69,14 @@ module Oxidized
|
|
|
69
69
|
class Hook
|
|
70
70
|
attr_reader :cfg
|
|
71
71
|
|
|
72
|
-
def initialize
|
|
73
|
-
end
|
|
72
|
+
def initialize; end
|
|
74
73
|
|
|
75
74
|
def cfg=(cfg)
|
|
76
75
|
@cfg = cfg
|
|
77
|
-
validate_cfg! if
|
|
76
|
+
validate_cfg! if respond_to? :validate_cfg!
|
|
78
77
|
end
|
|
79
78
|
|
|
80
|
-
def run_hook
|
|
79
|
+
def run_hook(_ctx)
|
|
81
80
|
raise NotImplementedError
|
|
82
81
|
end
|
|
83
82
|
|
data/lib/oxidized/hook/awssns.rb
CHANGED
|
@@ -10,13 +10,13 @@ class AwsSns < Oxidized::Hook
|
|
|
10
10
|
sns = Aws::SNS::Resource.new(region: cfg.region)
|
|
11
11
|
topic = sns.topic(cfg.topic_arn)
|
|
12
12
|
message = {
|
|
13
|
-
:
|
|
13
|
+
event: ctx.event.to_s
|
|
14
14
|
}
|
|
15
15
|
if ctx.node
|
|
16
16
|
message.merge!(
|
|
17
|
-
:
|
|
18
|
-
:
|
|
19
|
-
:
|
|
17
|
+
group: ctx.node.group.to_s,
|
|
18
|
+
model: ctx.node.model.class.name.to_s.downcase,
|
|
19
|
+
node: ctx.node.name.to_s
|
|
20
20
|
)
|
|
21
21
|
end
|
|
22
22
|
topic.publish(
|
data/lib/oxidized/hook/exec.rb
CHANGED
|
@@ -12,12 +12,10 @@ class Exec < Oxidized::Hook
|
|
|
12
12
|
if cfg.has_key? "timeout"
|
|
13
13
|
@timeout = cfg.timeout
|
|
14
14
|
raise "invalid timeout value" unless @timeout.is_a?(Integer) &&
|
|
15
|
-
@timeout
|
|
15
|
+
@timeout.positive?
|
|
16
16
|
end
|
|
17
17
|
|
|
18
|
-
if cfg.has_key? "async"
|
|
19
|
-
@async = !!cfg.async
|
|
20
|
-
end
|
|
18
|
+
@async = !!cfg.async if cfg.has_key? "async"
|
|
21
19
|
|
|
22
20
|
if cfg.has_key? "cmd"
|
|
23
21
|
@cmd = cfg.cmd
|
|
@@ -28,23 +26,23 @@ class Exec < Oxidized::Hook
|
|
|
28
26
|
"#{self.class.name}: configuration invalid: #{e.message}"
|
|
29
27
|
end
|
|
30
28
|
|
|
31
|
-
def run_hook
|
|
29
|
+
def run_hook(ctx)
|
|
32
30
|
env = make_env ctx
|
|
33
31
|
log "Execute: #{@cmd.inspect}", :debug
|
|
34
32
|
th = Thread.new do
|
|
35
33
|
begin
|
|
36
34
|
run_cmd! env
|
|
37
|
-
rescue => e
|
|
35
|
+
rescue StandardError => e
|
|
38
36
|
raise e unless @async
|
|
39
37
|
end
|
|
40
38
|
end
|
|
41
39
|
th.join unless @async
|
|
42
40
|
end
|
|
43
41
|
|
|
44
|
-
def run_cmd!
|
|
42
|
+
def run_cmd!(env)
|
|
45
43
|
pid, status = nil, nil
|
|
46
44
|
Timeout.timeout(@timeout) do
|
|
47
|
-
pid = spawn env, @cmd, :
|
|
45
|
+
pid = spawn env, @cmd, unsetenv_others: true
|
|
48
46
|
pid, status = wait2 pid
|
|
49
47
|
unless status.exitstatus.zero?
|
|
50
48
|
msg = "#{@cmd.inspect} failed with exit value #{status.exitstatus}"
|
|
@@ -59,27 +57,25 @@ class Exec < Oxidized::Hook
|
|
|
59
57
|
raise Timeout::Error, msg
|
|
60
58
|
end
|
|
61
59
|
|
|
62
|
-
def make_env
|
|
60
|
+
def make_env(ctx)
|
|
63
61
|
env = {
|
|
64
62
|
"OX_EVENT" => ctx.event.to_s
|
|
65
63
|
}
|
|
66
64
|
if ctx.node
|
|
67
65
|
env.merge!(
|
|
68
|
-
"OX_NODE_NAME"
|
|
69
|
-
"OX_NODE_IP"
|
|
70
|
-
"OX_NODE_FROM"
|
|
71
|
-
"OX_NODE_MSG"
|
|
72
|
-
"OX_NODE_GROUP"
|
|
73
|
-
"OX_NODE_MODEL"
|
|
66
|
+
"OX_NODE_NAME" => ctx.node.name.to_s,
|
|
67
|
+
"OX_NODE_IP" => ctx.node.ip.to_s,
|
|
68
|
+
"OX_NODE_FROM" => ctx.node.from.to_s,
|
|
69
|
+
"OX_NODE_MSG" => ctx.node.msg.to_s,
|
|
70
|
+
"OX_NODE_GROUP" => ctx.node.group.to_s,
|
|
71
|
+
"OX_NODE_MODEL" => ctx.node.model.class.name,
|
|
74
72
|
"OX_REPO_COMMITREF" => ctx.commitref.to_s,
|
|
75
|
-
"OX_REPO_NAME"
|
|
73
|
+
"OX_REPO_NAME" => ctx.node.repo.to_s
|
|
76
74
|
)
|
|
77
75
|
end
|
|
78
76
|
if ctx.job
|
|
79
|
-
env.
|
|
80
|
-
|
|
81
|
-
"OX_JOB_TIME" => ctx.job.time.to_s,
|
|
82
|
-
)
|
|
77
|
+
env["OX_JOB_STATUS"] = ctx.job.status.to_s
|
|
78
|
+
env["OX_JOB_TIME"] = ctx.job.time.to_s
|
|
83
79
|
end
|
|
84
80
|
env
|
|
85
81
|
end
|
|
@@ -18,7 +18,7 @@ class GithubRepo < Oxidized::Hook
|
|
|
18
18
|
result = repo.fetch('origin', [repo.head.name], credentials: credentials)
|
|
19
19
|
log result.inspect, :debug
|
|
20
20
|
|
|
21
|
-
unless result[:total_deltas]
|
|
21
|
+
unless result[:total_deltas].positive?
|
|
22
22
|
log "nothing recieved after fetch", :debug
|
|
23
23
|
return
|
|
24
24
|
end
|
|
@@ -34,24 +34,18 @@ class GithubRepo < Oxidized::Hook
|
|
|
34
34
|
return
|
|
35
35
|
end
|
|
36
36
|
|
|
37
|
-
Rugged::Commit.create(repo,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
})
|
|
37
|
+
Rugged::Commit.create(repo,
|
|
38
|
+
parents: [repo.head.target, their_branch.target],
|
|
39
|
+
tree: merge_index.write_tree(repo),
|
|
40
|
+
message: "Merge remote-tracking branch '#{their_branch.name}'",
|
|
41
|
+
update_ref: "HEAD")
|
|
43
42
|
end
|
|
44
43
|
|
|
45
44
|
private
|
|
46
45
|
|
|
47
46
|
def credentials
|
|
48
|
-
Proc.new do |
|
|
49
|
-
|
|
50
|
-
git_user = cfg.username
|
|
51
|
-
else
|
|
52
|
-
git_user = username_from_url || 'git'
|
|
53
|
-
end
|
|
54
|
-
|
|
47
|
+
Proc.new do |_url, username_from_url, _allowed_types| # rubocop:disable Style/Proc
|
|
48
|
+
git_user = cfg.has_key?('username') ? cfg.username : (username_from_url || 'git')
|
|
55
49
|
if cfg.has_key?('password')
|
|
56
50
|
log "Authenticating using username and password as '#{git_user}'", :debug
|
|
57
51
|
Rugged::Credentials::UserPassword.new(username: git_user, password: cfg.password)
|
|
@@ -19,7 +19,7 @@ class XMPPDiff < Oxidized::Hook
|
|
|
19
19
|
diff = gitoutput.get_diff ctx.node, ctx.node.group, ctx.commitref, nil
|
|
20
20
|
|
|
21
21
|
interesting = diff[:patch].lines.to_a[4..-1].any? do |line|
|
|
22
|
-
["+", "-"].include?(line[0])
|
|
22
|
+
["+", "-"].include?(line[0]) && (not ["#", "!"].include?(line[1]))
|
|
23
23
|
end
|
|
24
24
|
interesting &&= diff[:patch].lines.to_a[5..-1].any? { |line| line[0] == '-' }
|
|
25
25
|
interesting &&= diff[:patch].lines.to_a[5..-1].any? { |line| line[0] == '+' }
|
data/lib/oxidized/input/cli.rb
CHANGED
|
@@ -32,24 +32,24 @@ module Oxidized
|
|
|
32
32
|
@pre_logout.each { |command, block| block ? block.call : (cmd command, nil) }
|
|
33
33
|
end
|
|
34
34
|
|
|
35
|
-
def post_login
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
35
|
+
def post_login(cmd = nil, &block)
|
|
36
|
+
return if @exec
|
|
37
|
+
|
|
38
|
+
@post_login << [cmd, block]
|
|
39
39
|
end
|
|
40
40
|
|
|
41
|
-
def pre_logout
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
41
|
+
def pre_logout(cmd = nil, &block)
|
|
42
|
+
return if @exec
|
|
43
|
+
|
|
44
|
+
@pre_logout << [cmd, block]
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
-
def username
|
|
48
|
-
@username
|
|
47
|
+
def username(regex = /^(Username|login)/)
|
|
48
|
+
@username || (@username = regex)
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
-
def password
|
|
52
|
-
@password
|
|
51
|
+
def password(regex = /^Password/)
|
|
52
|
+
@password || (@password = regex)
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def login
|