Class: OsCtld::ContainerControl::Command
- Inherits:
-
Object
- Object
- OsCtld::ContainerControl::Command
- 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. Command.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#exec_runner or Frontend#fork_runner. The runner can return data, which the frontend can transform and return to the caller.
Direct Known Subclasses
OsCtld::ContainerControl::Commands::Exec, OsCtld::ContainerControl::Commands::Freeze, OsCtld::ContainerControl::Commands::GetHostname, OsCtld::ContainerControl::Commands::Mount, OsCtld::ContainerControl::Commands::Reboot, OsCtld::ContainerControl::Commands::Runscript, OsCtld::ContainerControl::Commands::State, OsCtld::ContainerControl::Commands::Stop, OsCtld::ContainerControl::Commands::StopByHalt, OsCtld::ContainerControl::Commands::StopRunit, OsCtld::ContainerControl::Commands::Syscmd, OsCtld::ContainerControl::Commands::Unfreeze, OsCtld::ContainerControl::Commands::Unmount, OsCtld::ContainerControl::Commands::VethName, OsCtld::ContainerControl::Commands::Wall, OsCtld::ContainerControl::Commands::WithMountns, OsCtld::ContainerControl::Commands::WithRootfs
Class Method Summary collapse
-
.run!(ct) ⇒ Object
Call command frontend.
Class Method Details
.run!(ct) ⇒ Object
Call command frontend
See the command for what arguments it accepts and what it returns.
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/osctld/container_control/command.rb', line 29 def self.run!(ct, *, **) f = self::Frontend.new(self, ct) ret = f.execute(*, **) if ret.is_a?(ContainerControl::Result) if ret.ok? ret.data elsif ret.user_runner? raise ContainerControl::UserRunnerError, ret. else raise ContainerControl::Error, ret. end else ret end end |