Module: ForemanFogProxmox::ProxmoxConsole

Included in:
Proxmox
Defined in:
app/models/foreman_fog_proxmox/proxmox_console.rb

Instance Method Summary collapse

Instance Method Details

#console(uuid) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/models/foreman_fog_proxmox/proxmox_console.rb', line 22

def console(uuid)
  vm = find_vm_by_uuid(uuid)
  options = {}
  if vm.container?
    type_console = 'vnc'
    options.store(:console, type_console)
  else
    type_console = vm.config.type_console
  end
  options.store(:websocket, 1) if type_console == 'vnc'
  begin
    vnc_console = vm.start_console(options)
    WsProxy.start(:host => host, :host_port => vnc_console['port'], :password => vnc_console['ticket']).merge(
      :name => vm.name, :type => type_console
    )
  rescue StandardError => e
    logger.error(e)
    raise ::Foreman::Exception, _('%<s>s console is not supported at this time') % type_console
  end
end