supermicro 0.1.4 → 0.1.5
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/supermicro/client.rb +1 -0
- data/lib/supermicro/network.rb +95 -0
- data/lib/supermicro/version.rb +1 -1
- data/lib/supermicro.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: a25a05a0ca997122323e06a987141d8919bd662d2d7cdb2435fe24789d4ee7ee
|
4
|
+
data.tar.gz: aaed9e378c2e0b469e1c820cca17ac8770615ed07e2ee8ba81657a05239a94bd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5591347fb9df7593e69bd7718b19b95e7ba50172e2895f77ac34d517e34ee4cf4e1a700a7b975b09a2e76229ffef89051962458f5bf383f90e8df32128afa784
|
7
|
+
data.tar.gz: b32c17718b22629c0b52b85ddf0d009db37c4d0c2075d576bc7144616443300f6b501bb0764ba19a78e805f1ab44f667164c7e135b64f569a55aac00ecfa5bb5
|
data/lib/supermicro/client.rb
CHANGED
@@ -25,6 +25,7 @@ module Supermicro
|
|
25
25
|
include Utility
|
26
26
|
include License
|
27
27
|
include Tasks
|
28
|
+
include Network
|
28
29
|
|
29
30
|
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)
|
30
31
|
@host = host
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'json'
|
4
|
+
|
5
|
+
module Supermicro
|
6
|
+
module Network
|
7
|
+
def get_bmc_network
|
8
|
+
# Get the manager's ethernet interface
|
9
|
+
response = authenticated_request(:get, "/redfish/v1/Managers/1/EthernetInterfaces/1")
|
10
|
+
|
11
|
+
if response.status == 200
|
12
|
+
data = JSON.parse(response.body)
|
13
|
+
{
|
14
|
+
"ipv4_address" => data.dig("IPv4Addresses", 0, "Address"),
|
15
|
+
"subnet_mask" => data.dig("IPv4Addresses", 0, "SubnetMask"),
|
16
|
+
"gateway" => data.dig("IPv4Addresses", 0, "Gateway"),
|
17
|
+
"mode" => data.dig("IPv4Addresses", 0, "AddressOrigin"), # DHCP or Static
|
18
|
+
"mac_address" => data["MACAddress"],
|
19
|
+
"hostname" => data["HostName"],
|
20
|
+
"fqdn" => data["FQDN"],
|
21
|
+
"dns_servers" => data["NameServers"] || []
|
22
|
+
}
|
23
|
+
else
|
24
|
+
raise Error, "Failed to get BMC network config. Status: #{response.status}"
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_bmc_network(ip_address: nil, subnet_mask: nil, gateway: nil,
|
29
|
+
dns_primary: nil, dns_secondary: nil, hostname: nil,
|
30
|
+
dhcp: false)
|
31
|
+
|
32
|
+
if dhcp
|
33
|
+
puts "Setting BMC to DHCP mode...".yellow
|
34
|
+
body = {
|
35
|
+
"DHCPv4" => {
|
36
|
+
"DHCPEnabled" => true
|
37
|
+
},
|
38
|
+
"IPv4Addresses" => [{
|
39
|
+
"AddressOrigin" => "DHCP"
|
40
|
+
}]
|
41
|
+
}
|
42
|
+
else
|
43
|
+
puts "Configuring BMC network settings...".yellow
|
44
|
+
body = {}
|
45
|
+
|
46
|
+
# Configure static IP if provided
|
47
|
+
if ip_address && subnet_mask
|
48
|
+
body["IPv4Addresses"] = [{
|
49
|
+
"Address" => ip_address,
|
50
|
+
"SubnetMask" => subnet_mask,
|
51
|
+
"Gateway" => gateway,
|
52
|
+
"AddressOrigin" => "Static"
|
53
|
+
}]
|
54
|
+
puts " IP: #{ip_address}/#{subnet_mask}".cyan
|
55
|
+
puts " Gateway: #{gateway}".cyan if gateway
|
56
|
+
end
|
57
|
+
|
58
|
+
# Configure DNS if provided
|
59
|
+
if dns_primary || dns_secondary
|
60
|
+
dns_servers = []
|
61
|
+
dns_servers << dns_primary if dns_primary
|
62
|
+
dns_servers << dns_secondary if dns_secondary
|
63
|
+
body["StaticNameServers"] = dns_servers
|
64
|
+
puts " DNS: #{dns_servers.join(', ')}".cyan
|
65
|
+
end
|
66
|
+
|
67
|
+
# Configure hostname if provided
|
68
|
+
if hostname
|
69
|
+
body["HostName"] = hostname
|
70
|
+
puts " Hostname: #{hostname}".cyan
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
response = authenticated_request(
|
75
|
+
:patch,
|
76
|
+
"/redfish/v1/Managers/1/EthernetInterfaces/1",
|
77
|
+
body: body.to_json,
|
78
|
+
headers: { 'Content-Type' => 'application/json' }
|
79
|
+
)
|
80
|
+
|
81
|
+
if response.status.between?(200, 299)
|
82
|
+
puts "BMC network configured successfully.".green
|
83
|
+
puts "WARNING: BMC may restart network services. Connection may be lost.".yellow if ip_address
|
84
|
+
true
|
85
|
+
else
|
86
|
+
raise Error, "Failed to configure BMC network: #{response.status} - #{response.body}"
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def set_bmc_dhcp
|
91
|
+
# Convenience method
|
92
|
+
set_bmc_network(dhcp: true)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
data/lib/supermicro/version.rb
CHANGED
data/lib/supermicro.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: supermicro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonathan Siegel
|
@@ -152,6 +152,7 @@ files:
|
|
152
152
|
- lib/supermicro/error.rb
|
153
153
|
- lib/supermicro/jobs.rb
|
154
154
|
- lib/supermicro/license.rb
|
155
|
+
- lib/supermicro/network.rb
|
155
156
|
- lib/supermicro/power.rb
|
156
157
|
- lib/supermicro/session.rb
|
157
158
|
- lib/supermicro/spinner.rb
|