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.



9
10
11
12
13
14
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 9

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

end

Instance Attribute Details

#channelObject

Returns the value of attribute channel.



6
7
8
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 6

def channel
  @channel
end

#infoObject

Returns the value of attribute info.



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

def info
  @info
end

Instance Method Details

#dhcp?Boolean

Returns:

  • (Boolean)


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

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

#gatewayObject



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

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

#gateway=(address) ⇒ Object



90
91
92
93
94
95
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 90

def gateway=(address)
  @options["cmdargs"] = "lan set #{channel} defgw ipaddr #{address}"
  value = runcmd
  @options.delete_notify("cmdargs")
  return value
end

#ipObject



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

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


76
77
78
79
80
81
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 76

def ip=(address)
  @options["cmdargs"] = "lan set #{channel} ipaddr #{address}"
  value = runcmd
  @options.delete_notify("cmdargs")
  return value
end

#macObject



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

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

#netmaskObject



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

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

#netmask=(mask) ⇒ Object



83
84
85
86
87
88
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 83

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

#refreshObject

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



17
18
19
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 17

def refresh
  @info = {}
end

#snmpObject



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

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

#static?Boolean

Returns:

  • (Boolean)


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

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

#vlanidObject



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

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

#vlanid=(vlan) ⇒ Object



105
106
107
108
109
110
# File 'lib/rubyipmi/ipmitool/commands/lan.rb', line 105

def vlanid=(vlan)
  @options["cmdargs"] = "lan set #{channel} vlan id #{vlan}"
  value = runcmd
  @options.delete_notify("cmdargs")
  return value
end