Takes a JSON formatted spec file in the constructor, parses it and extracts the relevant fields.
More...
|
| DobbySpecConfig (const std::shared_ptr< IDobbyUtils > &utils, const std::shared_ptr< const IDobbySettings > &settings, const ContainerId &id, const std::shared_ptr< const DobbyBundle > &bundle, const std::string &specJson) |
| Constructor used to parse a Dobby spec file into an OCI config file.
|
|
| DobbySpecConfig (const std::shared_ptr< IDobbyUtils > &utils, const std::shared_ptr< const IDobbySettings > &settings, const std::shared_ptr< const DobbyBundle > &bundle, const std::string &specJson) |
| Constructor used to parse a Dobby spec file into an OCI config file. Used with bundle generation.
|
|
bool | isValid () const override |
| Getters used for plugins.
|
|
const std::string | spec () const override |
|
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 | restartOnCrash () const override |
|
std::shared_ptr< rt_dobby_schema > | config () const override |
|
const std::string & | etcHosts () const |
|
const std::string & | etcServices () const |
|
const std::string & | etcPasswd () const |
|
const std::string & | etcGroup () const |
|
const std::string & | etcLdSoPreload () const |
|
bool | consoleDisabled () const override |
|
ssize_t | consoleLimit () const override |
|
const std::string & | consolePath () const override |
|
const std::map< std::string, Json::Value > & | legacyPlugins () const override |
|
const std::map< std::string, Json::Value > & | rdkPlugins () const override |
|
std::vector< MountPoint > | mountPoints () const |
|
const std::string & | rootfsPath () const override |
|
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.
|
|
bool | addEnvironmentVar (const std::string &envVar) |
| Public api to allow for adding additional env variables.
|
|
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.
|
|
const std::string | configJson () const |
| Get OCI bundle config json as string.
|
|
void | printCommand () const |
|
bool | enableSTrace (const std::string &logsDir) |
| Enables strace for the container.
|
|
void | setApparmorProfile (const std::string &profileName) |
| Set apparmor profile in config.
|
|
void | setPidsLimit (int limit) |
| Set cgroup pids limit.
|
|
|
bool | parseSpec (ctemplate::TemplateDictionary *dictionary, const std::string &json, int bundleFd) |
| Generates the OCI.
|
|
| JSON_FIELD_PROCESSOR (processAppId) |
|
| JSON_FIELD_PROCESSOR (processEnv) |
|
| JSON_FIELD_PROCESSOR (processArgs) |
|
| JSON_FIELD_PROCESSOR (processCwd) |
|
| JSON_FIELD_PROCESSOR (processConsole) |
|
| JSON_FIELD_PROCESSOR (processUser) |
|
| JSON_FIELD_PROCESSOR (processUserNs) |
|
| JSON_FIELD_PROCESSOR (processEtc) |
|
| JSON_FIELD_PROCESSOR (processNetwork) |
|
| JSON_FIELD_PROCESSOR (processRtPriority) |
|
| JSON_FIELD_PROCESSOR (processRestartOnCrash) |
|
| JSON_FIELD_PROCESSOR (processMounts) |
|
| JSON_FIELD_PROCESSOR (processLegacyPlugins) |
|
| JSON_FIELD_PROCESSOR (processMemLimit) |
|
| JSON_FIELD_PROCESSOR (processGpu) |
|
| JSON_FIELD_PROCESSOR (processVpu) |
|
| JSON_FIELD_PROCESSOR (processDbus) |
|
| JSON_FIELD_PROCESSOR (processSyslog) |
|
| JSON_FIELD_PROCESSOR (processCpu) |
|
| JSON_FIELD_PROCESSOR (processDevices) |
|
| JSON_FIELD_PROCESSOR (processCapabilities) |
|
| JSON_FIELD_PROCESSOR (processSeccomp) |
|
bool | processLoopMount (const Json::Value &value, ctemplate::TemplateDictionary *dictionary, Json::Value &loopMntData) |
| Processes a loop mount field of the json spec.
|
|
void | insertIntoRdkPluginJson (const std::string &pluginName, const Json::Value &pluginData) |
| Inserts rdkPlugin json into existing json.
|
|
bool | processRdkPlugins (const Json::Value &value, ctemplate::TemplateDictionary *dictionary) |
| Processes the rdkPlugins field of the json spec.
|
|
bool | validateSeccompAction (const Json::Value &value) const |
| Validates the seccomp action field value.
|
|
template<std::size_t N> |
std::bitset< N > | parseBitset (const std::string &str) const |
| Parses a string to create a bitset for the appropriate bits set.
|
|
void | storeMountPoint (const std::string &type, const std::string &source, const std::string &destination) |
| Stores the mount point internally so it can be created by in the rootfs component.
|
|
std::string | jsonToString (const Json::Value &jsonObject) |
| Use the JsonCpp streamwriter builder to convert a Json object into a string for use in ctemplate.
|
|
|
const std::shared_ptr< IDobbyUtils > | mUtilities |
|
const std::shared_ptr< const IDobbySettings::HardwareAccessSettings > | mGpuSettings |
|
const std::shared_ptr< const IDobbySettings::HardwareAccessSettings > | mVpuSettings |
|
const std::vector< std::string > | mDefaultPlugins |
|
const Json::Value | mRdkPluginsData |
|
bool | mValid |
|
ctemplate::TemplateDictionary * | mDictionary |
|
Json::Value | mSpec |
|
Json::Value | mRdkPluginsJson |
|
std::shared_ptr< rt_dobby_schema > | mConf |
|
enum DobbySpecConfig::SpecVersion | mSpecVersion |
|
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 > | mLegacyPlugins |
|
std::map< std::string, Json::Value > | mRdkPlugins |
|
std::vector< MountPoint > | mMountPoints |
|
std::string | mEtcHosts |
|
std::string | mEtcServices |
|
std::string | mEtcPasswd |
|
std::string | mEtcGroup |
|
std::string | mEtcLdSoPreload |
|
std::string | mRootfsPath |
|
|
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.
|
|
bool | setHostnameToContainerId (const ContainerId &id, std::shared_ptr< rt_dobby_schema > cfg, const std::string &bundlePath) |
| Sets the container hostname to the container ID.
|
|
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.
|
|
bool | isApparmorProfileLoaded (const char *profile) const |
| Check if apparmor profile is loaded.
|
|
static std::list< DevNode > | scanDevNodes (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.
|
|
std::mutex | mLock |
|
Takes a JSON formatted spec file in the constructor, parses it and extracts the relevant fields.
The JSON should be in our custom 'dobby' container format, this includes extra custom fields for things like /etc files, plugin configurations and so forth.
It's main purpose is to convert the dobby spec file to a OCI conformant JSON file.
void DobbySpecConfig::insertIntoRdkPluginJson |
( |
const std::string & |
pluginName, |
|
|
const Json::Value & |
pluginData |
|
) |
| |
|
private |
Inserts rdkPlugin json into existing json.
Instead of blindly overwriting the plugin data, we only overwrite sections of the plugin data that have been set in the rdkPlugin field of the spec.
This allows us to set smaller portions of the plugin data and merge them with the data set by the processor methods.
- Parameters
-
[in] | value | The rdkPlugins field from the json spec |
[in] | dictionary | Pointer to the OCI dictionary to populate |
- Returns
- true if correctly processed the value, otherwise false.
bool DobbySpecConfig::processLoopMount |
( |
const Json::Value & |
value, |
|
|
ctemplate::TemplateDictionary * |
dictionary, |
|
|
Json::Value & |
loopMntData |
|
) |
| |
|
private |
Processes a loop mount field of the json spec.
Example json:
{
"destination": "/home/private",
"type": "loop",
"fstype": "ext4",
"source": "/mnt/apps/data.img",
"options": [ "nosuid", "nodev", "noexec", "strictatime" ]
}
- Parameters
-
[in] | value | The json spec document from the client |
[in] | dictionary | Ignored |
- Returns
- true if correctly processed the value, otherwise false.
bool DobbySpecConfig::processRdkPlugins |
( |
const Json::Value & |
value, |
|
|
ctemplate::TemplateDictionary * |
dictionary |
|
) |
| |
|
private |
Processes the rdkPlugins field of the json spec.
The format is a 1-to-1 match with the actual OCI config file's rdkPlugin section.
If any rdkPlugin has been added to mRdkPluginsJson by the processX methods, the plugin's data fields will be overwritten if the same data member exists in the rdkPlugins field.
- Parameters
-
[in] | value | The rdkPlugins field from the json spec |
[in] | dictionary | Pointer to the OCI dictionary to populate |
- Returns
- true if correctly processed the value, otherwise false.