Class: Collins::Ipmi

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/collins/ipmi.rb

Constant Summary

Constants included from Util::Logging

Util::Logging::DEFAULT_LOG_FORMAT

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Util

#deep_copy_hash, #get_asset_or_tag, included, #require_non_empty, #require_that, #stringify_hash, #symbolize_hash

Methods included from Util::Logging

#get_logger

Constructor Details

#initialize(opts = {}) ⇒ Ipmi

Returns a new instance of Ipmi.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/collins/ipmi.rb', line 13

def initialize opts = {}
  hash = symbolize_hash(opts).inject({}) do |result, (k,v)|
    key = k.to_s.downcase.sub(/^ipmi_/, "").to_sym
    result[key] = v
    result
  end
  @address = hash[:address].to_s
  @asset_id = hash[:asset_id].to_s.to_i
  @gateway = hash[:gateway].to_s
  @id = hash[:id].to_s.to_i
  @netmask = hash[:netmask].to_s
  @password = hash[:password].to_s
  @username = hash[:username].to_s
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



7
8
9
# File 'lib/collins/ipmi.rb', line 7

def address
  @address
end

#asset_idObject

Returns the value of attribute asset_id.



7
8
9
# File 'lib/collins/ipmi.rb', line 7

def asset_id
  @asset_id
end

#gatewayObject

Returns the value of attribute gateway.



7
8
9
# File 'lib/collins/ipmi.rb', line 7

def gateway
  @gateway
end

#idObject

Returns the value of attribute id.



7
8
9
# File 'lib/collins/ipmi.rb', line 7

def id
  @id
end

#netmaskObject

Returns the value of attribute netmask.



7
8
9
# File 'lib/collins/ipmi.rb', line 7

def netmask
  @netmask
end

#passwordObject

Returns the value of attribute password.



7
8
9
# File 'lib/collins/ipmi.rb', line 7

def password
  @password
end

#usernameObject

Returns the value of attribute username.



7
8
9
# File 'lib/collins/ipmi.rb', line 7

def username
  @username
end

Class Method Details

.from_json(json) ⇒ Object



9
10
11
# File 'lib/collins/ipmi.rb', line 9

def self.from_json json
  Collins::Ipmi.new json
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/collins/ipmi.rb', line 28

def empty?
  @id == 0
end

#to_sObject



32
33
34
35
36
37
38
# File 'lib/collins/ipmi.rb', line 32

def to_s
  if empty? then
    "Ipmi(None)"
  else
    "Ipmi(id = #{id}, asset_id = #{asset_id}, address = #{address}, gateway = #{gateway}, netmask = #{netmask}, username = #{username}, password = #{password})"
  end
end