Add support for restarting nymea in system api

pull/290/head
Michael Zanetti 2020-05-01 20:45:19 +02:00
parent 9af820b696
commit 28624e264d
7 changed files with 34 additions and 5 deletions

2
debian/control vendored
View File

@ -161,7 +161,7 @@ Depends: ${shlibs:Depends},
Replaces: libguh1
Provides: nymea-update-plugin-api-1,
nymea-zeroconf-plugin-api-1,
nymea-system-plugin-api-1
nymea-system-plugin-api-2
Description: An open source IoT server - core library
The nymea daemon is a plugin based IoT (Internet of Things) server. The
server works like a translator for devices, things and services and

View File

@ -47,7 +47,7 @@ SystemHandler::SystemHandler(Platform *platform, QObject *parent):
// Methods
QString description; QVariantMap params; QVariantMap returns;
description = "Get the list of capabilites on this system. The property \"powerManagement\" indicates whether "
"rebooting or shutting down is supported on this system. The property \"updateManagement indicates "
"restarting nymea and rebooting or shutting down is supported on this system. The property \"updateManagement indicates "
"whether system update features are available in this system. The property \"timeManagement\" "
"indicates whether the system time can be configured on this system. Note that GetTime will be "
"available in any case.";
@ -56,6 +56,11 @@ SystemHandler::SystemHandler(Platform *platform, QObject *parent):
returns.insert("timeManagement", enumValueName(Bool));
registerMethod("GetCapabilities", description, params, returns);
params.clear(); returns.clear();
description = "Initiate a restart of the nymea service. The return value will indicate whether the procedure has been initiated successfully.";
returns.insert("success", enumValueName(Bool));
registerMethod("Restart", description, params, returns);
params.clear(); returns.clear();
description = "Initiate a reboot of the system. The return value will indicate whether the procedure has been initiated successfully.";
returns.insert("success", enumValueName(Bool));
@ -283,6 +288,15 @@ JsonReply *SystemHandler::GetCapabilities(const QVariantMap &params)
return createReply(data);
}
JsonReply *SystemHandler::Restart(const QVariantMap &params) const
{
Q_UNUSED(params)
bool status = m_platform->systemController()->restart();
QVariantMap returns;
returns.insert("success", status);
return createReply(returns);
}
JsonReply *SystemHandler::Reboot(const QVariantMap &params) const
{
Q_UNUSED(params)

View File

@ -51,6 +51,7 @@ public:
Q_INVOKABLE JsonReply *GetCapabilities(const QVariantMap &params);
Q_INVOKABLE JsonReply *Restart(const QVariantMap &params) const;
Q_INVOKABLE JsonReply *Reboot(const QVariantMap &params) const;
Q_INVOKABLE JsonReply *Shutdown(const QVariantMap &params) const;

View File

@ -42,6 +42,11 @@ bool PlatformSystemController::powerManagementAvailable() const
return false;
}
bool PlatformSystemController::restart()
{
return false;
}
bool PlatformSystemController::reboot()
{
return false;

View File

@ -42,6 +42,7 @@ public:
virtual ~PlatformSystemController() = default;
virtual bool powerManagementAvailable() const;
virtual bool restart();
virtual bool reboot();
virtual bool shutdown();

View File

@ -5,7 +5,7 @@ NYMEA_VERSION_STRING=$$system('dpkg-parsechangelog | sed -n -e "s/^Version: //p"
# define protocol versions
JSON_PROTOCOL_VERSION_MAJOR=5
JSON_PROTOCOL_VERSION_MINOR=0
JSON_PROTOCOL_VERSION_MINOR=1
JSON_PROTOCOL_VERSION="$${JSON_PROTOCOL_VERSION_MAJOR}.$${JSON_PROTOCOL_VERSION_MINOR}"
LIBNYMEA_API_VERSION_MAJOR=5
LIBNYMEA_API_VERSION_MINOR=0

View File

@ -1,4 +1,4 @@
5.0
5.1
{
"enums": {
"BasicType": [
@ -1653,7 +1653,7 @@
}
},
"System.GetCapabilities": {
"description": "Get the list of capabilites on this system. The property \"powerManagement\" indicates whether rebooting or shutting down is supported on this system. The property \"updateManagement indicates whether system update features are available in this system. The property \"timeManagement\" indicates whether the system time can be configured on this system. Note that GetTime will be available in any case.",
"description": "Get the list of capabilites on this system. The property \"powerManagement\" indicates whether restarting nymea and rebooting or shutting down is supported on this system. The property \"updateManagement indicates whether system update features are available in this system. The property \"timeManagement\" indicates whether the system time can be configured on this system. Note that GetTime will be available in any case.",
"params": {
},
"returns": {
@ -1725,6 +1725,14 @@
"success": "Bool"
}
},
"System.Restart": {
"description": "Initiate a restart of the nymea service. The return value will indicate whether the procedure has been initiated successfully.",
"params": {
},
"returns": {
"success": "Bool"
}
},
"System.RollbackPackages": {
"description": "Starts a rollback. Returns true if the rollback has been started successfully. Before calling this method, clients should check whether the package can be rolled back (canRollback set to true).",
"params": {