[Pkg-puppet-devel] [facter] 111/180: (fact-233) Pass '-f all' to nmcli to ensure the dhcp_server field is available
Stig Sandbeck Mathisen
ssm at debian.org
Mon Jun 30 15:06:37 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 8bbad973b37335b78d8ac317098440ffa9c9dce6
Author: Kylo Ginsberg <kylo at puppetlabs.com>
Date: Wed May 28 12:02:58 2014 -0700
(fact-233) Pass '-f all' to nmcli to ensure the dhcp_server field is available
Prior to this change 'nmcli d' was invoked without specifying which
fields were needed. This happened to work on fedora 19 and fedora 20,
but doesn't work on redhat 7, which defaults to return a restricted
set of fields for devices.
This patch specifies '-f all' to nmcli so that all fields are returned.
I've tested this change on all 3 of the above distros. It works on all 3
and doesn't seem notably slower (I had some concern that maybe this would
cause a slowdown, so wanted to check that out.)
---
lib/facter/util/dhcp_servers.rb | 4 ++--
spec/unit/dhcp_servers_spec.rb | 32 ++++++++++++++++----------------
2 files changed, 18 insertions(+), 18 deletions(-)
diff --git a/lib/facter/util/dhcp_servers.rb b/lib/facter/util/dhcp_servers.rb
index e05b7d1..8fc0ffc 100644
--- a/lib/facter/util/dhcp_servers.rb
+++ b/lib/facter/util/dhcp_servers.rb
@@ -14,9 +14,9 @@ module Facter::Util::DHCPServers
def self.device_dhcp_server(device)
if Facter::Core::Execution.which('nmcli')
if self.nmcli_version and self.nmcli_version >= 990
- Facter::Core::Execution.exec("nmcli d show #{device}").scan(/dhcp_server_identifier.*?(\d+\.\d+\.\d+\.\d+)$/).flatten.first
+ Facter::Core::Execution.exec("nmcli -f all d show #{device}").scan(/dhcp_server_identifier.*?(\d+\.\d+\.\d+\.\d+)$/).flatten.first
else
- Facter::Core::Execution.exec("nmcli d list iface #{device}").scan(/dhcp_server_identifier.*?(\d+\.\d+\.\d+\.\d+)$/).flatten.first
+ Facter::Core::Execution.exec("nmcli -f all d list iface #{device}").scan(/dhcp_server_identifier.*?(\d+\.\d+\.\d+\.\d+)$/).flatten.first
end
end
end
diff --git a/spec/unit/dhcp_servers_spec.rb b/spec/unit/dhcp_servers_spec.rb
index 344e579..3e99685 100644
--- a/spec/unit/dhcp_servers_spec.rb
+++ b/spec/unit/dhcp_servers_spec.rb
@@ -16,8 +16,8 @@ describe "DHCP server facts" do
describe "with a main interface configured with DHCP" do
before :each do
Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices"))
- Facter::Core::Execution.stubs(:exec).with("nmcli d list iface eth0").returns(my_fixture_read("nmcli_eth0_dhcp"))
- Facter::Core::Execution.stubs(:exec).with("nmcli d list iface wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp"))
+ Facter::Core::Execution.stubs(:exec).with("nmcli -f all d list iface eth0").returns(my_fixture_read("nmcli_eth0_dhcp"))
+ Facter::Core::Execution.stubs(:exec).with("nmcli -f all d list iface wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp"))
end
it "should produce a dhcp_servers fact that includes values for 'system' as well as each dhcp enabled interface" do
@@ -28,8 +28,8 @@ describe "DHCP server facts" do
describe "with a main interface NOT configured with DHCP" do
before :each do
Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices"))
- Facter::Core::Execution.stubs(:exec).with("nmcli d list iface eth0").returns(my_fixture_read("nmcli_eth0_static"))
- Facter::Core::Execution.stubs(:exec).with("nmcli d list iface wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp"))
+ Facter::Core::Execution.stubs(:exec).with("nmcli -f all d list iface eth0").returns(my_fixture_read("nmcli_eth0_static"))
+ Facter::Core::Execution.stubs(:exec).with("nmcli -f all d list iface wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp"))
end
it "should a dhcp_servers fact that includes values for each dhcp enables interface and NO 'system' value" do
@@ -41,8 +41,8 @@ describe "DHCP server facts" do
before :each do
Facter::Core::Execution.stubs(:exec).with("route -n").returns(my_fixture_read("route_nogw"))
Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices"))
- Facter::Core::Execution.stubs(:exec).with("nmcli d list iface eth0").returns(my_fixture_read("nmcli_eth0_dhcp"))
- Facter::Core::Execution.stubs(:exec).with("nmcli d list iface wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp"))
+ Facter::Core::Execution.stubs(:exec).with("nmcli -f all d list iface eth0").returns(my_fixture_read("nmcli_eth0_dhcp"))
+ Facter::Core::Execution.stubs(:exec).with("nmcli -f all d list iface wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp"))
end
it "should a dhcp_servers fact that includes values for each dhcp enables interface and NO 'system' value" do
@@ -53,8 +53,8 @@ describe "DHCP server facts" do
describe "with no DHCP enabled interfaces" do
before :each do
Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices"))
- Facter::Core::Execution.stubs(:exec).with("nmcli d list iface eth0").returns(my_fixture_read("nmcli_eth0_static"))
- Facter::Core::Execution.stubs(:exec).with("nmcli d list iface wlan0").returns(my_fixture_read("nmcli_wlan0_static"))
+ Facter::Core::Execution.stubs(:exec).with("nmcli -f all d list iface eth0").returns(my_fixture_read("nmcli_eth0_static"))
+ Facter::Core::Execution.stubs(:exec).with("nmcli -f all d list iface wlan0").returns(my_fixture_read("nmcli_wlan0_static"))
end
it "should not produce a dhcp_servers fact" do
@@ -82,8 +82,8 @@ describe "DHCP server facts" do
describe "with a main interface configured with DHCP" do
before :each do
Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices"))
- Facter::Core::Execution.stubs(:exec).with("nmcli d show eth0").returns(my_fixture_read("nmcli_eth0_dhcp"))
- Facter::Core::Execution.stubs(:exec).with("nmcli d show wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp"))
+ Facter::Core::Execution.stubs(:exec).with("nmcli -f all d show eth0").returns(my_fixture_read("nmcli_eth0_dhcp"))
+ Facter::Core::Execution.stubs(:exec).with("nmcli -f all d show wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp"))
end
it "should produce a dhcp_servers fact that includes values for 'system' as well as each dhcp enabled interface" do
@@ -94,8 +94,8 @@ describe "DHCP server facts" do
describe "with a main interface NOT configured with DHCP" do
before :each do
Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices"))
- Facter::Core::Execution.stubs(:exec).with("nmcli d show eth0").returns(my_fixture_read("nmcli_eth0_static"))
- Facter::Core::Execution.stubs(:exec).with("nmcli d show wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp"))
+ Facter::Core::Execution.stubs(:exec).with("nmcli -f all d show eth0").returns(my_fixture_read("nmcli_eth0_static"))
+ Facter::Core::Execution.stubs(:exec).with("nmcli -f all d show wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp"))
end
it "should a dhcp_servers fact that includes values for each dhcp enables interface and NO 'system' value" do
@@ -107,8 +107,8 @@ describe "DHCP server facts" do
before :each do
Facter::Core::Execution.stubs(:exec).with("route -n").returns(my_fixture_read("route_nogw"))
Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices"))
- Facter::Core::Execution.stubs(:exec).with("nmcli d show eth0").returns(my_fixture_read("nmcli_eth0_dhcp"))
- Facter::Core::Execution.stubs(:exec).with("nmcli d show wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp"))
+ Facter::Core::Execution.stubs(:exec).with("nmcli -f all d show eth0").returns(my_fixture_read("nmcli_eth0_dhcp"))
+ Facter::Core::Execution.stubs(:exec).with("nmcli -f all d show wlan0").returns(my_fixture_read("nmcli_wlan0_dhcp"))
end
it "should a dhcp_servers fact that includes values for each dhcp enables interface and NO 'system' value" do
@@ -119,8 +119,8 @@ describe "DHCP server facts" do
describe "with no DHCP enabled interfaces" do
before :each do
Facter::Core::Execution.stubs(:exec).with("nmcli d").returns(my_fixture_read("nmcli_devices"))
- Facter::Core::Execution.stubs(:exec).with("nmcli d show eth0").returns(my_fixture_read("nmcli_eth0_static"))
- Facter::Core::Execution.stubs(:exec).with("nmcli d show wlan0").returns(my_fixture_read("nmcli_wlan0_static"))
+ Facter::Core::Execution.stubs(:exec).with("nmcli -f all d show eth0").returns(my_fixture_read("nmcli_eth0_static"))
+ Facter::Core::Execution.stubs(:exec).with("nmcli -f all d show wlan0").returns(my_fixture_read("nmcli_wlan0_static"))
end
it "should not produce a dhcp_servers fact" do
--
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