Module: ILO_SDK::ComputerDetailsHelper

Included in:
Client
Defined in:
lib/ilo-sdk/helpers/computer_details_helper.rb

Overview

Contains helper methods for computer details actions

Instance Method Summary collapse

Instance Method Details

#get_array_controller_detailsHash

Get the array controller details

Returns:

  • (Hash)

    array_controller_details

Raises:

  • (RuntimeError)

    if the request failed


81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/ilo-sdk/helpers/computer_details_helper.rb', line 81

def get_array_controller_details
  response = rest_get('/redfish/v1/Systems/1/SmartStorage/')
  storages = response_handler(response)
  array_controllers = []
  response = rest_get(storages['links']['ArrayControllers']['href'])
  array_ctrls = response_handler(response)
  if array_ctrls['links'].key? 'Member'
    array_ctrls['links']['Member'].each do |array_controller|
      response = rest_get(array_controller['href'])
      controller = response_handler(response)
      storage_enclosures = []
      response = rest_get(controller['links']['StorageEnclosures']['href'])
      response_handler(response)['links']['Member'].each do |enclosure|
        response = rest_get(enclosure['href'])
        enclsr = response_handler(response)
        enc = {
          'Model' => enclsr['Model'],
          'SerialNumber' => enclsr['SerialNumber'],
          'DriveBayCount' => enclsr['DriveBayCount'],
          'State' => enclsr['Status']['State'],
          'Health' => enclsr['Status']['Health'],
          'Location' => enclsr['Location'].to_s + ' (' + enclsr['LocationFormat'].to_s + ')',
          'FirmwareVersion' => enclsr['FirmwareVersion']['Current']['VersionString']
        }
        storage_enclosures.push(enc)
      end

      logical_drives = []
      response = rest_get(controller['links']['LogicalDrives']['href'])
      response_handler(response)['links']['Member'].each do |logicaldrive|
        response = rest_get(logicaldrive['href'])
        lds = response_handler(response)
        data_drives = []
        response = rest_get(lds['links']['DataDrives']['href'])
        response_handler(response)['links']['Member'].each do |datadrives|
          response = rest_get(datadrives['href'])
          disk_drive = response_handler(response)
          dd = {
            'Model' => disk_drive['Model'],
            'Name' => disk_drive['Name'],
            'RotationalSpeedRpm' => disk_drive['RotationalSpeedRpm'],
            'SerialNumber' => disk_drive['SerialNumber'],
            'State' => disk_drive['Status']['State'],
            'Health' => disk_drive['Status']['Health'],
            'CapacityMiB' => disk_drive['CapacityMiB'],
            'CurrentTemperatureCelsius' => disk_drive['CurrentTemperatureCelsius']
          }
          data_drives.push(dd)
        end
        ld = {
          'Size' => lds['CapacityMiB'],
          'Raid' => lds['Raid'],
          'Status' => lds['Status']['State'],
          'Health' => lds['Status']['Health'],
          'DataDrives' => data_drives
        }
        logical_drives.push(ld)
      end
      ac = {
        'Model' => controller['Model'],
        'SerialNumber' => controller['SerialNumber'],
        'State' => controller['Status']['State'],
        'Health' => controller['Status']['Health'],
        'Location' => controller['Location'],
        'FirmWareVersion' => controller['FirmwareVersion']['Current']['VersionString'],
        'LogicalDrives' => logical_drives,
        'Enclosures' => storage_enclosures
      }
      array_controllers.push(ac)
    end
  end
  {
    'HPSmartStorage' => {
      'Health' => storages['Status']['Health'],
      'ArrayControllers' => array_controllers
    }
  }
end

#get_computer_detailsHash

Get all of the computer details

Returns:

  • (Hash)

    computer_details

Raises:

  • (RuntimeError)

    if the request failed


18
19
20
21
22
23
# File 'lib/ilo-sdk/helpers/computer_details_helper.rb', line 18

def get_computer_details
  general_computer_details = get_general_computer_details
  computer_network_details = get_computer_network_details
  array_controller_details = get_array_controller_details
  general_computer_details.merge(computer_network_details).merge(array_controller_details)
end

#get_computer_network_detailsHash

Get the computer network details

Returns:

  • (Hash)

    computer_network_details

Raises:

  • (RuntimeError)

    if the request failed


46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/ilo-sdk/helpers/computer_details_helper.rb', line 46

def get_computer_network_details
  network_adapters = []
  response = rest_get('/redfish/v1/Systems/1/NetworkAdapters/')
  networks = response_handler(response)['links']['Member']
  networks.each do |network|
    response = rest_get(network['href'])
    detail = response_handler(response)
    physical_ports = []
    detail['PhysicalPorts'].each do |port|
      n = {
        'Name' => port['Name'],
        'StructuredName' => port['Oem']['Hp']['StructuredName'],
        'MacAddress' => port['MacAddress'],
        'State' => port['Status']['State']
      }
      physical_ports.push(n)
    end
    nets = {
      'Name' => detail['Name'],
      'StructuredName' => detail['StructuredName'],
      'PartNumber' => detail['PartNumber'],
      'State' => detail['Status']['State'],
      'Health' => detail['Status']['Health'],
      'PhysicalPorts' => physical_ports
    }
    network_adapters.push(nets)
  end
  {
    'NetworkAdapters' => network_adapters
  }
end

#get_general_computer_detailsFixnum

Get the general computer details

Returns:

  • (Fixnum)

    general_computer_details

Raises:

  • (RuntimeError)

    if the request failed


28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/ilo-sdk/helpers/computer_details_helper.rb', line 28

def get_general_computer_details
  response = rest_get('/redfish/v1/Systems/1/')
  details = response_handler(response)
  {
    'GeneralDetails' => {
      'manufacturer' => details['Manufacturer'],
      'model' => details['Model'],
      'AssetTag' => details['AssetTag'],
      'bios_version' => details['Bios']['Current']['VersionString'],
      'memory' => details['Memory']['TotalSystemMemoryGB'].to_s + ' GB',
      'processors' => details['Processors']['Count'].to_s + ' x ' + details['Processors']['ProcessorFamily'].to_s
    }
  }
end