Module: ILO_SDK::DateTimeHelper

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

Overview

Contains helper methods for Date and Time actions

Instance Method Summary collapse

Instance Method Details

#get_ntpTrueClass, FalseClass

Get whether or not ntp servers are being used

Raises:

  • (RuntimeError)

    if the request failed


39
40
41
42
# File 'lib/ilo-sdk/helpers/date_time_helper.rb', line 39

def get_ntp
  response = rest_get('/redfish/v1/Managers/1/EthernetInterfaces/1/')
  response_handler(response)['Oem']['Hp']['DHCPv4']['UseNTPServers']
end

#get_ntp_serversArray

Get the NTP Servers

Raises:

  • (RuntimeError)

    if the request failed


58
59
60
61
# File 'lib/ilo-sdk/helpers/date_time_helper.rb', line 58

def get_ntp_servers
  response = rest_get('/redfish/v1/Managers/1/DateTime/')
  response_handler(response)['StaticNTPServers']
end

#get_time_zoneString

Get the Time Zone

Raises:

  • (RuntimeError)

    if the request failed


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

def get_time_zone
  response = rest_get('/redfish/v1/Managers/1/DateTime/')
  response_handler(response)['TimeZone']['Name']
end

#set_ntp(use_ntp) ⇒ Object

Set whether or not ntp servers are being used

Raises:

  • (RuntimeError)

    if the request failed


48
49
50
51
52
53
# File 'lib/ilo-sdk/helpers/date_time_helper.rb', line 48

def set_ntp(use_ntp)
  new_action = { 'Oem' => { 'Hp' => { 'DHCPv4' => { 'UseNTPServers' => use_ntp } } } }
  response = rest_patch('/redfish/v1/Managers/1/EthernetInterfaces/1/', body: new_action)
  response_handler(response)
  true
end

#set_ntp_servers(ntp_servers) ⇒ Object

Set the NTP Servers

Raises:

  • (RuntimeError)

    if the request failed


67
68
69
70
71
72
# File 'lib/ilo-sdk/helpers/date_time_helper.rb', line 67

def set_ntp_servers(ntp_servers)
  new_action = { 'StaticNTPServers' => ntp_servers }
  response = rest_patch('/redfish/v1/Managers/1/DateTime/', body: new_action)
  response_handler(response)
  true
end

#set_time_zone(time_zone) ⇒ Object

Set the Time Zone

Raises:

  • (RuntimeError)

    if the request failed


27
28
29
30
31
32
33
34
# File 'lib/ilo-sdk/helpers/date_time_helper.rb', line 27

def set_time_zone(time_zone)
  time_response = rest_get('/redfish/v1/Managers/1/DateTime/')
  new_time_zone = response_handler(time_response)['TimeZoneList'].select { |timezone| timezone['Name'] == time_zone }
  new_action = { 'TimeZone' => { 'Index' => new_time_zone[0]['Index'] } }
  response = rest_patch('/redfish/v1/Managers/1/DateTime/', body: new_action)
  response_handler(response)
  true
end