facter 2.4.1-x64-mingw32 → 2.4.3-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,7 +15,7 @@
15
15
  # Directly queries the EC2 metadata endpoint.
16
16
  #
17
17
 
18
- require 'facter/ec2/rest'
18
+ require 'facter/ec2/rest' unless defined?(Facter::EC2)
19
19
 
20
20
  Facter.define_fact(:ec2_metadata) do
21
21
  define_resolution(:rest) do
@@ -96,6 +96,9 @@ module Facter
96
96
  rescue *CONNECTION_ERRORS => e
97
97
  Facter.log_exception(e, "Failed to fetch ec2 uri #{uri}: #{e.message}")
98
98
  return nil
99
+ rescue Timeout::Error => e
100
+ Facter.log_exception(e, "Failed to fetch ec2 uri #{uri}: #{e.message}")
101
+ return nil
99
102
  end
100
103
 
101
104
  private
@@ -1,4 +1,5 @@
1
1
  require 'facter/operatingsystem/base'
2
+ require 'facter/operatingsystem/osreleaselinux'
2
3
  require 'facter/operatingsystem/cumuluslinux'
3
4
  require 'facter/operatingsystem/linux'
4
5
  require 'facter/operatingsystem/sunos'
@@ -13,6 +14,8 @@ module Facter
13
14
  release_info = Facter::Util::Operatingsystem.os_release
14
15
  if release_info['NAME'] == "Cumulus Linux"
15
16
  Facter::Operatingsystem::CumulusLinux.new
17
+ elsif release_info['NAME'] == "CoreOS"
18
+ Facter::Operatingsystem::OsReleaseLinux.new
16
19
  else
17
20
  Facter::Operatingsystem::Linux.new
18
21
  end
@@ -0,0 +1,28 @@
1
+ require 'facter/util/operatingsystem'
2
+ require 'facter/operatingsystem/linux'
3
+
4
+ module Facter
5
+ module Operatingsystem
6
+ class OsReleaseLinux < Linux
7
+ def get_operatingsystem
8
+ # Native cfacter also uses the NAME field.
9
+ Facter::Util::Operatingsystem.os_release['NAME']
10
+ end
11
+
12
+ def get_osfamily
13
+ Facter::Util::Operatingsystem.os_release['NAME']
14
+ end
15
+
16
+ def get_operatingsystemrelease
17
+ @operatingsystemrelease ||= Facter::Util::Operatingsystem.os_release['VERSION_ID']
18
+ @operatingsystemrelease
19
+ end
20
+
21
+ def get_operatingsystemmajrelease
22
+ if operatingsystemrelease = get_operatingsystemrelease
23
+ operatingsystemrelease.split(".").first
24
+ end
25
+ end
26
+ end
27
+ end
28
+ end
@@ -11,8 +11,8 @@
11
11
  Facter.add(:puppetversion) do
12
12
  setcode do
13
13
  begin
14
- require 'puppet'
15
- Puppet::PUPPETVERSION.to_s
14
+ require 'puppet/version'
15
+ Puppet.version.to_s
16
16
  rescue LoadError
17
17
  nil
18
18
  end
@@ -148,7 +148,7 @@ Facter.add("selinux_config_policy") do
148
148
  setcode do
149
149
  result = 'unknown'
150
150
  mode = Facter::Core::Execution.exec(sestatus_cmd)
151
- mode.each_line { |l| result = $1 if l =~ /^Policy from config file\:\s+(\w+)$/i }
151
+ mode.each_line { |l| result = $2 if l =~ /^(Policy from config file|Loaded policy name)\:\s+(\w+)$/i }
152
152
  result.chomp
153
153
  end
154
154
  end
@@ -41,16 +41,19 @@ module Facter::Util::Config
41
41
  if Facter::Util::Root.root?
42
42
  windows_dir = windows_data_dir
43
43
  if windows_dir.nil? then
44
- # Note: Beginning with Facter 3, /opt/puppetlabs/agent/facts.d will be the only
44
+ # Note: Beginning with Facter 3, /opt/puppetlabs/facter/facts.d will be the only
45
45
  # default external fact directory.
