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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6f473c02ec107566a4badc6a56c3acaa668ff32853a808f2071b248155e4c63d
4
- data.tar.gz: c5999ddaccfd4ca09f8f60c86d603ccd1db953b265b0ae380d1f8b244e699bb6
3
+ metadata.gz: a25a05a0ca997122323e06a987141d8919bd662d2d7cdb2435fe24789d4ee7ee
4
+ data.tar.gz: aaed9e378c2e0b469e1c820cca17ac8770615ed07e2ee8ba81657a05239a94bd
5
5
  SHA512:
6
- metadata.gz: 52042e73ee2724096d38462b2dfe16d12eb237839ad886f0cb43369bf9dc3fb55380182d5ea064012985ff0136a6788ed9a128c44e56cc8e342d389c4eb71e44
7
- data.tar.gz: d24140fc56d8ee13e61c8da5e5200f64c8d3fed416b3c987a6f505800bb98e36d51ff0dde8a6ab7a4a99f750ada1c8c7200c15348acdb4c9f953bcb5f1b24359
6
+ metadata.gz: 5591347fb9df7593e69bd7718b19b95e7ba50172e2895f77ac34d517e34ee4cf4e1a700a7b975b09a2e76229ffef89051962458f5bf383f90e8df32128afa784
7
+ data.tar.gz: b32c17718b22629c0b52b85ddf0d009db37c4d0c2075d576bc7144616443300f6b501bb0764ba19a78e805f1ab44f667164c7e135b64f569a55aac00ecfa5bb5
@@ -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
@@ -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.5"
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,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
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