Dobby
3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
|
Object containing the settings to pass to the Dobby. More...
#include <Settings.h>
Public Member Functions | |
std::string | workspaceDir () const override |
Should return the path to a directory used to store temporary data like runc bundles. More... | |
std::string | persistentDir () const override |
Should return a path to a directory on a persistent storage mount. More... | |
std::string | consoleSocketPath () const override |
Location to create the socket used for capturing container logs. More... | |
std::map< std::string, std::string > | extraEnvVariables () const override |
A list of extra environment variables that will be set for all containers. More... | |
std::shared_ptr< HardwareAccessSettings > | gpuAccessSettings () const override |
Returns any extra details needed to access the GPU inside the container. | |
std::shared_ptr< HardwareAccessSettings > | vpuAccessSettings () const override |
Returns any extra details needed to access the VPU (video pipeline) inside the container. | |
std::vector< std::string > | externalInterfaces () const override |
Returns the set of external interface that container traffic maybe routed through. More... | |
std::string | addressRangeStr () const override |
Returns the Dobby network address range in string format. More... | |
in_addr_t | addressRange () const override |
Returns the Dobby network address range in in_addr_t format. More... | |
std::vector< std::string > | defaultPlugins () const override |
Returns any default plugins the platform should run. More... | |
Json::Value | rdkPluginsData () const override |
LogRelaySettings | logRelaySettings () const override |
StraceSettings | straceSettings () const override |
ApparmorSettings | apparmorSettings () const override |
PidsSettings | pidsSettings () const override |
void | dump (int aiLogLevel=-1) const |
Debugging function to dump the settings to the log - info level. | |
Static Public Member Functions | |
static std::shared_ptr< Settings > | fromJsonFile (const std::string &filePath) |
Sets the default values for all settings. | |
static std::shared_ptr< Settings > | defaultSettings () |
Private Member Functions | |
Settings () | |
Constructs the settings object with the default settings. | |
Settings (const Json::Value &settings) | |
Constructs the settings source the data from the supplied JSON object. | |
void | setDefaults () |
Sets the default values for all settings. | |
bool | isDir (const std::string &path, int accessFlags=0) const |
Checks if path is a directory and has the given access flags. More... | |
int | getGroupId (const std::string &name) const |
Returns the group id associated with the name. More... | |
std::set< int > | getGroupIds (const Json::Value &field) const |
Processes a JSON array containing numbers and names of user groups. More... | |
std::string | getPathFromEnv (const char *env, const char *fallbackPath) const |
Attempts to get and validate a path from environment vars. More... | |
std::list< std::string > | getPathsFromJson (const Json::Value &value) const |
Attempts to read a path from the JSON object. More... | |
std::map< std::string, std::string > | getEnvVarsFromJson (const Json::Value &root, const Json::Path &path) const |
Returns a map of strings to strings as read from the JSON. More... | |
std::list< std::string > | getDevNodes (const Json::Value &root, const Json::Path &path) const |
Attempts to read the list of GPU device nodes that are needed for apps. More... | |
std::list< ExtraMount > | getExtraMounts (const Json::Value &root, const Json::Path &path) const |
Attempts to read the mount JSON structure(s) from the object. More... | |
bool | processMountObject (const Json::Value &value, ExtraMount *mount) const |
Processes a json 'mount' object. More... | |
std::shared_ptr< HardwareAccessSettings > | getHardwareAccess (const Json::Value &root, const Json::Path &path) const |
Processes a json 'gpu' or 'vpu' object. More... | |
void | dumpHardwareAccess (int aiLogLevel, const std::string &name, const std::shared_ptr< const HardwareAccessSettings > &hwAccess) const |
Debugging function to dump the settings to access certain H/W. | |
Private Attributes | |
std::string | mWorkspaceDir |
std::string | mPersistentDir |
std::string | mConsoleSocketPath |
std::map< std::string, std::string > | mExtraEnvVars |
std::shared_ptr< HardwareAccessSettings > | mGpuHardwareAccess |
std::shared_ptr< HardwareAccessSettings > | mVpuHardwareAccess |
std::vector< std::string > | mExternalInterfaces |
std::pair< std::string, in_addr_t > | mAddressRange |
std::vector< std::string > | mDefaultPlugins |
Json::Value | mRdkPluginsData |
LogRelaySettings | mLogRelaySettings |
StraceSettings | mStraceSettings |
ApparmorSettings | mApparmorSettings |
PidsSettings | mPidsSettings |
Object containing the settings to pass to the Dobby.
Usually this is the parsed content of a JSON file and contains the platform specific details that Dobby needs to setup some stuff in the container.
|
overridevirtual |
Returns the Dobby network address range in in_addr_t format.
IPv4 address, masked with /24, i.e. address can be nnn.nnn.nnn.0
Implements IDobbySettings.
|
overridevirtual |
Returns the Dobby network address range in string format.
IPv4 address, masked with /24, i.e. address can be nnn.nnn.nnn.0
Implements IDobbySettings.
|
overridevirtual |
Location to create the socket used for capturing container logs.
This needs to be somewhere writable
Implements IDobbySettings.
|
overridevirtual |
Returns any default plugins the platform should run.
It's assumed the plugins will have an empty data section (i.e. {}) and that the default plugin options will always be suitable
Implements IDobbySettings.
|
overridevirtual |
Returns the set of external interface that container traffic maybe routed through.
On every RDK platform this is { "eth0", "wlan0" } but it may change.
Implements IDobbySettings.
|
overridevirtual |
A list of extra environment variables that will be set for all containers.
This would typically define platform specific variables.
Implements IDobbySettings.
|
private |
Attempts to read the list of GPU device nodes that are needed for apps.
|
private |
Returns a map of strings to strings as read from the JSON.
This expects the json value to contain an array of strings, each string in the array should be formatted as a "<NAME>=<VALUE>" and follow the same rules as for standard environment variables.
|
private |
Attempts to read the mount JSON structure(s) from the object.
|
private |
Returns the group id associated with the name.
|
private |
Processes a JSON array containing numbers and names of user groups.
|
private |
Processes a json 'gpu' or 'vpu' object.
The JSON is expected to look like the following:
{ "groupIds": [ "video" ], "devNodes": [ "/dev/ion", "/dev/rpc[0-7]" ], "extraEnvVariables": [ "ENABLE_MEDIAINFO=0" ], "extraMounts": [ { "source": "/etc/xdg/gstomx.conf", "destination": "/etc/xdg/gstomx.conf", "type": "bind", "options": [ "bind", "ro", "nosuid", "nodev", "noexec" ] }, ... ] }
|
private |
Attempts to get and validate a path from environment vars.
If the env var is not set or points to an non-existing directory then the function falls back to fallbackPath.
Either way this function guarantees that the returned string will point to a valid directory.
|
private |
Attempts to read a path from the JSON object.
The path(s) are expanded using the wordexp() function, meaning that glob and environment variable expansion are performed on the string stored in the json object.
|
private |
Checks if path is a directory and has the given access flags.
|
overridevirtual |
Should return a path to a directory on a persistent storage mount.
This is currently not used, but maybe in the future.
Implements IDobbySettings.
|
private |
Processes a json 'mount' object.
|
overridevirtual |
Should return the path to a directory used to store temporary data like runc bundles.
This should be non-persistent storage and will be used for transient data. If the directory doesn't exist the library will try and create it. If the directory (and any leading dirs) has to be created it will be created with 1755 permissions.
Because of the way container setup works, this directory needs to be accessible - but not writable - by un-privileged processes.
Implements IDobbySettings.