46
- @external_facts_dirs = ["/opt/puppetlabs/agent/facts.d",
46
+ @external_facts_dirs = ["/opt/puppetlabs/facter/facts.d",
47
47
  "/etc/facter/facts.d",
48
48
  "/etc/puppetlabs/facter/facts.d"]
49
49
  else
50
50
  @external_facts_dirs = [File.join(windows_dir, 'PuppetLabs', 'facter', 'facts.d')]
51
51
  end
52
52
  elsif ENV['HOME']
53
- @external_facts_dirs = [File.expand_path(File.join(ENV['HOME'], ".facter", "facts.d"))]
53
+ # Note: Beginning with Facter 3, ~/.puppetlabs/opt/facter/facts.d will be the only
54
+ # default external fact directory.
55
+ @external_facts_dirs = [File.expand_path(File.join(ENV['HOME'], ".puppetlabs", "opt", "facter", "facts.d")),
56
+ File.expand_path(File.join(ENV['HOME'], ".facter", "facts.d"))]
54
57
  else
55
58
  @external_facts_dirs = []
56
59
  end
@@ -64,4 +67,22 @@ module Facter::Util::Config
64
67
  end
65
68
 
66
69
  setup_default_ext_facts_dirs
70
+
71
+ def self.override_binary_dir=(dir)
72
+ @override_binary_dir = dir
73
+ end
74
+
75
+ def self.override_binary_dir
76
+ @override_binary_dir
77
+ end
78
+
79
+ def self.setup_default_override_binary_dir
80
+ if Facter::Util::Config.is_windows?
81
+ @override_binary_dir = nil
82
+ else
83
+ @override_binary_dir = "/opt/puppetlabs/puppet/bin"
84
+ end
85
+ end
86
+
87
+ setup_default_override_binary_dir
67
88
  end
@@ -1,9 +1,9 @@
1
1
  # A Facter plugin that loads external facts.
2
2
  #
3
3
  # Default Unix Directories:
4
- # /opt/puppetlabs/agent/facts.d, /etc/facter/facts.d, /etc/puppetlabs/facter/facts.d
4
+ # /opt/puppetlabs/facter/facts.d, /etc/facter/facts.d, /etc/puppetlabs/facter/facts.d
5
5
  #
6
- # Beginning with Facter 3, only /opt/puppetlabs/agent/facts.d will be a default external fact
6
+ # Beginning with Facter 3, only /opt/puppetlabs/facter/facts.d will be a default external fact
7
7
  # directory in Unix.
8
8
  #
9
9
  # Default Windows Direcotires:
@@ -286,8 +286,8 @@ module Facter::Util::IP
286
286
  # Linux changes the MAC address reported via ifconfig when an ethernet interface
287
287
  # becomes a slave of a bonding device to the master MAC address.
288
288
  # We have to dig a bit to get the original/real MAC address of the interface.
289
- bonddev = get_bonding_master(interface)
290
- if label == 'macaddress' and bonddev
289
+ bonddev = get_bonding_master(interface) if label == 'macaddress'
290
+ if bonddev
291
291
  bondinfo = read_proc_net_bonding("/proc/net/bonding/#{bonddev}")
292
292
  re = /^Slave Interface: #{interface}\b.*?\bPermanent HW addr: (([0-9A-F]{2}:?)*)$/im
293
293
  if match = re.match(bondinfo)
@@ -13,9 +13,17 @@ module Facter::Util::Virtual
13
13
  # and later versions of virt-what may emit this message on stderr. This
14
14
  # method ensures stderr is redirected and that error messages are stripped
15
15
  # from stdout.
16
- def self.virt_what(command = "virt-what")
17
- command = Facter::Core::Execution.which(command)
18
- return unless command
16
+ def self.virt_what(cmd = "virt-what")
17
+ if bindir = Facter::Util::Config.override_binary_dir
18
+ command = Facter::Core::Execution.which(File.join(bindir, cmd))
19
+ else
20
+ command = nil
21
+ end
22
+
23
+ if !command
24
+ command = Facter::Core::Execution.which(cmd)
25
+ return unless command
26
+ end
19
27
 
20
28
  if Facter.value(:kernel) == 'windows'
21
29
  redirected_cmd = "#{command} 2>NUL"
@@ -4,7 +4,16 @@ module Facter::Util::Xendomains
4
4
  XEN_COMMANDS = ['/usr/sbin/xl', '/usr/sbin/xm']
5
5
 
6
6
  def self.xen_command
7
- XEN_COMMANDS.find { |cmd| Facter::Util::Resolution.which(cmd) }
7
+ if File.file?('/usr/lib/xen-common/bin/xen-toolstack')
8
+ xen_toolstack_cmd = Facter::Util::Resolution.exec('/usr/lib/xen-common/bin/xen-toolstack')
9
+ if xen_toolstack_cmd
10
+ xen_toolstack_cmd.chomp
11
+ else
12
+ nil
13
+ end
14
+ else
15
+ XEN_COMMANDS.find { |cmd| Facter::Util::Resolution.which(cmd) }
16
+ end
8
17
  end
9
18
 
10
19
  def self.get_domains
@@ -1,6 +1,6 @@
1
1
  module Facter
2
2
  if not defined? FACTERVERSION then
3
- FACTERVERSION = '2.4.1'
3
+ FACTERVERSION = '2.4.3'
4
4
  end
5
5
 
6
6
  # Returns the running version of Facter.
@@ -73,7 +73,7 @@ end
73
73
  Facter.add("virtual") do
74
74
  confine :kernel => 'SunOS'
75
75
  has_weight 10
76
- self.timeout = 6
76
+ self.timeout = 20
77
77
 
78
78
  setcode do
79
79
  next "zone" if Facter::Util::Virtual.zone?
@@ -164,6 +164,7 @@ Facter.add("virtual") do
164
164
  next "rhev" if lines.any? {|l| l =~ /Product Name: RHEV Hypervisor/ }
165
165
  next "ovirt" if lines.any? {|l| l =~ /Product Name: oVirt Node/ }
166
166
  next "bochs" if lines.any? {|l| l =~ /Bochs/ }
167
+ next "kvm" if lines.any? {|l| l =~ /Manufacturer: QEMU/ }
167
168
  end
168
169
 
169
170
  # Default to 'physical'
@@ -0,0 +1,9 @@
1
+ SELinux status: enabled
2
+ SELinuxfs mount: /sys/fs/selinux
3
+ SELinux root directory: /etc/selinux
4
+ Loaded policy name: default
5
+ Current mode: enforcing
6
+ Mode from config file: permissive
7
+ Policy MLS status: enabled
8
+ Policy deny_unknown status: denied
9
+ Max kernel policy version: 29
@@ -0,0 +1,9 @@
1
+ NAME=CoreOS
2
+ ID=coreos
3
+ VERSION=575.0.0
4
+ VERSION_ID=575.0.0
5
+ BUILD_ID=
6
+ PRETTY_NAME="CoreOS 575.0.0"
7
+ ANSI_COLOR="1;32"
8
+ HOME_URL="https://coreos.com/"
9
+ BUG_REPORT_URL="https://github.com/coreos/bugs/issues"
@@ -2,6 +2,7 @@ require 'spec_helper'
2
2
  require 'facter/operatingsystem/implementation'
3
3
  require 'facter/operatingsystem/base'
4
4
  require 'facter/operatingsystem/cumuluslinux'
5
+ require 'facter/operatingsystem/osreleaselinux'
5
6
  require 'facter/operatingsystem/linux'
6
7
  require 'facter/operatingsystem/sunos'
7
8
  require 'facter/operatingsystem/vmkernel'
@@ -298,7 +298,7 @@ describe Facter::Operatingsystem::Linux do
298
298
  end
299
299
 
300
300
  describe "Operatingsystemmajrelease key" do
301
- ['Amazon' 'AristaEOS', 'CentOS','CloudLinux','Debian','Fedora','OEL','OracleLinux','OVS','RedHat','Scientific','SLC','CumulusLinux'].each do |operatingsystem|
301
+ ['Amazon' 'AristaEOS', 'CentOS','CloudLinux','Debian','Fedora','OEL','OracleLinux','OVS','RedHat','Scientific','SLC','CumulusLinux','CoreOS'].each do |operatingsystem|
302
302
  describe "on #{operatingsystem} operatingsystems" do
303
303
  it "should be derived from operatingsystemrelease" do
304
304
  subject.stubs(:get_operatingsystem).returns(operatingsystem)
@@ -96,6 +96,11 @@ describe "SELinux facts" do
96
96
 
97
97
  Facter.fact(:selinux_config_policy).value.should == "targeted"
98
98
  end
99
+ it "should return the loaded SELinux policy" do
100
+ sestatus_is(my_fixture_read("selinux_sestatus2"))
101
+
102
+ Facter.fact(:selinux_config_policy).value.should == "default"
103
+ end
99
104
  end
100
105
 
101
106
  def sestatus_is(status)
@@ -55,7 +55,7 @@ describe Facter::Util::Config do
55
55
  Facter::Util::Config.stubs(:is_windows?).returns(false)
56
56
  Facter::Util::Config.stubs(:windows_data_dir).returns(nil)
57
57
  Facter::Util::Config.setup_default_ext_facts_dirs
58
- Facter::Util::Config.external_facts_dirs.should == ["/opt/puppetlabs/agent/facts.d", "/etc/facter/facts.d", "/etc/puppetlabs/facter/facts.d"]
58
+ Facter::Util::Config.external_facts_dirs.should == ["/opt/puppetlabs/facter/facts.d", "/etc/facter/facts.d", "/etc/puppetlabs/facter/facts.d"]
59
59
  end
60
60
 
61
61
  it "should return the default value for windows 2008" do
@@ -72,10 +72,11 @@ describe Facter::Util::Config do
72
72
  Facter::Util::Config.external_facts_dirs.should == [File.join("C:\\Documents", 'PuppetLabs', 'facter', 'facts.d')]
73
73
  end
74
74
 
75
- it "returns the users home directory when not root" do
75
+ it "returns the old and new (AIO) paths under user's home directory when not root" do
76
76
  Facter::Util::Root.stubs(:root?).returns(false)
77
77
  Facter::Util::Config.setup_default_ext_facts_dirs
78
- Facter::Util::Config.external_facts_dirs.should == [File.expand_path(File.join("~", ".facter", "facts.d"))]
78
+ Facter::Util::Config.external_facts_dirs.should == [File.expand_path(File.join("~", ".puppetlabs", "opt", "facter", "facts.d")),
79
+ File.expand_path(File.join("~", ".facter", "facts.d"))]
79
80
  end
80
81
 
81
82
  it "includes additional values when user appends to the list" do
@@ -94,4 +95,26 @@ describe Facter::Util::Config do
94
95
  end
95
96
 
96
97
  end
98
+
99
+ describe "override_binary_dir" do
100
+ it "should return the default value for linux" do
101
+ Facter::Util::Config.stubs(:is_windows?).returns(false)
102
+ Facter::Util::Config.setup_default_override_binary_dir
103
+ Facter::Util::Config.override_binary_dir.should == "/opt/puppetlabs/puppet/bin"
104
+ end
105
+
106
+ it "should return nil for windows" do
107
+ Facter::Util::Config.stubs(:is_windows?).returns(true)
108
+ Facter::Util::Config.setup_default_override_binary_dir
109
+ Facter::Util::Config.override_binary_dir.should == nil
110
+ end
111
+
112
+ it "should output new values when explicitly set" do
113
+ Facter::Util::Config.setup_default_override_binary_dir
114
+ new_value = '/usr/share/newdir'
115
+ Facter::Util::Config.override_binary_dir = new_value
116
+ Facter::Util::Config.override_binary_dir.should == new_value
117
+ end
118
+ end
119
+
97
120
  end
@@ -19,6 +19,21 @@ describe Facter::Util::Operatingsystem do
19
19
  })
