softwarecontainer
0.18.0-739e8d7 2017-05-04
|
Public Member Functions | |
SoftwareContainerAgent (Glib::RefPtr< Glib::MainContext > mainLoopContext, std::shared_ptr< Config > config, std::shared_ptr< SoftwareContainerFactory > factory, std::shared_ptr< ContainerUtilityInterface > utility) | |
creates a new agent object and runs some initialization More... | |
std::vector< ContainerID > | listContainers () |
get a list of all containers More... | |
std::vector< std::string > | listCapabilities () |
List all capabilities that the user can set. More... | |
void | deleteContainer (ContainerID containerID) |
delete container by ID More... | |
SoftwareContainerPtr | getContainer (ContainerID containerID) |
Fetches a pointer to a SoftwareContainer matching an ID. More... | |
ContainerID | createContainer (const std::string &config) |
Create a new container. More... | |
pid_t | execute (ContainerID containerID, const std::string &cmdLine, const std::string &workingDirectory, const std::string &outputFile, const EnvironmentVariables &env, std::function< void(pid_t, int)> listener) |
Launch the given command in a the given container. More... | |
void | shutdownContainer (ContainerID containerID) |
shuts down a container More... | |
void | suspendContainer (ContainerID containerID) |
suspends execution of a container More... | |
void | resumeContainer (ContainerID containerID) |
resumes execution of a container More... | |
void | bindMount (const ContainerID containerID, const std::string &pathInHost, const std::string &pathInContainer, bool readOnly) |
Bind mount a folder into the container. More... | |
void | setCapabilities (const ContainerID &containerID, const std::vector< std::string > &capabilities) |
Set capabilities for the container. More... | |
Definition at line 82 of file softwarecontaineragent.h.
softwarecontainer::SoftwareContainerAgent::SoftwareContainerAgent | ( | Glib::RefPtr< Glib::MainContext > | mainLoopContext, |
std::shared_ptr< Config > | config, | ||
std::shared_ptr< SoftwareContainerFactory > | factory, | ||
std::shared_ptr< ContainerUtilityInterface > | utility | ||
) |
creates a new agent object and runs some initialization
This will check if the workspace is sound
The config is used to set various values in the agent, or for the agent to pass along to objects it creates.
mainLoopContext | A Glib::MainContext |
config | A general SoftwareContainer config |
SoftwareContainerAgentError | if initialization of the agent fails because of the Workspace initialization |
ConfigStoreError | if initialization of ConfigStore fails |
Definition at line 32 of file softwarecontaineragent.cpp.
std::vector< ContainerID > softwarecontainer::SoftwareContainerAgent::listContainers | ( | ) |
get a list of all containers
Definition at line 131 of file softwarecontaineragent.cpp.
std::vector< std::string > softwarecontainer::SoftwareContainerAgent::listCapabilities | ( | ) |
List all capabilities that the user can set.
Capabilities are a mapping from a string to a set of gateway configurations. This method returns all capability names that can be used through setCapabilities.
SoftwareContainerError | if not possible to create. |
Definition at line 300 of file softwarecontaineragent.cpp.
void softwarecontainer::SoftwareContainerAgent::deleteContainer | ( | ContainerID | containerID | ) |
delete container by ID
SoftwareContainerError | on failure. |
Definition at line 141 of file softwarecontaineragent.cpp.
Referenced by shutdownContainer().
SoftwareContainerAgent::SoftwareContainerPtr softwarecontainer::SoftwareContainerAgent::getContainer | ( | ContainerID | containerID | ) |
Fetches a pointer to a SoftwareContainer matching an ID.
containerID | the ID for the container |
SoftwareContainerError | on failure. |
Definition at line 149 of file softwarecontaineragent.cpp.
Referenced by bindMount(), execute(), resumeContainer(), shutdownContainer(), and suspendContainer().
ContainerID softwarecontainer::SoftwareContainerAgent::createContainer | ( | const std::string & | config | ) |
Create a new container.
config | container-wide configuration string |
a | reference to ContainerID |
SoftwareContainerError | if not possible to create. |
Definition at line 168 of file softwarecontaineragent.cpp.
References softwarecontainer::ContainerOptionParser::parse().
pid_t softwarecontainer::SoftwareContainerAgent::execute | ( | ContainerID | containerID, |
const std::string & | cmdLine, | ||
const std::string & | workingDirectory, | ||
const std::string & | outputFile, | ||
const EnvironmentVariables & | env, | ||
std::function< void(pid_t, int)> | listener | ||
) |
Launch the given command in a the given container.
containerID | the id for the container |
cmdLine | the command to run |
workingDirectory | the working directory to use when running |
outputFile | where to log any output |
env | any environment variables to pass to the command |
listener | a function that runs when the process exits |
Definition at line 186 of file softwarecontaineragent.cpp.
References softwarecontainer::addProcessListener(), and getContainer().
void softwarecontainer::SoftwareContainerAgent::shutdownContainer | ( | ContainerID | containerID | ) |
shuts down a container
containerID | the container to shut down |
SoftwareContainerError | on failure. |
Definition at line 243 of file softwarecontaineragent.cpp.
References deleteContainer(), and getContainer().
void softwarecontainer::SoftwareContainerAgent::suspendContainer | ( | ContainerID | containerID | ) |
suspends execution of a container
containerID | the container to suspend |
SoftwareContainerError | on failure. |
Definition at line 261 of file softwarecontaineragent.cpp.
References getContainer().
void softwarecontainer::SoftwareContainerAgent::resumeContainer | ( | ContainerID | containerID | ) |
resumes execution of a container
containerID | the container to resume |
SoftwareContainerError | on failure. |
Definition at line 267 of file softwarecontaineragent.cpp.
References getContainer().
void softwarecontainer::SoftwareContainerAgent::bindMount | ( | const ContainerID | containerID, |
const std::string & | pathInHost, | ||
const std::string & | pathInContainer, | ||
bool | readOnly | ||
) |
Bind mount a folder into the container.
containerID | the container to bind into |
pathInHost | path to the folder in the host system |
subPathInContainer | path (relative to a fixed start point) to use in the container |
readOnly | whether or not to mount read-only |
reference | to the full path of the mounted folder in the container |
SoftwareContainerError | on failure. |
Definition at line 273 of file softwarecontaineragent.cpp.
References getContainer().
void softwarecontainer::SoftwareContainerAgent::setCapabilities | ( | const ContainerID & | containerID, |
const std::vector< std::string > & | capabilities | ||
) |
Set capabilities for the container.
Capabilities are a mapping from a string to a set of gateway configurations. Capabilities are translated into gateway configurations and then sent the same way as with startGateways
containerID | the container to use |
capabilities | the capabilities |
SoftwareContainerError | on failure. |
Definition at line 305 of file softwarecontaineragent.cpp.