FreeBSD Bugzilla – Attachment 144728 Details for
Bug 190796
Patch for sysutils/rubygem-facter to add interface alias support
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Enhanced freebsd aliases for facter
rubygem_facter_netaliases_enhanced.diff (text/plain), 4.13 KB, created by
Daniel Siechniewicz
on 2014-07-16 15:24:53 UTC
(
hide
)
Description:
Enhanced freebsd aliases for facter
Filename:
MIME Type:
Creator:
Daniel Siechniewicz
Created:
2014-07-16 15:24:53 UTC
Size:
4.13 KB
patch
obsolete
>diff -ruN rubygem-facter.orig/files/patch-lib__facter__interfaces.rb rubygem-facter/files/patch-lib__facter__interfaces.rb >--- rubygem-facter.orig/files/patch-lib__facter__interfaces.rb 1970-01-01 00:00:00.000000000 +0000 >+++ rubygem-facter/files/patch-lib__facter__interfaces.rb 2014-07-16 14:40:28.208690833 +0000 >@@ -0,0 +1,20 @@ >+--- lib/facter/interfaces.rb.orig 2014-06-08 11:05:48.000000000 -0500 >++++ lib/facter/interfaces.rb 2014-06-08 11:06:21.000000000 -0500 >+@@ -39,3 +39,17 @@ >+ end >+ end >+ end >++ >++# Get the firs 10 aliases on *BSD - however there could be more, just don't support them >++# as it pushes up execution time >++Facter::Util::IP.get_interfaces.each do |interface| >++ %w{ipaddress ipaddress6 netmask}.each do |label| >++ (0..Facter::Util::IP.get_alias_no(interface, label)).each do |a| >++ Facter.add(label + "_" + Facter::Util::IP.alphafy(interface) + "_alias#{a}") do >++ setcode do >++ Facter::Util::IP.get_interface_value(interface, label, a) >++ end >++ end >++ end >++ end >++end >diff -ruN rubygem-facter.orig/files/patch-lib__facter__util__ip.rb rubygem-facter/files/patch-lib__facter__util__ip.rb >--- rubygem-facter.orig/files/patch-lib__facter__util__ip.rb 1970-01-01 00:00:00.000000000 +0000 >+++ rubygem-facter/files/patch-lib__facter__util__ip.rb 2014-07-16 14:41:04.385773996 +0000 >@@ -0,0 +1,85 @@ >+--- lib/facter/util/ip.rb.orig 2014-07-16 14:14:07.291250019 +0000 >++++ lib/facter/util/ip.rb 2014-07-16 14:30:20.549088658 +0000 >+@@ -206,11 +206,13 @@ >+ # @param label [String] the attribute of the interface to obtain a value for, >+ # e.g. "netmask" or "ipaddress" >+ # >++ # @param intalias [Integer] the alias number to obtain a value for >++ # >+ # @api private >+ # >+ # @return [String] representing the requested value. An empty array is >+ # returned if the kernel is not supported by the REGEX_MAP constant. >+- def self.get_interface_value(interface, label) >++ def self.get_interface_value(interface, label, intalias = -1) >+ if Facter.value(:kernel) == 'windows' >+ require 'facter/util/ip/windows' >+ return Facter::Util::IP::Windows.value_for_interface_and_label(interface, label) >+@@ -252,12 +254,66 @@ >+ end >+ >+ if tmp1 >+- value = tmp1.shift >++ (-1..intalias).each do |i| >++ value = tmp1.shift >++ end >++ value >+ end >+ end >+ end >+ >+ ## >++ # get_alias_no obtains alias count for a specified interface and label >++ # >++ # @param interface [String] the interface identifier, e.g. "eth0" or "bond0" >++ # >++ # @param label [String] the attribute of the interface to obtain a value for, >++ # e.g. "netmask" or "ipaddress" (note eg. ipaddress and ipaddress6 can have different >++ # number of aliases, so label does make sense here) >++ # >++ # @api private >++ # >++ # @return [Integer] representing the requested value. 0 is returned if the >++ # kernel is not supported by the REGEX_MAP constant and on Windows. >++ def self.get_alias_no(interface, label) >++ if Facter.value(:kernel) == 'windows' >++ # No handling of aliases in util/ip/windows as yet >++ return 0 >++ end >++ >++ tmp1 = [] >++ >++ kernel = Facter.value(:kernel).downcase.to_sym >++ >++ # If it's not directly in the map or aliased in the map, then we don't know how to deal with it. >++ unless map = REGEX_MAP[kernel] || REGEX_MAP.values.find { |tmp| tmp[:aliases] and tmp[:aliases].include?(kernel) } >++ return 0 >++ end >++ >++ # Pull the correct regex out of the map. >++ regex = map[label.to_sym] >++ >++ output_int = get_output_for_interface_and_label(interface, label) >++ >++ output_int.each_line do |s| >++ if s =~ regex >++ value = $1 >++ if label == 'netmask' && convert_from_hex?(kernel) >++ value = value.scan(/../).collect do |byte| byte.to_i(16) end.join('.') >++ end >++ tmp1.push(value) >++ end >++ end >++ >++ if tmp1 >++ value = tmp1.length >++ else >++ value = 0 >++ end >++ value >++ end >++ >++ ## >+ # read_proc_net_bonding is a seam method for mocking purposes. >+ # >+ # @param path [String] representing the path to read, e.g. "/proc/net/bonding/bond0"
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 190796
:
143533
| 144728