20
20
  end
21
21
 
22
+ it "correctly parses the file on CoreOS Linux" do
23
+ values = described_class.os_release(my_fixture('coreos.txt'))
24
+
25
+ expect(values).to eq({
26
+ 'NAME' => "CoreOS",
27
+ 'VERSION_ID' => "575.0.0",
28
+ 'VERSION' => "575.0.0",
29
+ 'PRETTY_NAME' => "CoreOS 575.0.0",
30
+ 'ID' => "coreos",
31
+ 'HOME_URL' => "https://coreos.com/",
32
+ 'BUG_REPORT_URL' => "https://github.com/coreos/bugs/issues",
33
+ 'ANSI_COLOR' => "1;32",
34
+ })
35
+ end
36
+
22
37
  it "correctly parses the file on Sabayon" do
23
38
  values = described_class.os_release(my_fixture('sabayon.txt'))
24
39
 
@@ -278,10 +278,15 @@ describe Facter::Util::Virtual do
278
278
  mockfile
279
279
  end
280
280
 
281
- shared_examples_for "virt-what" do |kernel, path, null_device|
281
+ shared_examples_for "virt-what" do |kernel, path, null_device, override_location|
282
282
  before(:each) do
283
283
  Facter.fact(:kernel).stubs(:value).returns(kernel)
