Class: OsCtld::ContainerControl::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/osctld/container_control/command.rb

Overview

Container control is used to interact with LXC containers

In order to work manipulate LXC containers, osctld has to fork and switch to the container's system user. This class then provides an interface for various actions that manipulate the LXC containers.

Each command is a subclass of this class. It needs to define two classes: `Frontend` as a subclass of Frontend and `Runner` as a subclass of Runner. #run! invokes `Frontend` from osctld in daemon mode, where it is running as root. The frontend initiates the runner, which is run in a forked process and as a different user, e.g. using Frontend#pipe_runner. The runner can return data, which the frontend can transform and return to the caller.

Class Method Summary collapse

Class Method Details

.run!(ct, *args) ⇒ Object

Call command frontend

See the command for what arguments it accepts and what it returns.

Parameters:

  • ct (Container)
  • args (Array)

    command arguments

Raises:



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/osctld/container_control/command.rb', line 24

def self.run!(ct, *args)
  f = self::Frontend.new(self, ct)
  ret = f.execute(*args)

  if ret.is_a?(ContainerControl::Result)
    if ret.ok?
      ret.data
    else
      raise ContainerControl::Error, ret.message
    end
  else
    ret
  end
end