supermicro 0.1.4 → 0.1.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f473c02ec107566a4badc6a56c3acaa668ff32853a808f2071b248155e4c63d
4
- data.tar.gz: c5999ddaccfd4ca09f8f60c86d603ccd1db953b265b0ae380d1f8b244e699bb6
3
+ metadata.gz: 471ad0e0ecd001b34f54992ae215ef9473518591ddda5971439fd50142d7f147
4
+ data.tar.gz: 2cbb22954501401431bf37021c8ffd2275a806f1d9daaa189490dbdb7199e34b
5
5
  SHA512:
6
- metadata.gz: 52042e73ee2724096d38462b2dfe16d12eb237839ad886f0cb43369bf9dc3fb55380182d5ea064012985ff0136a6788ed9a128c44e56cc8e342d389c4eb71e44
7
- data.tar.gz: d24140fc56d8ee13e61c8da5e5200f64c8d3fed416b3c987a6f505800bb98e36d51ff0dde8a6ab7a4a99f750ada1c8c7200c15348acdb4c9f953bcb5f1b24359
6
+ metadata.gz: 27c30adcb6de01ce1b5de29ab05221477fdf04bd36e768a74e43b8a5e60fc2093174b2d70670afe21aa245768ef9592694ed48c458be0b5d5fa15b8dfb8eab51
7
+ data.tar.gz: 937d9d4acb761743b4c9db40cf9c282b823ca83e9ba83ae4ce5a1fbaf1df158cf6d6c98039f75b13d965fb8125cee04d54cf89c4ef89b148bade0f467427426d
@@ -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,91 @@
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
+ }
39
+ else
40
+ puts "Configuring BMC network settings...".yellow
41
+ body = {}
42
+
43
+ # Configure static IP if provided
44
+ if ip_address && subnet_mask
45
+ body["IPv4StaticAddresses"] = [{
46
+ "Address" => ip_address,
47
+ "SubnetMask" => subnet_mask,
48
+ "Gateway" => gateway
49
+ }]
50
+ puts " IP: #{ip_address}/#{subnet_mask}".cyan
51
+ puts " Gateway: #{gateway}".cyan if gateway
52
+ end
53
+
54
+ # Configure DNS if provided
55
+ if dns_primary || dns_secondary
56
+ dns_servers = []
57
+ dns_servers << dns_primary if dns_primary
58
+ dns_servers << dns_secondary if dns_secondary
59
+ body["StaticNameServers"] = dns_servers
60
+ puts " DNS: #{dns_servers.join(', ')}".cyan
61
+ end
62
+
63
+ # Configure hostname if provided
64
+ if hostname
65
+ body["HostName"] = hostname
66
+ puts " Hostname: #{hostname}".cyan
67
+ end
68
+ end
69
+
70
+ response = authenticated_request(
71
+ :patch,
72
+ "/redfish/v1/Managers/1/EthernetInterfaces/1",
73
+ body: body.to_json,
74
+ headers: { 'Content-Type' => 'application/json' }
75
+ )
76
+
77
+ if response.status.between?(200, 299)
78
+ puts "BMC network configured successfully.".green
79
+ puts "WARNING: BMC may restart network services. Connection may be lost.".yellow if ip_address
80
+ true
81
+ else
82
+ raise Error, "Failed to configure BMC network: #{response.status} - #{response.body}"
83
+ end
84
+ end
85
+
86
+ def set_bmc_dhcp
87
+ # Convenience method
88
+ set_bmc_network(dhcp: true)
89
+ end
90
+ end
91
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Supermicro
4
- VERSION = "0.1.4"
4
+ VERSION = "0.1.6"
5
5
  end
data/lib/supermicro.rb CHANGED
@@ -52,4 +52,5 @@ require 'supermicro/boot'
52
52
  require 'supermicro/system_config'
53
53
  require 'supermicro/utility'
54
54
  require 'supermicro/license'
55
+ require 'supermicro/network'
55
56
  require 'supermicro/client'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: supermicro
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-08-28 00:00:00.000000000 Z
11
+ date: 2025-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -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