28#if defined(DOBBY_BUILD)
29#include <Dobby/IDobbyProxy.h>
30#include <IIpcService.h>
31#include <IDGenerator.h>
33#include <Dobby/Public/Dobby/IDobbyProxy.h>
34#include <Dobby/IpcService/IIpcService.h>
35#include <Dobby/IDGenerator.h>
42#include <condition_variable>
59 DobbyProxy(
const std::shared_ptr<AI_IPC::IIpcService>& ipcService,
60 const std::string& serviceName,
61 const std::string& objectName);
68 bool ping()
const override;
70 bool isAlive(
const std::chrono::milliseconds& timeout)
const override;
72 bool setLogMethod(uint32_t method,
int pipeFd)
const override;
77 const std::string& address)
const override;
82 const std::string& jsonSpec,
83 const std::list<int>& files,
84 const std::string& command =
"",
85 const std::string& displaySocket =
"",
86 const std::vector<std::string>& envVars = std::vector<std::string>())
const override;
90 const std::string& bundlePath,
91 const std::list<int>& files,
92 const std::string& command =
"",
93 const std::string& displaySocket =
"",
94 const std::vector<std::string>& envVars = std::vector<std::string>())
const override;
96 bool stopContainer(int32_t cd,
bool withPrejudice)
const override;
102 bool hibernateContainer(int32_t descriptor,
const std::string& options)
const override;
107 const std::string& source,
108 const std::string& destination,
109 const std::vector<std::string>& mountFlags,
110 const std::string& mountData)
const override;
113 const std::string& key,
114 const std::string& value)
const override;
117 const std::string& key)
const override;
122 const std::string& options,
123 const std::string& command)
const override;
127 int registerListener(
const StateChangeListener &listener,
const void* cbParams)
override;
133 std::list<std::pair<int32_t, std::string>>
listContainers()
const override;
135#if (AI_BUILD_TYPE == AI_DEBUG)
140 const std::string& jsonSpec)
const override;
142 std::string
getSpec(int32_t descriptor)
const override;
144 std::string
getOCIConfig(int32_t descriptor)
const override;
146#if (AI_ENABLE_TRACING)
147 bool startInProcessTracing(
int traceFileFd,
148 const std::string &categoryFilter)
const override;
150 bool stopInProcessTracing()
const override;
162 bool invokeMethod(
const char *interface_,
const char *method_,
163 const AI_IPC::VariantList& params_,
164 AI_IPC::VariantList& returns_)
const;
169 const std::shared_ptr<AI_IPC::IIpcService> mIpcService;
170 const std::string mServiceName;
171 const std::string mObjectName;
174 std::string mContainerStartedSignal;
175 std::string mContainerStoppedSignal;
178 std::thread mStateChangeThread;
179 std::mutex mStateChangeLock;
180 std::condition_variable mStateChangeCond;
184 enum Type { Terminate, ContainerStarted, ContainerStopped, ContainerHibernated, ContainerAwoken };
187 : type(type_), descriptor(-1)
191 : type(type_), descriptor(descriptor_), name(name_)
199 std::deque<StateChangeEvent> mStateChangeQueue;
201 std::mutex mListenersLock;
203 std::map<int, std::pair<StateChangeListener, const void*>> mListeners;
Class used to generate unique numbers.
Definition IDGenerator.h:62
Wrapper around an IpcService object that provides simpler method calls to the dobby daemon.
Definition DobbyProxy.h:57
void unregisterListener(int tag) override
Unregisters a listener previously registered.
Definition DobbyProxy.cpp:184
bool addAnnotation(int32_t cd, const std::string &key, const std::string &value) const override
adds a key value pair to the container annotation
Definition DobbyProxy.cpp:940
bool execInContainer(int32_t cd, const std::string &options, const std::string &command) const override
Executes a command in the given container.
Definition DobbyProxy.cpp:1039
int registerListener(const StateChangeListener &listener, const void *cbParams) override
Installs a callback 'listener' to be notified of changes to the state of the containers.
Definition DobbyProxy.cpp:159
void containerStateChangeThread()
Thread function that receives notifications on container state changes and then calls the install han...
Definition DobbyProxy.cpp:1448
void onContainerStartedEvent(const AI_IPC::VariantList &args)
Called when a org.rdk.dobby.ctrl1.Started event is received from the Dobby 'hypervisor' daemon.
Definition DobbyProxy.cpp:209
bool removeContainerMount(int32_t descriptor, const std::string &source) const override
unmounts a directory/device inside the container
Definition DobbyProxy.cpp:1004
int getContainerState(int32_t cd) const override
Returns the current state of a container.
Definition DobbyProxy.cpp:1079
std::string getContainerInfo(int32_t descriptor) const override
Gets the stats / info for the given container.
Definition DobbyProxy.cpp:1175
bool createBundle(const std::string &id, const std::string &jsonSpec) const override
Debugging utility that can be used to create a bundle based on a dobby spec file.
Definition DobbyProxy.cpp:1269
int32_t startContainerFromBundle(const std::string &id, const std::string &bundlePath, const std::list< int > &files, const std::string &command="", const std::string &displaySocket="", const std::vector< std::string > &envVars=std::vector< std::string >()) const override
Starts a container with the given id, bundle path and the list of files.
Definition DobbyProxy.cpp:677
bool addContainerMount(int32_t descriptor, const std::string &source, const std::string &destination, const std::vector< std::string > &mountFlags, const std::string &mountData) const override
mounts a new host directory/device inside container
Definition DobbyProxy.cpp:907
std::string getSpec(int32_t descriptor) const override
Debugging utility to retrieve the original spec file for a running container (i.e....
Definition DobbyProxy.cpp:1307
bool isAlive(const std::chrono::milliseconds &timeout) const override
Checks if the daemon is alive.
Definition DobbyProxy.cpp:381
bool hibernateContainer(int32_t descriptor, const std::string &options) const override
Checkpoints the container with the descriptor (container integer id)
Definition DobbyProxy.cpp:834
bool ping() const override
Asks the daemon to send back a pong message.
Definition DobbyProxy.cpp:444
bool pauseContainer(int32_t cd) const override
Pauses the container with the descriptor (container integer id)
Definition DobbyProxy.cpp:768
~DobbyProxy() final
Unregisters the signal listeners and flushes the ipc connection.
Definition DobbyProxy.cpp:119
std::list< std::pair< int32_t, std::string > > listContainers() const override
Returns a list of containers.
Definition DobbyProxy.cpp:1213
bool invokeMethod(const char *interface_, const char *method_, const AI_IPC::VariantList ¶ms_, AI_IPC::VariantList &returns_) const
Invokes a dbus method on the daemon.
Definition DobbyProxy.cpp:351
bool wakeupContainer(int32_t descriptor) const override
Restores previously checkpointed container with the given id.
Definition DobbyProxy.cpp:869
bool stopContainer(int32_t cd, bool withPrejudice) const override
Stops the container with the descriptor (container integer id)
Definition DobbyProxy.cpp:730
std::string getOCIConfig(int32_t descriptor) const override
Debugging utility to retrieve the config.json file for a running container (i.e. like the 'virsh dump...
Definition DobbyProxy.cpp:1344
bool setLogLevel(int level) const override
Simply sets the log level in the daemon.
Definition DobbyProxy.cpp:577
void onContainerAwokenEvent(const AI_IPC::VariantList &args)
Called when a org.rdk.dobby.ctrl1.Awoken event is received from the Dobby 'hypervisor' daemon.
Definition DobbyProxy.cpp:311
bool setAIDbusAddress(bool privateBus, const std::string &address) const override
Sets the AI dbus address for use by the containeriser.
Definition DobbyProxy.cpp:470
bool resumeContainer(int32_t cd) const override
Resumes the container with the descriptor (container integer id)
Definition DobbyProxy.cpp:801
void onContainerHibernatedEvent(const AI_IPC::VariantList &args)
Called when a org.rdk.dobby.ctrl1.Hibernated event is received from the Dobby 'hypervisor' daemon.
Definition DobbyProxy.cpp:277
int32_t startContainerFromSpec(const std::string &id, const std::string &jsonSpec, const std::list< int > &files, const std::string &command="", const std::string &displaySocket="", const std::vector< std::string > &envVars=std::vector< std::string >()) const override
Starts a container with the given id, json spec file and the list of files.
Definition DobbyProxy.cpp:621
bool shutdown() const override
Asks the daemon to shut itself down.
Definition DobbyProxy.cpp:423
bool removeAnnotation(int32_t cd, const std::string &key) const override
removes a key value pair from the container annotation
Definition DobbyProxy.cpp:972
void onContainerStoppedEvent(const AI_IPC::VariantList &args)
Called when a org.rdk.dobby.ctrl1.Stopped event is received from the Dobby 'hypervisor' daemon.
Definition DobbyProxy.cpp:243
bool setLogMethod(uint32_t method, int pipeFd) const override
Sets the logging method used by the daemon.
Definition DobbyProxy.cpp:516
Wrapper around an IpcService object that provides simpler method calls to the Dobby 'hypervisor' daem...
Definition IDobbyProxy.h:92
Definition DobbyProxy.h:183