26 #include "IDobbyUtils.h"
27 #include "DobbyLogger.h"
28 #include "ContainerId.h"
30 #include <json/json.h>
51 explicit DobbyRunC(
const std::shared_ptr<IDobbyUtils> &utils,
52 const std::shared_ptr<const IDobbySettings> &settings);
56 enum class ContainerStatus
70 std::string bundlePath;
71 ContainerStatus status;
76 const std::shared_ptr<const DobbyBundle> &bundle,
77 const std::shared_ptr<const IDobbyStream> &console,
78 const std::list<int> &files = std::list<int>(),
79 const std::string& customConfigPath =
"")
const;
81 bool destroy(
const ContainerId &
id,
const std::shared_ptr<const IDobbyStream> &console,
bool force =
false)
const;
82 bool start(
const ContainerId &
id,
const std::shared_ptr<const IDobbyStream> &console)
const;
87 const std::string &options,
88 const std::string &command)
const;
91 std::list<ContainerListItem>
list()
const;
95 const std::shared_ptr<const DobbyBundle> &bundle,
96 const std::shared_ptr<const IDobbyStream> &console,
97 const std::list<int> &files = std::list<int>())
const;
100 const std::string getWorkingDir()
const;
103 pid_t
forkExecRunC(
const std::vector<const char *> &args,
104 const std::initializer_list<const char *> &envs,
105 const std::list<int> &files = std::list<int>(),
106 const std::shared_ptr<const IDobbyStream> &stdoutStream =
nullptr,
107 const std::shared_ptr<const IDobbyStream> &stderrStream =
nullptr)
const;
109 pid_t
readPidFile(
const std::string pidFilePath)
const;
114 const std::shared_ptr<IDobbyUtils> mUtilities;
115 const std::string mRuncPath;
117 const std::string mWorkingDir;
118 const std::string mLogDir;
119 const std::string mLogFilePath;
120 const std::string mConsoleSocket;
A wrapper around a std::string, used to add some type definition to to an id and also to sanity check...
Definition: ContainerId.h:41
Simple class that just creates a subdir in the bundles directory.
Definition: DobbyBundle.h:46
Wrapper around the runc command line app.
Definition: DobbyRunC.h:49
bool destroy(const ContainerId &id, const std::shared_ptr< const IDobbyStream > &console, bool force=false) const
Runs the runc command line tool with the 'delete' command.
Definition: DobbyRunC.cpp:720
bool killCont(const ContainerId &id, int signal, bool all=false) const
Runs the runc command line tool with the 'kill' command.
Definition: DobbyRunC.cpp:395
std::list< ContainerListItem > list() const
Runs the runc command line tool with the 'list' command.
Definition: DobbyRunC.cpp:930
bool start(const ContainerId &id, const std::shared_ptr< const IDobbyStream > &console) const
Starts a container created with create command.
Definition: DobbyRunC.cpp:343
pid_t readPidFile(const std::string pidFilePath) const
Reads file with pid of the container and converts it into pid_t type variable.
Definition: DobbyRunC.cpp:1295
ContainerStatus state(const ContainerId &id) const
Runs the runc command line tool with the 'state' command.
Definition: DobbyRunC.cpp:839
bool pause(const ContainerId &id) const
Runs the runc command line tool with the 'pause' command.
Definition: DobbyRunC.cpp:504
pid_t forkExecRunC(const std::vector< const char * > &args, const std::initializer_list< const char * > &envs, const std::list< int > &files=std::list< int >(), const std::shared_ptr< const IDobbyStream > &stdoutStream=nullptr, const std::shared_ptr< const IDobbyStream > &stderrStream=nullptr) const
Performs a fork then exec of the runC binary with the supplied args.
Definition: DobbyRunC.cpp:1083
std::pair< pid_t, pid_t > create(const ContainerId &id, const std::shared_ptr< const DobbyBundle > &bundle, const std::shared_ptr< const IDobbyStream > &console, const std::list< int > &files=std::list< int >(), const std::string &customConfigPath="") const
Creates the container but doesn't start the init process.
Definition: DobbyRunC.cpp:140
bool resume(const ContainerId &id) const
Runs the runc command line tool with the 'resume' command.
Definition: DobbyRunC.cpp:549
std::pair< pid_t, pid_t > exec(const ContainerId &id, const std::string &options, const std::string &command) const
Runs the crun command line tool with the 'exec' command.
Definition: DobbyRunC.cpp:604
ContainerStatus getContainerStatusFromJson(const Json::Value &state) const
Gets the container status from the json object.
Definition: DobbyRunC.cpp:798
pid_t run(const ContainerId &id, const std::shared_ptr< const DobbyBundle > &bundle, const std::shared_ptr< const IDobbyStream > &console, const std::list< int > &files=std::list< int >()) const
Runs the runc command line tool with the 'run' command.
Definition: DobbyRunC.cpp:94
Interface for all character streams used in the daemon.
Definition: DobbyStream.h:41
Definition: DobbyRunC.h:67