Class: Rubyipmi::Ipmitool::Lan

Inherits:
BaseCommand show all
Defined in:
lib/rubyipmi/ipmitool/commands/lan.rb

Constant Summary collapse

MAX_RETRY =
1

Instance Attribute Summary collapse

Attributes inherited from BaseCommand

#cmd, #lastcall, #max_retry_count, #options, #passfile, #result

Instance Method Summary collapse

Methods inherited from BaseCommand

#find_fix, #makecommand, #max_retry_count, #setpass

Methods inherited from BaseCommand

#dump_command, #find_fix, #locate_command, #logger, #makecommand, #removepass, #run, #runcmd, #setpass, #update, #validate_status

Constructor Details

#initialize(opts = ObservableHash.new) ⇒ Lan

Returns a new instance of Lan.



7
8
9
10
11
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 7

def initialize(opts = ObservableHash.new)
  super("ipmitool", opts)
  @info = {}
  @channel = 2
end

Instance Attribute Details

#channelObject

Returns the value of attribute channel.



4
5
6
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 4

def channel
  @channel
end

#infoObject

Returns the value of attribute info.



3
4
5
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 3

def info
  @info
end

Instance Method Details

#dhcp?Boolean

Returns:

  • (Boolean)


98
99
100
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 98

def dhcp?
  info.fetch("ip_address_source", nil).match(/dhcp/i) != nil
end

#gatewayObject



62
63
64
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 62

def gateway
  info.fetch("default_gateway_ip", nil)
end

#gateway=(address) ⇒ Object



91
92
93
94
95
96
# 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

#ipObject



50
51
52
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 50

def ip
  info.fetch("ip_address", nil)
end

#ip=(address) ⇒ Object

def snmp=(community)

  @options["cmdargs"] = "lan set #{channel} snmp #{community}"
  value = runcmd
  @options.delete_notify("cmdargs")
  return value
end


77
78
79
80
81
82
# 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

#macObject



54
55
56
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 54

def mac
  info.fetch("mac_address", nil)
end

#netmaskObject



58
59
60
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 58

def netmask
  info.fetch("subnet_mask", nil)
end

#netmask=(mask) ⇒ Object



84
85
86
87
88
89
# 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

#refreshObject

sets the info var to be empty causing the variable to repopulate upon the next call to info



14
15
16
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 14

def refresh
  @info = {}
end

#snmpObject



46
47
48
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 46

def snmp
  info.fetch("snmp_community_string", nil)
end

#static?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 102

def static?
  info.fetch("ip_address_source", nil).match(/static/i) != nil
end

#vlanidObject



66
67
68
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 66

def vlanid
  info.fetch("802.1q_vlan_id", nil)
end

#vlanid=(vlan) ⇒ Object



106
107
108
109
110
111
# 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