idrac 0.1.6 → 0.1.7
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/idrac/screenshot.rb +49 -0
- data/lib/idrac/version.rb +1 -1
- 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: 7861b7c63381663cd3f744ddeaf04f8dc05834511dd7d603890737df1f1d0e42
|
4
|
+
data.tar.gz: 10527f9d3a9247578727e6c50c4717427c676b4d9ff553b9cfa7d9ebf85f1e7b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b49ca40714ed11052d56d79cdf5b9b79d3a3006ca34a8fccc8b2d04cfd3323dcfcde3463aaf80ef7a4ce0ad5700f48fbb4e51d77a5c92b9a7783bdbcea2cd8b
|
7
|
+
data.tar.gz: 4ee880173ba0a0b477fb2f70fc81ebabd6586778985198f7e52e46c09460b50bd0dcbab97cb3234ea33e1cb065fb8afa238b574607d16c92db734e0884f0ae89
|
@@ -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
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.
|
4
|
+
version: 0.1.7
|
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
|