onering-report 0.6.11 → 0.6.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YWYxMzU3MDY5YTVmNTVmNzU3MWI5M2NmYzMxNzBiOGRhMzA4YzMyMg==
4
+ MGE1ZjdkZmVjMTdlZDk2MWJkYjQ2NDBmMTI4ZTNiZmUwOGQ3YTFiNQ==
5
5
  data.tar.gz: !binary |-
6
- MGI2ODAyZGY5ZWQyNDg0NWFiMTUzMGQxNjUxMDMyNjlmZWE3ZTQyZQ==
6
+ ZjUyZDhlNTZjODE5ZTY2YmI5Y2IyYWU5NTJhNjVmMGExYWM3ZWNhNA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MDU0Y2YwNGJmNTE2MDRiOGE5ZDI1YjgxMDAxZGZhNGVhODYxZGY1MWQ3NDkz
10
- MzU1Yzc3Nzc1YTA2MzJhMTYyYmJjODkyNWE0YjBjOThlOTEyMmM0NjYxN2Ji
11
- ODM3YzgxMThhOGQ0MGRlNjMwYzAwZWYwOTExMTM0OTQ5OTMxNzA=
9
+ ZTI3MjY2YzUxYmFiMzg1ZGRhN2FlOTI1N2MxNzg0NjAxYjEyNzNmYmY1N2Uw
10
+ NWNiMmEyYTdjM2FlNWZhNTRhNTgwM2Y1Zjg3MTlkNzFmMjhmNzM5YjI4OWU0
11
+ NWQ4NGNlOTA5NjkyNWRhM2I4MWZjMGY2NDUyYmY4YWE0ODIwNjY=
12
12
  data.tar.gz: !binary |-
13
- YjdiNTgzZmQyZDA3NzMwZmFiMzNkZWI0NTQzMWEyMTY1MTk1Mzk0N2YxNDcw
14
- ZTZhYTVkYjQxMzYxNTYxNzRhYmU1NjU4ZDgxMGFkNDIwODg1MjJlNGQ5ZDY1
15
- OWU5YWUwNzBkOTBiNmE2YWI0NjU5YzkzYzg1ZDNlZDVlZWM1Zjc=
13
+ NjQyMWEyZjQ0NDI0YTJjMWMyYTU0YzZiMDI4M2EyNTQyZmE2NDg5NmU2ODdk
14
+ ZTRkMzQyODAzYWMxMjM1ODFlMjk1YmE0M2M1NGJjOTE0NzdiMjc3NTA4NzUz
15
+ YjhiY2U0MjdiNTFmYWI5Mzk4OGVhNzFjN2QwMmEyZmZmMDQ2YTQ=
@@ -6,108 +6,120 @@ end
6
6
 
7
7
  ALLOWED_IPMI = 5
8
8
 
9
- def ipmi_ok?
9
+ def with_timeout(&block)
10
10
  begin
11
- ipmi = IPMI_PATH if defined? IPMI_PATH
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
- Facter::Util::Resolution.exec("#{ipmi} health 2> /dev/null | tail -n1 | grep failed").nil?
13
+ res = yield
19
14
  }
20
- return true
15
+ return res
21
16
  rescue Timeout::Error
22
- $stderr.puts "timed out while running #{ipmi}"
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
- else
34
- if File.exists?('/proc/cmdline')
35
- site = (File.read('/proc/cmdline').chomp.split(' ').select{|i| i =~ /^domain=/ }.first rescue nil)
36
- site = site.split('=', 2).last if site
37
- site = site.split('.').first if site
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
- site = nil if ['test', 'hw', 'vm'].include?(site)
48
+ site = nil if ['test', 'hw', 'vm'].include?(site)
42
49
 
43
- if site
44
- site
45
- else
46
- Facter.value('fqdn').split('.')[-3].downcase rescue nil
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
- setcode do
53
- env = (Facter.value('fqdn').split('.').first.split('-')[-2].downcase rescue nil)
54
-
55
- case env
56
- when 'dev'
57
- 'development'
58
- when /(stg|stage)/
59
- 'staging'
60
- when 'prod'
61
- 'production'
62
- else
63
- nil
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
- if ipmi_ok?
70
- setcode do
71
- slot = Integer(Facter::Util::Resolution.exec("bmc node_number 2> /dev/null")) rescue nil
72
- slot = nil if slot == 0
73
- slot
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
- ipmi_lan = Facter::Util::Resolution.exec("ipmitool lan print 1 2> /dev/null")
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
- if ipmi_lan
82
- ipmi_lan_data = {}
93
+ if ipmi_lan
94
+ ipmi_lan_data = {}
83
95
 
84
- ipmi_lan.lines.each do |line|
85
- key, value = line.split(/:/, 2)
86
- value = value.strip.squeeze(' ').chomp
96
+ ipmi_lan.lines.each do |line|
97
+ key, value = line.split(/:/, 2)
98
+ value = value.strip.squeeze(' ').chomp
87
99
 
88
- case key
89
- when /^IP Address/i
90
- ipmi_lan_data[:ip] = value
100
+ case key
101
+ when /^IP Address/i
102
+ ipmi_lan_data[:ip] = value
91
103
 
92
- when /^Subnet Mask/i
93
- ipmi_lan_data[:netmask] = value
104
+ when /^Subnet Mask/i
105
+ ipmi_lan_data[:netmask] = value
94
106
 
95
- when /^MAC Address/i
96
- ipmi_lan_data[:macaddress] = value.upcase
107
+ when /^MAC Address/i
108
+ ipmi_lan_data[:macaddress] = value.upcase
97
109
 
98
- when /^Default Gateway IP/i
99
- ipmi_lan_data[:gateway] = value
110
+ when /^Default Gateway IP/i
111
+ ipmi_lan_data[:gateway] = value
100
112
 
101
- when /^SNMP Community String/i
102
- ipmi_lan_data[:snmp_community] = value
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
- ipmi_lan_data.each do |key, value|
108
- Facter.add("ipmi_#{key}") do
109
- setcode { value }
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
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |gem|
3
3
  gem.name = 'onering-report'
4
- gem.version = '0.6.11'
4
+ gem.version = '0.6.12'
5
5
  gem.authors = ['rnarkis']
6
6
  gem.email = ['rnarkis@outbrain.com']
7
7
  gem.description = %q{Onering facter facts}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onering-report
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.11
4
+ version: 0.6.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - rnarkis