summaryrefslogtreecommitdiffstats
path: root/lib/facter/virtual.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-01-02 15:08:26 -0600
committerLuke Kanies <luke@madstop.com>2009-01-15 11:42:17 -0600
commit91e25b9cc12fcb5e8d684b6258aec20735b992e1 (patch)
treefb2617415ba9a4eb252f334bdb387d71b0266389 /lib/facter/virtual.rb
parent074eda99ffd186a667ec3f50fbb6d4e267f585cb (diff)
downloadfacter-91e25b9cc12fcb5e8d684b6258aec20735b992e1.tar.gz
facter-91e25b9cc12fcb5e8d684b6258aec20735b992e1.tar.xz
facter-91e25b9cc12fcb5e8d684b6258aec20735b992e1.zip
Fixing indentation everywhere
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/facter/virtual.rb')
-rw-r--r--lib/facter/virtual.rb133
1 files changed, 66 insertions, 67 deletions
diff --git a/lib/facter/virtual.rb b/lib/facter/virtual.rb
index db8dc33..fdb340f 100644
--- a/lib/facter/virtual.rb
+++ b/lib/facter/virtual.rb
@@ -1,76 +1,75 @@
Facter.add("virtual") do
- confine :kernel => %w{Linux FreeBSD OpenBSD SunOS}
-
- result = "physical"
-
- setcode do
+ confine :kernel => %w{Linux FreeBSD OpenBSD SunOS}
- if FileTest.exists?("/proc/user_beancounters")
- # openvz. can be hardware node or virtual environment
- # read the init process' status file, it has laxer permissions
- # than /proc/user_beancounters (so this won't fail as non-root)
- txt = File.read("/proc/1/status")
- if txt =~ /^envID:[[:blank:]]+0$/mi
- result = "openvzhn"
- else
- result = "openvzve"
- end
- end
+ result = "physical"
- if FileTest.exists?("/proc/xen/capabilities") && FileTest.readable?("/proc/xen/capabilities")
- txt = File.read("/proc/xen/capabilities")
- if txt =~ /control_d/i
- result = "xen0"
- else
- result = "xenu"
- end
- end
+ setcode do
+ if FileTest.exists?("/proc/user_beancounters")
+ # openvz. can be hardware node or virtual environment
+ # read the init process' status file, it has laxer permissions
+ # than /proc/user_beancounters (so this won't fail as non-root)
+ txt = File.read("/proc/1/status")
+ if txt =~ /^envID:[[:blank:]]+0$/mi
+ result = "openvzhn"
+ else
+ result = "openvzve"
+ end
+ end
- if result == "physical"
- path = %x{which lspci 2> /dev/null}.chomp
- if path !~ /no lspci/
- output = %x{#{path}}
- output.each {|p|
- # --- look for the vmware video card to determine if it is virtual => vmware.
- # --- 00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter
- result = "vmware" if p =~ /VM[wW]are/
- }
- else
- path = %x{which dmidecode 2> /dev/null}.chomp
- if path !~ /no dmidecode/
- output = %x{#{path}}
- output.each {|pd|
- result = "vmware" if pd =~ /VMware|Parallels/
- }
- else
- path = %x{which prtdiag 2> /dev/null}.chomp
- if path !~ /no prtdiag/
- output = %x{#{path}}
- output.each {|pd|
- result = "vmware" if pd =~ /VMware|Parallels/
- }
- end
- end
- end
- end
+ if FileTest.exists?("/proc/xen/capabilities") && FileTest.readable?("/proc/xen/capabilities")
+ txt = File.read("/proc/xen/capabilities")
+ if txt =~ /control_d/i
+ result = "xen0"
+ else
+ result = "xenu"
+ end
+ end
- # VMware server 1.0.3 rpm places vmware-vmx in this place, other versions or platforms may not.
- if FileTest.exists?("/usr/lib/vmware/bin/vmware-vmx")
- result = "vmware_server"
- end
+ if result == "physical"
+ path = %x{which lspci 2> /dev/null}.chomp
+ if path !~ /no lspci/
+ output = %x{#{path}}
+ output.each do |p|
+ # --- look for the vmware video card to determine if it is virtual => vmware.
+ # --- 00:0f.0 VGA compatible controller: VMware Inc [VMware SVGA II] PCI Display Adapter
+ result = "vmware" if p =~ /VM[wW]are/
+ end
+ else
+ path = %x{which dmidecode 2> /dev/null}.chomp
+ if path !~ /no dmidecode/
+ output = %x{#{path}}
+ output.each do |pd|
+ result = "vmware" if pd =~ /VMware|Parallels/
+ end
+ else
+ path = %x{which prtdiag 2> /dev/null}.chomp
+ if path !~ /no prtdiag/
+ output = %x{#{path}}
+ output.each do |pd|
+ result = "vmware" if pd =~ /VMware|Parallels/
+ end
+ end
+ end
+ end
+ end
- mountexists = system "which mount > /dev/null 2>&1"
- if $?.exitstatus == 0
- output = %x{mount}
- output.each {|p|
- result = "vserver" if p =~ /\/dev\/hdv1/
- }
- end
+ # VMware server 1.0.3 rpm places vmware-vmx in this place, other versions or platforms may not.
+ if FileTest.exists?("/usr/lib/vmware/bin/vmware-vmx")
+ result = "vmware_server"
+ end
- if FileTest.directory?('/proc/virtual')
- result = "vserver_host"
- end
+ mountexists = system "which mount > /dev/null 2>&1"
+ if $?.exitstatus == 0
+ output = %x{mount}
+ output.each do |p|
+ result = "vserver" if p =~ /\/dev\/hdv1/
+ end
+ end
- result
- end
+ if FileTest.directory?('/proc/virtual')
+ result = "vserver_host"
+ end
+
+ result
+ end
end