284
- Facter::Core::Execution.expects(:which).with("virt-what").returns(path)
284
+ if override_location
285
+ Facter::Core::Execution.expects(:which).with(File.join(Facter::Util::Config.override_binary_dir, "virt-what")).returns(path)
286
+ else
287
+ Facter::Core::Execution.expects(:which).with(File.join(Facter::Util::Config.override_binary_dir, "virt-what")).returns(nil)
288
+ Facter::Core::Execution.expects(:which).with("virt-what").returns(path)
289
+ end
285
290
  Facter::Core::Execution.expects(:exec).with("#{path} 2>#{null_device}")
286
291
  end
287
292
 
@@ -291,23 +296,28 @@ describe Facter::Util::Virtual do
291
296
  end
292
297
 
293
298
  context "on linux" do
294
- it_should_behave_like "virt-what", "linux", "/usr/bin/virt-what", "/dev/null"
295
-
296
- it "should strip out warnings on stdout from virt-what" do
297
- virt_what_warning = "virt-what: this script must be run as root"
298
- Facter.fact(:kernel).stubs(:value).returns('linux')
299
- Facter::Core::Execution.expects(:which).with('virt-what').returns "/usr/bin/virt-what"
300
- Facter::Core::Execution.expects(:exec).with('/usr/bin/virt-what 2>/dev/null').returns virt_what_warning
301
- Facter::Util::Virtual.virt_what.should_not match /^virt-what: /
299
+ describe "override binary dir doesn't exist" do
300
+ it_should_behave_like "virt-what", "linux", "/usr/bin/virt-what", "/dev/null", true
301
+ it_should_behave_like "virt-what", "linux", "/usr/bin/virt-what", "/dev/null", false
302
+
303
+ it "should strip out warnings on stdout from virt-what" do
304
+ virt_what_warning = "virt-what: this script must be run as root"
305
+ Facter.fact(:kernel).stubs(:value).returns('linux')
306
+ Facter::Core::Execution.expects(:which).with(File.join(Facter::Util::Config.override_binary_dir, "virt-what")).returns(nil)
307
+ Facter::Core::Execution.expects(:which).with('virt-what').returns "/usr/bin/virt-what"
308
+ Facter::Core::Execution.expects(:exec).with('/usr/bin/virt-what 2>/dev/null').returns virt_what_warning
309
+ Facter::Util::Virtual.virt_what.should_not match /^virt-what: /
310
+ end
302
311
  end
