network.rb

Path: lib/ohai/plugins/darwin/network.rb
Last Update: Thu Jan 17 19:03:16 +0000 2013
dot/f_0.png
Author:Benjamin Black (<bb@opscode.com>)
Copyright:Copyright (c) 2008 Opscode, Inc.
License:Apache License, Version 2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Required files

scanf  

Methods

Public Instance methods

[Source]

    # File lib/ohai/plugins/darwin/network.rb, line 64
64: def encaps_lookup(ifname)
65:   return "Loopback" if ifname.eql?("lo")
66:   return "1394" if ifname.eql?("fw")
67:   return "IPIP" if ifname.eql?("gif")
68:   return "6to4" if ifname.eql?("stf")
69:   return "dot1q" if ifname.eql?("vlan")
70:   "Unknown"
71: end

[Source]

    # File lib/ohai/plugins/darwin/network.rb, line 80
80: def excluded_setting?(setting)
81:   setting.match('_sw_cksum')
82: end

[Source]

    # File lib/ohai/plugins/darwin/network.rb, line 84
84: def locate_interface(ifaces, ifname, mac)
85:   return ifname unless ifaces[ifname].nil?
86:   # oh well, time to go hunting!
87:   return ifname.chop if ifname.match /\*$/
88:   ifaces.keys.each do |ifc|
89:     ifaces[ifc][:addresses].keys.each do |addr|
90:       return ifc if addr.eql? mac
91:     end
92:   end
93:   
94:   nil
95: end

[Source]

    # File lib/ohai/plugins/darwin/network.rb, line 34
34: def parse_media(media_string)
35:   media = Hash.new
36:   line_array = media_string.split(' ')
37: 
38:   0.upto(line_array.length - 1) do |i|
39:     unless line_array[i].eql?("none")
40: 
41:       if line_array[i + 1] =~ /^\<([a-zA-Z\-\,]+)\>$/
42:         media[line_array[i]] = Hash.new unless media.has_key?(line_array[i])
43:         if media[line_array[i]].has_key?("options")
44:           $1.split(",").each do |opt|
45:             media[line_array[i]]["options"] << opt unless media[line_array[i]]["options"].include?(opt)
46:           end
47:         else
48:           media[line_array[i]]["options"] = $1.split(",") 
49:         end
50:       else
51:         if line_array[i].eql?("autoselect")
52:           media["autoselect"] = Hash.new unless media.has_key?("autoselect")
53:           media["autoselect"]["options"] = []
54:         end
55:       end
56:     else
57:       media["none"] = { "options" => [] }
58:     end
59:   end
60: 
61:   media
62: end

[Source]

    # File lib/ohai/plugins/darwin/network.rb, line 73
73: def scope_lookup(scope)
74:   return "Node" if scope.eql?("::1")
75:   return "Link" if scope.match(/^fe80\:/)
76:   return "Site" if scope.match(/^fec0\:/)
77:   "Global"
78: end

[Validate]