radfish 0.1.2 → 0.1.4

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: c2534886d2e0c3a44557ba45fd676bc906ae16264722482edb048673196e0ae6
4
- data.tar.gz: 89e181a9cb4ca8522a0cac8207df8179fac3498bd8e3d6a1fc43d07a76c33cfc
3
+ metadata.gz: 6fb2656b390f3016128a43472976efddf6593d7e30f3e498de88ed63122d6f75
4
+ data.tar.gz: 696317fe19cbceef762da5e5ab4dad28c0b8a1f923a5677fdfcfd551f84225d5
5
5
  SHA512:
6
- metadata.gz: 8c11bd5b855ae57164589e4e251c0537b31a38f13a29fde244ca20a232bf03067541e6b299c19153dec2676cdcb35b1977a8b68150f7d093f6799b159b2d9aa8
7
- data.tar.gz: ee6d258fa7c775222c0b3584c68489ae7dc0868081cfcb87dfa43b01afa1d97b4b17a2776cb4b6ae023581cab52e800a8bbd49449cef6616c9e1aca6f63e270a
6
+ metadata.gz: e9ba57f9683e6177abd5bce2481e3e4338e75b04769c160c20c5596094bea4a4b8b0e59fdca9a8473f350fcc2cab2d6d50a88f456f147ebdd23ea54cbe47f1f6
7
+ data.tar.gz: e51c1b2ec7fc3013fa65661868dbc9a1c655009f58f0c537966991b2575af45f72a72979cd78acf8b6d4902e5460689821bb524abbf95b97fb08c1d9e72029d1
data/lib/radfish/cli.rb CHANGED
@@ -74,6 +74,13 @@ module Radfish
74
74
  when 'status', 'state'
75
75
  status = client.power_status
76
76
  output_result({ power_status: status }, "Power Status: #{status}", status == 'On' ? :green : :yellow)
77
+ when 'consumption', 'usage', 'watts'
78
+ begin
79
+ watts = client.power_consumption_watts
80
+ output_result({ power_consumption_watts: watts }, "Power Consumption: #{watts}W", :green)
81
+ rescue NotImplementedError
82
+ error "Power consumption not supported for this vendor"
83
+ end
77
84
  when 'on'
78
85
  result = client.power_on
79
86
  output_result({ success: result }, result ? "System powered on" : "Failed to power on")
@@ -96,7 +103,7 @@ module Radfish
96
103
  output_result({ success: result }, result ? "Power cycle initiated" : "Failed to power cycle")
97
104
  else
98
105
  error "Unknown power command: #{subcommand}"
99
- puts "Available: status, on, off, force-off, restart, force-restart, cycle"
106
+ puts "Available: status, on, off, force-off, restart, force-restart, cycle, consumption"
100
107
  puts "Use --force flag with 'off' or 'restart' to skip graceful shutdown"
101
108
  end
102
109
  end
@@ -370,6 +377,64 @@ module Radfish
370
377
  end
371
378
  end
372
379
 
380
+ # Network Commands
381
+ desc "network SUBCOMMAND", "BMC network configuration"
382
+ option :ip, desc: "IP address to set"
383
+ option :mask, desc: "Subnet mask"
384
+ option :gateway, desc: "Gateway address"
385
+ option :dns1, desc: "Primary DNS server"
386
+ option :dns2, desc: "Secondary DNS server"
387
+ option :hostname, desc: "BMC hostname"
388
+ def network(subcommand = 'show')
389
+ with_client do |client|
390
+ case subcommand
391
+ when 'show', 'get', 'status'
392
+ data = client.get_bmc_network
393
+ if options[:json]
394
+ puts JSON.pretty_generate(data)
395
+ else
396
+ puts "=== BMC Network Configuration ===".green
397
+ puts "IP Address: #{data['ipv4_address']}".cyan
398
+ puts "Subnet Mask: #{data['subnet_mask']}".cyan
399
+ puts "Gateway: #{data['gateway']}".cyan
400
+ puts "Mode: #{data['mode']}".cyan
401
+ puts "MAC Address: #{data['mac_address']}".cyan
402
+ puts "Hostname: #{data['hostname']}".cyan if data['hostname']
403
+ puts "FQDN: #{data['fqdn']}".cyan if data['fqdn']
404
+ if data['dns_servers'] && !data['dns_servers'].empty?
405
+ puts "DNS Servers: #{data['dns_servers'].join(', ')}".cyan
406
+ end
407
+ end
408
+ when 'set', 'configure'
409
+ if !options[:ip] && !options[:hostname] && !options[:dns1]
410
+ error "Must provide at least --ip, --hostname, or --dns1"
411
+ return
412
+ end
413
+
414
+ if options[:ip] && !options[:mask]
415
+ error "Must provide --mask when setting --ip"
416
+ return
417
+ end
418
+
419
+ result = client.set_bmc_network(
420
+ ip_address: options[:ip],
421
+ subnet_mask: options[:mask],
422
+ gateway: options[:gateway],
423
+ dns_primary: options[:dns1],
424
+ dns_secondary: options[:dns2],
425
+ hostname: options[:hostname]
426
+ )
427
+ output_result({ success: result }, result ? "Network configured successfully" : "Failed to configure network")
428
+ when 'dhcp'
429
+ result = client.set_bmc_dhcp
430
+ output_result({ success: result }, result ? "BMC set to DHCP mode" : "Failed to set DHCP mode")
431
+ else
432
+ error "Unknown network command: #{subcommand}"
433
+ puts "Available: show, set, dhcp"
434
+ end
435
+ end
436
+ end
437
+
373
438
  # Config Commands
374
439
  desc "config SUBCOMMAND", "Configuration file management"
375
440
  def config(subcommand = 'generate')
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Radfish
4
+ module Core
5
+ module Network
6
+ def get_bmc_network
7
+ raise NotImplementedError, "Adapter must implement #get_bmc_network"
8
+ end
9
+
10
+ def set_bmc_network(ip_address: nil, subnet_mask: nil, gateway: nil,
11
+ dns_primary: nil, dns_secondary: nil, hostname: nil,
12
+ dhcp: false)
13
+ raise NotImplementedError, "Adapter must implement #set_bmc_network"
14
+ end
15
+
16
+ def set_bmc_dhcp
17
+ # Convenience method that calls set_bmc_network with dhcp: true
18
+ set_bmc_network(dhcp: true)
19
+ end
20
+ end
21
+ end
22
+ end
@@ -34,6 +34,10 @@ module Radfish
34
34
  def power_consumption
35
35
  raise NotImplementedError, "Adapter must implement #power_consumption"
36
36
  end
37
+
38
+ def power_consumption_watts
39
+ raise NotImplementedError, "Adapter must implement #power_consumption_watts"
40
+ end
37
41
  end
38
42
  end
39
43
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Radfish
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.4"
5
5
  end
data/lib/radfish.rb CHANGED
@@ -72,6 +72,7 @@ require 'radfish/core/virtual_media'
72
72
  require 'radfish/core/boot'
73
73
  require 'radfish/core/jobs'
74
74
  require 'radfish/core/utility'
75
+ require 'radfish/core/network'
75
76
  require 'radfish/vendor_detector'
76
77
  require 'radfish/client'
77
78
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radfish
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel
@@ -171,6 +171,7 @@ files:
171
171
  - lib/radfish/core/base_client.rb
172
172
  - lib/radfish/core/boot.rb
173
173
  - lib/radfish/core/jobs.rb
174
+ - lib/radfish/core/network.rb
174
175
  - lib/radfish/core/power.rb
175
176
  - lib/radfish/core/session.rb
176
177
  - lib/radfish/core/storage.rb