303
312
  end
304
313
 
305
314
  context "on unix" do
306
- it_should_behave_like "virt-what", "unix", "/usr/bin/virt-what", "/dev/null"
315
+ it_should_behave_like "virt-what", "unix", "/usr/bin/virt-what", "/dev/null", true
316
+ it_should_behave_like "virt-what", "unix", "/usr/bin/virt-what", "/dev/null", false
307
317
  end
308
318
 
309
319
  context "on windows" do
310
- it_should_behave_like "virt-what", "windows", 'c:\windows\system32\virt-what', "NUL"
320
+ it_should_behave_like "virt-what", "windows", 'c:\windows\system32\virt-what', "NUL", false
311
321
  end
312
322
 
313
323
  describe '.lxc?' do
@@ -7,60 +7,108 @@ describe Facter::Util::Xendomains do
7
7
 
8
8
  let(:xen0_domains) { my_fixture_read("xendomains") }
9
9
 
10
- describe "when the xl command is present" do
10
+ describe "when the xen-toolstack command is present" do
11
11
  before do
12
- Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xl').returns('/usr/sbin/xl')
12
+ File.expects(:file?).with('/usr/lib/xen-common/bin/xen-toolstack').returns true
13
13
  end
14
14
 
15
- describe "and the xm command is not present" do
16
-
15
+ describe "and the xen-toolstack returns xl" do
17
16
  before do
18
- Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xm').returns(nil)
19
- Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xm list 2>/dev/null').never
17
+ Facter::Util::Resolution.stubs(:exec).with('/usr/lib/xen-common/bin/xen-toolstack').returns('/usr/sbin/xl')
20
18
  end
21
19
 
22
20
  it "lists the domains running on Xen0 with the 'xl' command" do
23
21
  Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xl list 2>/dev/null').returns(xen0_domains)
