idrac 0.1.6 → 0.1.8

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: 7f9e7e13774b28b39da48892cce8d6de1d6bfd2c4d226c54d584805b4dd886cd
4
- data.tar.gz: 736cc4cb000a46b39a6faba61ffd03ceaf19fe40476171f3b911eb697d0045f0
3
+ metadata.gz: 5a94bc677f6ec7117c98a52a48462be78e1433d445a630369353d86ece9e6c39
4
+ data.tar.gz: f6453f23e3ddd78332adaca17132446baa94953e9346d7644c3c66903106b013
5
5
  SHA512:
6
- metadata.gz: 35d7645d8b5d964ffc7b2dba7382fe0650015686b9eb781b6c7fda75aa6b6ab64b5944bb33c99fa38731309b18b3b232a3d8ed5c0553736e50ef43602a746495
7
- data.tar.gz: 124ee6ee23aef24e7908d4765c2ccf01ca33bcbdf42b0ae7e36175c3b48db7aa0fe400578d6437bd22403959c1a6ccb9177254ef4c34001320f98707d5c46320
6
+ metadata.gz: 916af1bff71865d7cca2e195a47d2725911aebeda2f408dbc05a769d0b874365bdd9d29d15b31de50d46cd4c1e9ffd0a0790e04e08d2c13fb2a0aea8b6f7f655
7
+ data.tar.gz: c7367f3b45afee92a4d9fd54e0f4a4091f54378797e93ed3d73e5143127a764a9e53ab1388ef3c5a212334ac20ab68eba1aaecd73e56b68bb51dc85509d28c58
data/bin/idrac CHANGED
@@ -18,7 +18,7 @@ module IDRAC
18
18
  class_option :password, type: :string, required: true, desc: "iDRAC password"
19
19
  class_option :port, type: :numeric, default: 443, desc: "iDRAC port"
20
20
  class_option :no_ssl, type: :boolean, default: false, desc: "Disable SSL"
21
- class_option :no_verify_ssl, type: :boolean, default: false, desc: "Disable SSL verification"
21
+ class_option :no_verify_ssl, type: :boolean, default: false, desc: "Disable SSL verification (use this for self-signed certificates)"
22
22
 
23
23
  desc "firmware:update PATH", "Update firmware using the specified file"
24
24
  method_option :wait, type: :boolean, default: true, desc: "Wait for the update to complete"
@@ -0,0 +1,49 @@
1
+ require 'httparty'
2
+ require 'nokogiri'
3
+
4
+ module IDRAC
5
+ # Reverse engineered screenshot functionality for iDRAC
6
+ # This uses introspection on how the web UI creates screenshots rather than the Redfish API
7
+ class Screenshot
8
+ attr_reader :client
9
+
10
+ def initialize(client)
11
+ @client = client
12
+ end
13
+
14
+ def capture
15
+ # Login to get the forward URL and cookies
16
+ forward_url = client.login
17
+
18
+ # Extract the key-value pairs from the forward URL (format: index?ST1=ABC,ST2=DEF)
19
+ tokens = forward_url.split("?").last.split(",").inject({}) do |acc, kv|
20
+ k, v = kv.split("=")
21
+ acc[k] = v
22
+ acc
23
+ end
24
+
25
+ # Generate a timestamp for the request
26
+ timestamp_ms = (Time.now.to_f * 1000).to_i
27
+
28
+ # First request to trigger the screenshot capture
29
+ path = "data?get=consolepreview[manual%20#{timestamp_ms}]"
30
+ res = client.get(path: path, headers: tokens)
31
+ raise Error, "Failed to trigger screenshot capture." unless res.code.between?(200, 299)
32
+
33
+ # Wait for the screenshot to be generated
34
+ sleep 2
35
+
36
+ # Second request to get the actual screenshot image
37
+ path = "capconsole/scapture0.png?#{timestamp_ms}"
38
+ res = client.get(path: path, headers: tokens)
39
+ raise Error, "Failed to retrieve screenshot image." unless res.code.between?(200, 299)
40
+
41
+ # Save the screenshot to a file
42
+ filename = "idrac_screenshot_#{timestamp_ms}.png"
43
+ File.open(filename, "wb") { |f| f.write(res.body) }
44
+
45
+ # Return the filename
46
+ filename
47
+ end
48
+ end
49
+ end
data/lib/idrac/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module IDRAC
4
- VERSION = "0.1.6"
4
+ VERSION = "0.1.8"
5
5
  end
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.1.6
4
+ version: 0.1.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jonathan Siegel
@@ -210,6 +210,7 @@ files:
210
210
  - lib/idrac.rb
211
211
  - lib/idrac/client.rb
212
212
  - lib/idrac/firmware.rb
213
+ - lib/idrac/screenshot.rb
213
214
  - lib/idrac/version.rb
214
215
  - sig/idrac.rbs
215
216
  homepage: http://github.com