idrac 0.8.2 → 0.8.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/idrac/client.rb +1 -0
- data/lib/idrac/network.rb +122 -0
- data/lib/idrac/version.rb +1 -1
- data/lib/idrac.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ddf0acabc047b9ba1160d2c650b3590e7d6cc06d2d5c12aac37a4762fa85b7c
|
4
|
+
data.tar.gz: 40264a916185644f08009c693234d7463b929be7db77e8a1e4a1c28d13da70a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be5ef5de0dac918e3f5cc55304b478cdba291a5637fecea1d456d993861246286d9601103aa20ac600a54c14acd15a92866fe455e96aa7cd7abebaf1ffbe5956
|
7
|
+
data.tar.gz: 5c148a96e54a35a8ffac7fca95163fb68ec86fd15500692210ebd9d3951ea836d25cb11d9a287379b7fbd265edd5fe0e67b57473aa6e9909b4f3578b33ba6d75
|
data/lib/idrac/client.rb
CHANGED
@@ -23,6 +23,7 @@ module IDRAC
|
|
23
23
|
include License
|
24
24
|
include SystemConfig
|
25
25
|
include Utility
|
26
|
+
include Network
|
26
27
|
|
27
28
|
def initialize(host:, username:, password:, port: 443, use_ssl: true, verify_ssl: false, direct_mode: false, retry_count: 3, retry_delay: 1, host_header: nil)
|
28
29
|
@host = host
|
@@ -0,0 +1,122 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module IDRAC
|
6
|
+
module Network
|
7
|
+
def get_bmc_network
|
8
|
+
# Get the iDRAC ethernet interface
|
9
|
+
collection_response = authenticated_request(:get, "/redfish/v1/Managers/iDRAC.Embedded.1/EthernetInterfaces")
|
10
|
+
|
11
|
+
if collection_response.status == 200
|
12
|
+
collection = JSON.parse(collection_response.body)
|
13
|
+
|
14
|
+
if collection["Members"] && collection["Members"].any?
|
15
|
+
interface_path = collection["Members"][0]["@odata.id"]
|
16
|
+
response = authenticated_request(:get, interface_path)
|
17
|
+
|
18
|
+
if response.status == 200
|
19
|
+
data = JSON.parse(response.body)
|
20
|
+
{
|
21
|
+
"ipv4_address" => data.dig("IPv4Addresses", 0, "Address"),
|
22
|
+
"subnet_mask" => data.dig("IPv4Addresses", 0, "SubnetMask"),
|
23
|
+
"gateway" => data.dig("IPv4Addresses", 0, "Gateway"),
|
24
|
+
"mode" => data.dig("IPv4Addresses", 0, "AddressOrigin"), # DHCP or Static
|
25
|
+
"mac_address" => data["MACAddress"],
|
26
|
+
"hostname" => data["HostName"],
|
27
|
+
"fqdn" => data["FQDN"],
|
28
|
+
"dns_servers" => data["NameServers"] || []
|
29
|
+
}
|
30
|
+
else
|
31
|
+
raise Error, "Failed to get interface details. Status: #{response.status}"
|
32
|
+
end
|
33
|
+
else
|
34
|
+
raise Error, "No ethernet interfaces found"
|
35
|
+
end
|
36
|
+
else
|
37
|
+
raise Error, "Failed to get ethernet interfaces. Status: #{collection_response.status}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def set_bmc_network(ip_address: nil, subnet_mask: nil, gateway: nil,
|
42
|
+
dns_primary: nil, dns_secondary: nil, hostname: nil,
|
43
|
+
dhcp: false)
|
44
|
+
# Get the interface path first
|
45
|
+
collection_response = authenticated_request(:get, "/redfish/v1/Managers/iDRAC.Embedded.1/EthernetInterfaces")
|
46
|
+
|
47
|
+
if collection_response.status == 200
|
48
|
+
collection = JSON.parse(collection_response.body)
|
49
|
+
|
50
|
+
if collection["Members"] && collection["Members"].any?
|
51
|
+
interface_path = collection["Members"][0]["@odata.id"]
|
52
|
+
|
53
|
+
if dhcp
|
54
|
+
puts "Setting iDRAC to DHCP mode...".yellow
|
55
|
+
body = {
|
56
|
+
"DHCPv4" => {
|
57
|
+
"DHCPEnabled" => true
|
58
|
+
},
|
59
|
+
"IPv4Addresses" => [{
|
60
|
+
"AddressOrigin" => "DHCP"
|
61
|
+
}]
|
62
|
+
}
|
63
|
+
else
|
64
|
+
puts "Configuring iDRAC network settings...".yellow
|
65
|
+
body = {}
|
66
|
+
|
67
|
+
# Configure static IP if provided
|
68
|
+
if ip_address && subnet_mask
|
69
|
+
body["IPv4Addresses"] = [{
|
70
|
+
"Address" => ip_address,
|
71
|
+
"SubnetMask" => subnet_mask,
|
72
|
+
"Gateway" => gateway,
|
73
|
+
"AddressOrigin" => "Static"
|
74
|
+
}]
|
75
|
+
puts " IP: #{ip_address}/#{subnet_mask}".cyan
|
76
|
+
puts " Gateway: #{gateway}".cyan if gateway
|
77
|
+
end
|
78
|
+
|
79
|
+
# Configure DNS if provided
|
80
|
+
if dns_primary || dns_secondary
|
81
|
+
dns_servers = []
|
82
|
+
dns_servers << dns_primary if dns_primary
|
83
|
+
dns_servers << dns_secondary if dns_secondary
|
84
|
+
body["StaticNameServers"] = dns_servers
|
85
|
+
puts " DNS: #{dns_servers.join(', ')}".cyan
|
86
|
+
end
|
87
|
+
|
88
|
+
# Configure hostname if provided
|
89
|
+
if hostname
|
90
|
+
body["HostName"] = hostname
|
91
|
+
puts " Hostname: #{hostname}".cyan
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
response = authenticated_request(
|
96
|
+
:patch,
|
97
|
+
interface_path,
|
98
|
+
body: body.to_json,
|
99
|
+
headers: { 'Content-Type' => 'application/json' }
|
100
|
+
)
|
101
|
+
|
102
|
+
if response.status.between?(200, 299)
|
103
|
+
puts "iDRAC network configured successfully.".green
|
104
|
+
puts "WARNING: iDRAC may restart network services. Connection may be lost.".yellow if ip_address
|
105
|
+
true
|
106
|
+
else
|
107
|
+
raise Error, "Failed to configure iDRAC network: #{response.status} - #{response.body}"
|
108
|
+
end
|
109
|
+
else
|
110
|
+
raise Error, "No ethernet interfaces found"
|
111
|
+
end
|
112
|
+
else
|
113
|
+
raise Error, "Failed to get ethernet interfaces"
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def set_bmc_dhcp
|
118
|
+
# Convenience method
|
119
|
+
set_bmc_network(dhcp: true)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
data/lib/idrac/version.rb
CHANGED
data/lib/idrac.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: idrac
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Siegel
|
@@ -265,6 +265,7 @@ files:
|
|
265
265
|
- lib/idrac/jobs.rb
|
266
266
|
- lib/idrac/license.rb
|
267
267
|
- lib/idrac/lifecycle.rb
|
268
|
+
- lib/idrac/network.rb
|
268
269
|
- lib/idrac/power.rb
|
269
270
|
- lib/idrac/session.rb
|
270
271
|
- lib/idrac/storage.rb
|