ilo-sdk 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +2 -0
- data/README.md +23 -4
- data/lib/ilo-sdk/client.rb +1 -0
- data/lib/ilo-sdk/helpers/ethernet_interface_helper.rb +108 -0
- data/lib/ilo-sdk/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 719398b8e8cbf0b240edab29282a232691405b99
|
4
|
+
data.tar.gz: 3d1f8d562fefd4cb9502f20d322702b28a156a0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0ce46b05b61ab55b663fa665c2ff36cefe319ee59c881ac174a7410dd4605b437cf44d54e09f15c74e3a77aaa80ef07955b551f7d7441b925fca8259cf7e503
|
7
|
+
data.tar.gz: 90257545f83a88547e14d3c1296ad78dc433eb631fe85ab1d276e730c9cac5cd07f8c02979411b2bcb8cf36bbd370d46ab4b50e77d0e10dacd6f379b3b07d7e2
|
data/.rubocop.yml
CHANGED
data/README.md
CHANGED
@@ -239,6 +239,25 @@ ntp_servers = ['10.1.1.1', '10.1.1.2']
|
|
239
239
|
client.set_ntp_server(ntp_servers)
|
240
240
|
```
|
241
241
|
|
242
|
+
#### Manager EthernetInterface settings
|
243
|
+
|
244
|
+
```ruby
|
245
|
+
# Get EthernetInteface settings
|
246
|
+
client.get_ilo_ethernet_interface
|
247
|
+
|
248
|
+
# Set EthernetInterface to obtain all IPv4 parameters from DHCP server
|
249
|
+
client.set_ilo_ipv4_dhcp
|
250
|
+
|
251
|
+
# Set static IPv4 address, netmask and gateway
|
252
|
+
client.set_ilo_ipv4_static(ip: '192.168.1.1', netmask: '255.255.255.0', gateway: '192.168.1.254')
|
253
|
+
|
254
|
+
# Set IPv4 DNS servers
|
255
|
+
client.set_ilo_ipv4_dns_servers(dns_servers: ['2.2.2.2', '4.4.4.4', '8.8.8.8'])
|
256
|
+
|
257
|
+
# Set hostname and domain name 'server-ilo.domain.local'
|
258
|
+
client.set_ilo_hostname(hostname: 'server-ilo', domain_name: 'domain.local')
|
259
|
+
```
|
260
|
+
|
242
261
|
#### Firmware
|
243
262
|
|
244
263
|
```ruby
|
@@ -398,7 +417,7 @@ client.eject_virtual_media(id)
|
|
398
417
|
|
399
418
|
## Custom requests
|
400
419
|
|
401
|
-
This gem includes some
|
420
|
+
This gem includes some useful helper methods, but sometimes you need to make your own custom requests to the iLO.
|
402
421
|
This project makes it extremely easy to do with some built-in methods for the client object. Here are some examples:
|
403
422
|
|
404
423
|
```ruby
|
@@ -412,11 +431,11 @@ data = client.response_handler(response)
|
|
412
431
|
|
413
432
|
# For updating iLO resources, use patch:
|
414
433
|
options = { ServiceName: 'iLO Admin', ServiceEmail: 'admin@domain.com' }
|
415
|
-
response = rest_patch('/redfish/v1/Systems/1/bios/Settings/', body: options)
|
434
|
+
response = client.rest_patch('/redfish/v1/Systems/1/bios/Settings/', body: options)
|
416
435
|
|
417
436
|
# For creating new iLO resources, use post:
|
418
437
|
options = { UserName: 'admin', Password: '123' }
|
419
|
-
response = rest_post('/redfish/v1/AccountService/Accounts/', body: options)
|
438
|
+
response = client.rest_post('/redfish/v1/AccountService/Accounts/', body: options)
|
420
439
|
```
|
421
440
|
|
422
441
|
These example are about as basic as it gets, but you can make any type of iLO API request.
|
@@ -426,7 +445,7 @@ Please refer to the documentation and [code](lib/ilo-sdk/rest.rb) for complete l
|
|
426
445
|
|
427
446
|
## CLI
|
428
447
|
|
429
|
-
This gem also comes with a command-line interface to make
|
448
|
+
This gem also comes with a command-line interface to make interacting with the iLO API possible without needing to create a Ruby program.
|
430
449
|
|
431
450
|
Note: In order to use this, you will need to make sure your ruby bin directory is in your path. Run $ gem environment to see where the executable paths are for your Ruby installation.
|
432
451
|
|
data/lib/ilo-sdk/client.rb
CHANGED
@@ -0,0 +1,108 @@
|
|
1
|
+
# (C) Copyright 2016 Hewlett Packard Enterprise Development LP
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# You may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
6
|
+
#
|
7
|
+
# Unless required by applicable law or agreed to in writing, software distributed
|
8
|
+
# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
|
9
|
+
# CONDITIONS OF ANY KIND, either express or implied. See the License for the
|
10
|
+
# specific language governing permissions and limitations under the License.
|
11
|
+
|
12
|
+
module ILO_SDK
|
13
|
+
# Contains helper methods for EthernetInterface IPv4 actions
|
14
|
+
module EthernetInterfaceHelper
|
15
|
+
# Get all the Ethernet Interface settings
|
16
|
+
# @param manager_id [Integer, String] ID of the Manager
|
17
|
+
# @param ethernet_interface [Integer, String] ID of the EthernetInterface
|
18
|
+
# @raise [RuntimeError] if the request failed
|
19
|
+
# @return [Hash] EthernetInterface settings
|
20
|
+
def get_ilo_ethernet_interface(manager_id: 1, ethernet_interface: 1)
|
21
|
+
response_handler(rest_get("/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/"))
|
22
|
+
end
|
23
|
+
|
24
|
+
# Set EthernetInterface to obtain IPv4 settings from DHCP
|
25
|
+
# @param manager_id [Integer, String] ID of the Manager
|
26
|
+
# @param ethernet_interface [Integer, String] ID of the EthernetInterface
|
27
|
+
# @raise [RuntimeError] if the request failed
|
28
|
+
# @return true
|
29
|
+
def set_ilo_ipv4_dhcp(manager_id: 1, ethernet_interface: 1)
|
30
|
+
new_action = {
|
31
|
+
'Oem' => {
|
32
|
+
'Hp' => {
|
33
|
+
'DHCPv4' => {
|
34
|
+
'Enabled' => true,
|
35
|
+
'UseDNSServers' => true,
|
36
|
+
'UseDomainName' => true,
|
37
|
+
'UseGateway' => true,
|
38
|
+
'UseNTPServers' => true,
|
39
|
+
'UseStaticRoutes' => true,
|
40
|
+
'UseWINSServers' => true
|
41
|
+
}
|
42
|
+
}
|
43
|
+
}
|
44
|
+
}
|
45
|
+
response = rest_patch("/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/", body: new_action)
|
46
|
+
response_handler(response)
|
47
|
+
true
|
48
|
+
end
|
49
|
+
|
50
|
+
# Set EthernetInterface to static IPv4 address
|
51
|
+
# @param ip [String] IPv4 address
|
52
|
+
# @param netmask [String] IPv4 subnet mask
|
53
|
+
# @param gateway [String] IPv4 default gateway
|
54
|
+
# @param manager_id [Integer, String] ID of the Manager
|
55
|
+
# @param ethernet_interface [Integer, String] ID of the EthernetInterface
|
56
|
+
# @raise [RuntimeError] if the request failed
|
57
|
+
# @return true
|
58
|
+
def set_ilo_ipv4_static(ip:, netmask:, gateway: '0.0.0.0', manager_id: 1, ethernet_interface: 1)
|
59
|
+
new_action = {
|
60
|
+
'Oem' => { 'Hp' => { 'DHCPv4' => { 'Enabled' => false } } },
|
61
|
+
'IPv4Addresses' => [
|
62
|
+
'Address' => ip, 'SubnetMask' => netmask, 'Gateway' => gateway
|
63
|
+
]
|
64
|
+
}
|
65
|
+
response = rest_patch("/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/", body: new_action)
|
66
|
+
response_handler(response)
|
67
|
+
true
|
68
|
+
end
|
69
|
+
|
70
|
+
# Set EthernetInterface DNS servers
|
71
|
+
# @param dns_servers [Array] list of DNS servers
|
72
|
+
# @param manager_id [Integer, String] ID of the Manager
|
73
|
+
# @param ethernet_interface [Integer, String] ID of the EthernetInterface
|
74
|
+
# @raise [RuntimeError] if the request failed
|
75
|
+
# @return true
|
76
|
+
def set_ilo_ipv4_dns_servers(dns_servers:, manager_id: 1, ethernet_interface: 1)
|
77
|
+
new_action = {
|
78
|
+
'Oem' => {
|
79
|
+
'Hp' => {
|
80
|
+
'DHCPv4' => { 'UseDNSServers' => false },
|
81
|
+
'IPv4' => { 'DNSServers' => dns_servers }
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
response = rest_patch("/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/", body: new_action)
|
86
|
+
response_handler(response)
|
87
|
+
true
|
88
|
+
end
|
89
|
+
|
90
|
+
# Set iLO hostname and domain name
|
91
|
+
# @param hostname [String] iLO hostname
|
92
|
+
# @param domain_name [String] iLO domain name
|
93
|
+
# @param manager_id [Integer, String] ID of the Manager
|
94
|
+
# @param ethernet_interface [Integer, String] ID of the EthernetInterface
|
95
|
+
# @raise [RuntimeError] if the request failed
|
96
|
+
# @return true
|
97
|
+
def set_ilo_hostname(hostname:, domain_name: nil, manager_id: 1, ethernet_interface: 1)
|
98
|
+
new_action = { 'Oem' => { 'Hp' => { 'HostName' => hostname } } }
|
99
|
+
new_action['Oem']['Hp'].merge!('DHCPv4' => {}, 'DHCPv6' => {}) if domain_name
|
100
|
+
new_action['Oem']['Hp']['DHCPv4']['UseDomainName'] = false if domain_name
|
101
|
+
new_action['Oem']['Hp']['DHCPv6']['UseDomainName'] = false if domain_name
|
102
|
+
new_action['Oem']['Hp']['DomainName'] = domain_name if domain_name
|
103
|
+
response = rest_patch("/redfish/v1/Managers/#{manager_id}/EthernetInterfaces/#{ethernet_interface}/", body: new_action)
|
104
|
+
response_handler(response)
|
105
|
+
true
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
data/lib/ilo-sdk/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ilo-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anirudh Gupta
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2017-06-23 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: thor
|
@@ -143,6 +143,7 @@ files:
|
|
143
143
|
- lib/ilo-sdk/helpers/computer_details_helper.rb
|
144
144
|
- lib/ilo-sdk/helpers/computer_system_helper.rb
|
145
145
|
- lib/ilo-sdk/helpers/date_time_helper.rb
|
146
|
+
- lib/ilo-sdk/helpers/ethernet_interface_helper.rb
|
146
147
|
- lib/ilo-sdk/helpers/firmware_update.rb
|
147
148
|
- lib/ilo-sdk/helpers/https_cert_helper.rb
|
148
149
|
- lib/ilo-sdk/helpers/log_entry_helper.rb
|
@@ -175,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
175
176
|
version: '0'
|
176
177
|
requirements: []
|
177
178
|
rubyforge_project:
|
178
|
-
rubygems_version: 2.
|
179
|
+
rubygems_version: 2.6.11
|
179
180
|
signing_key:
|
180
181
|
specification_version: 4
|
181
182
|
summary: Gem to interact with iLO API
|