mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[hp|compute] Add vnc console feature into request layer and server model.
This commit is contained in:
parent
35d6c0a6d0
commit
63617483d4
3 changed files with 62 additions and 5 deletions
|
@ -57,6 +57,7 @@ module Fog
|
|||
request :get_windows_password
|
||||
request :get_security_group
|
||||
request :get_server_details
|
||||
request :get_vnc_console
|
||||
request :list_addresses
|
||||
request :list_flavors
|
||||
request :list_flavors_detail
|
||||
|
|
|
@ -47,11 +47,6 @@ module Fog
|
|||
super
|
||||
end
|
||||
|
||||
def console_output(num_lines)
|
||||
requires :id
|
||||
service.get_console_output(id, num_lines)
|
||||
end
|
||||
|
||||
def metadata
|
||||
@metadata ||= begin
|
||||
Fog::Compute::HP::Metadata.new({
|
||||
|
@ -71,6 +66,20 @@ module Fog
|
|||
self.user_data_encoded = [ascii_userdata].pack('m') # same as Base64.encode64
|
||||
end
|
||||
|
||||
def console_output(num_lines)
|
||||
requires :id
|
||||
service.get_console_output(id, num_lines)
|
||||
end
|
||||
|
||||
def vnc_console_url(type='novnc')
|
||||
requires :id
|
||||
if resp = service.get_vnc_console(id, type).body
|
||||
resp['console']['url']
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
requires :id
|
||||
service.delete_server(id)
|
||||
|
|
47
lib/fog/hp/requests/compute/get_vnc_console.rb
Normal file
47
lib/fog/hp/requests/compute/get_vnc_console.rb
Normal file
|
@ -0,0 +1,47 @@
|
|||
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
|
||||
# * type<~String> - Type of the vnc console, defaults to 'novnc'
|
||||
# ==== Returns
|
||||
# # * response<~Excon::Response>:
|
||||
# * body<~Hash>:
|
||||
# * 'console'
|
||||
# * 'type'<~String> - Type of the vnc console
|
||||
# * 'url'<~String> - Url to access a VNC console of a server from a browser
|
||||
#
|
||||
def get_vnc_console(server_id, type='novnc')
|
||||
body = { 'os-getVNCConsole' => { 'type' => type }}
|
||||
server_action(server_id, body, 200)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class Mock
|
||||
|
||||
def get_vnc_console(server_id, type='novnc')
|
||||
output = {
|
||||
'type' => type,
|
||||
'url' => 'https://region.compute.hpcloud.com/vnc_auto.html?token=123ABX234'
|
||||
}
|
||||
response = Excon::Response.new
|
||||
if list_servers_detail.body['servers'].detect {|_| _['id'] == server_id}
|
||||
response.body = { 'console' => output }
|
||||
response.status = 200
|
||||
else
|
||||
raise Fog::Compute::HP::NotFound
|
||||
end
|
||||
response
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue