typedef api::String ZoneId;
typedef api::String Declaration;
typedef api::String FileMoveRequestStatus;
+typedef api::StringPair GetNetDevAttrsIn;
+typedef api::StringPair CreateNetDevPhysIn;
+typedef api::StringPair RemoveDeclarationIn;
+typedef api::StringPair CreateZoneIn;
+typedef api::StringPair RevokeDeviceIn;
+typedef api::StringPair DestroyNetDevIn;
typedef api::VectorOfStrings ZoneIds;
typedef api::VectorOfStrings Declarations;
typedef api::VectorOfStrings NetDevList;
typedef api::VectorOfStringPairs Dbuses;
-typedef api::VectorOfStringPairs NetDevAttrs;
+typedef api::VectorOfStringPairs GetNetDevAttrs;
-struct ZoneInfo {
+struct ZoneInfoOut {
std::string id;
int vt;
std::string state;
)
};
-// struct MethodSetActiveZoneConfig {
-// std::string id;
-
-// CONFIG_REGISTER
-// (
-// id
-// )
-// };
-
-// struct MethodGetZoneDbusesConfig {
-// CONFIG_REGISTER_EMPTY
-// };
-
-// struct MethodGetZoneIdListConfig {
-// CONFIG_REGISTER_EMPTY
-// };
-
-
-// struct MethodGetActiveZoneIdConfig {
-// CONFIG_REGISTER_EMPTY
-// };
-
-
-// struct MethodGetZoneInfoConfig {
-// std::string id;
-
-// CONFIG_REGISTER
-// (
-// id
-// )
-// };
-
-// struct MethodSetNetDevAttrsConfig {
-// std::string zone;
-// std::string netdev;
-
-// struct Store {
-// std::string key;
-// std::string value;
-
-// CONFIG_REGISTER
-// (
-// key,
-// value
-// )
-// };
-
-// std::vector<Store> attrs;
-
-// CONFIG_REGISTER
-// (
-// zone,
-// netdev,
-// attrs
-// )
-// };
-
-// struct MethodGetNetDevAttrsConfig {
-// std::string zone;
-// std::string netdev;
-
-// CONFIG_REGISTER
-// (
-// zone,
-// netdev
-// )
-// };
-
-// struct MethodGetNetDevListConfig {
-// std::string zone;
-
-// CONFIG_REGISTER
-// (
-// zone
-// )
-// };
-
-// struct MethodCreateNetDevVethConfig {
-// std::string id;
-// std::string zoneDev;
-// std::string hostDev;
-
-// CONFIG_REGISTER
-// (
-// id,
-// zoneDev,
-// hostDev
-// )
-// };
-
-// struct MethodCreateNetDevMacvlanConfig {
-// std::string id;
-// std::string zoneDev;
-// std::string hostDev;
-
-// CONFIG_REGISTER
-// (
-// id,
-// zoneDev,
-// hostDev
-// )
-// };
-
-// struct MethodCreateNetDevPhysConfig {
-// std::string id;
-// std::string devId;
-
-// CONFIG_REGISTER
-// (
-// id,
-// devId
-// )
-// };
-
-// struct MethodGetDeclareFileConfig {
-// std::string zone;
-// int32_t type;
-// std::string path;
-// int32_t flags;
-// int32_t mode;
-
-// CONFIG_REGISTER
-// (
-// zone,
-// type,
-// path,
-// flags,
-// mode
-// )
-// };
-
-// struct MethodGetDeclareMountConfig {
-// std::string source;
-// std::string zone;
-// std::string target;
-// uint64_t flags;
-// std::string data;
-
-// CONFIG_REGISTER
-// (
-// source,
-// zone,
-// target,
-// flags,
-// data
-// )
-// };
-
-// struct MethodGetDeclareLinkConfig {
-// std::string source;
-// std::string zone;
-// std::string target;
-
-// CONFIG_REGISTER
-// (
-// source,
-// zone,
-// target
-// )
-// };
-
-// struct MethodGetDeclarationConfig {
-// std::string zone;
-// std::string declarationId;
-
-// CONFIG_REGISTER
-// (
-// zone,
-// declarationId
-// )
-// };
-
-// struct MethodRemoveDeclarationConfig {
-// std::string id;
-// std::string declarationId;
-
-// CONFIG_REGISTER
-// (
-// id,
-// declarationId
-// )
-// };
-
-// struct MethodCreateZoneConfig {
-// std::string id;
-// std::string templateName;
-
-// CONFIG_REGISTER
-// (
-// id,
-// templateName
-// )
-// };
-
-// struct MethodDestroyZoneConfig {
-// std::string id;
-
-// CONFIG_REGISTER
-// (
-// id
-// )
-// };
-
-
-// struct MethodShutdownZoneConfig {
-// std::string id;
-
-// CONFIG_REGISTER
-// (
-// id
-// )
-// };
-
-// struct MethodStartZoneConfig {
-// std::string id;
-
-// CONFIG_REGISTER
-// (
-// id
-// )
-// };
-
-// struct MethodLockZoneConfig {
-// std::string id;
-
-// CONFIG_REGISTER
-// (
-// id
-// )
-// };
-
-// struct MethodUnlockZoneConfig {
-// std::string id;
-
-// CONFIG_REGISTER
-// (
-// id
-// )
-// };
-
-// struct MethodGrantDeviceConfig {
-// std::string id;
-// std::string device;
-// uint32_t flags;
-
-// CONFIG_REGISTER
-// (
-// id,
-// device,
-// flags
-// )
-// };
-
-// struct MethodRevokeDeviceConfig {
-// std::string id;
-// std::string device;
-
-// CONFIG_REGISTER
-// (
-// id,
-// device
-// )
-// };
-
-// TODO: Agregate configs if it makes sense. For example: MethodLockZoneConfig and MethodUnlockZoneConfig
-
-
-// Zone:
-// struct MethodNotifyActiveZoneConfig {
-// std::string application;
-// std::string message;
-
-// CONFIG_REGISTER
-// (
-// application,
-// message
-// )
-// };
-
-// struct MethodFileMoveRequest {
-// std::string destination;
-// std::string path;
-
-// CONFIG_REGISTER
-// (
-// destination,
-// path
-// )
-// };
-
-// struct MethodFileMoveRequestResult {
-// std::string result;
-
-// CONFIG_REGISTER
-// (
-// result
-// )
-// };
+struct SetNetDevAttrsIn {
+ std::string id; // Zone's id
+ std::string netDev;
+ std::vector<StringPair> attrs;
+
+ CONFIG_REGISTER
+ (
+ id,
+ netDev,
+ attrs
+ )
+};
+
+struct CreateNetDevVethIn {
+ std::string id;
+ std::string zoneDev;
+ std::string hostDev;
+
+ CONFIG_REGISTER
+ (
+ id,
+ zoneDev,
+ hostDev
+ )
+};
+
+struct CreateNetDevMacvlanIn {
+ std::string id;
+ std::string zoneDev;
+ std::string hostDev;
+ uint32_t mode;
+
+ CONFIG_REGISTER
+ (
+ id,
+ zoneDev,
+ hostDev,
+ mode
+ )
+};
+
+struct DeclareFileIn {
+ std::string zone;
+ int32_t type;
+ std::string path;
+ int32_t flags;
+ int32_t mode;
+
+ CONFIG_REGISTER
+ (
+ zone,
+ type,
+ path,
+ flags,
+ mode
+ )
+};
+
+struct DeclareMountIn {
+ std::string source;
+ std::string zone;
+ std::string target;
+ std::string type;
+ uint64_t flags;
+ std::string data;
+
+ CONFIG_REGISTER
+ (
+ source,
+ zone,
+ target,
+ type,
+ flags,
+ data
+ )
+};
+
+struct DeclareLinkIn
+{
+ std::string source;
+ std::string zone;
+ std::string target;
+
+ CONFIG_REGISTER
+ (
+ source,
+ zone,
+ target
+ )
+};
+
+struct GrantDeviceIn
+{
+ std::string id;
+ std::string device;
+ uint32_t flags;
+
+ CONFIG_REGISTER
+ (
+ id,
+ device,
+ flags
+ )
+};
} // namespace api
} // namespace vasum
#include "api/messages.hpp"
#include "logger/logger.hpp"
-
+#include "config/manager.hpp"
namespace vasum {
std::unique_lock<std::mutex> lock(mNameMutex);
mNameCondition.wait_for(lock,
std::chrono::milliseconds(timeoutMs),
- [this] {
- return mNameAcquired || mNameLost;
- });
+ [this] {
+ return mNameAcquired || mNameLost;
+ });
return mNameAcquired;
}
}
if (methodName == api::host::METHOD_SET_ACTIVE_ZONE) {
- const gchar* id = NULL;
- g_variant_get(parameters, "(&s)", &id);
+ api::ZoneId zoneId;
+ config::loadFromGVariant(parameters, zoneId);
if (mSetActiveZoneCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
- mSetActiveZoneCallback(id, rb);
+ mSetActiveZoneCallback(zoneId, rb);
}
return;
}
}
if (methodName == api::host::METHOD_GET_ZONE_INFO) {
- const gchar* id = NULL;
- g_variant_get(parameters, "(&s)", &id);
+ api::ZoneId zoneId;
+ config::loadFromGVariant(parameters, zoneId);
if (mGetZoneInfoCallback) {
- auto rb = std::make_shared<api::DbusMethodResultBuilder<api::ZoneInfo>>(result);
- mGetZoneInfoCallback(id, rb);
+ auto rb = std::make_shared<api::DbusMethodResultBuilder<api::ZoneInfoOut>>(result);
+ mGetZoneInfoCallback(zoneId, rb);
}
return;
}
if (methodName == api::host::METHOD_SET_NETDEV_ATTRS) {
- const gchar* zone = NULL;
- const gchar* netdev = NULL;
- GVariantIter* iter;
- g_variant_get(parameters, "(&s&sa(ss))", &zone, &netdev, &iter);
- gchar* key = NULL;
- gchar* value = NULL;
- std::vector<std::tuple<std::string, std::string>> attrs;
- while (g_variant_iter_loop(iter, "(&s&s)", &key, &value)) {
- attrs.push_back(std::make_tuple<std::string, std::string>(key, value));
- }
- g_variant_iter_free(iter);
+ api::SetNetDevAttrsIn data;
+ config::loadFromGVariant(parameters, data);
+
if (mSetNetdevAttrsCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
- mSetNetdevAttrsCallback(zone, netdev, attrs, rb);
+ mSetNetdevAttrsCallback(data, rb);
}
return;
}
if (methodName == api::host::METHOD_GET_NETDEV_ATTRS) {
- const gchar* zone = NULL;
- const gchar* netdev = NULL;
- g_variant_get(parameters, "(&s&s)", &zone, &netdev);
+ api::GetNetDevAttrsIn data;
+ config::loadFromGVariant(parameters, data);
+
if (mGetNetdevAttrsCallback) {
- auto rb = std::make_shared<api::DbusMethodResultBuilder<api::NetDevAttrs>>(result);
- mGetNetdevAttrsCallback(zone, netdev, rb);
+ auto rb = std::make_shared<api::DbusMethodResultBuilder<api::GetNetDevAttrs>>(result);
+ mGetNetdevAttrsCallback(data, rb);
}
return;
}
if (methodName == api::host::METHOD_GET_NETDEV_LIST) {
- const gchar* zone = NULL;
- g_variant_get(parameters, "(&s)", &zone);
+ api::ZoneId data;
+ config::loadFromGVariant(parameters, data);
+
if (mGetNetdevListCallback) {
- auto rb = std::make_shared<api::DbusMethodResultBuilder<api::NetDevList>>(result);
- mGetNetdevListCallback(zone, rb);
+ auto rb = std::make_shared<api::DbusMethodResultBuilder<api::GetNetDevAttrs>>(result);
+ mGetNetdevListCallback(data, rb);
}
return;
}
-
if (methodName == api::host::METHOD_CREATE_NETDEV_VETH) {
- const gchar* id = NULL;
- const gchar* zoneDev = NULL;
- const gchar* hostDev = NULL;
- g_variant_get(parameters, "(&s&s&s)", &id, &zoneDev, &hostDev);
+ api::CreateNetDevVethIn data;
+ config::loadFromGVariant(parameters, data);
+
if (mCreateNetdevVethCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
- mCreateNetdevVethCallback(id, zoneDev, hostDev, rb);
+ mCreateNetdevVethCallback(data, rb);
}
return;
}
if (methodName == api::host::METHOD_CREATE_NETDEV_MACVLAN) {
- const gchar* id = NULL;
- const gchar* zoneDev = NULL;
- const gchar* hostDev = NULL;
- guint32 mode;
- g_variant_get(parameters, "(&s&s&su)", &id, &zoneDev, &hostDev, &mode);
+ api::CreateNetDevMacvlanIn data;
+ config::loadFromGVariant(parameters, data);
+
if (mCreateNetdevMacvlanCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
- mCreateNetdevMacvlanCallback(id, zoneDev, hostDev, mode, rb);
+ mCreateNetdevMacvlanCallback(data, rb);
}
}
if (methodName == api::host::METHOD_CREATE_NETDEV_PHYS) {
- const gchar* id = NULL;
- const gchar* devId = NULL;
- g_variant_get(parameters, "(&s&s)", &id, &devId);
+ api::CreateNetDevPhysIn data;
+ config::loadFromGVariant(parameters, data);
+
if (mCreateNetdevPhysCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
- mCreateNetdevPhysCallback(id, devId, rb);
+ mCreateNetdevPhysCallback(data, rb);
}
}
if (methodName == api::host::METHOD_DESTROY_NETDEV) {
- const gchar* id = NULL;
- const gchar* devId = NULL;
- g_variant_get(parameters, "(&s&s)", &id, &devId);
+ api::DestroyNetDevIn data;
+ config::loadFromGVariant(parameters, data);
+
if (mDestroyNetdevCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
- mDestroyNetdevCallback(id, devId, rb);
+ mDestroyNetdevCallback(data, rb);
}
}
if (methodName == api::host::METHOD_DECLARE_FILE) {
- const gchar* zone;
- int32_t type;
- const gchar* path;
- int32_t flags;
- int32_t mode;
- g_variant_get(parameters, "(&si&sii)", &zone, &type, &path, &flags, &mode);
+ api::DeclareFileIn data;
+ config::loadFromGVariant(parameters, data);
if (mDeclareFileCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Declaration>>(result);
- mDeclareFileCallback(zone, type, path, flags, mode, rb);
+ mDeclareFileCallback(data, rb);
}
return;
}
if (methodName == api::host::METHOD_DECLARE_MOUNT) {
- const gchar* source;
- const gchar* zone;
- const gchar* target;
- const gchar* type;
- uint64_t flags;
- const gchar* data;
- g_variant_get(parameters,
- "(&s&s&s&st&s)",
- &source,
- &zone,
- &target,
- &type,
- &flags,
- &data);
+ api::DeclareMountIn data;
+ config::loadFromGVariant(parameters, data);
if (mDeclareMountCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Declaration>>(result);
- mDeclareMountCallback(source, zone, target, type, flags, data, rb);
+ mDeclareMountCallback(data, rb);
}
return;
}
if (methodName == api::host::METHOD_DECLARE_LINK) {
- const gchar* source;
- const gchar* zone;
- const gchar* target;
- g_variant_get(parameters, "(&s&s&s)", &source, &zone, &target);
+ api::DeclareLinkIn data;
+ config::loadFromGVariant(parameters, data);
if (mDeclareLinkCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Declaration>>(result);
- mDeclareLinkCallback(source, zone, target, rb);
+ mDeclareLinkCallback(data, rb);
}
return;
}
if (methodName == api::host::METHOD_GET_DECLARATIONS) {
- const gchar* zone;
- g_variant_get(parameters, "(&s)", &zone);
+ api::ZoneId data;
+ config::loadFromGVariant(parameters, data);
if (mGetDeclarationsCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Declarations>>(result);
- mGetDeclarationsCallback(zone, rb);
+ mGetDeclarationsCallback(data, rb);
}
return;
}
if (methodName == api::host::METHOD_REMOVE_DECLARATION) {
- const gchar* zone;
- const gchar* declarationId;
- g_variant_get(parameters, "(&s&s)", &zone, &declarationId);
+ api::RemoveDeclarationIn data;
+ config::loadFromGVariant(parameters, data);
if (mRemoveDeclarationCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
- mRemoveDeclarationCallback(zone, declarationId, rb);
+ mRemoveDeclarationCallback(data, rb);
}
return;
}
if (methodName == api::host::METHOD_CREATE_ZONE) {
- const gchar* id = NULL;
- const gchar* templateName = NULL;
- g_variant_get(parameters, "(&s&s)", &id, &templateName);
+ api::CreateZoneIn data;
+ config::loadFromGVariant(parameters, data);
if (mCreateZoneCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
- mCreateZoneCallback(id, templateName, rb);
+ mCreateZoneCallback(data, rb);
}
return;
}
if (methodName == api::host::METHOD_DESTROY_ZONE) {
- const gchar* id = NULL;
- g_variant_get(parameters, "(&s)", &id);
+ api::ZoneId data;
+ config::loadFromGVariant(parameters, data);
if (mDestroyZoneCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
- mDestroyZoneCallback(id, rb);
+ mDestroyZoneCallback(data, rb);
}
return;
}
if (methodName == api::host::METHOD_SHUTDOWN_ZONE) {
- const gchar* id = NULL;
- g_variant_get(parameters, "(&s)", &id);
+ api::ZoneId data;
+ config::loadFromGVariant(parameters, data);
if (mShutdownZoneCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
- mShutdownZoneCallback(id, rb);
+ mShutdownZoneCallback(data, rb);
}
}
if (methodName == api::host::METHOD_START_ZONE) {
- const gchar* id = NULL;
- g_variant_get(parameters, "(&s)", &id);
+ api::ZoneId data;
+ config::loadFromGVariant(parameters, data);
if (mStartZoneCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
- mStartZoneCallback(id, rb);
+ mStartZoneCallback(data, rb);
}
}
if (methodName == api::host::METHOD_LOCK_ZONE) {
- const gchar* id = NULL;
- g_variant_get(parameters, "(&s)", &id);
+ api::ZoneId data;
+ config::loadFromGVariant(parameters, data);
if (mLockZoneCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
- mLockZoneCallback(id, rb);
+ mLockZoneCallback(data, rb);
}
return;
}
if (methodName == api::host::METHOD_UNLOCK_ZONE) {
- const gchar* id = NULL;
- g_variant_get(parameters, "(&s)", &id);
+ api::ZoneId data;
+ config::loadFromGVariant(parameters, data);
if (mUnlockZoneCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
- mUnlockZoneCallback(id, rb);
+ mUnlockZoneCallback(data, rb);
}
return;
}
if (methodName == api::host::METHOD_GRANT_DEVICE) {
- const gchar* id = NULL;
- const gchar* device = NULL;
- uint32_t flags;
- g_variant_get(parameters, "(&s&su)", &id, &device, &flags);
+ api::GrantDeviceIn data;
+ config::loadFromGVariant(parameters, data);
if (mGrantDeviceCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
- mGrantDeviceCallback(id, device, flags, rb);
+ mGrantDeviceCallback(data, rb);
}
return;
}
if (methodName == api::host::METHOD_REVOKE_DEVICE) {
- const gchar* id = NULL;
- const gchar* device = NULL;
- g_variant_get(parameters, "(&s&s)", &id, &device);
+ api::RevokeDeviceIn data;
+ config::loadFromGVariant(parameters, data);
if (mRevokeDeviceCallback) {
auto rb = std::make_shared<api::DbusMethodResultBuilder<api::Void>>(result);
- mRevokeDeviceCallback(id, device, rb);
+ mRevokeDeviceCallback(data, rb);
}
return;
}
}
void HostConnection::signalZoneDbusState(const std::string& zoneId,
- const std::string& dbusAddress)
+ const std::string& dbusAddress)
{
GVariant* parameters = g_variant_new("(ss)", zoneId.c_str(), dbusAddress.c_str());
mDbusConnection->emitSignal(api::host::OBJECT_PATH,
#include "dbus/connection.hpp"
#include "api/method-result-builder.hpp"
+#include "api/messages.hpp"
#include <mutex>
#include <condition_variable>
)> GetZoneIdsCallback;
typedef std::function<void(api::MethodResultBuilder::Pointer result
)> GetActiveZoneIdCallback;
- typedef std::function<void(const std::string& id,
+ typedef std::function<void(const api::ZoneId& dataIn,
api::MethodResultBuilder::Pointer result
)> GetZoneInfoCallback;
- typedef std::function<void(const std::string& zone,
- const std::string& netdev,
- const std::vector<std::tuple<std::string, std::string>>& attrs,
+ typedef std::function<void(const api::SetNetDevAttrsIn& dataIn,
api::MethodResultBuilder::Pointer result
)> SetNetdevAttrsCallback;
- typedef std::function<void(const std::string& zone,
- const std::string& netdev,
+ typedef std::function<void(const api::GetNetDevAttrsIn& dataIn,
api::MethodResultBuilder::Pointer result
)> GetNetdevAttrsCallback;
- typedef std::function<void(const std::string& zone,
+ typedef std::function<void(const api::ZoneId& dataIn,
api::MethodResultBuilder::Pointer result
)> GetNetdevListCallback;
- typedef std::function<void(const std::string& zone,
- const std::string& netdev,
- const std::string& hostDev,
+ typedef std::function<void(const api::CreateNetDevVethIn& dataIn,
api::MethodResultBuilder::Pointer result
)> CreateNetdevVethCallback;
- typedef std::function<void(const std::string& id,
- const std::string& zoneDev,
- const std::string& hostDev,
- const uint32_t& mode,
+ typedef std::function<void(const api::CreateNetDevMacvlanIn& dataIn,
api::MethodResultBuilder::Pointer result
)> CreateNetdevMacvlanCallback;
- typedef std::function<void(const std::string& id,
- const std::string& devId,
+ typedef std::function<void(const api::CreateNetDevPhysIn& dataIn,
api::MethodResultBuilder::Pointer result
)> CreateNetdevPhysCallback;
- typedef std::function<void(const std::string& id,
- const std::string& devId,
+ typedef std::function<void(const api::DestroyNetDevIn& dataIn,
api::MethodResultBuilder::Pointer result
)> DestroyNetdevCallback;
- typedef std::function<void(const std::string& zone,
- const int32_t& type,
- const std::string& path,
- const int32_t& flags,
- const int32_t& mode,
+ typedef std::function<void(const api::DeclareFileIn& dataIn,
api::MethodResultBuilder::Pointer result
)> DeclareFileCallback;
- typedef std::function<void(const std::string& source,
- const std::string& zone,
- const std::string& target,
- const std::string& type,
- const uint64_t& flags,
- const std::string& data,
+ typedef std::function<void(const api::DeclareMountIn& dataIn,
api::MethodResultBuilder::Pointer result
)> DeclareMountCallback;
- typedef std::function<void(const std::string& source,
- const std::string& zone,
- const std::string& target,
+ typedef std::function<void(const api::DeclareLinkIn& dataIn,
api::MethodResultBuilder::Pointer result
)> DeclareLinkCallback;
- typedef std::function<void(const std::string& id,
+ typedef std::function<void(const api::ZoneId& dataIn,
api::MethodResultBuilder::Pointer result
)> GetDeclarationsCallback;
- typedef std::function<void(const std::string& id,
- const std::string& declarationId,
+ typedef std::function<void(const api::RemoveDeclarationIn& dataIn,
api::MethodResultBuilder::Pointer result
)> RemoveDeclarationCallback;
- typedef std::function<void(const std::string& id,
+ typedef std::function<void(const api::ZoneId& dataIn,
api::MethodResultBuilder::Pointer result
)> SetActiveZoneCallback;
- typedef std::function<void(const std::string& id,
- const std::string& templateName,
+ typedef std::function<void(const api::CreateZoneIn& dataIn,
api::MethodResultBuilder::Pointer result
)> CreateZoneCallback;
- typedef std::function<void(const std::string& id,
+ typedef std::function<void(const api::ZoneId& dataIn,
api::MethodResultBuilder::Pointer result
)> DestroyZoneCallback;
- typedef std::function<void(const std::string& id,
+ typedef std::function<void(const api::ZoneId& dataIn,
api::MethodResultBuilder::Pointer result
)> ShutdownZoneCallback;
- typedef std::function<void(const std::string& id,
+ typedef std::function<void(const api::ZoneId& dataIn,
api::MethodResultBuilder::Pointer result
)> StartZoneCallback;
- typedef std::function<void(const std::string& id,
+ typedef std::function<void(const api::ZoneId& dataIn,
api::MethodResultBuilder::Pointer result
)> LockZoneCallback;
- typedef std::function<void(const std::string& id,
+ typedef std::function<void(const api::ZoneId& dataIn,
api::MethodResultBuilder::Pointer result
)> UnlockZoneCallback;
- typedef std::function<void(const std::string& id,
- const std::string& device,
- uint32_t flags,
+ typedef std::function<void(const api::GrantDeviceIn& dataIn,
api::MethodResultBuilder::Pointer result
)> GrantDeviceCallback;
- typedef std::function<void(const std::string& id,
- const std::string& device,
+ typedef std::function<void(const api::RevokeDeviceIn& dataIn,
api::MethodResultBuilder::Pointer result
)> RevokeDeviceCallback;
this, _1, _2));
mHostConnection.setSetNetdevAttrsCallback(bind(&ZonesManager::handleSetNetdevAttrsCall,
- this, _1, _2, _3, _4));
+ this, _1, _2));
mHostConnection.setGetNetdevAttrsCallback(bind(&ZonesManager::handleGetNetdevAttrsCall,
- this, _1, _2, _3));
+ this, _1, _2));
mHostConnection.setGetNetdevListCallback(bind(&ZonesManager::handleGetNetdevListCall,
this, _1, _2));
mHostConnection.setCreateNetdevVethCallback(bind(&ZonesManager::handleCreateNetdevVethCall,
- this, _1, _2, _3, _4));
+ this, _1, _2));
mHostConnection.setCreateNetdevMacvlanCallback(bind(&ZonesManager::handleCreateNetdevMacvlanCall,
- this, _1, _2, _3, _4, _5));
+ this, _1, _2));
mHostConnection.setCreateNetdevPhysCallback(bind(&ZonesManager::handleCreateNetdevPhysCall,
- this, _1, _2, _3));
+ this, _1, _2));
mHostConnection.setDestroyNetdevCallback(bind(&ZonesManager::handleDestroyNetdevCall,
- this, _1, _2, _3));
+ this, _1, _2));
mHostConnection.setDeclareFileCallback(bind(&ZonesManager::handleDeclareFileCall,
- this, _1, _2, _3, _4, _5, _6));
+ this, _1, _2));
mHostConnection.setDeclareMountCallback(bind(&ZonesManager::handleDeclareMountCall,
- this, _1, _2, _3, _4, _5, _6, _7));
+ this, _1, _2));
mHostConnection.setDeclareLinkCallback(bind(&ZonesManager::handleDeclareLinkCall,
- this, _1, _2, _3, _4));
+ this, _1, _2));
mHostConnection.setGetDeclarationsCallback(bind(&ZonesManager::handleGetDeclarationsCall,
this, _1, _2));
mHostConnection.setRemoveDeclarationCallback(bind(&ZonesManager::handleRemoveDeclarationCall,
- this, _1, _2, _3));
+ this, _1, _2));
mHostConnection.setSetActiveZoneCallback(bind(&ZonesManager::handleSetActiveZoneCall,
this, _1, _2));
mHostConnection.setCreateZoneCallback(bind(&ZonesManager::handleCreateZoneCall,
- this, _1, _2, _3));
+ this, _1, _2));
mHostConnection.setDestroyZoneCallback(bind(&ZonesManager::handleDestroyZoneCall,
this, _1, _2));
this, _1, _2));
mHostConnection.setGrantDeviceCallback(bind(&ZonesManager::handleGrantDeviceCall,
- this, _1, _2, _3, _4));
+ this, _1, _2));
mHostConnection.setRevokeDeviceCallback(bind(&ZonesManager::handleRevokeDeviceCall,
- this, _1, _2, _3));
+ this, _1, _2));
for (const auto& zoneId : mDynamicConfig.zoneIds) {
insertZone(zoneId, getTemplatePathForExistingZone(zoneId));
result->set(zoneId);
}
-void ZonesManager::handleGetZoneInfoCall(const std::string& id,
+void ZonesManager::handleGetZoneInfoCall(const api::ZoneId& zoneId,
api::MethodResultBuilder::Pointer result)
{
LOGI("GetZoneInfo call");
Lock lock(mMutex);
- auto iter = findZone(id);
+ auto iter = findZone(zoneId.value);
if (iter == mZones.end()) {
- LOGE("No zone with id=" << id);
+ LOGE("No zone with id=" << zoneId.value);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
return;
}
Zone& zone = get(iter);
- auto zoneInfo = std::make_shared<api::ZoneInfo>();
+ auto zoneInfo = std::make_shared<api::ZoneInfoOut>();
if (zone.isRunning()) {
zoneInfo->state = "RUNNING";
} else if (zone.isPaused()) {
zoneInfo->state = "FROZEN";
} else {
- LOGE("Unrecognized state of zone id=" << id);
+ LOGE("Unrecognized state of zone id=" << zoneId.value);
result->setError(api::ERROR_INTERNAL, "Unrecognized state of zone");
return;
}
result->set(zoneInfo);
}
-void ZonesManager::handleSetNetdevAttrsCall(const std::string& zone,
- const std::string& netdev,
- const std::vector<std::tuple<std::string, std::string>>& attrs,
+void ZonesManager::handleSetNetdevAttrsCall(const api::SetNetDevAttrsIn& data,
api::MethodResultBuilder::Pointer result)
{
LOGI("SetNetdevAttrs call");
try {
Lock lock(mMutex);
- getZone(zone).setNetdevAttrs(netdev, attrs);
+
+ // TODO: Use vector<StringPair> instead of tuples
+ std::vector<std::tuple<std::string, std::string>> attrsAsTuples;
+ for(const auto& entry: data.attrs){
+ attrsAsTuples.push_back(std::make_tuple(entry.first, entry.second));
+ }
+
+ getZone(data.id).setNetdevAttrs(data.netDev, attrsAsTuples);
result->setVoid();
} catch (const InvalidZoneIdException&) {
- LOGE("No zone with id=" << zone);
+ LOGE("No zone with id=" << data.id);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
} catch (const VasumException& ex) {
LOGE("Can't set attributes: " << ex.what());
}
}
-void ZonesManager::handleGetNetdevAttrsCall(const std::string& zone,
- const std::string& netdev,
+void ZonesManager::handleGetNetdevAttrsCall(const api::GetNetDevAttrsIn& data,
api::MethodResultBuilder::Pointer result)
{
LOGI("GetNetdevAttrs call");
try {
Lock lock(mMutex);
- auto netDevAttrs = std::make_shared<api::NetDevAttrs>();
- const auto attrs = getZone(zone).getNetdevAttrs(netdev);
+ auto netDevAttrs = std::make_shared<api::GetNetDevAttrs>();
+ const auto attrs = getZone(data.first).getNetdevAttrs(data.second);
for (size_t i = 0; i < attrs.size(); ++i) {
netDevAttrs->values.push_back({std::get<0>(attrs[i]), std::get<1>(attrs[i])});
}
result->set(netDevAttrs);
} catch (const InvalidZoneIdException&) {
- LOGE("No zone with id=" << zone);
+ LOGE("No zone with id=" << data.first);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
} catch (const VasumException& ex) {
LOGE("Can't set attributes: " << ex.what());
}
}
-void ZonesManager::handleGetNetdevListCall(const std::string& zone,
+void ZonesManager::handleGetNetdevListCall(const api::ZoneId& zoneId,
api::MethodResultBuilder::Pointer result)
{
LOGI("GetNetdevList call");
try {
Lock lock(mMutex);
auto netDevList = std::make_shared<api::NetDevList>();
- netDevList->values = getZone(zone).getNetdevList();
+ netDevList->values = getZone(zoneId.value).getNetdevList();
result->set(netDevList);
} catch (const InvalidZoneIdException&) {
- LOGE("No zone with id=" << zone);
+ LOGE("No zone with id=" << zoneId.value);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
} catch (const VasumException& ex) {
LOGE("Can't set attributes: " << ex.what());
}
}
-void ZonesManager::handleCreateNetdevVethCall(const std::string& zone,
- const std::string& zoneDev,
- const std::string& hostDev,
+void ZonesManager::handleCreateNetdevVethCall(const api::CreateNetDevVethIn& data,
api::MethodResultBuilder::Pointer result)
{
LOGI("CreateNetdevVeth call");
try {
Lock lock(mMutex);
- getZone(zone).createNetdevVeth(zoneDev, hostDev);
+ getZone(data.id).createNetdevVeth(data.zoneDev, data.hostDev);
result->setVoid();
} catch (const InvalidZoneIdException&) {
- LOGE("No zone with id=" << zone);
+ LOGE("No zone with id=" << data.id);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
} catch (const VasumException& ex) {
LOGE("Can't create veth: " << ex.what());
}
}
-void ZonesManager::handleCreateNetdevMacvlanCall(const std::string& zone,
- const std::string& zoneDev,
- const std::string& hostDev,
- const uint32_t& mode,
+void ZonesManager::handleCreateNetdevMacvlanCall(const api::CreateNetDevMacvlanIn& data,
api::MethodResultBuilder::Pointer result)
{
LOGI("CreateNetdevMacvlan call");
try {
Lock lock(mMutex);
-
- getZone(zone).createNetdevMacvlan(zoneDev, hostDev, mode);
+ getZone(data.id).createNetdevMacvlan(data.zoneDev, data.hostDev, data.mode);
result->setVoid();
} catch (const InvalidZoneIdException&) {
- LOGE("No zone with id=" << zone);
+ LOGE("No zone with id=" << data.id);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
} catch (const VasumException& ex) {
LOGE("Can't create macvlan: " << ex.what());
}
}
-void ZonesManager::handleCreateNetdevPhysCall(const std::string& zone,
- const std::string& devId,
+void ZonesManager::handleCreateNetdevPhysCall(const api::CreateNetDevPhysIn& data,
api::MethodResultBuilder::Pointer result)
{
LOGI("CreateNetdevPhys call");
try {
Lock lock(mMutex);
- getZone(zone).moveNetdev(devId);
+ getZone(data.first).moveNetdev(data.second);
result->setVoid();
} catch (const InvalidZoneIdException&) {
- LOGE("No zone with id=" << zone);
+ LOGE("No zone with id=" << data.first);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
} catch (const VasumException& ex) {
LOGE("Can't create netdev: " << ex.what());
}
}
-void ZonesManager::handleDestroyNetdevCall(const std::string& zone,
- const std::string& devId,
+void ZonesManager::handleDestroyNetdevCall(const api::DestroyNetDevIn& data,
api::MethodResultBuilder::Pointer result)
{
LOGI("DestroyNetdev call");
try {
Lock lock(mMutex);
- getZone(zone).destroyNetdev(devId);
+ getZone(data.first).destroyNetdev(data.second);
result->setVoid();
} catch (const InvalidZoneIdException&) {
- LOGE("No zone with id=" << zone);
+ LOGE("No zone with id=" << data.first);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
} catch (const VasumException& ex) {
LOGE("Can't create netdev: " << ex.what());
}
}
-void ZonesManager::handleDeclareFileCall(const std::string& zone,
- const int32_t& type,
- const std::string& path,
- const int32_t& flags,
- const int32_t& mode,
+void ZonesManager::handleDeclareFileCall(const api::DeclareFileIn& data,
api::MethodResultBuilder::Pointer result)
{
LOGI("DeclareFile call");
try {
Lock lock(mMutex);
auto declaration = std::make_shared<api::Declaration>();
- declaration->value = getZone(zone).declareFile(type, path, flags, mode);
+ declaration->value = getZone(data.zone).declareFile(data.type, data.path, data.flags, data.mode);
result->set(declaration);
} catch (const InvalidZoneIdException&) {
- LOGE("No zone with id=" << zone);
+ LOGE("No zone with id=" << data.zone);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
} catch (const config::ConfigException& ex) {
LOGE("Can't declare file: " << ex.what());
}
}
-void ZonesManager::handleDeclareMountCall(const std::string& source,
- const std::string& zone,
- const std::string& target,
- const std::string& type,
- const uint64_t& flags,
- const std::string& data,
+void ZonesManager::handleDeclareMountCall(const api::DeclareMountIn& data,
api::MethodResultBuilder::Pointer result)
{
LOGI("DeclareMount call");
try {
Lock lock(mMutex);
auto declaration = std::make_shared<api::Declaration>();
- declaration->value = getZone(zone).declareMount(source, target, type, flags, data);
+ declaration->value = getZone(data.zone).declareMount(data.source, data.target, data.type, data.flags, data.data);
result->set(declaration);
} catch (const InvalidZoneIdException&) {
- LOGE("No zone with id=" << zone);
+ LOGE("No zone with id=" << data.zone);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
} catch (const config::ConfigException& ex) {
LOGE("Can't declare mount: " << ex.what());
}
}
-void ZonesManager::handleDeclareLinkCall(const std::string& source,
- const std::string& zone,
- const std::string& target,
+void ZonesManager::handleDeclareLinkCall(const api::DeclareLinkIn& data,
api::MethodResultBuilder::Pointer result)
{
LOGI("DeclareLink call");
try {
Lock lock(mMutex);
auto declaration = std::make_shared<api::Declaration>();
- declaration->value = getZone(zone).declareLink(source, target);
+ declaration->value = getZone(data.zone).declareLink(data.source, data.target);
result->set(declaration);
} catch (const InvalidZoneIdException&) {
- LOGE("No zone with id=" << zone);
+ LOGE("No zone with id=" << data.zone);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
} catch (const config::ConfigException& ex) {
LOGE("Can't declare link: " << ex.what());
}
}
-void ZonesManager::handleGetDeclarationsCall(const std::string& zone,
+void ZonesManager::handleGetDeclarationsCall(const api::ZoneId& zoneId,
api::MethodResultBuilder::Pointer result)
{
- LOGI("GetDeclarations call Id=" << zone);
+ LOGI("GetDeclarations call Id=" << zoneId.value);
try {
Lock lock(mMutex);
auto declarations = std::make_shared<api::Declarations>();
- declarations->values = getZone(zone).getDeclarations();
+ declarations->values = getZone(zoneId.value).getDeclarations();
result->set(declarations);
} catch (const InvalidZoneIdException&) {
- LOGE("No zone with id=" << zone);
+ LOGE("No zone with id=" << zoneId.value);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
} catch (const VasumException& ex) {
LOGE(ex.what());
}
}
-void ZonesManager::handleRemoveDeclarationCall(const std::string& zone,
- const std::string& declarationId,
+void ZonesManager::handleRemoveDeclarationCall(const api::RemoveDeclarationIn& data,
api::MethodResultBuilder::Pointer result)
{
- LOGI("RemoveDeclaration call Id=" << zone);
+ LOGI("RemoveDeclaration call Id=" << data.first);
try {
Lock lock(mMutex);
-
- getZone(zone).removeDeclaration(declarationId);
-
+ getZone(data.first).removeDeclaration(data.second);
result->setVoid();
} catch (const InvalidZoneIdException&) {
- LOGE("No zone with id=" << zone);
+ LOGE("No zone with id=" << data.first);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
} catch (const VasumException& ex) {
LOGE(ex.what());
}
}
-void ZonesManager::handleSetActiveZoneCall(const std::string& id,
+void ZonesManager::handleSetActiveZoneCall(const api::ZoneId& zoneId,
api::MethodResultBuilder::Pointer result)
{
- LOGI("SetActiveZone call; Id=" << id );
+ LOGI("SetActiveZone call; Id=" << zoneId.value );
Lock lock(mMutex);
- auto iter = findZone(id);
+ auto iter = findZone(zoneId.value);
if (iter == mZones.end()) {
- LOGE("No zone with id=" << id );
+ LOGE("No zone with id=" << zoneId.value);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
return;
}
updateDefaultId();
}
-void ZonesManager::handleCreateZoneCall(const std::string& id,
- const std::string& templateName,
+void ZonesManager::handleCreateZoneCall(const api::CreateZoneIn& data,
api::MethodResultBuilder::Pointer result)
{
try {
- createZone(id, templateName);
+ createZone(data.first, data.second);
result->setVoid();
} catch (const InvalidZoneIdException& e) {
result->setError(api::ERROR_INVALID_ID, "Existing or invalid zone id");
}
}
-void ZonesManager::handleDestroyZoneCall(const std::string& id,
+void ZonesManager::handleDestroyZoneCall(const api::ZoneId& zoneId,
api::MethodResultBuilder::Pointer result)
{
- auto destroyer = [id, result, this] {
+ auto destroyer = [zoneId, result, this] {
try {
- LOGI("Destroying zone " << id);
-
- destroyZone(id);
+ LOGI("Destroying zone " << zoneId.value);
+ destroyZone(zoneId.value);
} catch (const InvalidZoneIdException&) {
- LOGE("Failed to destroy zone - no such zone id: " << id);
+ LOGE("Failed to destroy zone - no such zone id: " << zoneId.value);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
} catch (const VasumException& e) {
LOGE("Error during zone destruction: " << e.what());
mWorker->addTask(destroyer);
}
-void ZonesManager::handleShutdownZoneCall(const std::string& id,
+void ZonesManager::handleShutdownZoneCall(const api::ZoneId& zoneId,
api::MethodResultBuilder::Pointer result)
{
- LOGI("ShutdownZone call; Id=" << id );
+ LOGI("ShutdownZone call; Id=" << zoneId.value);
- auto shutdown = [id, result, this] {
+ auto shutdown = [zoneId, result, this] {
try {
- LOGT("Shutdown zone " << id);
+ LOGT("Shutdown zone " << zoneId.value);
Lock lock(mMutex);
- auto iter = findZone(id);
+ auto iter = findZone(zoneId.value);
if (iter == mZones.end()) {
- LOGE("Failed to shutdown zone - no such zone id: " << id);
+ LOGE("Failed to shutdown zone - no such zone id: " << zoneId.value);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
return;
}
mWorker->addTask(shutdown);
}
-void ZonesManager::handleStartZoneCall(const std::string& id,
+void ZonesManager::handleStartZoneCall(const api::ZoneId& zoneId,
api::MethodResultBuilder::Pointer result)
{
- LOGI("StartZone call; Id=" << id );
+ LOGI("StartZone call; Id=" << zoneId.value);
- auto startAsync = [this, id, result]() {
+ auto startAsync = [this, zoneId, result]() {
try {
- LOGT("Start zone " << id );
+ LOGT("Start zone " << zoneId.value);
Lock lock(mMutex);
- auto iter = findZone(id);
+ auto iter = findZone(zoneId.value);
if (iter == mZones.end()) {
- LOGE("Failed to start zone - no such zone id: " << id);
+ LOGE("Failed to start zone - no such zone id: " << zoneId.value);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
return;
}
focusInternal(iter);
result->setVoid();
} catch (const std::exception& e) {
- LOGE(id << ": failed to start: " << e.what());
+ LOGE(zoneId.value << ": failed to start: " << e.what());
result->setError(api::ERROR_INTERNAL, "Failed to start zone");
}
};
mWorker->addTask(startAsync);
}
-void ZonesManager::handleLockZoneCall(const std::string& id,
+void ZonesManager::handleLockZoneCall(const api::ZoneId& zoneId,
api::MethodResultBuilder::Pointer result)
{
- LOGI("LockZone call; Id=" << id );
+ LOGI("LockZone call; Id=" << zoneId.value );
Lock lock(mMutex);
- auto iter = findZone(id);
+ auto iter = findZone(zoneId.value);
if (iter == mZones.end()) {
- LOGE("Failed to lock zone - no such zone id: " << id);
+ LOGE("Failed to lock zone - no such zone id: " << zoneId.value);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
return;
}
Zone& zone = get(iter);
if (!zone.isRunning()) {
- LOGE("Zone id=" << id << " is not running.");
+ LOGE("Zone id=" << zoneId.value << " is not running.");
result->setError(api::ERROR_INVALID_STATE, "Zone is not running");
return;
}
result->setVoid();
}
-void ZonesManager::handleUnlockZoneCall(const std::string& id,
+void ZonesManager::handleUnlockZoneCall(const api::ZoneId& zoneId,
api::MethodResultBuilder::Pointer result)
{
- LOGI("UnlockZone call; Id=" << id );
+ LOGI("UnlockZone call; Id=" << zoneId.value );
Lock lock(mMutex);
- auto iter = findZone(id);
+ auto iter = findZone(zoneId.value);
if (iter == mZones.end()) {
- LOGE("Failed to unlock zone - no such zone id: " << id);
+ LOGE("Failed to unlock zone - no such zone id: " << zoneId.value);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
return;
}
Zone& zone = get(iter);
if (!zone.isPaused()) {
- LOGE("Zone id=" << id << " is not paused.");
+ LOGE("Zone id=" << zoneId.value << " is not paused.");
result->setError(api::ERROR_INVALID_STATE, "Zone is not paused");
return;
}
result->setVoid();
}
-void ZonesManager::handleGrantDeviceCall(const std::string& id,
- const std::string& device,
- uint32_t flags,
+void ZonesManager::handleGrantDeviceCall(const api::GrantDeviceIn& data,
api::MethodResultBuilder::Pointer result)
{
- LOGI("GrantDevice call; id=" << id << "; dev=" << device);
+ LOGI("GrantDevice call; id=" << data.id << "; dev=" << data.device);
Lock lock(mMutex);
- auto iter = findZone(id);
+ auto iter = findZone(data.id);
if (iter == mZones.end()) {
- LOGE("Failed to grant device - no such zone id: " << id);
+ LOGE("Failed to grant device - no such zone id: " << data.id);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
return;
}
Zone& zone = get(iter);
if (!zone.isRunning() && !zone.isPaused()) {
- LOGE("Zone id=" << id << " is not running");
+ LOGE("Zone id=" << data.id << " is not running");
result->setError(api::ERROR_INVALID_STATE, "Zone is not running");
return;
}
- std::string devicePath = "/dev/" + device;
+ std::string devicePath = "/dev/" + data.device;
if (!lxc::isDevice(devicePath)) {
- LOGE("Failed to grant device - cannot acces device: " << device);
+ LOGE("Failed to grant device - cannot acces device: " << data.device);
result->setError(api::ERROR_FORBIDDEN, "Cannot access device");
return;
}
// assume device node is created inside zone
- if (!lxc::setDeviceAccess(id, devicePath, true, flags)) {
- LOGE("Failed to grant device: " << device << " for zone: " << id);
+ if (!lxc::setDeviceAccess(data.id, devicePath, true, data.flags)) {
+ LOGE("Failed to grant device: " << data.device << " for zone: " << data.id);
result->setError(api::ERROR_INTERNAL, "Cannot grant device");
return;
}
result->setVoid();
}
-void ZonesManager::handleRevokeDeviceCall(const std::string& id,
- const std::string& device,
+void ZonesManager::handleRevokeDeviceCall(const api::RevokeDeviceIn& data,
api::MethodResultBuilder::Pointer result)
{
- LOGI("RevokeDevice call; id=" << id << "; dev=" << device);
+ LOGI("RevokeDevice call; id=" << data.first << "; dev=" << data.second);
Lock lock(mMutex);
- auto iter = findZone(id);
+ auto iter = findZone(data.first);
if (iter == mZones.end()) {
- LOGE("Failed to revoke device - no such zone id: " << id);
+ LOGE("Failed to revoke device - no such zone id: " << data.first);
result->setError(api::ERROR_INVALID_ID, "No such zone id");
return;
}
Zone& zone = get(iter);
if (!zone.isRunning() && !zone.isPaused()) {
- LOGE("Zone id=" << id << " is not running");
+ LOGE("Zone id=" << data.first << " is not running");
result->setError(api::ERROR_INVALID_STATE, "Zone is not running");
return;
}
- std::string devicePath = "/dev/" + device;
+ std::string devicePath = "/dev/" + data.second;
if (!lxc::isDevice(devicePath)) {
- LOGE("Failed to revoke device - cannot acces device: " << device);
+ LOGE("Failed to revoke device - cannot acces device: " << data.second);
result->setError(api::ERROR_FORBIDDEN, "Cannot access device");
return;
}
- if (!lxc::setDeviceAccess(id, devicePath, false, 0)) {
- LOGE("Failed to revoke device: " << device << " for zone: " << id);
+ if (!lxc::setDeviceAccess(data.first, devicePath, false, 0)) {
+ LOGE("Failed to revoke device: " << data.second << " for zone: " << data.first);
result->setError(api::ERROR_INTERNAL, "Cannot revoke device");
return;
}
int getVTForNewZone();
void insertZone(const std::string& zoneId, const std::string& templatePath);
+ // Zone's handlers---------------------------------------------------------
void handleNotifyActiveZoneCall(const std::string& caller,
const std::string& appliaction,
const std::string& message,
api::MethodResultBuilder::Pointer result);
void handleDisplayOffCall(const std::string& caller);
void handleFileMoveCall(const std::string& srcZoneId,
- const std::string& dstZoneId,
- const std::string& path,
- api::MethodResultBuilder::Pointer result);
+ const std::string& dstZoneId,
+ const std::string& path,
+ api::MethodResultBuilder::Pointer result);
void handleProxyCall(const std::string& caller,
const std::string& target,
const std::string& targetBusName,
GVariant* parameters,
dbus::MethodResultBuilder::Pointer result);
void handleGetZoneDbusesCall(api::MethodResultBuilder::Pointer result);
- void handleDbusStateChanged(const std::string& zoneId, const std::string& dbusAddress);
+
+ void handleDbusStateChanged(const std::string& zoneId,
+ const std::string& dbusAddress);
+ // Host's handlers --------------------------------------------------------
void handleGetZoneIdsCall(api::MethodResultBuilder::Pointer result);
void handleGetActiveZoneIdCall(api::MethodResultBuilder::Pointer result);
- void handleGetZoneInfoCall(const std::string& id, api::MethodResultBuilder::Pointer result);
- void handleSetNetdevAttrsCall(const std::string& zone,
- const std::string& netdev,
- const std::vector<std::tuple<std::string, std::string>>& attrs,
+ void handleGetZoneInfoCall(const api::ZoneId& data,
+ api::MethodResultBuilder::Pointer result);
+ void handleSetNetdevAttrsCall(const api::SetNetDevAttrsIn& data,
api::MethodResultBuilder::Pointer result);
- void handleGetNetdevAttrsCall(const std::string& zone,
- const std::string& netdev,
+ void handleGetNetdevAttrsCall(const api::GetNetDevAttrsIn& data,
api::MethodResultBuilder::Pointer result);
- void handleGetNetdevListCall(const std::string& zone,
+ void handleGetNetdevListCall(const api::ZoneId& data,
api::MethodResultBuilder::Pointer result);
- void handleCreateNetdevVethCall(const std::string& zone,
- const std::string& zoneDev,
- const std::string& hostDev,
+ void handleCreateNetdevVethCall(const api::CreateNetDevVethIn& data,
api::MethodResultBuilder::Pointer result);
- void handleCreateNetdevMacvlanCall(const std::string& zone,
- const std::string& zoneDev,
- const std::string& hostDev,
- const uint32_t& mode,
+ void handleCreateNetdevMacvlanCall(const api::CreateNetDevMacvlanIn& data,
api::MethodResultBuilder::Pointer result);
- void handleCreateNetdevPhysCall(const std::string& zone,
- const std::string& devId,
+ void handleCreateNetdevPhysCall(const api::CreateNetDevPhysIn& data,
api::MethodResultBuilder::Pointer result);
- void handleDestroyNetdevCall(const std::string& zone,
- const std::string& devId,
+ void handleDestroyNetdevCall(const api::DestroyNetDevIn& data,
api::MethodResultBuilder::Pointer result);
- void handleDeclareFileCall(const std::string& zone,
- const int32_t& type,
- const std::string& path,
- const int32_t& flags,
- const int32_t& mode,
+ void handleDeclareFileCall(const api::DeclareFileIn& data,
api::MethodResultBuilder::Pointer result);
- void handleDeclareMountCall(const std::string& source,
- const std::string& zone,
- const std::string& target,
- const std::string& type,
- const uint64_t& flags,
- const std::string& data,
+ void handleDeclareMountCall(const api::DeclareMountIn& data,
api::MethodResultBuilder::Pointer result);
- void handleDeclareLinkCall(const std::string& source,
- const std::string& zone,
- const std::string& target,
+ void handleDeclareLinkCall(const api::DeclareLinkIn& data,
api::MethodResultBuilder::Pointer result);
- void handleGetDeclarationsCall(const std::string& zone,
+ void handleGetDeclarationsCall(const api::ZoneId& data,
api::MethodResultBuilder::Pointer result);
- void handleRemoveDeclarationCall(const std::string& zone,
- const std::string& declarationId,
+ void handleRemoveDeclarationCall(const api::RemoveDeclarationIn& data,
api::MethodResultBuilder::Pointer result);
- void handleSetActiveZoneCall(const std::string& id,
+ void handleSetActiveZoneCall(const api::ZoneId& data,
api::MethodResultBuilder::Pointer result);
- void handleCreateZoneCall(const std::string& id,
- const std::string& templateName,
+ void handleCreateZoneCall(const api::CreateZoneIn& data,
api::MethodResultBuilder::Pointer result);
- void handleDestroyZoneCall(const std::string& id,
+ void handleDestroyZoneCall(const api::ZoneId& data,
api::MethodResultBuilder::Pointer result);
- void handleShutdownZoneCall(const std::string& id,
+ void handleShutdownZoneCall(const api::ZoneId& data,
api::MethodResultBuilder::Pointer result);
- void handleStartZoneCall(const std::string& id,
+ void handleStartZoneCall(const api::ZoneId& data,
api::MethodResultBuilder::Pointer result);
- void handleLockZoneCall(const std::string& id,
+ void handleLockZoneCall(const api::ZoneId& data,
api::MethodResultBuilder::Pointer result);
- void handleUnlockZoneCall(const std::string& id,
+ void handleUnlockZoneCall(const api::ZoneId& data,
api::MethodResultBuilder::Pointer result);
- void handleGrantDeviceCall(const std::string& id,
- const std::string& device,
- uint32_t flags,
+ void handleGrantDeviceCall(const api::GrantDeviceIn& data,
api::MethodResultBuilder::Pointer result);
- void handleRevokeDeviceCall(const std::string& id,
- const std::string& device,
+ void handleRevokeDeviceCall(const api::RevokeDeviceIn& data,
api::MethodResultBuilder::Pointer result);
};
int intVal;
std::int64_t int64Val;
+ std::uint32_t uint32Val;
+ std::uint64_t uint64Val;
std::string stringVal;
double doubleVal;
bool boolVal;
(
intVal,
int64Val,
+ uint32Val,
+ uint64Val,
stringVal,
doubleVal,
boolVal,
const std::string jsonTestString =
"{ \"intVal\": 12345, "
"\"int64Val\": -1234567890123456789, "
+ "\"uint32Val\": 123456, "
+ "\"uint64Val\": 1234567890123456789, "
"\"stringVal\": \"blah\", "
"\"doubleVal\": -1.234000, "
"\"boolVal\": true, "
const std::string jsonEmptyTestString =
"{ \"intVal\": 0, "
"\"int64Val\": 0, "
+ "\"uint32Val\": 0, "
+ "\"uint64Val\": 0, "
"\"stringVal\": \"\", "
"\"boolVal\": false, "
"\"emptyIntVector\": [ ], "
BOOST_CHECK_EQUAL(12345, testConfig.intVal);
BOOST_CHECK_EQUAL(-1234567890123456789ll, testConfig.int64Val);
+ BOOST_CHECK_EQUAL(123456, testConfig.uint32Val);
+ BOOST_CHECK_EQUAL(1234567890123456789ll, testConfig.uint64Val);
BOOST_CHECK_EQUAL("blah", testConfig.stringVal);
BOOST_CHECK_CLOSE(-1.234, testConfig.doubleVal, TOLERANCE);
BOOST_CHECK_EQUAL(true, testConfig.boolVal);