24
22
  Facter::Util::Xendomains.get_domains.should == %{web01,mailserver}
25
23
  end
24
+
26
25
  end
27
26
 
28
- describe "and the xm command is also present" do
27
+ describe "and the xen-toolstack returns xm" do
29
28
  before do
30
- Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xm').returns('/usr/bin/xm')
31
- Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xm list 2>/dev/null').never
29
+ Facter::Util::Resolution.stubs(:exec).with('/usr/lib/xen-common/bin/xen-toolstack').returns('/usr/sbin/xm')
32
30
  end
33
31
 
34
- it "prefers xl over xm" do
35
- Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xl list 2>/dev/null').returns(xen0_domains)
32
+ it "lists the domains running on Xen0 with the 'xm' command" do
33
+ Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xm list 2>/dev/null').returns(xen0_domains)
36
34
  Facter::Util::Xendomains.get_domains.should == %{web01,mailserver}
37
35
  end
36
+
38
37
  end
38
+
39
+ describe "and the xen-toolstack returns nil" do
40
+ before do
41
+ Facter::Util::Resolution.stubs(:exec).with('/usr/lib/xen-common/bin/xen-toolstack').returns(nil)
42
+ end
43
+
44
+ it "returns nil" do
45
+ Facter::Util::Xendomains.get_domains.should == nil
46
+ end
47
+
48
+ end
49
+
39
50
  end
40
51
 
41
- describe "when xl is not present" do
52
+ describe "when the xen-toolstack command is not present" do
42
53
  before do
43
- Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xl').returns(nil)
44
- Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xl list 2>/dev/null').never
54
+ File.expects(:file?).with('/usr/lib/xen-common/bin/xen-toolstack').returns false
45
55
  end
46
56
 
47
- describe "and the xm command is present" do
57
+ describe "and the xl command is present" do
48
58
  before do
49
- Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xm').returns('/usr/sbin/xm')
59
+ Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xl').returns('/usr/sbin/xl')
50
60
  end
51
61
 
52
- it "lists the domains running on Xen0 with the 'xm' command" do
53
- Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xm list 2>/dev/null').returns(xen0_domains)
54
- Facter::Util::Xendomains.get_domains.should == %{web01,mailserver}
62
+ describe "and the xm command is not present" do
63
+
64
+ before do
65
+ Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xm').returns(nil)
66
+ Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xm list 2>/dev/null').never
67
+ end
68
+
69
+ it "lists the domains running on Xen0 with the 'xl' command" do
70
+ Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xl list 2>/dev/null').returns(xen0_domains)
71
+ Facter::Util::Xendomains.get_domains.should == %{web01,mailserver}
72
+ end
73
+ end
74
+
75
+ describe "and the xm command is also present" do
76
+ before do
77
+ Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xm').returns('/usr/bin/xm')
78
+ Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xm list 2>/dev/null').never
79
+ end
80
+
81
+ it "prefers xl over xm" do
82
+ Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xl list 2>/dev/null').returns(xen0_domains)
83
+ Facter::Util::Xendomains.get_domains.should == %{web01,mailserver}
84
+ end
85
+ end
86
+ end
87
+
88
+ describe "when xl is not present" do
89
+ before do
90
+ Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xl').returns(nil)
91
+ Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xl list 2>/dev/null').never
92
+ end
93
+
94
+ describe "and the xm command is present" do
95
+ before do
96
+ Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xm').returns('/usr/sbin/xm')
97
+ end
98
+
99
+ it "lists the domains running on Xen0 with the 'xm' command" do
100
+ Facter::Util::Resolution.expects(:exec).with('/usr/sbin/xm list 2>/dev/null').returns(xen0_domains)
101
+ Facter::Util::Xendomains.get_domains.should == %{web01,mailserver}
102
+ end
55
103
  end
56
104
  end
57
- end
58
105
 
59
- describe "neither xl or xm are present" do
60
- it "returns nil" do
61
- Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xl').returns(nil)
62
- Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xm').returns(nil)
63
- Facter::Util::Xendomains.get_domains.should == nil
106
+ describe "neither xl or xm are present" do
107
+ it "returns nil" do
108
+ Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xl').returns(nil)
109
+ Facter::Util::Resolution.stubs(:which).with('/usr/sbin/xm').returns(nil)
110
+ Facter::Util::Xendomains.get_domains.should == nil
111
+ end
64
112
  end
65
113
  end
66
114
  end