Class: OSC::VNC::Session

Inherits:
Object
  • Object
show all
Includes:
Listenable
Defined in:
lib/osc/vnc/session.rb

Overview

Provides a way for developers to create and submit VNC sessions to the OSC batch systems. Also, developers are now able to submit any server session to the batch systems whether it is VNC or not following the same principles as a VNC session.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Listenable

#create_listen, #read_listen

Constructor Details

#initialize(batch, script, opts = {}) ⇒ Session

Returns a new instance of Session.

Parameters:

  • job (PBS::Batch)

    The batch object used.

  • script (ScriptView)

    The batch script used.

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

    The options used to construct a session.



21
22
23
24
# File 'lib/osc/vnc/session.rb', line 21

def initialize(batch, script, opts = {})
  @batch = batch
  @script = script
end

Instance Attribute Details

#batchPBS::Batch (readonly)

Returns The batch object used.

Returns:

  • (PBS::Batch)

    The batch object used.



13
14
15
# File 'lib/osc/vnc/session.rb', line 13

def batch
  @batch
end

#scriptScriptView (readonly)

Returns The batch script used.

Returns:



16
17
18
# File 'lib/osc/vnc/session.rb', line 16

def script
  @script
end

Instance Method Details

#submit(opts = {}) ⇒ Session

Submit the VNC job to the defined batch server.

Parameters:

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

    The options used in job submission.

Options Hash (opts):

  • :headers (Hash)

    The headers for the PBS job.

  • :resources (Hash)

    The resources for the PBS job.

  • :envvars (Hash)

    The environment variables for the PBS job.

Returns:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/osc/vnc/session.rb', line 33

def submit(opts = {})
  script.valid? # check if script is valid (can raise errors here)

  h = opts.fetch(:headers, {})
  r = opts.fetch(:resources, {})
  e = opts.fetch(:envvars, {})

  # Create tcp listen server if requested
  listen_server = _create_listen_server(e) if script.tcp_server?

  id = batch.submit_string(
    script.render,
    headers: _get_headers(h),
    resources: _get_resources(r),
    envvars: _get_envvars(e)
  )

  _write_listen_conn_info(listen_server) if script.tcp_server?

  id
end