Please review pull request #170: Make ec2 facts work on CentOS again opened by (katzj)
Description:
Refactoring the ec2 facts lost the support for CentOS where the
hardware address in arp -an is uppercased. Fix and add a unit
test now that there are those
(Originally fixed with https://github.com/puppetlabs/facter/pull/7 but has regressed now)
- Opened: Wed Feb 15 14:26:50 UTC 2012
- Based on: puppetlabs:master (6a59c77117d8acee595565764554dad2796eea36)
- Requested merge: katzj:downcase-arp-again (b842c77bf6957c318d1a74c70f584f56751ff43c)
Diff follows:
diff --git a/lib/facter/util/ec2.rb b/lib/facter/util/ec2.rb
index bcfda60..d42254a 100644
--- a/lib/facter/util/ec2.rb
+++ b/lib/facter/util/ec2.rb
@@ -46,7 +46,7 @@ def has_ec2_arp?
arp_table = Facter::Util::Resolution.exec(arp_command)
if not arp_table.nil?
arp_table.each_line do |line|
- return true if line.include?(mac_address)
+ return true if line.downcase.include?(mac_address)
end
end
return false
diff --git a/spec/fixtures/unit/util/ec2/centos-arp-ec2.out b/spec/fixtures/unit/util/ec2/centos-arp-ec2.out
new file mode 100644
index 0000000..24d2ec0
--- /dev/null
+++ b/spec/fixtures/unit/util/ec2/centos-arp-ec2.out
@@ -0,0 +1 @@
+? (10.240.93.1) at FE:FF:FF:FF:FF:FF [ether] on eth0
\ No newline at end of file
diff --git a/spec/unit/util/ec2_spec.rb b/spec/unit/util/ec2_spec.rb
index 62fdcb7..f1fbe3c 100755
--- a/spec/unit/util/ec2_spec.rb
+++ b/spec/unit/util/ec2_spec.rb
@@ -22,6 +22,13 @@
Facter::Util::EC2.has_ec2_arp?.should == true
end
+ it "should succeed if arp table contains FE:FF:FF:FF:FF:FF" do
+ ec2arp = my_fixture_read("centos-arp-ec2.out")
+ Facter::Util::Resolution.expects(:exec).with("arp -an").\
+ at_least_once.returns(ec2arp)
+ Facter::Util::EC2.has_ec2_arp?.should == true
+ end
+
it "should fail if arp table does not contain fe:ff:ff:ff:ff:ff" do
ec2arp = my_fixture_read("linux-arp-not-ec2.out")
Facter::Util::Resolution.expects(:exec).with("arp -an").
-- You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
