Class: VirtualAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/HMC/virtual_adapter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string = '') ⇒ VirtualAdapter

Returns a new instance of VirtualAdapter.



19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/HMC/virtual_adapter.rb', line 19

def initialize(string = '')
  @lpar_name = nil
  @lpar_id = nil
  @state = nil
  @isRequired = 0
  @_type = 'profile'

  @vios = nil
  @frame = nil

  @params = []
end

Instance Attribute Details

#_typeObject (readonly)

type of input / output (data can be taken from profile or real setup (lshwres…))



12
13
14
# File 'lib/HMC/virtual_adapter.rb', line 12

def _type
  @_type
end

#frameObject

Returns the value of attribute frame.



16
17
18
# File 'lib/HMC/virtual_adapter.rb', line 16

def frame
  @frame
end

#isRequiredObject

Returns the value of attribute isRequired.



4
5
6
# File 'lib/HMC/virtual_adapter.rb', line 4

def isRequired
  @isRequired
end

#lpar_idObject

Returns the value of attribute lpar_id.



8
9
10
# File 'lib/HMC/virtual_adapter.rb', line 8

def lpar_id
  @lpar_id
end

#lpar_nameObject

below data can be taken only from lshwres, they are exist only for running lpars



7
8
9
# File 'lib/HMC/virtual_adapter.rb', line 7

def lpar_name
  @lpar_name
end

#stateObject

Returns the value of attribute state.



9
10
11
# File 'lib/HMC/virtual_adapter.rb', line 9

def state
  @state
end

#viosObject

for compare where important are only adapters



15
16
17
# File 'lib/HMC/virtual_adapter.rb', line 15

def vios
  @vios
end

#virtualSlotNumberObject

Returns the value of attribute virtualSlotNumber.



3
4
5
# File 'lib/HMC/virtual_adapter.rb', line 3

def virtualSlotNumber
  @virtualSlotNumber
end

Instance Method Details

#==(other) ⇒ Object



57
58
59
# File 'lib/HMC/virtual_adapter.rb', line 57

def ==(other)
  to_s == other.to_s
end

#diff(other_adapter, profile1, profile2, null_0_none_equal = false) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/HMC/virtual_adapter.rb', line 32

def diff(other_adapter, profile1, profile2, null_0_none_equal = false )
  diff = {}

  if self.class.name != other_adapter.class.name
    raise "Wrong type of adapter has been compared #{other_adapter.class.name}"
  end

  @params.sort.each do |param|
    next if  instance_variable_get("@#{param}") == other_adapter.instance_variable_get("@#{param}")

    if null_0_none_equal
      a = instance_variable_get("@#{param}")
      b = other_adapter.instance_variable_get("@#{param}")
      next if ( a.to_s == '0' || a == 'none' || a == 'null')  && (b.to_s == '0' || b == 'none' || b == 'null')
    end

    diff_entry = {}
    diff_entry[profile2] = other_adapter.instance_variable_get("@#{param}")
    diff_entry[profile1]  = instance_variable_get("@#{param}")
    diff[param.to_s] = diff_entry
  end

  diff
end