Path: | lib/ohai/plugins/darwin/network.rb |
Last Update: | Mon Jul 13 14:39:49 +0000 2009 |
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.
# File lib/ohai/plugins/darwin/network.rb, line 55 55: def encaps_lookup(ifname) 56: return "Loopback" if ifname.eql?("lo") 57: return "1394" if ifname.eql?("fw") 58: return "IPIP" if ifname.eql?("gif") 59: return "6to4" if ifname.eql?("stf") 60: return "dot1q" if ifname.eql?("vlan") 61: "Unknown" 62: end
# File lib/ohai/plugins/darwin/network.rb, line 70 70: def excluded_setting?(setting) 71: setting.match('_sw_cksum') 72: end
# File lib/ohai/plugins/darwin/network.rb, line 74 74: def locate_interface(ifaces, ifname, mac) 75: return ifname unless ifaces[ifname].nil? 76: # oh well, time to go hunting! 77: return ifname.chop if ifname.match /\*$/ 78: ifaces.keys.each do |ifc| 79: ifaces[ifc][:addresses].keys.each do |addr| 80: return ifc if addr.eql? mac 81: end 82: end 83: 84: nil 85: end
# File lib/ohai/plugins/darwin/network.rb, line 25 25: def parse_media(media_string) 26: media = Hash.new 27: line_array = media_string.split(' ') 28: 29: 0.upto(line_array.length - 1) do |i| 30: unless line_array[i].eql?("none") 31: 32: if line_array[i + 1] =~ /^\<([a-zA-Z\-\,]+)\>$/ 33: media[line_array[i]] = Hash.new unless media.has_key?(line_array[i]) 34: if media[line_array[i]].has_key?("options") 35: $1.split(",").each do |opt| 36: media[line_array[i]]["options"] << opt unless media[line_array[i]]["options"].include?(opt) 37: end 38: else 39: media[line_array[i]]["options"] = $1.split(",") 40: end 41: else 42: if line_array[i].eql?("autoselect") 43: media["autoselect"] = Hash.new unless media.has_key?("autoselect") 44: media["autoselect"]["options"] = [] 45: end 46: end 47: else 48: media["none"] = { "options" => [] } 49: end 50: end 51: 52: media 53: end