class Rubyipmi::Ipmitool::Lan
Constants
- MAX_RETRY
Attributes
channel[RW]
info[RW]
Public Class Methods
new(opts = ObservableHash.new)
click to toggle source
Calls superclass method
Rubyipmi::BaseCommand::new
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 7 def initialize(opts = ObservableHash.new) super("ipmitool", opts) @info = {} @channel = 2 end
Public Instance Methods
channel=(num)
click to toggle source
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 18 def channel=(num) refresh @channel = num end
dhcp?()
click to toggle source
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 98 def dhcp? info.fetch("ip_address_source", nil).match(/dhcp/i) != nil end
gateway()
click to toggle source
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 62 def gateway info.fetch("default_gateway_ip", nil) end
gateway=(address)
click to toggle source
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 91 def gateway=(address) @options["cmdargs"] = "lan set #{channel} defgw ipaddr #{address}" value = runcmd @options.delete_notify("cmdargs") value end
ip()
click to toggle source
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 50 def ip info.fetch("ip_address", nil) end
ip=(address)
click to toggle source
def snmp=(community)
@options["cmdargs"] = "lan set #{channel} snmp #{community}" value = runcmd @options.delete_notify("cmdargs") return value
end
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 77 def ip=(address) @options["cmdargs"] = "lan set #{channel} ipaddr #{address}" value = runcmd @options.delete_notify("cmdargs") value end
mac()
click to toggle source
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 54 def mac info.fetch("mac_address", nil) end
netmask()
click to toggle source
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 58 def netmask info.fetch("subnet_mask", nil) end
netmask=(mask)
click to toggle source
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 84 def netmask=(mask) @options["cmdargs"] = "lan set #{channel} netmask #{mask}" value = runcmd @options.delete_notify("cmdargs") value end
refresh()
click to toggle source
sets the info var to be empty causing the variable to repopulate upon the next call to info
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 14 def refresh @info = {} end
snmp()
click to toggle source
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 46 def snmp info.fetch("snmp_community_string", nil) end
static?()
click to toggle source
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 102 def static? info.fetch("ip_address_source", nil).match(/static/i) != nil end
vlanid()
click to toggle source
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 66 def vlanid info.fetch("802.1q_vlan_id", nil) end
vlanid=(vlan)
click to toggle source
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 106 def vlanid=(vlan) @options["cmdargs"] = "lan set #{channel} vlan id #{vlan}" value = runcmd @options.delete_notify("cmdargs") value end
Private Instance Methods
normalize(text)
click to toggle source
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 133 def normalize(text) text.gsub(/\ /, '_').gsub(/\./, '').downcase end
parse(landata)
click to toggle source
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 122 def parse(landata) landata.lines.each do |line| # clean up the data from spaces item = line.split(':', 2) key = normalize(item.first.strip) value = item.last.strip @info[key] = value end @info end
print()
click to toggle source
# File lib/rubyipmi/ipmitool/commands/lan.rb, line 115 def print @options["cmdargs"] = "lan print" value = runcmd @options.delete_notify("cmdargs") @result if value end