mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[rackspace] Add support for get_vnc_console request to compute_v2
This PR basically copies the relevant code from the OpenStack provider
This commit is contained in:
parent
0351e96aa8
commit
5cc782933c
5 changed files with 65 additions and 1 deletions
|
@ -117,6 +117,7 @@ module Fog
|
|||
request :list_virtual_interfaces
|
||||
request :create_virtual_interface
|
||||
request :delete_virtual_interface
|
||||
request :get_vnc_console
|
||||
|
||||
class Mock < Fog::Rackspace::Service
|
||||
include Fog::Rackspace::MockData
|
||||
|
|
|
@ -120,7 +120,7 @@ To see a list of requests supported by the service:
|
|||
|
||||
This returns:
|
||||
|
||||
:list_servers, :get_server, :create_server, :update_server, :delete_server, :change_server_password, :reboot_server, :rebuild_server, :resize_server, :confirm_resize_server, :revert_resize_server, :list_images, :get_image, :list_flavors, :get_flavor, :attach_volume, :get_attachment, :list_attachments, :delete_attachment
|
||||
:list_servers, :get_server, :create_server, :update_server, :delete_server, :change_server_password, :reboot_server, :rebuild_server, :resize_server, :confirm_resize_server, :revert_resize_server, :list_images, :get_image, :list_flavors, :get_flavor, :attach_volume, :get_attachment, :list_attachments, :delete_attachment, :get_vnc_console
|
||||
|
||||
|
||||
#### Example Request
|
||||
|
|
|
@ -618,6 +618,20 @@ module Fog
|
|||
@virtual_interfaces ||= Fog::Compute::RackspaceV2::VirtualInterfaces.new :server => self, :service => service
|
||||
end
|
||||
|
||||
# VNC Console URL
|
||||
# @param [String] Type of vnc console to get ('novnc' or 'xvpvnc')
|
||||
# @return [String] returns URL to vnc console
|
||||
# @raise [Fog::Compute::RackspaceV2::NotFound] - HTTP 404
|
||||
# @raise [Fog::Compute::RackspaceV2::BadRequest] - HTTP 400
|
||||
# @raise [Fog::Compute::RackspaceV2::InternalServerError] - HTTP 500
|
||||
# @raise [Fog::Compute::RackspaceV2::ServiceError]
|
||||
# @note This URL will time out due to inactivity
|
||||
def get_vnc_console(console_type = "xvpvnc")
|
||||
requires :identity
|
||||
data = service.get_vnc_console(identity, console_type)
|
||||
data.body['console']['url']
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def adminPass=(new_admin_pass)
|
||||
|
|
45
lib/fog/rackspace/requests/compute_v2/get_vnc_console.rb
Normal file
45
lib/fog/rackspace/requests/compute_v2/get_vnc_console.rb
Normal file
|
@ -0,0 +1,45 @@
|
|||
module Fog
|
||||
module Compute
|
||||
class RackspaceV2
|
||||
class Real
|
||||
# Get a vnc console for an instance.
|
||||
#
|
||||
# === Parameters
|
||||
# * server_id <~String> - The ID of the server.
|
||||
# * console_type <~String> - Type of vnc console to get ('novnc' or 'xvpvnc').
|
||||
# === Returns
|
||||
# * response <~Excon::Response>:
|
||||
# * body <~Hash>:
|
||||
# * url <~String>
|
||||
# * type <~String>
|
||||
def get_vnc_console(server_id, console_type)
|
||||
data = {
|
||||
'os-getVNCConsole' => {
|
||||
'type' => console_type
|
||||
}
|
||||
}
|
||||
request(
|
||||
:body => Fog::JSON.encode(data),
|
||||
:expects => [200],
|
||||
:method => 'POST',
|
||||
:path => "servers/#{server_id}/action"
|
||||
)
|
||||
end # def get_vnc_console
|
||||
end # class Real
|
||||
|
||||
class Mock
|
||||
def get_vnc_console(server_id, console_type)
|
||||
response = Excon::Response.new
|
||||
response.status = 200
|
||||
response.body = {
|
||||
"console" => {
|
||||
"url" => "http://192.168.27.100:6080/vnc_auto.html?token=c3606020-d1b7-445d-a88f-f7af48dd6a20",
|
||||
"type" => "novnc"
|
||||
}
|
||||
}
|
||||
response
|
||||
end # def get_vnc_console
|
||||
end # class Mock
|
||||
end # class OpenStack
|
||||
end # module Compute
|
||||
end # module Fog
|
|
@ -164,5 +164,9 @@ Shindo.tests('Fog::Compute::RackspaceV2 | server_tests', ['rackspace']) do
|
|||
tests('#delete_server').succeeds do
|
||||
service.delete_server(server_id)
|
||||
end
|
||||
|
||||
tests('#get_vnc_console').succeeds do
|
||||
service.get_vnc_console(server_id, 'novnc')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue