Class: OsCtld::ContainerControl::Commands::WithMountns::Frontend

Inherits:
Frontend
  • Object
show all
Defined in:
lib/osctld/container_control/commands/with_mountns.rb

Constant Summary

Constants inherited from Frontend

Frontend::FAILED_RUNNER_GRACE

Instance Attribute Summary

Attributes inherited from Frontend

#command_class, #ct

Instance Method Summary collapse

Methods inherited from Frontend

#cleanup_runner_cgroup, #exec_runner, #fork_runner, #initialize, #reap_failed_runner, #runner_result, #write_runner_failure

Constructor Details

This class inherits a constructor from OsCtld::ContainerControl::Frontend

Instance Method Details

#execute(opts) ⇒ Object

Parameters:

  • opts (Hash)

Options Hash (opts):

  • :ctrc (Container::RunConfiguration, nil)
  • :ns_pid (Integer)
  • :mnt_ns (IO, nil) —

    opened mount namespace

  • :chroot (String, nil)
  • :root_dir (IO, nil) —

    opened chroot directory

  • :switch_to_system (Boolean)
  • :stdout (IO, nil)
  • :block (Proc)


21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/osctld/container_control/commands/with_mountns.rb', line 21

def execute(opts)
  ct.mount

  ret = fork_runner({
    args: [{
      ctrc: opts.fetch(:ctrc, ct.get_run_conf),
      ns_pid: opts[:ns_pid],
      mnt_ns: opts[:mnt_ns],
      chroot: opts[:chroot],
      root_dir: opts[:root_dir],
      switch_to_system: opts.fetch(:switch_to_system, true),
      block: opts[:block]
    }],
    keep_fds: [opts[:mnt_ns], opts[:root_dir]].compact,
    switch_to_system: false,
    stdout: opts[:stdout]
  }.compact)
  ret.ok? ? ret.data : ret
end