On 12 June 2010 00:54, James Turnbull <[email protected]> wrote:
>
> Signed-off-by: James Turnbull <[email protected]>
> ---
>  lib/facter/util/ip.rb                         |   17 +++++++-
>  spec/unit/data/hpux_ifconfig_single_interface |    2 +
>  spec/unit/data/hpux_netstat_all_interfaces    |    6 +++
>  spec/unit/util/ip.rb                          |   51 
> ++++++++++++++++++++++++-
>  4 files changed, 72 insertions(+), 4 deletions(-)
>  create mode 100644 spec/unit/data/hpux_ifconfig_single_interface
>  create mode 100644 spec/unit/data/hpux_netstat_all_interfaces
>
> diff --git a/lib/facter/util/ip.rb b/lib/facter/util/ip.rb
> index 25acf3a..d889d99 100644
> --- a/lib/facter/util/ip.rb
> +++ b/lib/facter/util/ip.rb
> @@ -16,9 +16,14 @@ module Facter::Util::IP
>             :netmask    => /netmask\s+0x(\w{8})/
>         },
>         :sunos => {
> -            :ipaddress => /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/,
> +            :ipaddress  => /inet\s+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/,
>             :macaddress => 
> /(?:ether|lladdr)\s+(\w?\w:\w?\w:\w?\w:\w?\w:\w?\w:\w?\w)/,
>             :netmask    => /netmask\s+(\w{8})/
> +        },
> +        :"hp-ux" => {
> +            :ipaddress  => /\s+inet (\S+)\s.*/,
> +            :macaddress => /(?:[0-9a-f]{2}[:-]){5}[0-9a-f]{2}/,
> +            :netmask    => /.*\s+netmask (\S+)\s.*/
>         }
>     }
>
> @@ -28,7 +33,7 @@ module Facter::Util::IP
>     end
>
>     def self.convert_from_hex?(kernel)
> -        kernels_to_convert = [:sunos, :openbsd, :netbsd, :freebsd, :darwin]
> +        kernels_to_convert = [:sunos, :openbsd, :netbsd, :freebsd, :darwin, 
> :"hp-ux"]
>         kernels_to_convert.include?(kernel)
>     end
>
> @@ -60,6 +65,8 @@ module Facter::Util::IP
>             output = %x{/sbin/ifconfig -a}
>         when 'SunOS'
>             output = %x{/usr/sbin/ifconfig -a}
> +        when 'HP-UX'
> +            output = %x{/bin/netstat -i}
>         end
>         output
>     end
> @@ -71,6 +78,12 @@ module Facter::Util::IP
>             output = %x{/sbin/ifconfig #{interface}}
>         when 'SunOS'
>             output = %x{/usr/sbin/ifconfig #{interface}}
> +        when 'HP-UX'
> +           mac = ""
> +           ifc = %x{/usr/sbin/ifconfig #{interface}}
> +           %x{/usr/sbin/lanscan}.scan(/(\dx\S+).*UP\s+(\w+\d+)/).each {|i| 
> mac = i[0] if i.include?(interface) }

Could you also include sample output and a test for the lanscan
parsing. Looking over the patch there doesn't seem to be one.

Paul

-- 
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.

Reply via email to