[Pkg-puppet-devel] [facter] 323/352: (maint) Return nil on zoneadm command fail
Stig Sandbeck Mathisen
ssm at debian.org
Sun Apr 6 22:21:57 UTC 2014
This is an automated email from the git hooks/post-receive script.
ssm pushed a commit to branch master
in repository facter.
commit f8365356d6f339f878643190ddc269e371d7a9b7
Author: Adrien Thebo <git at somethingsinistral.net>
Date: Mon Mar 10 17:20:14 2014 -0700
(maint) Return nil on zoneadm command fail
---
lib/facter/util/solaris_zones.rb | 8 ++++----
spec/unit/util/solaris_zones_spec.rb | 4 ++--
spec/unit/zones_spec.rb | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/lib/facter/util/solaris_zones.rb b/lib/facter/util/solaris_zones.rb
index e6b287d..e0c4d5e 100644
--- a/lib/facter/util/solaris_zones.rb
+++ b/lib/facter/util/solaris_zones.rb
@@ -93,7 +93,7 @@ module Util
#
# @return [Hash] the parsed output of the zoneadm command
def refresh
- @zoneadm_output = Facter::Core::Execution.exec(zoneadm_cmd)
+ @zoneadm_output = Facter::Core::Execution.exec(zoneadm_cmd, {:on_fail => nil})
parse!
end
@@ -103,11 +103,11 @@ module Util
#
# @api private
def parse!
- if @zoneadm_output.empty?
+ if @zoneadm_output
+ rows = @zoneadm_output.split("\n").collect { |line| line.split(':') }
+ else
Facter.debug "Cannot parse zone facts, #{zoneadm_cmd} returned no output"
rows = []
- else
- rows = @zoneadm_output.split("\n").collect { |line| line.split(':') }
end
@zone_hash = rows.inject({}) do |memo, fields|
diff --git a/spec/unit/util/solaris_zones_spec.rb b/spec/unit/util/solaris_zones_spec.rb
index c7d4a05..c444c8e 100644
--- a/spec/unit/util/solaris_zones_spec.rb
+++ b/spec/unit/util/solaris_zones_spec.rb
@@ -47,7 +47,7 @@ describe Facter::Util::SolarisZones do
describe '#refresh' do
it 'executes the zoneadm_cmd' do
- Facter::Core::Execution.expects(:exec).with(subject.zoneadm_cmd).returns(zone_list)
+ Facter::Core::Execution.expects(:exec).with(subject.zoneadm_cmd, {:on_fail => nil}).returns(zone_list)
subject.refresh
end
end
@@ -112,7 +112,7 @@ describe Facter::Util::SolarisZones do
def given_initial_zone_facts
Facter::Core::Execution.stubs(:exec).
- with(subject.zoneadm_cmd).
+ with(subject.zoneadm_cmd, {:on_fail => nil}).
returns(zone_list)
described_class.add_facts
end
diff --git a/spec/unit/zones_spec.rb b/spec/unit/zones_spec.rb
index 55e3d14..11563f4 100644
--- a/spec/unit/zones_spec.rb
+++ b/spec/unit/zones_spec.rb
@@ -10,7 +10,7 @@ describe "on Solaris" do
-:local:configured:/::native:shared
-:zoneA:stopped:/::native:shared
EOF
- Facter::Core::Execution.stubs(:exec).with('/usr/sbin/zoneadm list -cp').returns(zone_list)
+ Facter::Core::Execution.stubs(:exec).with('/usr/sbin/zoneadm list -cp', {:on_fail => nil}).returns(zone_list)
Facter.collection.internal_loader.load(:zones)
end
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git
More information about the Pkg-puppet-devel
mailing list