Class: RedfishTools::Server

Inherits:
WEBrick::HTTPServer
  • Object
show all
Defined in:
lib/redfish_tools/server.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(datastore, username, password, config = {}) ⇒ Server

Returns a new instance of Server.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/redfish_tools/server.rb', line 12

def initialize(datastore, username, password, config = {})
  super(config)

  @datastore = datastore
  root = datastore.get("/redfish/v1").body
  @login_path = root.dig("Links", "Sessions", "@odata.id")&.chomp("/")
  @username = username
  @password = password

  mount("/", Servlet)
end

Instance Attribute Details

#datastoreObject (readonly)

Returns the value of attribute datastore.



24
25
26
# File 'lib/redfish_tools/server.rb', line 24

def datastore
  @datastore
end

#login_pathObject (readonly)

Returns the value of attribute login_path.



24
25
26
# File 'lib/redfish_tools/server.rb', line 24

def 
  @login_path
end

#passwordObject (readonly)

Returns the value of attribute password.



24
25
26
# File 'lib/redfish_tools/server.rb', line 24

def password
  @password
end

#usernameObject (readonly)

Returns the value of attribute username.



24
25
26
# File 'lib/redfish_tools/server.rb', line 24

def username
  @username
end

Instance Method Details

#basic_auth_headerObject



26
27
28
29
# File 'lib/redfish_tools/server.rb', line 26

def basic_auth_header
  @basic_auth_header ||= "Basic " +
    Base64.strict_encode64("#{username}:#{password}")
end