A class wrapping lxc container. More...
#include <zone.hpp>
Public Types | |
enum | State { State::STOPPED, State::STARTING, State::RUNNING, State::STOPPING, State::ABORTING, State::FREEZING, State::FROZEN, State::THAWED } |
typedef std::function< int()> | Call |
Public Member Functions | |
LxcZone (const std::string &lxcPath, const std::string &zoneName) | |
LxcZone constructor. More... | |
~LxcZone () | |
LxcZone (const LxcZone &)=delete | |
LxcZone & | operator= (const LxcZone &)=delete |
std::string | getName () const |
Get zone name. More... | |
std::string | getConfigItem (const std::string &key) |
Get item from lxc config file. More... | |
bool | isDefined () |
Is zone defined (created)? More... | |
State | getState () |
Get zone state. More... | |
bool | waitForState (State state, int timeout) |
Wait till zone is in specified state. More... | |
bool | create (const std::string &templatePath, const char *const *argv) |
Create zone. More... | |
bool | destroy () |
Destroy zone. More... | |
bool | start (const char *const *argv) |
Start zone. More... | |
bool | stop () |
Immediate stop the zone It kills all processes within this zone. More... | |
bool | reboot () |
Reboot zone. More... | |
bool | shutdown (int timeout) |
Gracefully shutdown zone. More... | |
bool | freeze () |
Freeze (pause/lock) zone. More... | |
bool | unfreeze () |
Unfreeze zone. More... | |
pid_t | getInitPid () const |
Get pid of init process. More... | |
bool | runInZone (Call &call) |
Attach to the Zone and run the call. More... | |
bool | createFile (const std::string &path, const std::int32_t flags, const std::int32_t mode, int *fdPtr) |
Create a file inside the zone and return it's file descriptor. More... | |
Static Public Member Functions | |
static std::string | toString (State state) |
String representation of state. More... | |
Private Member Functions | |
bool | setRunLevel (int runLevel) |
void | refresh () |
Private Attributes | |
lxc_container * | mLxcContainer |
A class wrapping lxc container.
typedef std::function<int()> vasum::lxc::LxcZone::Call |
|
strong |
vasum::lxc::LxcZone::LxcZone | ( | const std::string & | lxcPath, |
const std::string & | zoneName | ||
) |
LxcZone constructor.
lxcPath | path where zones lives |
zoneName | name of zone |
vasum::lxc::LxcZone::~LxcZone | ( | ) |
|
delete |
bool vasum::lxc::LxcZone::create | ( | const std::string & | templatePath, |
const char *const * | argv | ||
) |
Create zone.
templatePath | template from which zone will be created |
argv | additional template arguments |
bool vasum::lxc::LxcZone::createFile | ( | const std::string & | path, |
const std::int32_t | flags, | ||
const std::int32_t | mode, | ||
int * | fdPtr | ||
) |
Create a file inside the zone and return it's file descriptor.
[in] | path | Path in container where file shall be created |
[in] | flags | Flags used when creating file. Note that the method already provides O_CREAT and O_EXCL flags. User must provide the function with O_RDWR/O_RDONLY/O_WRONLY flag explicitly. |
[in] | mode | Permissions with which file is created |
[out] | fdPtr | Pointer to opened file descriptor. |
bool vasum::lxc::LxcZone::destroy | ( | ) |
Destroy zone.
bool vasum::lxc::LxcZone::freeze | ( | ) |
Freeze (pause/lock) zone.
std::string vasum::lxc::LxcZone::getConfigItem | ( | const std::string & | key | ) |
Get item from lxc config file.
LxcException | if key not found |
pid_t vasum::lxc::LxcZone::getInitPid | ( | ) | const |
Get pid of init process.
std::string vasum::lxc::LxcZone::getName | ( | ) | const |
Get zone name.
LxcZone::State vasum::lxc::LxcZone::getState | ( | ) |
Get zone state.
bool vasum::lxc::LxcZone::isDefined | ( | ) |
Is zone defined (created)?
bool vasum::lxc::LxcZone::reboot | ( | ) |
Reboot zone.
|
private |
bool vasum::lxc::LxcZone::runInZone | ( | Call & | call | ) |
Attach to the Zone and run the call.
This call will fork, so ensure the call object will withstand this
call | function object to run |
|
private |
bool vasum::lxc::LxcZone::shutdown | ( | int | timeout | ) |
Gracefully shutdown zone.
bool vasum::lxc::LxcZone::start | ( | const char *const * | argv | ) |
Start zone.
argv | init process with arguments |
bool vasum::lxc::LxcZone::stop | ( | ) |
Immediate stop the zone It kills all processes within this zone.
|
static |
String representation of state.
bool vasum::lxc::LxcZone::unfreeze | ( | ) |
Unfreeze zone.
bool vasum::lxc::LxcZone::waitForState | ( | State | state, |
int | timeout | ||
) |
Wait till zone is in specified state.
|
private |