1
0
Fork 0
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:
Rupak Ganguly 2012-04-18 14:09:08 -04:00
parent c26e8a04db
commit 1805a3a164
4 changed files with 52 additions and 4 deletions

View file

@ -39,6 +39,7 @@ module Fog
request :delete_server
request :disassociate_address
request :get_address
request :get_console_output
request :get_flavor_details
request :get_image_details
request :get_security_group

View file

@ -41,6 +41,11 @@ module Fog
super
end
def console_output(num_lines)
requires :id
connection.get_console_output(id, num_lines)
end
def destroy
requires :id
connection.delete_server(id)

View 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

View file

@ -31,7 +31,7 @@ Shindo.tests('Fog::Compute[:hp] | server requests', ['hp']) do
}
@get_console_output_format = {
'output' => String
}
@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? }
tests("#get_console_output('#{@server_id}')").formats(@get_console_output_format) do
pending
Fog::Compute[:hp].get_console_output(@server_id).body
tests("#get_console_output('#{@server_id}', 10)").formats(@get_console_output_format) do
Fog::Compute[:hp].get_console_output(@server_id, 10).body
end
Fog::Compute[:hp].servers.get(@server_id).wait_for { ready? }