Fork Vasum on GitHub Official Vasum Wiki on Tizen.org
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
vasum::lxc::LxcZone Class Reference

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
 
LxcZoneoperator= (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
 

Detailed Description

A class wrapping lxc container.

Member Typedef Documentation

typedef std::function<int()> vasum::lxc::LxcZone::Call

Member Enumeration Documentation

Enumerator
STOPPED 
STARTING 
RUNNING 
STOPPING 
ABORTING 
FREEZING 
FROZEN 
THAWED 

Constructor & Destructor Documentation

vasum::lxc::LxcZone::LxcZone ( const std::string &  lxcPath,
const std::string &  zoneName 
)

LxcZone constructor.

Parameters
lxcPathpath where zones lives
zoneNamename of zone
vasum::lxc::LxcZone::~LxcZone ( )
vasum::lxc::LxcZone::LxcZone ( const LxcZone )
delete

Member Function Documentation

bool vasum::lxc::LxcZone::create ( const std::string &  templatePath,
const char *const *  argv 
)

Create zone.

Parameters
templatePathtemplate from which zone will be created
argvadditional 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.

Parameters
[in]pathPath in container where file shall be created
[in]flagsFlags 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]modePermissions with which file is created
[out]fdPtrPointer to opened file descriptor.
Returns
True on success, false on failure.
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.

Exceptions
LxcExceptionif 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)?

LxcZone& vasum::lxc::LxcZone::operator= ( const LxcZone )
delete
bool vasum::lxc::LxcZone::reboot ( )

Reboot zone.

void vasum::lxc::LxcZone::refresh ( )
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

Parameters
callfunction object to run
bool vasum::lxc::LxcZone::setRunLevel ( int  runLevel)
private
bool vasum::lxc::LxcZone::shutdown ( int  timeout)

Gracefully shutdown zone.

bool vasum::lxc::LxcZone::start ( const char *const *  argv)

Start zone.

Parameters
argvinit process with arguments
bool vasum::lxc::LxcZone::stop ( )

Immediate stop the zone It kills all processes within this zone.

std::string vasum::lxc::LxcZone::toString ( State  state)
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.

Returns
false on timeout

Member Data Documentation

lxc_container* vasum::lxc::LxcZone::mLxcContainer
private

The documentation for this class was generated from the following files: