+1 On Aug 11, 2009, at 3:59 PM, Paul Nasrat wrote:
> > Solaris orders inet and inet6 seperately. This tests for and fixes > this by > uniqueing the list. Will probably need work when we get to ipv6 > support. > > Signed-off-by: Paul Nasrat <[email protected]> > --- > lib/facter/util/ip.rb | 2 +- > .../solaris_ifconfig_all_with_multiple_interfaces | 8 ++++++++ > spec/unit/util/ip.rb | 7 +++++++ > 3 files changed, 16 insertions(+), 1 deletions(-) > create mode 100644 spec/unit/data/ > solaris_ifconfig_all_with_multiple_interfaces > > diff --git a/lib/facter/util/ip.rb b/lib/facter/util/ip.rb > index fb32d70..9fb7034 100644 > --- a/lib/facter/util/ip.rb > +++ b/lib/facter/util/ip.rb > @@ -51,7 +51,7 @@ module Facter::Util::IP > # at the end of interfaces. So, we have to trim those > trailing > # characters. I tried making the regex better but > supporting all > # platforms with a single regex is probably a bit too much. > - output.scan(/^\w+[.:]?\d+[.:]?\d*[.:]?\w*/).collect { |i| > i.sub(/:$/, '') } > + output.scan(/^\w+[.:]?\d+[.:]?\d*[.:]?\w*/).collect { |i| > i.sub(/:$/, '') }.uniq > end > > def self.get_all_interface_output > diff --git a/spec/unit/data/ > solaris_ifconfig_all_with_multiple_interfaces b/spec/unit/data/ > solaris_ifconfig_all_with_multiple_interfaces > new file mode 100644 > index 0000000..f04ad5d > --- /dev/null > +++ b/spec/unit/data/solaris_ifconfig_all_with_multiple_interfaces > @@ -0,0 +1,8 @@ > +lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> > mtu 8232 index 1 > + inet 127.0.0.1 netmask ff000000 > +e1000g0: > flags=201004843<UP,BROADCAST,RUNNING,MULTICAST,DHCP,IPv4,CoS> mtu > 1500 index 2 > + inet 192.168.162.130 netmask ffffff00 broadcast 192.168.162.255 > +lo0: flags=2002000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv6,VIRTUAL> > mtu 8252 index 1 > + inet6 ::1/128 > +e1000g0: flags=202004841<UP,RUNNING,MULTICAST,DHCP,IPv6,CoS> mtu > 1500 index 2 > + inet6 fe80::20c:29ff:fe09:627e/10 > diff --git a/spec/unit/util/ip.rb b/spec/unit/util/ip.rb > index 512c07b..60ec09e 100644 > --- a/spec/unit/util/ip.rb > +++ b/spec/unit/util/ip.rb > @@ -34,6 +34,13 @@ describe Facter::Util::IP do > Facter::Util::IP.get_interfaces().should == ["lo0", "en0"] > end > > + it "should return a list two interfaces on Solaris with two > interfaces multiply reporting" do > + sample_output_file = File.dirname(__FILE__) + '/../data/ > solaris_ifconfig_all_with_multiple_interfaces' > + solaris_ifconfig = File.new(sample_output_file).read() > + > Facter > ::Util::IP.stubs(:get_all_interface_output).returns(solaris_ifconfig) > + Facter::Util::IP.get_interfaces().should == ["lo0", > "e1000g0"] > + end > + > it "should return a value for a specific interface" do > Facter::Util::IP.should respond_to(:get_interface_value) > end > -- > 1.6.1.3 > > > > -- The remarkable thing about Shakespeare is that he really is very good, in spite of all the people who say he is very good. -- Robert Graves --------------------------------------------------------------------- Luke Kanies | http://reductivelabs.com | http://madstop.com --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
