mirror of
https://github.com/arcan1s/queued.git
synced 2025-04-24 15:37:19 +00:00
add interface adaptor
This commit is contained in:
parent
b1821507dc
commit
b5839051e9
@ -25,7 +25,6 @@
|
||||
#define QUEUED_H
|
||||
|
||||
#include "QueuedAdvancedSettings.h"
|
||||
#include "QueuedConfiguration.h"
|
||||
#include "QueuedCore.h"
|
||||
#include "QueuedCoreAdaptor.h"
|
||||
#include "QueuedCoreInterface.h"
|
||||
@ -43,6 +42,7 @@
|
||||
#include "QueuedProcessManager.h"
|
||||
#include "QueuedReportManager.h"
|
||||
#include "QueuedSettings.h"
|
||||
#include "QueuedStaticConfig.h"
|
||||
#include "QueuedSystemInfo.h"
|
||||
#include "QueuedTokenManager.h"
|
||||
#include "QueuedUser.h"
|
||||
|
@ -27,7 +27,7 @@
|
||||
#include <QObject>
|
||||
#include <QVariant>
|
||||
|
||||
#include "QueuedConfiguration.h"
|
||||
#include "QueuedStaticConfig.h"
|
||||
|
||||
|
||||
/**
|
||||
@ -66,7 +66,7 @@ public:
|
||||
* key to search in
|
||||
* @return value by key if found
|
||||
*/
|
||||
QVariant get(const QueuedCfg::QueuedSettings _key) const;
|
||||
QVariant get(const QueuedConfig::QueuedSettings _key) const;
|
||||
/**
|
||||
* @brief get database value ID
|
||||
* @param _key
|
||||
@ -87,7 +87,7 @@ public:
|
||||
* string key
|
||||
* @return ID in settings representation
|
||||
*/
|
||||
static QString internalId(const QueuedCfg::QueuedSettings _key);
|
||||
static QString internalId(const QueuedConfig::QueuedSettings _key);
|
||||
/**
|
||||
* @brief set value
|
||||
* @param _key
|
||||
@ -113,8 +113,8 @@ signals:
|
||||
* @param _value
|
||||
* changed value
|
||||
*/
|
||||
void valueUpdated(const QueuedCfg::QueuedSettings _id, const QString &_key,
|
||||
const QVariant &_value);
|
||||
void valueUpdated(const QueuedConfig::QueuedSettings _id,
|
||||
const QString &_key, const QVariant &_value);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -26,9 +26,9 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "QueuedConfiguration.h"
|
||||
#include "QueuedEnums.h"
|
||||
#include "QueuedLimits.h"
|
||||
#include "QueuedStaticConfig.h"
|
||||
|
||||
|
||||
class QueuedAdvancedSettings;
|
||||
@ -77,20 +77,18 @@ public:
|
||||
* command arguments
|
||||
* @param _workingDirectory
|
||||
* working directory
|
||||
* @param _nice
|
||||
* nice level
|
||||
* @param _userId
|
||||
* task owner user ID
|
||||
* @param _limits
|
||||
* task defined limits
|
||||
* @param _token
|
||||
* user auth token
|
||||
* @return true on successfully addition
|
||||
* @return task ID or -1 if no task added
|
||||
*/
|
||||
bool addTask(const QString &_command, const QStringList &_arguments,
|
||||
const QString &_workingDirectory, const uint _nice,
|
||||
const long long _userId, const QueuedLimits::Limits &_limits,
|
||||
const QString &_token);
|
||||
long long addTask(const QString &_command, const QStringList &_arguments,
|
||||
const QString &_workingDirectory, const long long _userId,
|
||||
const QueuedLimits::Limits &_limits,
|
||||
const QString &_token);
|
||||
/**
|
||||
* @brief add new user
|
||||
* @param _name
|
||||
@ -105,11 +103,12 @@ public:
|
||||
* user limits
|
||||
* @param _token
|
||||
* user auth token
|
||||
* @return true on successfully addition
|
||||
* @return user ID or -1 if no user created
|
||||
*/
|
||||
bool addUser(const QString &_name, const QString &_email,
|
||||
const QString &_password, const uint _permissions,
|
||||
const QueuedLimits::Limits &_limits, const QString &_token);
|
||||
long long addUser(const QString &_name, const QString &_email,
|
||||
const QString &_password, const uint _permissions,
|
||||
const QueuedLimits::Limits &_limits,
|
||||
const QString &_token);
|
||||
/**
|
||||
* @brief authorize and create new token for user
|
||||
* @param _name
|
||||
@ -253,7 +252,7 @@ private slots:
|
||||
* @param _value
|
||||
* new value
|
||||
*/
|
||||
void updateSettings(const QueuedCfg::QueuedSettings _id,
|
||||
void updateSettings(const QueuedConfig::QueuedSettings _id,
|
||||
const QString &_key, const QVariant &_value);
|
||||
/**
|
||||
* @brief update process time
|
||||
@ -356,18 +355,17 @@ private:
|
||||
* command arguments
|
||||
* @param _workingDirectory
|
||||
* working directory
|
||||
* @param _nice
|
||||
* nice level
|
||||
* @param _userId
|
||||
* task owner user ID
|
||||
* @param _limits
|
||||
* task defined limits
|
||||
* @return true on successfully addition
|
||||
* @return task ID or -1 if no task added
|
||||
*/
|
||||
bool addTaskPrivate(const QString &_command, const QStringList &_arguments,
|
||||
const QString &_workingDirectory, const uint _nice,
|
||||
const long long _userId,
|
||||
const QueuedLimits::Limits &_limits);
|
||||
long long addTaskPrivate(const QString &_command,
|
||||
const QStringList &_arguments,
|
||||
const QString &_workingDirectory,
|
||||
const long long _userId,
|
||||
const QueuedLimits::Limits &_limits);
|
||||
/**
|
||||
* @brief add new user
|
||||
* @param _name
|
||||
@ -380,11 +378,11 @@ private:
|
||||
* user permissions
|
||||
* @param _limits
|
||||
* user limits
|
||||
* @return true on successfully addition
|
||||
* @return user ID or -1 if no user found
|
||||
*/
|
||||
bool addUserPrivate(const QString &_name, const QString &_email,
|
||||
const QString &_password, const uint _permissions,
|
||||
const QueuedLimits::Limits &_limits);
|
||||
long long addUserPrivate(const QString &_name, const QString &_email,
|
||||
const QString &_password, const uint _permissions,
|
||||
const QueuedLimits::Limits &_limits);
|
||||
/**
|
||||
* @brief edit advanced settings
|
||||
* @param _key
|
||||
|
@ -27,6 +27,9 @@
|
||||
#include <QDBusArgument>
|
||||
#include <QVariant>
|
||||
|
||||
#include "QueuedProcess.h"
|
||||
#include "QueuedUser.h"
|
||||
|
||||
|
||||
/**
|
||||
* @addtogroup QueuedCoreAdaptor
|
||||
@ -34,6 +37,164 @@
|
||||
*/
|
||||
namespace QueuedCoreAdaptor
|
||||
{
|
||||
// specific methods for control interface
|
||||
/**
|
||||
* @brief send auth method
|
||||
* @param _name
|
||||
* user name
|
||||
* @param _password
|
||||
* user password
|
||||
* @return generated token ID or empty string in case of invalid password
|
||||
*/
|
||||
QString auth(const QString &_name, const QString &_password);
|
||||
/**
|
||||
* @brief send OptionEdit
|
||||
* @param _key
|
||||
* option key to edit
|
||||
* @param _value
|
||||
* option value to edit
|
||||
* @param _token
|
||||
* auth user token
|
||||
* @return true on successful option edition
|
||||
*/
|
||||
bool sendOptionEdit(const QString &_key, const QVariant &_value,
|
||||
const QString &_token);
|
||||
/**
|
||||
* @brief send PluginAdd
|
||||
* @param _plugin
|
||||
* plugin name
|
||||
* @param _token
|
||||
* auth user token
|
||||
* @return true on successful plugin addition
|
||||
*/
|
||||
bool sendPluginAdd(const QString &_plugin, const QString &_token);
|
||||
/**
|
||||
* @brief send PluginRemove
|
||||
* @param _plugin
|
||||
* plugin name
|
||||
* @param _token
|
||||
* auth user token
|
||||
* @return true on successful plugin removal
|
||||
*/
|
||||
bool sendPluginRemove(const QString &_plugin, const QString &_token);
|
||||
/**
|
||||
* @brief send TaskAdd
|
||||
* @param _definitions
|
||||
* process definitions
|
||||
* @param _token
|
||||
* auth user token
|
||||
* @return task ID or -1 if no task found
|
||||
*/
|
||||
long long
|
||||
sendTaskAdd(const QueuedProcess::QueuedProcessDefinitions &_definitions,
|
||||
const QString &_token);
|
||||
/**
|
||||
* @brief send TaskEdit
|
||||
* @param _id
|
||||
* task ID to edit
|
||||
* @param _definitions
|
||||
* process definitions
|
||||
* @param _token
|
||||
* auth user token
|
||||
* @return true on successful task edition
|
||||
*/
|
||||
bool sendTaskEdit(const long long _id,
|
||||
const QueuedProcess::QueuedProcessDefinitions &_definitions,
|
||||
const QString &_token);
|
||||
/**
|
||||
* @brief send TaskStart
|
||||
* @param _id
|
||||
* task ID
|
||||
* @param _token
|
||||
* auth user token
|
||||
* @return true on successful task start
|
||||
*/
|
||||
bool sendTaskStart(const long long _id, const QString &_token);
|
||||
/**
|
||||
* @brief send TaskStop
|
||||
* @param _id
|
||||
* task ID
|
||||
* @param _token
|
||||
* auth user token
|
||||
* @return true on successful task stop
|
||||
*/
|
||||
bool sendTaskStop(const long long _id, const QString &_token);
|
||||
/**
|
||||
* @brief send UserAdd
|
||||
* @param _definitions
|
||||
* user definitions
|
||||
* @param _token
|
||||
* auth user token
|
||||
* @return user ID or -1 if no user added
|
||||
*/
|
||||
long long sendUserAdd(const QueuedUser::QueuedUserDefinitions &_definitions,
|
||||
const QString &_token);
|
||||
/**
|
||||
* @brief send UserEdit
|
||||
* @param _id
|
||||
* user ID to edit
|
||||
* @param _definitions
|
||||
* user definitions
|
||||
* @param _token
|
||||
* auth user token
|
||||
* @return true on successful user edition
|
||||
*/
|
||||
bool sendUserEdit(const long long _id,
|
||||
const QueuedUser::QueuedUserDefinitions &_definitions,
|
||||
const QString &_token);
|
||||
/**
|
||||
* @brief send UserPermissionsAdd
|
||||
* @param _id
|
||||
* user ID
|
||||
* @param _permission
|
||||
* permission to add
|
||||
* @param _token
|
||||
* auth user token
|
||||
* @return true on successful permission addition
|
||||
*/
|
||||
bool sendUserPermissionAdd(const long long _id,
|
||||
const QueuedEnums::Permission _permission,
|
||||
const QString &_token);
|
||||
/**
|
||||
* @brief send sendUserPermissionRemove
|
||||
* @param _id
|
||||
* user ID
|
||||
* @param _permission
|
||||
* permission to remove
|
||||
* @param _token
|
||||
* auth user token
|
||||
* @return true on successful permission removal
|
||||
*/
|
||||
bool sendUserPermissionRemove(const long long _id,
|
||||
const QueuedEnums::Permission _permission,
|
||||
const QString &_token);
|
||||
// specific methods for properties
|
||||
/**
|
||||
* @brief get option
|
||||
* @param _property
|
||||
* option name
|
||||
* @return option value
|
||||
*/
|
||||
QVariant getOption(const QString &_property);
|
||||
/**
|
||||
* @brief get task property
|
||||
* @param _id
|
||||
* task id
|
||||
* @param _property
|
||||
* task property name
|
||||
* @return task property value
|
||||
*/
|
||||
QVariant getTask(const long long _id, const QString &_property);
|
||||
/**
|
||||
* @brief get user property
|
||||
* @param _id
|
||||
* user id
|
||||
* @param _property
|
||||
* user property name
|
||||
* @return user property value
|
||||
*/
|
||||
QVariant getUser(const long long _id, const QString &_property);
|
||||
// common methods
|
||||
/**
|
||||
* @brief common DBus request
|
||||
* @param _service
|
||||
|
@ -100,8 +100,6 @@ public slots:
|
||||
* command line arguments
|
||||
* @param workingDirectory
|
||||
* working directory
|
||||
* @param nice
|
||||
* nice level
|
||||
* @param user
|
||||
* user ID
|
||||
* @param cpu
|
||||
@ -116,13 +114,13 @@ public slots:
|
||||
* limit by storage
|
||||
* @param token
|
||||
* auth user token
|
||||
* @return true on successful task addition
|
||||
* @return task ID or -1 if no task added
|
||||
*/
|
||||
bool TaskAdd(const QString &command, const QStringList &arguments,
|
||||
const QString &workingDirectory, const uint nice,
|
||||
const long long user, const long long cpu, const long long gpu,
|
||||
const QString &memory, const QString &gpumemory,
|
||||
const QString &storage, const QString &token);
|
||||
qlonglong TaskAdd(const QString &command, const QStringList &arguments,
|
||||
const QString &workingDirectory, const qlonglong user,
|
||||
const qlonglong cpu, const qlonglong gpu,
|
||||
const QString &memory, const QString &gpumemory,
|
||||
const QString &storage, const QString &token);
|
||||
/**
|
||||
* @brief edit task
|
||||
* @param id
|
||||
@ -139,8 +137,8 @@ public slots:
|
||||
* new uid or 0
|
||||
* @param gid
|
||||
* new gid or 0
|
||||
* @param state
|
||||
* new state or 0
|
||||
* @param user
|
||||
* new user ID or 0
|
||||
* @param cpu
|
||||
* new limit by CPU cores or -1
|
||||
* @param gpu
|
||||
@ -158,9 +156,10 @@ public slots:
|
||||
bool TaskEdit(const qlonglong id, const QString &command,
|
||||
const QStringList &arguments, const QString &directory,
|
||||
const uint nice, const uint uid, const uint gid,
|
||||
const uint state, const long long cpu, const long long gpu,
|
||||
const QString &memory, const QString &gpumemory,
|
||||
const QString &storage, const QString &token);
|
||||
const qlonglong user, const qlonglong cpu,
|
||||
const qlonglong gpu, const QString &memory,
|
||||
const QString &gpumemory, const QString &storage,
|
||||
const QString &token);
|
||||
/**
|
||||
* @brief force start task
|
||||
* @param id
|
||||
@ -201,13 +200,13 @@ public slots:
|
||||
* limit by storage
|
||||
* @param token
|
||||
* auth user token
|
||||
* @return true on successful task addition
|
||||
* @return user ID or -1 if no user found
|
||||
*/
|
||||
bool UserAdd(const QString &name, const QString &email,
|
||||
const QString &password, const uint permissions,
|
||||
const long long cpu, const long long gpu,
|
||||
const QString &memory, const QString &gpumemory,
|
||||
const QString &storage, const QString &token);
|
||||
qlonglong UserAdd(const QString &name, const QString &email,
|
||||
const QString &password, const uint permissions,
|
||||
const qlonglong cpu, const qlonglong gpu,
|
||||
const QString &memory, const QString &gpumemory,
|
||||
const QString &storage, const QString &token);
|
||||
/**
|
||||
* @brief edit user
|
||||
* @param id
|
||||
@ -234,7 +233,7 @@ public slots:
|
||||
*/
|
||||
bool UserEdit(const qlonglong id, const QString &name,
|
||||
const QString &password, const QString &email,
|
||||
const long long cpu, const long long gpu,
|
||||
const qlonglong cpu, const qlonglong gpu,
|
||||
const QString &memory, const QString &gpumemory,
|
||||
const QString &storage, const QString &token);
|
||||
/**
|
||||
|
@ -68,7 +68,7 @@ public slots:
|
||||
* property name
|
||||
* @return property value or empty if task or property not found
|
||||
*/
|
||||
QDBusVariant TaskProperty(const long long id, const QString &property);
|
||||
QDBusVariant Task(const long long id, const QString &property);
|
||||
/**
|
||||
* @brief get user property
|
||||
* @param id
|
||||
@ -77,7 +77,7 @@ public slots:
|
||||
* property name
|
||||
* @return property value or empty if user or property not found
|
||||
*/
|
||||
QDBusVariant UserProperty(const long long id, const QString &property);
|
||||
QDBusVariant User(const long long id, const QString &property);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@ -87,14 +87,14 @@ const QueuedDBSchema DBSchema = {
|
||||
{{"_id",
|
||||
{"_id", "INTEGER PRIMARY KEY AUTOINCREMENT UNIQUE", QVariant::LongLong,
|
||||
true}},
|
||||
{"user", {"user", "INT NOT NULL DEFAULT 0", QVariant::LongLong, false}},
|
||||
{"user", {"user", "INT NOT NULL DEFAULT 0", QVariant::LongLong, true}},
|
||||
{"command", {"command", "TEXT", QVariant::String, false}},
|
||||
{"commandArguments",
|
||||
{"commandArguments", "TEXT", QVariant::String, false}},
|
||||
{"workDirectory", {"workDirectory", "TEXT", QVariant::String, false}},
|
||||
{"nice", {"nice", "INT", QVariant::UInt, false}},
|
||||
{"uid", {"uid", "INT", QVariant::UInt, false}},
|
||||
{"gid", {"gid", "INT", QVariant::UInt, false}},
|
||||
{"nice", {"nice", "INT NOT NULL DEFAULT 0", QVariant::UInt, true}},
|
||||
{"uid", {"uid", "INT", QVariant::UInt, true}},
|
||||
{"gid", {"gid", "INT", QVariant::UInt, true}},
|
||||
{"limits", {"limits", "TEXT", QVariant::String, false}},
|
||||
{"startTime", {"startTime", "INT", QVariant::LongLong, true}},
|
||||
{"endTime", {"endTime", "INT", QVariant::LongLong, true}}}},
|
||||
|
@ -82,12 +82,12 @@ public:
|
||||
QString command;
|
||||
QStringList arguments;
|
||||
QString workingDirectory;
|
||||
uint uid;
|
||||
uint gid;
|
||||
uint nice;
|
||||
uint uid = 0;
|
||||
uint gid = 0;
|
||||
uint nice = 0;
|
||||
QDateTime startTime;
|
||||
QDateTime endTime;
|
||||
long long user;
|
||||
long long user = 0;
|
||||
QString limits;
|
||||
} QueuedProcessDefinitions;
|
||||
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
#include <QObject>
|
||||
|
||||
#include "QueuedConfiguration.h"
|
||||
#include "QueuedStaticConfig.h"
|
||||
|
||||
|
||||
/**
|
||||
@ -36,8 +36,8 @@ class QueuedSettings : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(QString path READ path)
|
||||
Q_PROPERTY(QueuedCfg::QueuedAdminSetup admin READ admin)
|
||||
Q_PROPERTY(QueuedCfg::QueuedDBSetup db READ db)
|
||||
Q_PROPERTY(QueuedConfig::QueuedAdminSetup admin READ admin)
|
||||
Q_PROPERTY(QueuedConfig::QueuedDBSetup db READ db)
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -56,12 +56,12 @@ public:
|
||||
* @brief administrator settings
|
||||
* @return QueuedAdminSetup structure
|
||||
*/
|
||||
QueuedCfg::QueuedAdminSetup admin() const;
|
||||
QueuedConfig::QueuedAdminSetup admin() const;
|
||||
/**
|
||||
* @brief database settings
|
||||
* @return QueuedDBSetup structure
|
||||
*/
|
||||
QueuedCfg::QueuedDBSetup db() const;
|
||||
QueuedConfig::QueuedDBSetup db() const;
|
||||
/**
|
||||
* @brief default path to configuration
|
||||
* @return default path to configuration file
|
||||
@ -83,11 +83,11 @@ private:
|
||||
/**
|
||||
* @brief admin configuration
|
||||
*/
|
||||
QueuedCfg::QueuedAdminSetup m_cfgAdmin;
|
||||
QueuedConfig::QueuedAdminSetup m_cfgAdmin;
|
||||
/**
|
||||
* @brief database configuration
|
||||
*/
|
||||
QueuedCfg::QueuedDBSetup m_cfgDB;
|
||||
QueuedConfig::QueuedDBSetup m_cfgDB;
|
||||
/**
|
||||
* @brief path to configuration
|
||||
*/
|
||||
|
@ -13,7 +13,7 @@
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
/**
|
||||
* @file QueuedCOnfiguration.h
|
||||
* @file QueuedStaticConfig.h
|
||||
* Header of Queued library
|
||||
* @author Evgeniy Alekseev
|
||||
* @copyright MIT
|
||||
@ -32,10 +32,10 @@
|
||||
|
||||
|
||||
/**
|
||||
* @addtogroup QueuedCfg
|
||||
* @addtogroup QueuedConfig
|
||||
* @brief Queued configuration related types
|
||||
*/
|
||||
namespace QueuedCfg
|
||||
namespace QueuedConfig
|
||||
{
|
||||
/**
|
||||
* @struct QueuedAdminSetup
|
@ -66,7 +66,7 @@ public:
|
||||
QString name;
|
||||
QString email;
|
||||
QString password;
|
||||
uint permissions;
|
||||
uint permissions = 0;
|
||||
QString limits;
|
||||
} QueuedUserDefinitions;
|
||||
|
||||
|
@ -22,7 +22,6 @@
|
||||
|
||||
|
||||
#include "queued/Queued.h"
|
||||
#include <queued/QueuedConfiguration.h>
|
||||
|
||||
|
||||
/**
|
||||
@ -52,7 +51,7 @@ QueuedAdvancedSettings::~QueuedAdvancedSettings()
|
||||
*/
|
||||
bool QueuedAdvancedSettings::checkDatabaseVersion() const
|
||||
{
|
||||
QString key = internalId(QueuedCfg::QueuedSettings::DatabaseVersion);
|
||||
QString key = internalId(QueuedConfig::QueuedSettings::DatabaseVersion);
|
||||
|
||||
if (m_values.contains(key.toLower()))
|
||||
return get(key).toInt() == QueuedConfig::DATABASE_VERSION;
|
||||
@ -72,19 +71,21 @@ QVariant QueuedAdvancedSettings::get(const QString &_key) const
|
||||
if (m_values.contains(key))
|
||||
return m_values.value(key);
|
||||
else
|
||||
return QueuedCfg::QueuedSettingsDefaults[internalId(_key)].defaultValue;
|
||||
return QueuedConfig::QueuedSettingsDefaults[internalId(_key)]
|
||||
.defaultValue;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn get
|
||||
*/
|
||||
QVariant QueuedAdvancedSettings::get(const QueuedCfg::QueuedSettings _key) const
|
||||
QVariant
|
||||
QueuedAdvancedSettings::get(const QueuedConfig::QueuedSettings _key) const
|
||||
{
|
||||
qCDebug(LOG_LIB) << "Looking for key" << static_cast<int>(_key);
|
||||
|
||||
for (auto &key : QueuedCfg::QueuedSettingsDefaults.keys()) {
|
||||
if (QueuedCfg::QueuedSettingsDefaults[key].id != _key)
|
||||
for (auto &key : QueuedConfig::QueuedSettingsDefaults.keys()) {
|
||||
if (QueuedConfig::QueuedSettingsDefaults[key].id != _key)
|
||||
continue;
|
||||
return get(key);
|
||||
}
|
||||
@ -112,7 +113,7 @@ QString QueuedAdvancedSettings::internalId(const QString &_key)
|
||||
qCDebug(LOG_LIB) << "Looking for key" << _key;
|
||||
|
||||
QString key = _key.toLower();
|
||||
for (auto &internal : QueuedCfg::QueuedSettingsDefaults.keys()) {
|
||||
for (auto &internal : QueuedConfig::QueuedSettingsDefaults.keys()) {
|
||||
if (internal.toLower() != key)
|
||||
continue;
|
||||
return internal;
|
||||
@ -125,12 +126,13 @@ QString QueuedAdvancedSettings::internalId(const QString &_key)
|
||||
/**
|
||||
* @fn internalId
|
||||
*/
|
||||
QString QueuedAdvancedSettings::internalId(const QueuedCfg::QueuedSettings _key)
|
||||
QString
|
||||
QueuedAdvancedSettings::internalId(const QueuedConfig::QueuedSettings _key)
|
||||
{
|
||||
qCDebug(LOG_LIB) << "Looking for key" << static_cast<int>(_key);
|
||||
|
||||
for (auto &internal : QueuedCfg::QueuedSettingsDefaults.keys()) {
|
||||
if (QueuedCfg::QueuedSettingsDefaults[internal].id != _key)
|
||||
for (auto &internal : QueuedConfig::QueuedSettingsDefaults.keys()) {
|
||||
if (QueuedConfig::QueuedSettingsDefaults[internal].id != _key)
|
||||
continue;
|
||||
return internal;
|
||||
}
|
||||
@ -147,7 +149,7 @@ void QueuedAdvancedSettings::set(const QString &_key, const QVariant &_value)
|
||||
qCDebug(LOG_LIB) << "Set value" << _value << "for key" << _key;
|
||||
|
||||
m_values[_key.toLower()] = _value;
|
||||
auto id = QueuedCfg::QueuedSettingsDefaults[internalId(_key)].id;
|
||||
auto id = QueuedConfig::QueuedSettingsDefaults[internalId(_key)].id;
|
||||
emit(valueUpdated(id, _key, _value));
|
||||
}
|
||||
|
||||
|
@ -73,11 +73,10 @@ bool QueuedCore::addPlugin(const QString &_plugin, const QString &_token)
|
||||
/**
|
||||
* @addTask
|
||||
*/
|
||||
bool QueuedCore::addTask(const QString &_command, const QStringList &_arguments,
|
||||
const QString &_workingDirectory, const uint _nice,
|
||||
const long long _userId,
|
||||
const QueuedLimits::Limits &_limits,
|
||||
const QString &_token)
|
||||
long long
|
||||
QueuedCore::addTask(const QString &_command, const QStringList &_arguments,
|
||||
const QString &_workingDirectory, const long long _userId,
|
||||
const QueuedLimits::Limits &_limits, const QString &_token)
|
||||
{
|
||||
qCDebug(LOG_LIB) << "Add task" << _command << "with arguments" << _arguments
|
||||
<< "from user" << _userId;
|
||||
@ -97,28 +96,28 @@ bool QueuedCore::addTask(const QString &_command, const QStringList &_arguments,
|
||||
// it means that user places task as own one
|
||||
if (!isUser) {
|
||||
qCInfo(LOG_LIB) << "User" << _token << "not allowed to add task";
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
// user tries to place task as another one
|
||||
if (!isAdmin) {
|
||||
qCInfo(LOG_LIB) << "User" << _token << "not allowed to add task";
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
return addTaskPrivate(_command, _arguments, _workingDirectory, _nice,
|
||||
_userId, _limits);
|
||||
return addTaskPrivate(_command, _arguments, _workingDirectory, _userId,
|
||||
_limits);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn addUser
|
||||
*/
|
||||
bool QueuedCore::addUser(const QString &_name, const QString &_email,
|
||||
const QString &_password, const uint _permissions,
|
||||
const QueuedLimits::Limits &_limits,
|
||||
const QString &_token)
|
||||
long long QueuedCore::addUser(const QString &_name, const QString &_email,
|
||||
const QString &_password, const uint _permissions,
|
||||
const QueuedLimits::Limits &_limits,
|
||||
const QString &_token)
|
||||
{
|
||||
qCDebug(LOG_LIB) << "Add user" << _name << "with email" << _email
|
||||
<< "and permissions" << _permissions;
|
||||
@ -127,14 +126,14 @@ bool QueuedCore::addUser(const QString &_name, const QString &_email,
|
||||
bool isAdmin = m_users->authorize(_token, QueuedEnums::Permission::Admin);
|
||||
if (!isAdmin) {
|
||||
qCInfo(LOG_LIB) << "User" << _token << "not allowed to add user";
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
// check if already exists
|
||||
auto user = m_users->user(_name, false);
|
||||
if (user) {
|
||||
qCWarning(LOG_LIB) << "User" << _name << "already exists";
|
||||
return false;
|
||||
return -1;
|
||||
}
|
||||
|
||||
return addUserPrivate(_name, _email, _password, _permissions, _limits);
|
||||
@ -499,9 +498,9 @@ void QueuedCore::init(const QString &_configuration)
|
||||
// settings update notifier
|
||||
m_connections += connect(
|
||||
m_advancedSettings,
|
||||
SIGNAL(valueUpdated(const QueuedCfg::QueuedSettings, const QString &,
|
||||
SIGNAL(valueUpdated(const QueuedConfig::QueuedSettings, const QString &,
|
||||
const QVariant &)),
|
||||
this, SLOT(updateSettings(const QueuedCfg::QueuedSettings,
|
||||
this, SLOT(updateSettings(const QueuedConfig::QueuedSettings,
|
||||
const QString &, const QVariant &)));
|
||||
|
||||
// dbus session
|
||||
@ -515,7 +514,7 @@ void QueuedCore::init(const QString &_configuration)
|
||||
/**
|
||||
* @fn updateSettings
|
||||
*/
|
||||
void QueuedCore::updateSettings(const QueuedCfg::QueuedSettings _id,
|
||||
void QueuedCore::updateSettings(const QueuedConfig::QueuedSettings _id,
|
||||
const QString &_key, const QVariant &_value)
|
||||
{
|
||||
qCDebug(LOG_LIB) << "Received update for" << static_cast<int>(_id) << _key
|
||||
@ -523,36 +522,36 @@ void QueuedCore::updateSettings(const QueuedCfg::QueuedSettings _id,
|
||||
|
||||
// FIXME propbably there is a better way to change settings
|
||||
switch (_id) {
|
||||
case QueuedCfg::QueuedSettings::Invalid:
|
||||
case QueuedConfig::QueuedSettings::Invalid:
|
||||
// check if it is plugin settings
|
||||
if (_key.startsWith("Plugin."))
|
||||
m_plugins->optionChanged(_key, _value);
|
||||
// do nothing otherwise
|
||||
break;
|
||||
case QueuedCfg::QueuedSettings::DatabaseInterval:
|
||||
case QueuedConfig::QueuedSettings::DatabaseInterval:
|
||||
m_databaseManager->setInterval(_value.toLongLong());
|
||||
break;
|
||||
case QueuedCfg::QueuedSettings::DatabaseVersion:
|
||||
case QueuedConfig::QueuedSettings::DatabaseVersion:
|
||||
break;
|
||||
case QueuedCfg::QueuedSettings::DefaultLimits:
|
||||
case QueuedConfig::QueuedSettings::DefaultLimits:
|
||||
break;
|
||||
case QueuedCfg::QueuedSettings::KeepTasks:
|
||||
case QueuedConfig::QueuedSettings::KeepTasks:
|
||||
m_databaseManager->setKeepTasks(_value.toLongLong());
|
||||
break;
|
||||
case QueuedCfg::QueuedSettings::KeepUsers:
|
||||
case QueuedConfig::QueuedSettings::KeepUsers:
|
||||
m_databaseManager->setKeepUsers(_value.toLongLong());
|
||||
break;
|
||||
case QueuedCfg::QueuedSettings::OnExitAction:
|
||||
case QueuedConfig::QueuedSettings::OnExitAction:
|
||||
m_processes->setExitAction(
|
||||
static_cast<QueuedEnums::ExitAction>(_value.toInt()));
|
||||
break;
|
||||
case QueuedCfg::QueuedSettings::Plugins:
|
||||
case QueuedConfig::QueuedSettings::Plugins:
|
||||
// do nothing here
|
||||
break;
|
||||
case QueuedCfg::QueuedSettings::ProcessCommandLine:
|
||||
case QueuedConfig::QueuedSettings::ProcessCommandLine:
|
||||
m_processes->setProcessLine(_value.toString());
|
||||
break;
|
||||
case QueuedCfg::QueuedSettings::TokenExpiration:
|
||||
case QueuedConfig::QueuedSettings::TokenExpiration:
|
||||
m_users->setTokenExpiration(_value.toLongLong());
|
||||
break;
|
||||
}
|
||||
@ -656,7 +655,7 @@ void QueuedCore::initDBus()
|
||||
void QueuedCore::initPlugins()
|
||||
{
|
||||
QStringList pluginList
|
||||
= m_advancedSettings->get(QueuedCfg::QueuedSettings::Plugins)
|
||||
= m_advancedSettings->get(QueuedConfig::QueuedSettings::Plugins)
|
||||
.toString()
|
||||
.split('\n');
|
||||
|
||||
@ -673,10 +672,11 @@ void QueuedCore::initProcesses()
|
||||
{
|
||||
// init processes
|
||||
auto onExitAction = static_cast<QueuedEnums::ExitAction>(
|
||||
m_advancedSettings->get(QueuedCfg::QueuedSettings::OnExitAction)
|
||||
m_advancedSettings->get(QueuedConfig::QueuedSettings::OnExitAction)
|
||||
.toInt());
|
||||
auto processLine
|
||||
= m_advancedSettings->get(QueuedCfg::QueuedSettings::ProcessCommandLine)
|
||||
= m_advancedSettings
|
||||
->get(QueuedConfig::QueuedSettings::ProcessCommandLine)
|
||||
.toString();
|
||||
|
||||
m_processes = new QueuedProcessManager(this, processLine, onExitAction);
|
||||
@ -726,7 +726,7 @@ void QueuedCore::initSettings(const QString &_configuration)
|
||||
qCInfo(LOG_LIB) << "Bump database version to"
|
||||
<< QueuedConfig::DATABASE_VERSION;
|
||||
editOptionPrivate(m_advancedSettings->internalId(
|
||||
QueuedCfg::QueuedSettings::DatabaseVersion),
|
||||
QueuedConfig::QueuedSettings::DatabaseVersion),
|
||||
QueuedConfig::DATABASE_VERSION);
|
||||
}
|
||||
|
||||
@ -744,7 +744,7 @@ void QueuedCore::initUsers()
|
||||
{
|
||||
// load users and tokens
|
||||
auto expiry
|
||||
= m_advancedSettings->get(QueuedCfg::QueuedSettings::TokenExpiration)
|
||||
= m_advancedSettings->get(QueuedConfig::QueuedSettings::TokenExpiration)
|
||||
.toLongLong();
|
||||
|
||||
m_users = new QueuedUserManager(this);
|
||||
@ -766,11 +766,11 @@ void QueuedCore::initUsers()
|
||||
/**
|
||||
* @addTaskPrivate
|
||||
*/
|
||||
bool QueuedCore::addTaskPrivate(const QString &_command,
|
||||
const QStringList &_arguments,
|
||||
const QString &_workingDirectory,
|
||||
const uint _nice, const long long _userId,
|
||||
const QueuedLimits::Limits &_limits)
|
||||
long long QueuedCore::addTaskPrivate(const QString &_command,
|
||||
const QStringList &_arguments,
|
||||
const QString &_workingDirectory,
|
||||
const long long _userId,
|
||||
const QueuedLimits::Limits &_limits)
|
||||
{
|
||||
qCDebug(LOG_LIB) << "Add task" << _command << "with arguments" << _arguments
|
||||
<< "from user" << _userId;
|
||||
@ -785,35 +785,36 @@ bool QueuedCore::addTaskPrivate(const QString &_command,
|
||||
auto taskLimits = QueuedLimits::minimalLimits(
|
||||
_limits, user->nativeLimits(),
|
||||
QueuedLimits::Limits(
|
||||
m_advancedSettings->get(QueuedCfg::QueuedSettings::DefaultLimits)
|
||||
m_advancedSettings->get(QueuedConfig::QueuedSettings::DefaultLimits)
|
||||
.toString()));
|
||||
QVariantHash properties = {{"user", _userId},
|
||||
{"command", _command},
|
||||
{"commandArguments", _arguments},
|
||||
{"workDirectory", _workingDirectory},
|
||||
{"nice", _nice},
|
||||
{"nice", 0},
|
||||
{"uid", ids.first},
|
||||
{"gid", ids.second},
|
||||
{"limits", taskLimits.toString()}};
|
||||
auto id = m_database->add(QueuedDB::TASKS_TABLE, properties);
|
||||
if (id == -1) {
|
||||
qCWarning(LOG_LIB) << "Could not add task" << _command;
|
||||
return false;
|
||||
return id;
|
||||
}
|
||||
|
||||
// add to child object
|
||||
m_processes->add(properties, id);
|
||||
return true;
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn addUserPrivate
|
||||
*/
|
||||
bool QueuedCore::addUserPrivate(const QString &_name, const QString &_email,
|
||||
const QString &_password,
|
||||
const uint _permissions,
|
||||
const QueuedLimits::Limits &_limits)
|
||||
long long QueuedCore::addUserPrivate(const QString &_name,
|
||||
const QString &_email,
|
||||
const QString &_password,
|
||||
const uint _permissions,
|
||||
const QueuedLimits::Limits &_limits)
|
||||
{
|
||||
qCDebug(LOG_LIB) << "Add user" << _name << "with email" << _email
|
||||
<< "and permissions" << _permissions;
|
||||
@ -827,12 +828,12 @@ bool QueuedCore::addUserPrivate(const QString &_name, const QString &_email,
|
||||
auto id = m_database->add(QueuedDB::USERS_TABLE, properties);
|
||||
if (id == -1) {
|
||||
qCWarning(LOG_LIB) << "Could not add user" << _name;
|
||||
return false;
|
||||
return id;
|
||||
}
|
||||
|
||||
// add to child object
|
||||
m_users->add(properties, id);
|
||||
return true;
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
@ -875,7 +876,7 @@ bool QueuedCore::editPluginPrivate(const QString &_plugin, const bool _add)
|
||||
qCDebug(LOG_LIB) << "Edit plugin" << _plugin << "add" << _add;
|
||||
|
||||
QStringList pluginList
|
||||
= m_advancedSettings->get(QueuedCfg::QueuedSettings::Plugins)
|
||||
= m_advancedSettings->get(QueuedConfig::QueuedSettings::Plugins)
|
||||
.toString()
|
||||
.split('\n');
|
||||
|
||||
|
@ -25,6 +25,307 @@
|
||||
|
||||
#include <QDBusConnection>
|
||||
#include <QDBusMessage>
|
||||
#include <queued/QueuedProcess.h>
|
||||
#include <queued/QueuedUser.h>
|
||||
|
||||
|
||||
/**
|
||||
* @fn auth
|
||||
*/
|
||||
QString QueuedCoreAdaptor::auth(const QString &_name, const QString &_password)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Auth user" << _name;
|
||||
|
||||
QVariantList args = {_name, _password};
|
||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||
QueuedConfig::DBUS_OBJECT_PATH,
|
||||
QueuedConfig::DBUS_SERVICE, "/Auth", args))
|
||||
.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn sendOptionEdit
|
||||
*/
|
||||
bool QueuedCoreAdaptor::sendOptionEdit(const QString &_key,
|
||||
const QVariant &_value,
|
||||
const QString &_token)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Edit option" << _key << "to" << _value;
|
||||
|
||||
QVariantList args = {_key, _value, _token};
|
||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||
QueuedConfig::DBUS_OBJECT_PATH,
|
||||
QueuedConfig::DBUS_SERVICE, "/OptionEdit",
|
||||
args))
|
||||
.toBool();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn sendPluginAdd
|
||||
*/
|
||||
bool QueuedCoreAdaptor::sendPluginAdd(const QString &_plugin,
|
||||
const QString &_token)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Add plugin" << _plugin;
|
||||
|
||||
QVariantList args = {_plugin, _token};
|
||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||
QueuedConfig::DBUS_OBJECT_PATH,
|
||||
QueuedConfig::DBUS_SERVICE, "/PluginAdd",
|
||||
args))
|
||||
.toBool();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn sendPluginRemove
|
||||
*/
|
||||
bool QueuedCoreAdaptor::sendPluginRemove(const QString &_plugin,
|
||||
const QString &_token)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Remove plugin" << _plugin;
|
||||
|
||||
QVariantList args = {_plugin, _token};
|
||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||
QueuedConfig::DBUS_OBJECT_PATH,
|
||||
QueuedConfig::DBUS_SERVICE, "/PluginRemove",
|
||||
args))
|
||||
.toBool();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn sendTaskAdd
|
||||
*/
|
||||
long long QueuedCoreAdaptor::sendTaskAdd(
|
||||
const QueuedProcess::QueuedProcessDefinitions &_definitions,
|
||||
const QString &_token)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Add task" << _definitions.command;
|
||||
|
||||
auto limits = QueuedLimits::Limits(_definitions.limits);
|
||||
QVariantList args = {_definitions.command,
|
||||
_definitions.arguments,
|
||||
_definitions.workingDirectory,
|
||||
_definitions.user,
|
||||
limits.cpu,
|
||||
limits.gpu,
|
||||
limits.memory,
|
||||
limits.gpumemory,
|
||||
limits.storage,
|
||||
_token};
|
||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||
QueuedConfig::DBUS_OBJECT_PATH,
|
||||
QueuedConfig::DBUS_SERVICE, "/TaskAdd",
|
||||
args))
|
||||
.toLongLong();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn sendTaskEdit
|
||||
*/
|
||||
bool QueuedCoreAdaptor::sendTaskEdit(
|
||||
const long long _id,
|
||||
const QueuedProcess::QueuedProcessDefinitions &_definitions,
|
||||
const QString &_token)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Edit task" << _id;
|
||||
|
||||
auto limits = QueuedLimits::Limits(_definitions.limits);
|
||||
QVariantList args = {_id,
|
||||
_definitions.command,
|
||||
_definitions.arguments,
|
||||
_definitions.workingDirectory,
|
||||
_definitions.nice,
|
||||
_definitions.uid,
|
||||
_definitions.gid,
|
||||
_definitions.user,
|
||||
limits.cpu,
|
||||
limits.gpu,
|
||||
limits.memory,
|
||||
limits.gpumemory,
|
||||
limits.storage,
|
||||
_token};
|
||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||
QueuedConfig::DBUS_OBJECT_PATH,
|
||||
QueuedConfig::DBUS_SERVICE, "/TaskEdit",
|
||||
args))
|
||||
.toBool();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn sendTaskStart
|
||||
*/
|
||||
bool QueuedCoreAdaptor::sendTaskStart(const long long _id,
|
||||
const QString &_token)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Start task" << _id;
|
||||
|
||||
QVariantList args = {_id, _token};
|
||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||
QueuedConfig::DBUS_OBJECT_PATH,
|
||||
QueuedConfig::DBUS_SERVICE, "/TaskStart",
|
||||
args))
|
||||
.toBool();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn sendTaskStop
|
||||
*/
|
||||
bool QueuedCoreAdaptor::sendTaskStop(const long long _id, const QString &_token)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Stop task" << _id;
|
||||
|
||||
QVariantList args = {_id, _token};
|
||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||
QueuedConfig::DBUS_OBJECT_PATH,
|
||||
QueuedConfig::DBUS_SERVICE, "/TaskStop",
|
||||
args))
|
||||
.toBool();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn sendUserAdd
|
||||
*/
|
||||
long long QueuedCoreAdaptor::sendUserAdd(
|
||||
const QueuedUser::QueuedUserDefinitions &_definitions,
|
||||
const QString &_token)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Add user" << _definitions.name;
|
||||
|
||||
auto limits = QueuedLimits::Limits(_definitions.limits);
|
||||
QVariantList args = {_definitions.name,
|
||||
_definitions.email,
|
||||
_definitions.password,
|
||||
_definitions.permissions,
|
||||
limits.cpu,
|
||||
limits.gpu,
|
||||
limits.memory,
|
||||
limits.gpumemory,
|
||||
limits.storage,
|
||||
_token};
|
||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||
QueuedConfig::DBUS_OBJECT_PATH,
|
||||
QueuedConfig::DBUS_SERVICE, "/UserAdd",
|
||||
args))
|
||||
.toLongLong();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn sendUserEdit
|
||||
*/
|
||||
bool QueuedCoreAdaptor::sendUserEdit(
|
||||
const long long _id, const QueuedUser::QueuedUserDefinitions &_definitions,
|
||||
const QString &_token)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Edit user" << _id;
|
||||
|
||||
auto limits = QueuedLimits::Limits(_definitions.limits);
|
||||
QVariantList args = {_id,
|
||||
_definitions.name,
|
||||
_definitions.password,
|
||||
_definitions.email,
|
||||
limits.cpu,
|
||||
limits.gpu,
|
||||
limits.memory,
|
||||
limits.gpumemory,
|
||||
limits.storage,
|
||||
_token};
|
||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||
QueuedConfig::DBUS_OBJECT_PATH,
|
||||
QueuedConfig::DBUS_SERVICE, "/UserEdit",
|
||||
args))
|
||||
.toBool();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* sendUserPermissionAdd
|
||||
*/
|
||||
bool QueuedCoreAdaptor::sendUserPermissionAdd(
|
||||
const long long _id, const QueuedEnums::Permission _permission,
|
||||
const QString &_token)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Add permission" << static_cast<int>(_permission)
|
||||
<< "to" << _id;
|
||||
|
||||
QVariantList args = {_id, static_cast<uint>(_permission), _token};
|
||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||
QueuedConfig::DBUS_OBJECT_PATH,
|
||||
QueuedConfig::DBUS_SERVICE,
|
||||
"/UserPermissionAdd", args))
|
||||
.toBool();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* sendUserPermissionRemove
|
||||
*/
|
||||
bool QueuedCoreAdaptor::sendUserPermissionRemove(
|
||||
const long long _id, const QueuedEnums::Permission _permission,
|
||||
const QString &_token)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Remove permission" << static_cast<int>(_permission)
|
||||
<< "from" << _id;
|
||||
|
||||
QVariantList args = {_id, static_cast<uint>(_permission), _token};
|
||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||
QueuedConfig::DBUS_OBJECT_PATH,
|
||||
QueuedConfig::DBUS_SERVICE,
|
||||
"/UserPermissionRemove", args))
|
||||
.toBool();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn getOption
|
||||
*/
|
||||
QVariant QueuedCoreAdaptor::getOption(const QString &_property)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Get option" << _property;
|
||||
|
||||
QVariantList args = {_property};
|
||||
return toNativeType(sendRequest(
|
||||
QueuedConfig::DBUS_SERVICE, QueuedConfig::DBUS_PROPERTY_PATH,
|
||||
QueuedConfig::DBUS_SERVICE, "/Option", args));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn getTask
|
||||
*/
|
||||
QVariant QueuedCoreAdaptor::getTask(const long long _id,
|
||||
const QString &_property)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Get task property" << _id << _property;
|
||||
|
||||
QVariantList args = {_id, _property};
|
||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||
QueuedConfig::DBUS_PROPERTY_PATH,
|
||||
QueuedConfig::DBUS_SERVICE, "/Task", args));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn getUser
|
||||
*/
|
||||
QVariant QueuedCoreAdaptor::getUser(const long long _id,
|
||||
const QString &_property)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Get user property" << _id << _property;
|
||||
|
||||
QVariantList args = {_id, _property};
|
||||
return toNativeType(sendRequest(QueuedConfig::DBUS_SERVICE,
|
||||
QueuedConfig::DBUS_PROPERTY_PATH,
|
||||
QueuedConfig::DBUS_SERVICE, "/User", args));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
@ -97,17 +97,17 @@ bool QueuedCoreInterface::PluginRemove(const QString &plugin,
|
||||
/**
|
||||
* @fn TaskAdd
|
||||
*/
|
||||
bool QueuedCoreInterface::TaskAdd(
|
||||
qlonglong QueuedCoreInterface::TaskAdd(
|
||||
const QString &command, const QStringList &arguments,
|
||||
const QString &workingDirectory, const uint nice, const long long user,
|
||||
const long long cpu, const long long gpu, const QString &memory,
|
||||
const QString &gpumemory, const QString &storage, const QString &token)
|
||||
const QString &workingDirectory, const qlonglong user, const qlonglong cpu,
|
||||
const qlonglong gpu, const QString &memory, const QString &gpumemory,
|
||||
const QString &storage, const QString &token)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Add new task with parameters" << command << arguments
|
||||
<< workingDirectory << nice << "from user" << user;
|
||||
<< workingDirectory << "from user" << user;
|
||||
|
||||
return m_core->addTask(
|
||||
command, arguments, workingDirectory, nice, user,
|
||||
command, arguments, workingDirectory, user,
|
||||
QueuedLimits::Limits(cpu, gpu, QueuedLimits::convertMemory(memory),
|
||||
QueuedLimits::convertMemory(gpumemory),
|
||||
QueuedLimits::convertMemory(storage)),
|
||||
@ -122,14 +122,14 @@ bool QueuedCoreInterface::TaskEdit(const qlonglong id, const QString &command,
|
||||
const QStringList &arguments,
|
||||
const QString &directory, const uint nice,
|
||||
const uint uid, const uint gid,
|
||||
const uint state, const long long cpu,
|
||||
const long long gpu, const QString &memory,
|
||||
const qlonglong user, const qlonglong cpu,
|
||||
const qlonglong gpu, const QString &memory,
|
||||
const QString &gpumemory,
|
||||
const QString &storage, const QString &token)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Edit task" << id << command << arguments << directory
|
||||
<< nice << uid << gid << state << cpu << gpu << memory
|
||||
<< gpumemory << storage;
|
||||
<< nice << uid << gid << cpu << gpu << memory << gpumemory
|
||||
<< storage;
|
||||
|
||||
auto task = m_core->task(id);
|
||||
if (!task) {
|
||||
@ -151,8 +151,8 @@ bool QueuedCoreInterface::TaskEdit(const qlonglong id, const QString &command,
|
||||
data[QString("uid")] = uid;
|
||||
if (gid > 0)
|
||||
data[QString("gid")] = gid;
|
||||
if (state > 0)
|
||||
data[QString("state")] = state;
|
||||
if (user > 0)
|
||||
data[QString("user")] = user;
|
||||
// append limits now
|
||||
auto limits = task->nativeLimits();
|
||||
if (cpu > -1)
|
||||
@ -196,12 +196,12 @@ bool QueuedCoreInterface::TaskStop(const qlonglong id, const QString &token)
|
||||
/**
|
||||
* @fn UserAdd
|
||||
*/
|
||||
bool QueuedCoreInterface::UserAdd(const QString &name, const QString &email,
|
||||
const QString &password,
|
||||
const uint permissions, const long long cpu,
|
||||
const long long gpu, const QString &memory,
|
||||
const QString &gpumemory,
|
||||
const QString &storage, const QString &token)
|
||||
qlonglong
|
||||
QueuedCoreInterface::UserAdd(const QString &name, const QString &email,
|
||||
const QString &password, const uint permissions,
|
||||
const qlonglong cpu, const qlonglong gpu,
|
||||
const QString &memory, const QString &gpumemory,
|
||||
const QString &storage, const QString &token)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Add new user with paramaters" << name << email
|
||||
<< permissions;
|
||||
@ -220,8 +220,8 @@ bool QueuedCoreInterface::UserAdd(const QString &name, const QString &email,
|
||||
*/
|
||||
bool QueuedCoreInterface::UserEdit(const qlonglong id, const QString &name,
|
||||
const QString &password,
|
||||
const QString &email, const long long cpu,
|
||||
const long long gpu, const QString &memory,
|
||||
const QString &email, const qlonglong cpu,
|
||||
const qlonglong gpu, const QString &memory,
|
||||
const QString &gpumemory,
|
||||
const QString &storage, const QString &token)
|
||||
{
|
||||
|
@ -59,11 +59,10 @@ QDBusVariant QueuedCorePropertiesInterface::Option(const QString &property)
|
||||
|
||||
|
||||
/**
|
||||
* @fn TaskProperty
|
||||
* @fn Task
|
||||
*/
|
||||
QDBusVariant
|
||||
QueuedCorePropertiesInterface::TaskProperty(const long long id,
|
||||
const QString &property)
|
||||
QDBusVariant QueuedCorePropertiesInterface::Task(const long long id,
|
||||
const QString &property)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Get property" << property << "from task" << id;
|
||||
|
||||
@ -78,11 +77,10 @@ QueuedCorePropertiesInterface::TaskProperty(const long long id,
|
||||
|
||||
|
||||
/**
|
||||
* @fn UserProperty
|
||||
* @fn User
|
||||
*/
|
||||
QDBusVariant
|
||||
QueuedCorePropertiesInterface::UserProperty(const long long id,
|
||||
const QString &property)
|
||||
QDBusVariant QueuedCorePropertiesInterface::User(const long long id,
|
||||
const QString &property)
|
||||
{
|
||||
qCDebug(LOG_DBUS) << "Get property" << property << "from user" << id;
|
||||
|
||||
|
@ -35,8 +35,7 @@ QueuedProcessManager::QueuedProcessManager(QObject *parent,
|
||||
{
|
||||
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
|
||||
|
||||
qRegisterMetaType<QueuedEnums::ExitAction>(
|
||||
"QueuedEnums::ExitAction");
|
||||
qRegisterMetaType<QueuedEnums::ExitAction>("QueuedEnums::ExitAction");
|
||||
|
||||
setExitAction(onExit);
|
||||
setProcessLine(processLine);
|
||||
|
@ -39,9 +39,10 @@ QueuedSettings::QueuedSettings(QObject *parent, const QString path)
|
||||
{
|
||||
qCDebug(LOG_LIB) << __PRETTY_FUNCTION__;
|
||||
|
||||
qRegisterMetaType<QueuedCfg::QueuedAdminSetup>(
|
||||
"QueuedCfg::QueuedAdminSetup");
|
||||
qRegisterMetaType<QueuedCfg::QueuedDBSetup>("QueuedCfg::QueuedDBSetup");
|
||||
qRegisterMetaType<QueuedConfig::QueuedAdminSetup>(
|
||||
"QueuedConfig::QueuedAdminSetup");
|
||||
qRegisterMetaType<QueuedConfig::QueuedDBSetup>(
|
||||
"QueuedConfig::QueuedDBSetup");
|
||||
|
||||
readConfiguration();
|
||||
}
|
||||
@ -59,7 +60,7 @@ QueuedSettings::~QueuedSettings()
|
||||
/**
|
||||
* @fn admin
|
||||
*/
|
||||
QueuedCfg::QueuedAdminSetup QueuedSettings::admin() const
|
||||
QueuedConfig::QueuedAdminSetup QueuedSettings::admin() const
|
||||
{
|
||||
return m_cfgAdmin;
|
||||
}
|
||||
@ -68,7 +69,7 @@ QueuedCfg::QueuedAdminSetup QueuedSettings::admin() const
|
||||
/**
|
||||
* @fn db
|
||||
*/
|
||||
QueuedCfg::QueuedDBSetup QueuedSettings::db() const
|
||||
QueuedConfig::QueuedDBSetup QueuedSettings::db() const
|
||||
{
|
||||
return m_cfgDB;
|
||||
}
|
||||
|
@ -71,8 +71,8 @@ QString QueuedTokenManager::isTokenValid(const QString &_token) const
|
||||
void QueuedTokenManager::loadToken(
|
||||
const QueuedTokenManager::QueuedTokenDefinitions &_definitions)
|
||||
{
|
||||
qCDebug(LOG_LIB) << "Add toen for user" << _definitions.user
|
||||
<< "valud until" << _definitions.validUntil;
|
||||
qCDebug(LOG_LIB) << "Add token for user" << _definitions.user
|
||||
<< "valid until" << _definitions.validUntil;
|
||||
|
||||
m_tokens[_definitions.token] = _definitions;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user