Dobby  3.0
Dobby “Docker based Thingy” is a tool for managing and running OCI containers using crun
Public Member Functions | Private Member Functions | Private Attributes | List of all members
DobbyBundleConfig Class Reference

Takes a JSON formatted OCI bundle configuration file in the constructor, parses it and extracts the relevant fields. More...

#include <DobbyBundleConfig.h>

Inheritance diagram for DobbyBundleConfig:
Inheritance graph
[legend]
Collaboration diagram for DobbyBundleConfig:
Collaboration graph
[legend]

Public Member Functions

 DobbyBundleConfig (const std::shared_ptr< IDobbyUtils > &utils, const std::shared_ptr< const IDobbySettings > &settings, const ContainerId &id, const std::string &bundlePath)
 Constructor that parses an OCI bundle's config file to be used by Dobby. Plugins under 'rdkPlugins' and 'legacyPlugins' are parsed if found (OCI bundle*). More...
 
bool isValid () const override
 Getters used for plugins.
 
uid_t userId () const override
 
gid_t groupId () const override
 
IDobbyIPCUtils::BusType systemDbus () const override
 
IDobbyIPCUtils::BusType sessionDbus () const override
 
IDobbyIPCUtils::BusType debugDbus () const override
 
bool consoleDisabled () const override
 
ssize_t consoleLimit () const override
 
const std::string & consolePath () const override
 
bool restartOnCrash () const override
 
const std::string & rootfsPath () const override
 
std::shared_ptr< rt_dobby_schema > config () const override
 
const std::map< std::string, Json::Value > & rdkPlugins () const override
 
- Public Member Functions inherited from DobbyConfig
bool addMount (const std::string &source, const std::string &target, const std::string &fsType, unsigned long mountFlags, const std::list< std::string > &mountOptions)
 Public api to allow for adding additional mounts. More...
 
bool addEnvironmentVar (const std::string &envVar)
 Public api to allow for adding additional env variables. More...
 
bool changeProcessArgs (const std::string &command)
 
bool addWesterosMount (const std::string &socketPath)
 
bool writeConfigJson (const std::string &filePath) const
 Writes bundle config string to a file. More...
 
const std::string configJson () const
 Get OCI bundle config json as string. More...
 
void printCommand () const
 
bool enableSTrace (const std::string &logsDir)
 Enables strace for the container. More...
 
void setApparmorProfile (const std::string &profileName)
 Set apparmor profile in config. More...
 
void setPidsLimit (int limit)
 Set cgroup pids limit. More...
 

Private Member Functions

bool parseOCIConfig (const std::string &bundlePath)
 Parses the bundle config's contents that are needed by plugins. More...
 
bool constructConfig (const ContainerId &id, const std::string &bundlePath)
 Creates config object. More...
 

Private Attributes

const std::shared_ptr< IDobbyUtilsmUtilities
 
const std::shared_ptr< const IDobbySettingsmSettings
 
bool mValid
 
Json::Value mConfig
 
std::shared_ptr< rt_dobby_schema > mConf
 
uid_t mUserId
 
gid_t mGroupId
 
bool mRestartOnCrash
 
IDobbyIPCUtils::BusType mSystemDbus
 
IDobbyIPCUtils::BusType mSessionDbus
 
IDobbyIPCUtils::BusType mDebugDbus
 
bool mConsoleDisabled
 
std::string mConsolePath
 
ssize_t mConsoleLimit
 
std::map< std::string, Json::Value > mRdkPlugins
 
std::string mRootfsPath
 

Additional Inherited Members

- Public Types inherited from DobbyConfig
enum class  NetworkType { None , Nat , Open }
 Network type used for Network plugin.
 
typedef struct DobbyConfig::_LoopMount LoopMount
 Loopmount struct used for Storage plugin.
 
- Protected Member Functions inherited from DobbyConfig
bool writeConfigJsonImpl (const std::string &filePath) const
 
bool updateBundleConfig (const ContainerId &id, std::shared_ptr< rt_dobby_schema > cfg, const std::string &bundlePath)
 Convert the input config.json into an OCI compliant bundle config that adds support for DobbyPluginLauncher to work with rdkPlugins. More...
 
bool setHostnameToContainerId (const ContainerId &id, std::shared_ptr< rt_dobby_schema > cfg, const std::string &bundlePath)
 Sets the container hostname to the container ID. More...
 
bool convertToCompliant (const ContainerId &id, std::shared_ptr< rt_dobby_schema > cfg, const std::string &bundlePath)
 Convert the input config.json into an OCI compliant bundle config that adds support for DobbyPluginLauncher to work with rdkPlugins. More...
 
bool isApparmorProfileLoaded (const char *profile) const
 Check if apparmor profile is loaded. More...
 
- Static Protected Member Functions inherited from DobbyConfig
static std::list< DevNodescanDevNodes (const std::list< std::string > &devNodes)
 Takes a list of glob patterns corresponding to dev node paths and returns a list of structs with their details. More...
 
- Protected Attributes inherited from DobbyConfig
std::mutex mLock
 

Detailed Description

Takes a JSON formatted OCI bundle configuration file in the constructor, parses it and extracts the relevant fields.

It's main purpose is to read an extended OCI bundle config with plugins so it can be converted into an OCI compliant bundle.

Constructor & Destructor Documentation

◆ DobbyBundleConfig()

DobbyBundleConfig::DobbyBundleConfig ( const std::shared_ptr< IDobbyUtils > &  utils,
const std::shared_ptr< const IDobbySettings > &  settings,
const ContainerId id,
const std::string &  bundlePath 
)

Constructor that parses an OCI bundle's config file to be used by Dobby. Plugins under 'rdkPlugins' and 'legacyPlugins' are parsed if found (OCI bundle*).

Public methods

Parameters
[in]utilsThe daemon utils object.
[in]settingsDobby settings object.
[in]idContainer ID.
[in]bundlePathPath to OCI bundle.

Member Function Documentation

◆ constructConfig()

bool DobbyBundleConfig::constructConfig ( const ContainerId id,
const std::string &  bundlePath 
)
private

Creates config object.

This method parses OCI config and creates dobby config based on that. This was an old constructor for DobbyBundleConfig, but we need to be able to recover in case config gets damaged.

Parameters
[in]idContainer ID.
[in]bundlePathPath to the container's OCI bundle
Returns
true if the config is valid, otherwise false.

◆ parseOCIConfig()

bool DobbyBundleConfig::parseOCIConfig ( const std::string &  bundlePath)
private

Parses the bundle config's contents that are needed by plugins.

Private methods

The function is atomic, therefore if it returns true you can guarantee it stuck and will be set for the lifetime of the function.

Parameters
[in]bundlePathpath to the container's OCI bundle
Returns
true if the path was set, otherwise false.

Member Data Documentation

◆ mUtilities

const std::shared_ptr<IDobbyUtils> DobbyBundleConfig::mUtilities
private

Member variables


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