Class: Radfish::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/radfish/controller.rb

Overview

Lightweight value object representing a storage controller. Holds a stable identifier and optional name.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client:, id:, name: nil, model: nil, vendor: nil, adapter_data: nil, firmware_version: nil, encryption_mode: nil, encryption_capability: nil, controller_type: nil, pci_slot: nil, status: nil, drives_count: nil, battery_status: nil) ⇒ Controller

Returns a new instance of Controller.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/radfish/controller.rb', line 11

def initialize(client:, id:, name: nil, model: nil, vendor: nil, adapter_data: nil,
               firmware_version: nil, encryption_mode: nil, encryption_capability: nil,
               controller_type: nil, pci_slot: nil, status: nil, drives_count: nil,
               battery_status: nil)
  @client = client
  @id = id
  @name = name
  @model = model
  @vendor = vendor
  @adapter_data = adapter_data
  @firmware_version = firmware_version
  @encryption_mode = encryption_mode
  @encryption_capability = encryption_capability
  @controller_type = controller_type
  @pci_slot = pci_slot
  @status = status
  @drives_count = drives_count
  @battery_status = battery_status
end

Instance Attribute Details

#adapter_dataObject (readonly)

Returns the value of attribute adapter_data.



7
8
9
# File 'lib/radfish/controller.rb', line 7

def adapter_data
  @adapter_data
end

#battery_statusObject (readonly)

Returns the value of attribute battery_status.



7
8
9
# File 'lib/radfish/controller.rb', line 7

def battery_status
  @battery_status
end

#controller_typeObject (readonly)

Returns the value of attribute controller_type.



7
8
9
# File 'lib/radfish/controller.rb', line 7

def controller_type
  @controller_type
end

#drives_countObject (readonly)

Returns the value of attribute drives_count.



7
8
9
# File 'lib/radfish/controller.rb', line 7

def drives_count
  @drives_count
end

#encryption_capabilityObject (readonly)

Returns the value of attribute encryption_capability.



7
8
9
# File 'lib/radfish/controller.rb', line 7

def encryption_capability
  @encryption_capability
end

#encryption_modeObject (readonly)

Returns the value of attribute encryption_mode.



7
8
9
# File 'lib/radfish/controller.rb', line 7

def encryption_mode
  @encryption_mode
end

#firmware_versionObject (readonly)

Returns the value of attribute firmware_version.



7
8
9
# File 'lib/radfish/controller.rb', line 7

def firmware_version
  @firmware_version
end

#idObject (readonly)

Returns the value of attribute id.



7
8
9
# File 'lib/radfish/controller.rb', line 7

def id
  @id
end

#modelObject (readonly)

Returns the value of attribute model.



7
8
9
# File 'lib/radfish/controller.rb', line 7

def model
  @model
end

#nameObject (readonly)

Returns the value of attribute name.



7
8
9
# File 'lib/radfish/controller.rb', line 7

def name
  @name
end

#pci_slotObject (readonly)

Returns the value of attribute pci_slot.



7
8
9
# File 'lib/radfish/controller.rb', line 7

def pci_slot
  @pci_slot
end

#statusObject (readonly)

Returns the value of attribute status.



7
8
9
# File 'lib/radfish/controller.rb', line 7

def status
  @status
end

#vendorObject (readonly)

Returns the value of attribute vendor.



7
8
9
# File 'lib/radfish/controller.rb', line 7

def vendor
  @vendor
end

Instance Method Details

#==(other) ⇒ Object



57
58
59
# File 'lib/radfish/controller.rb', line 57

def ==(other)
  other.is_a?(Controller) && other.id == id && other.vendor.to_s == vendor.to_s
end

#drivesObject

Convenience accessors delegate to the client wrappers



32
33
34
# File 'lib/radfish/controller.rb', line 32

def drives
  @client.drives(self)
end

#to_hObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/radfish/controller.rb', line 40

def to_h
  {
    id: id,
    name: name,
    model: model,
    vendor: vendor,
    firmware_version: firmware_version,
    encryption_mode: encryption_mode,
    encryption_capability: encryption_capability,
    controller_type: controller_type,
    pci_slot: pci_slot,
    status: status,
    drives_count: drives_count,
    battery_status: battery_status
  }.compact
end

#volumesObject



36
37
38
# File 'lib/radfish/controller.rb', line 36

def volumes
  @client.volumes(self)
end