mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Add and enable get_console_output request method and add server method console_output. Add test for get_console_output.
This commit is contained in:
parent
c26e8a04db
commit
1805a3a164
4 changed files with 52 additions and 4 deletions
|
@ -39,6 +39,7 @@ module Fog
|
||||||
request :delete_server
|
request :delete_server
|
||||||
request :disassociate_address
|
request :disassociate_address
|
||||||
request :get_address
|
request :get_address
|
||||||
|
request :get_console_output
|
||||||
request :get_flavor_details
|
request :get_flavor_details
|
||||||
request :get_image_details
|
request :get_image_details
|
||||||
request :get_security_group
|
request :get_security_group
|
||||||
|
|
|
@ -41,6 +41,11 @@ module Fog
|
||||||
super
|
super
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def console_output(num_lines)
|
||||||
|
requires :id
|
||||||
|
connection.get_console_output(id, num_lines)
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
requires :id
|
requires :id
|
||||||
connection.delete_server(id)
|
connection.delete_server(id)
|
||||||
|
|
43
lib/fog/hp/requests/compute/get_console_output.rb
Normal file
43
lib/fog/hp/requests/compute/get_console_output.rb
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
module Fog
|
||||||
|
module Compute
|
||||||
|
class HP
|
||||||
|
class Real
|
||||||
|
|
||||||
|
require 'fog/aws/parsers/compute/get_console_output'
|
||||||
|
|
||||||
|
# Retrieve console output for specified instance
|
||||||
|
#
|
||||||
|
# ==== Parameters
|
||||||
|
# * server_id<~Integer> - Id of instance to get console output from
|
||||||
|
# * num_lines<~Integer> - Number of lines of console output from the end
|
||||||
|
# ==== Returns
|
||||||
|
# # * response<~Excon::Response>:
|
||||||
|
# * body<~Hash>:
|
||||||
|
# * 'output'<~String> - Console output
|
||||||
|
#
|
||||||
|
def get_console_output(server_id, num_lines)
|
||||||
|
body = { 'os-getConsoleOutput' => { 'length' => num_lines }}
|
||||||
|
server_action(server_id, body, 200)
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
class Mock
|
||||||
|
|
||||||
|
def get_console_output(server_id, num_lines)
|
||||||
|
output = ""
|
||||||
|
response = Excon::Response.new
|
||||||
|
if list_servers_detail.body['servers'].detect {|_| _['id'] == server_id}
|
||||||
|
(1..num_lines).each {|i| output += "Console Output Line #{i} \r\n"}
|
||||||
|
response.body = { 'output' => output }
|
||||||
|
response.status = 200
|
||||||
|
else
|
||||||
|
raise Fog::Compute::HP::NotFound
|
||||||
|
end
|
||||||
|
response
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -31,7 +31,7 @@ Shindo.tests('Fog::Compute[:hp] | server requests', ['hp']) do
|
||||||
}
|
}
|
||||||
|
|
||||||
@get_console_output_format = {
|
@get_console_output_format = {
|
||||||
|
'output' => String
|
||||||
}
|
}
|
||||||
|
|
||||||
@base_image_id = ENV["BASE_IMAGE_ID"] ||= 1242
|
@base_image_id = ENV["BASE_IMAGE_ID"] ||= 1242
|
||||||
|
@ -87,9 +87,8 @@ Shindo.tests('Fog::Compute[:hp] | server requests', ['hp']) do
|
||||||
|
|
||||||
Fog::Compute[:hp].servers.get(@server_id).wait_for { ready? }
|
Fog::Compute[:hp].servers.get(@server_id).wait_for { ready? }
|
||||||
|
|
||||||
tests("#get_console_output('#{@server_id}')").formats(@get_console_output_format) do
|
tests("#get_console_output('#{@server_id}', 10)").formats(@get_console_output_format) do
|
||||||
pending
|
Fog::Compute[:hp].get_console_output(@server_id, 10).body
|
||||||
Fog::Compute[:hp].get_console_output(@server_id).body
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Fog::Compute[:hp].servers.get(@server_id).wait_for { ready? }
|
Fog::Compute[:hp].servers.get(@server_id).wait_for { ready? }
|
||||||
|
|
Loading…
Reference in a new issue