onering-report-plugins 0.0.21 → 0.0.22

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.
@@ -1,9 +1,11 @@
1
1
  Facter.add('uuid') do
2
2
  setcode do
3
- if Facter.value('uuid')
3
+ if not Facter.value('uuid').nil?
4
4
  Facter.value('uuid')
5
5
  elsif Facter::Util::Resolution.which('dmidecode')
6
6
  Facter::Util::Resolution.exec('dmidecode -s system-uuid').strip.chomp
7
+ elsif File.exists?('/sys/hypervisor/uuid')
8
+ File.read('/sys/hypervisor/uuid').lines.first.strip.chomp
7
9
  else
8
10
  nil
9
11
  end
@@ -12,36 +14,33 @@ end
12
14
 
13
15
  Facter.add('signature') do
14
16
  setcode do
15
- if File.size?("/etc/onering/signature")
16
- parts = File.read("/etc/onering/signature").split("\n").
17
- reject{|i| i =~ /^\s*#/ }.
18
- reject{|i| i.strip.chomp.empty? }.
19
- collect{|i| i.gsub(/\H/,'') }
20
-
21
- elsif Facter.value('macaddress')
22
- if Facter.value('is_virtual')
23
- if File.exists?('/sys/hypervisor/uuid')
24
- parts = [
25
- File.read('/sys/hypervisor/uuid').strip.chomp.delete('-'),
26
- Facter.value('macaddress').strip.delete(':')
27
- ]
28
- end
29
- elsif Facter::Util::Resolution.which('dmidecode')
30
- parts = [
31
- Facter::Util::Resolution.exec('dmidecode -s system-uuid').strip.chomp.delete('-'),
32
- Facter.value('macaddress').strip.delete(':')
33
- ]
34
- end
17
+ parts = []
35
18
 
36
- else
19
+ if Facter.value('uuid')
20
+ parts << Facter.value('uuid').gsub(/[\W\_]+/,'').upcase
21
+ end
22
+
23
+ if Facter.value('macaddress')
24
+ parts << Facter.value('macaddress').gsub(/[\W\_]+/,'').upcase
25
+ end
26
+
27
+ # still empty, now we really have to grasp at straws
28
+ if parts.empty?
37
29
  if Facter.value('ipaddress')
38
- parts = [
39
- Facter.value('ipaddress').split(',').first.strip.chomp.delete('.')
40
- ].compact
30
+ parts << Facter.value('ipaddress').split(',').first.strip.chomp.delete('.')
41
31
  end
42
32
  end
43
33
 
44
- (parts && !parts.empty? ? parts.collect{|i| i.upcase }.join('-') : nil)
34
+
35
+ # final pruning
36
+ parts = parts.reject{|i| i.nil? || i.empty? }
37
+
38
+ # still empty?
39
+ if parts.empty?
40
+ nil
41
+ else
42
+ parts.join('-')
43
+ end
45
44
  end
46
45
  end
47
46
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: onering-report-plugins
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.22
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: