Skip to content
This repository has been archived by the owner on Jul 17, 2019. It is now read-only.

Commit

Permalink
Merge pull request #23 from profmaad/master
Browse files Browse the repository at this point in the history
Fix login and screenshot functionality for iDRAC7/8
  • Loading branch information
nferch committed Nov 2, 2015
2 parents 1ab2aa1 + 8f53267 commit 9273424
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/moob.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def self.show_console_preview lom
def self.save_console_preview lom
imgfile, headers = lom.fetch_console_preview

timestamp=Time.parse(headers['Last-modified'])
fileext=headers['Content-type'].split('/')[1]
timestamp=Time.parse(headers['Last-modified'] || headers['Last-Modified'])
fileext=(headers['Content-type'] || headers['Content-Type']).split('/')[1]

filename="#{lom.hostname}-#{timestamp.utc.iso8601(0)}.#{fileext}"

Expand Down
4 changes: 3 additions & 1 deletion lib/moob/idrac6.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,9 @@ def fetch_console_preview
req = @session.get_file "capconsole/scapture0.png?#{Time.now.utc.to_i}", imgfile.path

raise ResponseError.new req unless req.status == 200
raise UnexpectedContentError.new req unless req.headers['Content-type'] =~ /image\//

content_type = req.headers['Content-type'] || req.headers['Content-Type']
raise "Unexpected content type #{content_type}, expected 'image/' prefix" unless content_type =~ /image\//

return imgfile, req.headers
end
Expand Down
6 changes: 5 additions & 1 deletion lib/moob/idrac7.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def authenticate
@session.handle_cookies nil
# Needed for new version of iDrac emb web server to even responde
@session.headers['Accept-Language'] = 'en-US,en;q=0.8,sv;q=0.6'
# idrac7 responds with a 404 if the request is sent for html is sent without encoding headers
@session.headers['Accept-Encoding'] = 'gzip,deflate,sdch'

login = @session.get 'login.html'

Expand Down Expand Up @@ -223,7 +225,9 @@ def fetch_console_preview
req = @session.get_file "capconsole/scapture0.png?#{Time.now.utc.to_i}", imgfile.path

raise ResponseError.new req unless req.status == 200
raise UnexpectedContentError.new req unless req.headers['Content-type'] =~ /image\//

content_type = req.headers['Content-type'] || req.headers['Content-Type']
raise "Unexpected content type #{content_type}, expected 'image/' prefix" unless content_type =~ /image\//

return imgfile, req.headers
end
Expand Down
4 changes: 3 additions & 1 deletion lib/moob/idrac8.rb
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ def fetch_console_preview
req = @session.get_file "capconsole/scapture0.png?#{Time.now.utc.to_i}", imgfile.path

raise ResponseError.new req unless req.status == 200
raise UnexpectedContentError.new req unless req.headers['Content-type'] =~ /image\//

content_type = req.headers['Content-type'] || req.headers['Content-Type']
raise "Unexpected content type #{content_type}, expected 'image/' prefix" unless content_type =~ /image\//

return imgfile, req.headers
end
Expand Down

0 comments on commit 9273424

Please sign in to comment.