Sha256: bb78b915a32f6da3da4c0da8584bfafb4040d555e7a1dc7a2828a2e213494d71

Contents?: true

Size: 1.42 KB

Versions: 4

Compression:

Stored size: 1.42 KB

Contents

module Fog
  module Compute
    class HuaweiCloud
      class Real
        # Get a vnc console for an instance.
        # For microversion < 2.6 as it has been replaced with remote-consoles
        #
        # === 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)
          fixed_microversion = nil
          if microversion_newer_than?('2.5')
            fixed_microversion = @microversion
            @microversion = '2.5'
          end

          body = {
            'os-getVNCConsole' => {
              'type' => console_type
            }
          }
          result = server_action(server_id, body)
          @microversion = fixed_microversion if fixed_microversion
          result
        end
      end

      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
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
fog-huaweicloud-0.0.3 lib/fog/compute/huaweicloud/requests/get_vnc_console.rb
fog-huaweicloud-0.0.2 lib/fog/compute/huaweicloud/requests/get_vnc_console.rb
fog-huaweicloud-0.1.3 lib/fog/compute/huaweicloud/requests/get_vnc_console.rb
fog-huaweicloud-0.1.2 lib/fog/compute/huaweicloud/requests/get_vnc_console.rb