Class: OvirtSDK4::VmGraphicsConsoleService

Inherits:
Service
  • Object
show all
Defined in:
lib/ovirtsdk4/services.rb,
lib/ovirtsdk4/services.rb

Instance Method Summary collapse

Methods inherited from Service

#inspect, #to_s

Instance Method Details

#get(opts = {}) ⇒ GraphicsConsole

Retrieves the graphics console configuration of the virtual machine.

Important
By default, when the current parameter is not specified, the data returned corresponds to the next execution of the virtual machine. In the current implementation of the system this means that the address and port attributes will not be populated because the system does not know what address and port will be used for the next execution. Since in most cases those attributes are needed, it is strongly advised to aways explicitly include the current parameter with the value true.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :current (Boolean)

    Specifies if the data returned should correspond to the next execution of the virtual machine, or to the current execution.

    Important
    The address and port attributes will not be populated unless the value is true.

    For example, to get data for the current execution of the virtual machine, including the address and port attributes, send a request like this:

    GET /ovit-engine/api/vms/123/graphicsconsoles/456?current=true

    The default value is false.

  • :follow (String)

    Indicates which inner links should be followed. The objects referenced by these links will be fetched as part of the current request. See here for details.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.

Returns:



33270
33271
33272
# File 'lib/ovirtsdk4/services.rb', line 33270

def get(opts = {})
  internal_get(GET, opts)
end

#proxy_ticket(opts = {}) ⇒ Object

Executes the proxy_ticket method.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the generation of the ticket should be performed asynchronously.

  • :proxy_ticket (ProxyTicket)
  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.



33298
33299
33300
# File 'lib/ovirtsdk4/services.rb', line 33298

def proxy_ticket(opts = {})
  internal_action(:proxyticket, :proxy_ticket, PROXY_TICKET, opts)
end

#remote_viewer_connection_file(opts = {}) ⇒ Object

Generates the file which is compatible with remote-viewer client.

Use the following request to generate remote viewer connection file of the graphics console. Note that this action generates the file only if virtual machine is running.

POST /ovirt-engine/api/vms/123/graphicsconsoles/456/remoteviewerconnectionfile

The remoteviewerconnectionfile action does not take any action specific parameters, so the request body should contain an empty action:

<action/>

The response contains the file, which can be used with remote-viewer client.

<action>
  <remote_viewer_connection_file>
    [virt-viewer]
    type=spice
    host=192.168.1.101
    port=-1
    password=123456789
    delete-this-file=1
    fullscreen=0
    toggle-fullscreen=shift+f11
    release-cursor=shift+f12
    secure-attention=ctrl+alt+end
    tls-port=5900
    enable-smartcard=0
    enable-usb-autoshare=0
    usb-filter=null
    tls-ciphers=DEFAULT
    host-subject=O=local,CN=example.com
    ca=...
  </remote_viewer_connection_file>
</action>

E.g., to fetch the content of remote viewer connection file and save it into temporary file, user can use oVirt Python SDK as follows:

# Find the virtual machine:
vm = vms_service.list(search='name=myvm')[0]

# Locate the service that manages the virtual machine, as that is where
# the locators are defined:
vm_service = vms_service.vm_service(vm.id)

# Find the graphic console of the virtual machine:
graphics_consoles_service = vm_service.graphics_consoles_service()
graphics_console = graphics_consoles_service.list()[0]

# Generate the remote viewer connection file:
console_service = graphics_consoles_service.console_service(graphics_console.id)
remote_viewer_connection_file = console_service.remote_viewer_connection_file()

# Write the content to file "/tmp/remote_viewer_connection_file.vv"
path = "/tmp/remote_viewer_connection_file.vv"
with open(path, "w") as f:
    f.write(remote_viewer_connection_file)

When you create the remote viewer connection file, then you can connect to virtual machine graphic console, as follows:

#!/bin/sh -ex

remote-viewer --ovirt-ca-file=/etc/pki/ovirt-engine/ca.pem /tmp/remote_viewer_connection_file.vv

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :remote_viewer_connection_file (String)

    Contains the file which is compatible with remote-viewer client.

    User can use the content of this attribute to create a file, which can be passed to remote-viewer client to connect to virtual machine graphic console.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.



33405
33406
33407
# File 'lib/ovirtsdk4/services.rb', line 33405

def remote_viewer_connection_file(opts = {})
  internal_action(:remoteviewerconnectionfile, :remote_viewer_connection_file, REMOTE_VIEWER_CONNECTION_FILE, opts)
end

#remove(opts = {}) ⇒ Object

Remove the graphics console from the virtual machine.

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :async (Boolean)

    Indicates if the remove should be performed asynchronously.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.



33430
33431
33432
# File 'lib/ovirtsdk4/services.rb', line 33430

def remove(opts = {})
  internal_remove(REMOVE, opts)
end

#service(path) ⇒ Service

Locates the service corresponding to the given path.

Parameters:

  • path (String)

    The path of the service.

Returns:

  • (Service)

    A reference to the service.

Raises:



33486
33487
33488
33489
33490
33491
# File 'lib/ovirtsdk4/services.rb', line 33486

def service(path)
  if path.nil? || path == ''
    return self
  end
  raise Error.new("The path \"#{path}\" doesn't correspond to any service")
end

#ticket(opts = {}) ⇒ Object

Generates a time-sensitive authentication token for accessing this virtual machine’s console.

POST /ovirt-engine/api/vms/123/graphicsconsoles/456/ticket

The client-provided action optionally includes a desired ticket value and/or an expiry time in seconds.

In any case, the response specifies the actual ticket value and expiry used.

<action>
  <ticket>
    <value>abcd12345</value>
    <expiry>120</expiry>
  </ticket>
</action>

Parameters:

  • opts (Hash) (defaults to: {})

    Additional options.

Options Hash (opts):

  • :ticket (Ticket)

    The generated ticket that can be used to access this console.

  • :headers (Hash) — default: {}

    Additional HTTP headers.

  • :query (Hash) — default: {}

    Additional URL query parameters.

  • :timeout (Integer) — default: nil

    The timeout for this request, in seconds. If no value is explicitly given then the timeout set globally for the connection will be used.

  • :wait (Boolean) — default: true

    If true wait for the response.



33475
33476
33477
# File 'lib/ovirtsdk4/services.rb', line 33475

def ticket(opts = {})
  internal_action(:ticket, :ticket, TICKET, opts)
end