onering-report 0.6.11 → 0.6.12
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 +8 -8
- data/lib/facter/onering_properties_physical.rb +82 -70
- data/onering-report.gemspec +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MGE1ZjdkZmVjMTdlZDk2MWJkYjQ2NDBmMTI4ZTNiZmUwOGQ3YTFiNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZjUyZDhlNTZjODE5ZTY2YmI5Y2IyYWU5NTJhNjVmMGExYWM3ZWNhNA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZTI3MjY2YzUxYmFiMzg1ZGRhN2FlOTI1N2MxNzg0NjAxYjEyNzNmYmY1N2Uw
|
10
|
+
NWNiMmEyYTdjM2FlNWZhNTRhNTgwM2Y1Zjg3MTlkNzFmMjhmNzM5YjI4OWU0
|
11
|
+
NWQ4NGNlOTA5NjkyNWRhM2I4MWZjMGY2NDUyYmY4YWE0ODIwNjY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NjQyMWEyZjQ0NDI0YTJjMWMyYTU0YzZiMDI4M2EyNTQyZmE2NDg5NmU2ODdk
|
14
|
+
ZTRkMzQyODAzYWMxMjM1ODFlMjk1YmE0M2M1NGJjOTE0NzdiMjc3NTA4NzUz
|
15
|
+
YjhiY2U0MjdiNTFmYWI5Mzk4OGVhNzFjN2QwMmEyZmZmMDQ2YTQ=
|
@@ -6,108 +6,120 @@ end
|
|
6
6
|
|
7
7
|
ALLOWED_IPMI = 5
|
8
8
|
|
9
|
-
def
|
9
|
+
def with_timeout(&block)
|
10
10
|
begin
|
11
|
-
|
12
|
-
ipmi ||= 'ipmiutil'
|
13
|
-
if count_ipmi_instances('ipmitool') > ALLOWED_IPMI
|
14
|
-
$stderr.puts "More then #{ALLOWED_IPMI} #{ipmi} instances found"
|
15
|
-
return false
|
16
|
-
end
|
11
|
+
res = nil
|
17
12
|
Timeout::timeout(30) {
|
18
|
-
|
13
|
+
res = yield
|
19
14
|
}
|
20
|
-
return
|
15
|
+
return res
|
21
16
|
rescue Timeout::Error
|
22
|
-
$stderr.puts "timed out while running
|
17
|
+
$stderr.puts "timed out while running"
|
23
18
|
false
|
24
19
|
end
|
25
20
|
end
|
26
21
|
|
22
|
+
def ipmi_ok?
|
23
|
+
ipmi = IPMI_PATH if defined? IPMI_PATH
|
24
|
+
ipmi ||= 'ipmiutil'
|
25
|
+
if count_ipmi_instances('ipmitool') > ALLOWED_IPMI
|
26
|
+
$stderr.puts "More then #{ALLOWED_IPMI} #{ipmi} instances found"
|
27
|
+
return false
|
28
|
+
end
|
29
|
+
return with_timeout do
|
30
|
+
Facter::Util::Resolution.exec("#{ipmi} health 2> /dev/null | tail -n1 | grep failed").nil?
|
31
|
+
end
|
32
|
+
end
|
27
33
|
|
28
|
-
Facter.add('site') do
|
29
|
-
setcode do
|
30
|
-
if File.size?('/etc/onering/static/site')
|
31
|
-
site = File.read('/etc/onering/static/site').strip.chomp
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
site =
|
37
|
-
|
35
|
+
Facter.add('site') do
|
36
|
+
setcode do
|
37
|
+
if File.size?('/etc/onering/static/site')
|
38
|
+
site = File.read('/etc/onering/static/site').strip.chomp
|
39
|
+
|
40
|
+
else
|
41
|
+
if File.exists?('/proc/cmdline')
|
42
|
+
site = (File.read('/proc/cmdline').chomp.split(' ').select{|i| i =~ /^domain=/ }.first rescue nil)
|
43
|
+
site = site.split('=', 2).last if site
|
44
|
+
site = site.split('.').first if site
|
45
|
+
end
|
38
46
|
end
|
39
|
-
end
|
40
47
|
|
41
|
-
|
48
|
+
site = nil if ['test', 'hw', 'vm'].include?(site)
|
42
49
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
50
|
+
if site
|
51
|
+
site
|
52
|
+
else
|
53
|
+
Facter.value('fqdn').split('.')[-3].downcase rescue nil
|
54
|
+
end
|
47
55
|
end
|
48
56
|
end
|
49
|
-
end
|
50
57
|
|
51
|
-
Facter.add('environment') do
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
58
|
+
Facter.add('environment') do
|
59
|
+
setcode do
|
60
|
+
env = (Facter.value('fqdn').split('.').first.split('-')[-2].downcase rescue nil)
|
61
|
+
|
62
|
+
case env
|
63
|
+
when 'dev'
|
64
|
+
'development'
|
65
|
+
when /(stg|stage)/
|
66
|
+
'staging'
|
67
|
+
when 'prod'
|
68
|
+
'production'
|
69
|
+
else
|
70
|
+
nil
|
71
|
+
end
|
64
72
|
end
|
65
73
|
end
|
66
|
-
end
|
67
74
|
|
68
|
-
Facter.add('slot') do
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
75
|
+
Facter.add('slot') do
|
76
|
+
if ipmi_ok?
|
77
|
+
setcode do
|
78
|
+
slot = with_timeout do
|
79
|
+
Integer(Facter::Util::Resolution.exec("bmc node_number 2> /dev/null")) rescue nil
|
80
|
+
end
|
81
|
+
slot = nil if slot == 0
|
82
|
+
slot
|
83
|
+
end
|
74
84
|
end
|
75
85
|
end
|
76
|
-
end
|
77
86
|
|
78
|
-
if ipmi_ok?
|
79
|
-
|
87
|
+
if ipmi_ok?
|
88
|
+
ipmi_lan = nil
|
89
|
+
with_timeout do
|
90
|
+
ipmi_lan = Facter::Util::Resolution.exec("ipmitool lan print 1 2> /dev/null")
|
91
|
+
end
|
80
92
|
|
81
|
-
|
82
|
-
|
93
|
+
if ipmi_lan
|
94
|
+
ipmi_lan_data = {}
|
83
95
|
|
84
|
-
|
85
|
-
|
86
|
-
|
96
|
+
ipmi_lan.lines.each do |line|
|
97
|
+
key, value = line.split(/:/, 2)
|
98
|
+
value = value.strip.squeeze(' ').chomp
|
87
99
|
|
88
|
-
|
89
|
-
|
90
|
-
|
100
|
+
case key
|
101
|
+
when /^IP Address/i
|
102
|
+
ipmi_lan_data[:ip] = value
|
91
103
|
|
92
|
-
|
93
|
-
|
104
|
+
when /^Subnet Mask/i
|
105
|
+
ipmi_lan_data[:netmask] = value
|
94
106
|
|
95
|
-
|
96
|
-
|
107
|
+
when /^MAC Address/i
|
108
|
+
ipmi_lan_data[:macaddress] = value.upcase
|
97
109
|
|
98
|
-
|
99
|
-
|
110
|
+
when /^Default Gateway IP/i
|
111
|
+
ipmi_lan_data[:gateway] = value
|
100
112
|
|
101
|
-
|
102
|
-
|
113
|
+
when /^SNMP Community String/i
|
114
|
+
ipmi_lan_data[:snmp_community] = value
|
103
115
|
|
116
|
+
end
|
104
117
|
end
|
105
|
-
end
|
106
118
|
|
107
|
-
|
108
|
-
|
109
|
-
|
119
|
+
ipmi_lan_data.each do |key, value|
|
120
|
+
Facter.add("ipmi_#{key}") do
|
121
|
+
setcode { value }
|
122
|
+
end
|
110
123
|
end
|
111
124
|
end
|
112
125
|
end
|
113
|
-
end
|
data/onering-report.gemspec
CHANGED