SET(COMMON_FOLDER ${PROJECT_SOURCE_DIR}/common)
SET(CLIENT_FOLDER ${PROJECT_SOURCE_DIR}/client)
SET(SERVER_FOLDER ${PROJECT_SOURCE_DIR}/server)
-SET(CONTAINER_SUPPORT_FOLDER ${PROJECT_SOURCE_DIR}/container-support)
-SET(CONTAINER_DAEMON_FOLDER ${PROJECT_SOURCE_DIR}/container-daemon)
+SET(ZONE_SUPPORT_FOLDER ${PROJECT_SOURCE_DIR}/zone-support)
+SET(ZONE_DAEMON_FOLDER ${PROJECT_SOURCE_DIR}/zone-daemon)
SET(TESTS_FOLDER ${PROJECT_SOURCE_DIR}/tests)
SET(UNIT_TESTS_FOLDER ${TESTS_FOLDER}/unit_tests)
SET(CLI_FOLDER ${PROJECT_SOURCE_DIR}/cli)
ADD_SUBDIRECTORY(${CLIENT_FOLDER})
ADD_SUBDIRECTORY(${SERVER_FOLDER})
-ADD_SUBDIRECTORY(${CONTAINER_SUPPORT_FOLDER})
-ADD_SUBDIRECTORY(${CONTAINER_DAEMON_FOLDER})
+ADD_SUBDIRECTORY(${ZONE_SUPPORT_FOLDER})
+ADD_SUBDIRECTORY(${ZONE_DAEMON_FOLDER})
ADD_SUBDIRECTORY(${TESTS_FOLDER})
ADD_SUBDIRECTORY(${CLI_FOLDER})
}
-void set_active_container(int pos, int argc, const char** argv)
+void set_active_zone(int pos, int argc, const char** argv)
{
using namespace std::placeholders;
throw runtime_error("Not enough parameters");
}
- one_shot(bind(vsm_set_active_container, _1, argv[pos + 1]));
+ one_shot(bind(vsm_set_active_zone, _1, argv[pos + 1]));
}
void create_zone(int pos, int argc, const char** argv)
};
/**
- * Parses command line arguments and call vsm_set_active_container
+ * Parses command line arguments and call vsm_set_active_zone
*
- * @see vsm_set_active_container
+ * @see vsm_set_active_zone
*/
-void set_active_container(int pos, int argc, const char** argv);
+void set_active_zone(int pos, int argc, const char** argv);
/**
* Parses command line arguments and call vsm_create_zone
std::map<std::string, CommandLineInterface> commands = {
{
- "set_active_container", {
- set_active_container,
- "set_active_container container_id",
- "Set active (foreground) container",
- {{"container_id", "id container name"}}
+ "set_active_zone", {
+ set_active_zone,
+ "set_active_zone zone_id",
+ "Set active (foreground) zone",
+ {{"zone_id", "id zone name"}}
}
},
{
"create_zone", {
create_zone,
- "create_zone container_id",
- "Create and add container",
- {{"container_id", "id container name"}}
+ "create_zone zone_id",
+ "Create and add zone",
+ {{"zone_id", "id zone name"}}
}
},
{
"destroy_zone", {
destroy_zone,
- "destroy_zone container_id",
- "Destroy container",
- {{"container_id", "id container name"}}
+ "destroy_zone zone_id",
+ "Destroy zone",
+ {{"zone_id", "id zone name"}}
}
},
{
"lock_zone", {
lock_zone,
- "lock_zone container_id",
- "Lock container",
- {{"container_id", "id container name"}}
+ "lock_zone zone_id",
+ "Lock zone",
+ {{"zone_id", "id zone name"}}
}
},
{
"unlock_zone", {
unlock_zone,
- "unlock_zone container_id",
- "Unlock container",
- {{"container_id", "id container name"}}
+ "unlock_zone zone_id",
+ "Unlock zone",
+ {{"zone_id", "id zone name"}}
}
},
{
"lookup_zone_by_id", {
lookup_zone_by_id,
- "lookup_zone_by_id container_id",
+ "lookup_zone_by_id zone_id",
"Prints informations about zone",
- {{"container_id", "id container name"}}
+ {{"zone_id", "id zone name"}}
}
}
};
} // namespace
-bool parseContainerIdFromCpuSet(const std::string& cpuset, std::string& id)
+bool parseZoneIdFromCpuSet(const std::string& cpuset, std::string& id)
{
if (cpuset == CPUSET_HOST) {
id = "host";
#include <string>
-bool parseContainerIdFromCpuSet(const std::string& cpuset, std::string& id);
+bool parseZoneIdFromCpuSet(const std::string& cpuset, std::string& id);
#endif // VASUM_CLIENT_UTILS_HPP
#include <dbus/exception.hpp>
#include <utils/glib-loop.hpp>
#include <host-dbus-definitions.hpp>
-#include <container-dbus-definitions.hpp>
+#include <zone-dbus-definitions.hpp>
#include <cstring>
#include <cassert>
const DbusInterfaceInfo HOST_INTERFACE(api::host::BUS_NAME,
api::host::OBJECT_PATH,
api::host::INTERFACE);
-const DbusInterfaceInfo CONTAINER_INTERFACE(api::container::BUS_NAME,
- api::container::OBJECT_PATH,
- api::container::INTERFACE);
+const DbusInterfaceInfo ZONE_INTERFACE(api::zone::BUS_NAME,
+ api::zone::OBJECT_PATH,
+ api::zone::INTERFACE);
unique_ptr<ScopedGlibLoop> gGlibLoop;
return mStatus.mVsmStatus;
}
-VsmStatus Client::vsm_get_container_dbuses(VsmArrayString* keys, VsmArrayString* values) noexcept
+VsmStatus Client::vsm_get_zone_dbuses(VsmArrayString* keys, VsmArrayString* values) noexcept
{
assert(keys);
assert(values);
GVariant* out;
VsmStatus ret = callMethod(HOST_INTERFACE,
- api::host::METHOD_GET_CONTAINER_DBUSES,
+ api::host::METHOD_GET_ZONE_DBUSES,
NULL,
"(a{ss})",
&out);
GVariant* out;
VsmStatus ret = callMethod(HOST_INTERFACE,
- api::host::METHOD_GET_CONTAINER_ID_LIST,
+ api::host::METHOD_GET_ZONE_ID_LIST,
NULL,
"(as)",
&out);
return ret;
}
-VsmStatus Client::vsm_get_active_container_id(VsmString* id) noexcept
+VsmStatus Client::vsm_get_active_zone_id(VsmString* id) noexcept
{
assert(id);
GVariant* out;
VsmStatus ret = callMethod(HOST_INTERFACE,
- api::host::METHOD_GET_ACTIVE_CONTAINER_ID,
+ api::host::METHOD_GET_ACTIVE_ZONE_ID,
NULL,
"(s)",
&out);
return vsm_get_status();
}
- std::string containerId;
- if (!parseContainerIdFromCpuSet(cpuset, containerId)) {
+ std::string zoneId;
+ if (!parseZoneIdFromCpuSet(cpuset, zoneId)) {
mStatus = Status(VSMCLIENT_OTHER_ERROR, "unknown format of cpuset");
return vsm_get_status();
}
- *id = strdup(containerId.c_str());
+ *id = strdup(zoneId.c_str());
mStatus = Status();
return vsm_get_status();
}
GVariant* out;
GVariant* args_in = g_variant_new("(s)", id);
VsmStatus ret = callMethod(HOST_INTERFACE,
- api::host::METHOD_GET_CONTAINER_INFO,
+ api::host::METHOD_GET_ZONE_INFO,
args_in,
"((siss))",
&out);
return vsm_get_status();
}
-VsmStatus Client::vsm_set_active_container(const char* id) noexcept
+VsmStatus Client::vsm_set_active_zone(const char* id) noexcept
{
assert(id);
GVariant* args_in = g_variant_new("(s)", id);
- return callMethod(HOST_INTERFACE, api::host::METHOD_SET_ACTIVE_CONTAINER, args_in);
+ return callMethod(HOST_INTERFACE, api::host::METHOD_SET_ACTIVE_ZONE, args_in);
}
VsmStatus Client::vsm_create_zone(const char* id, const char* tname) noexcept
}
GVariant* args_in = g_variant_new("(s)", id);
- return callMethod(HOST_INTERFACE, api::host::METHOD_CREATE_CONTAINER, args_in);
+ return callMethod(HOST_INTERFACE, api::host::METHOD_CREATE_ZONE, args_in);
}
VsmStatus Client::vsm_destroy_zone(const char* id) noexcept
{
assert(id);
GVariant* args_in = g_variant_new("(s)", id);
- return callMethod(HOST_INTERFACE, api::host::METHOD_DESTROY_CONTAINER, args_in);
+ return callMethod(HOST_INTERFACE, api::host::METHOD_DESTROY_ZONE, args_in);
}
VsmStatus Client::vsm_shutdown_zone(const char*) noexcept
assert(id);
GVariant* args_in = g_variant_new("(s)", id);
- return callMethod(HOST_INTERFACE, api::host::METHOD_LOCK_CONTAINER, args_in);
+ return callMethod(HOST_INTERFACE, api::host::METHOD_LOCK_ZONE, args_in);
}
VsmStatus Client::vsm_unlock_zone(const char* id) noexcept
assert(id);
GVariant* args_in = g_variant_new("(s)", id);
- return callMethod(HOST_INTERFACE, api::host::METHOD_UNLOCK_CONTAINER, args_in);
+ return callMethod(HOST_INTERFACE, api::host::METHOD_UNLOCK_ZONE, args_in);
}
-VsmStatus Client::vsm_add_state_callback(VsmContainerDbusStateCallback containerDbusStateCallback,
+VsmStatus Client::vsm_add_state_callback(VsmZoneDbusStateCallback zoneDbusStateCallback,
void* data,
VsmSubscriptionId* subscriptionId) noexcept
{
- assert(containerDbusStateCallback);
+ assert(zoneDbusStateCallback);
auto onSigal = [=](GVariant * parameters)
{
- const char* container;
+ const char* zone;
const char* dbusAddress;
- g_variant_get(parameters, "(&s&s)", &container, &dbusAddress);
- containerDbusStateCallback(container, dbusAddress, data);
+ g_variant_get(parameters, "(&s&s)", &zone, &dbusAddress);
+ zoneDbusStateCallback(zone, dbusAddress, data);
};
return signalSubscribe(HOST_INTERFACE,
- api::host::SIGNAL_CONTAINER_DBUS_STATE,
+ api::host::SIGNAL_ZONE_DBUS_STATE,
onSigal,
subscriptionId);
}
return vsm_get_status();
}
-VsmStatus Client::vsm_declare_file(const char* container,
+VsmStatus Client::vsm_declare_file(const char* zone,
VsmFileType type,
const char *path,
int32_t flags,
{
assert(path);
- GVariant* args_in = g_variant_new("(sisii)", container, type, path, flags, mode);
- return callMethod(CONTAINER_INTERFACE,
+ GVariant* args_in = g_variant_new("(sisii)", zone, type, path, flags, mode);
+ return callMethod(ZONE_INTERFACE,
api::host::METHOD_DECLARE_FILE,
args_in);
}
VsmStatus Client::vsm_declare_mount(const char *source,
- const char* container,
+ const char* zone,
const char *target,
const char *type,
uint64_t flags,
data = "";
}
- GVariant* args_in = g_variant_new("(ssssts)", source, container, target, type, flags, data);
- return callMethod(CONTAINER_INTERFACE,
+ GVariant* args_in = g_variant_new("(ssssts)", source, zone, target, type, flags, data);
+ return callMethod(ZONE_INTERFACE,
api::host::METHOD_DECLARE_MOUNT,
args_in);
}
VsmStatus Client::vsm_declare_link(const char *source,
- const char* container,
+ const char* zone,
const char *target) noexcept
{
assert(source);
assert(target);
- GVariant* args_in = g_variant_new("(sss)", source, container, target);
- return callMethod(CONTAINER_INTERFACE,
+ GVariant* args_in = g_variant_new("(sss)", source, zone, target);
+ return callMethod(ZONE_INTERFACE,
api::host::METHOD_DECLARE_LINK,
args_in);
}
-VsmStatus Client::vsm_notify_active_container(const char* application, const char* message) noexcept
+VsmStatus Client::vsm_notify_active_zone(const char* application, const char* message) noexcept
{
assert(application);
assert(message);
GVariant* args_in = g_variant_new("(ss)", application, message);
- return callMethod(CONTAINER_INTERFACE,
- api::container::METHOD_NOTIFY_ACTIVE_CONTAINER,
+ return callMethod(ZONE_INTERFACE,
+ api::zone::METHOD_NOTIFY_ACTIVE_ZONE,
args_in);
}
-VsmStatus Client::vsm_file_move_request(const char* destContainer, const char* path) noexcept
+VsmStatus Client::vsm_file_move_request(const char* destZone, const char* path) noexcept
{
- assert(destContainer);
+ assert(destZone);
assert(path);
GVariant* out;
- GVariant* args_in = g_variant_new("(ss)", destContainer, path);
- VsmStatus ret = callMethod(CONTAINER_INTERFACE,
- api::container::METHOD_FILE_MOVE_REQUEST,
+ GVariant* args_in = g_variant_new("(ss)", destZone, path);
+ VsmStatus ret = callMethod(ZONE_INTERFACE,
+ api::zone::METHOD_FILE_MOVE_REQUEST,
args_in,
"(s)",
&out);
}
const gchar* retcode = NULL;;
g_variant_get(out, "(&s)", &retcode);
- if (strcmp(retcode, api::container::FILE_MOVE_SUCCEEDED.c_str()) != 0) {
+ if (strcmp(retcode, api::zone::FILE_MOVE_SUCCEEDED.c_str()) != 0) {
mStatus = Status(VSMCLIENT_CUSTOM_ERROR, retcode);
g_variant_unref(out);
return vsm_get_status();
assert(notificationCallback);
auto onSigal = [=](GVariant * parameters) {
- const char* container;
+ const char* zone;
const char* application;
const char* message;
- g_variant_get(parameters, "(&s&s&s)", &container, &application, &message);
- notificationCallback(container, application, message, data);
+ g_variant_get(parameters, "(&s&s&s)", &zone, &application, &message);
+ notificationCallback(zone, application, message, data);
};
- return signalSubscribe(CONTAINER_INTERFACE,
- api::container::SIGNAL_NOTIFICATION,
+ return signalSubscribe(ZONE_INTERFACE,
+ api::zone::SIGNAL_NOTIFICATION,
onSigal,
subscriptionId);
}
VsmStatus vsm_get_status() noexcept;
/**
- * @see ::vsm_get_container_dbuses
+ * @see ::vsm_get_zone_dbuses
*/
- VsmStatus vsm_get_container_dbuses(VsmArrayString* keys, VsmArrayString* values) noexcept;
+ VsmStatus vsm_get_zone_dbuses(VsmArrayString* keys, VsmArrayString* values) noexcept;
/**
* @see ::vsm_get_zone_ids
VsmStatus vsm_get_zone_ids(VsmArrayString* array) noexcept;
/**
- * @see ::vsm_get_active_container_id
+ * @see ::vsm_get_active_zone_id
*/
- VsmStatus vsm_get_active_container_id(VsmString* id) noexcept;
+ VsmStatus vsm_get_active_zone_id(VsmString* id) noexcept;
/**
* @see ::vsm_lookup_zone_by_pid
VsmStatus vsm_lookup_zone_by_terminal_id(int terminal, VsmString* id) noexcept;
/**
- * @see ::vsm_set_active_container
+ * @see ::vsm_set_active_zone
*/
- VsmStatus vsm_set_active_container(const char* id) noexcept;
+ VsmStatus vsm_set_active_zone(const char* id) noexcept;
/**
* @see ::vsm_create_zone
/**
* @see ::vsm_add_state_callback
*/
- VsmStatus vsm_add_state_callback(VsmContainerDbusStateCallback containerDbusStateCallback,
+ VsmStatus vsm_add_state_callback(VsmZoneDbusStateCallback zoneDbusStateCallback,
void* data,
VsmSubscriptionId* subscriptionId) noexcept;
/**
* @see ::vsm_declare_file
*/
- VsmStatus vsm_declare_file(const char* container,
+ VsmStatus vsm_declare_file(const char* zone,
VsmFileType type,
const char* path,
int32_t flags,
* @see ::vsm_declare_mount
*/
VsmStatus vsm_declare_mount(const char* source,
- const char* container,
+ const char* zone,
const char* target,
const char* type,
uint64_t flags,
* @see ::vsm_declare_link
*/
VsmStatus vsm_declare_link(const char* source,
- const char* container,
+ const char* zone,
const char* target) noexcept;
/**
- * @see ::vsm_notify_active_container
+ * @see ::vsm_notify_active_zone
*/
- VsmStatus vsm_notify_active_container(const char* application, const char* message) noexcept;
+ VsmStatus vsm_notify_active_zone(const char* application, const char* message) noexcept;
/**
* @see ::vsm_file_move_request
*/
- VsmStatus vsm_file_move_request(const char* destContainer, const char* path) noexcept;
+ VsmStatus vsm_file_move_request(const char* destZone, const char* path) noexcept;
/**
* @see ::vsm_add_notification_callback
return getClient(client).vsm_get_status();
}
-API VsmStatus vsm_get_container_dbuses(VsmClient client, VsmArrayString* keys, VsmArrayString* values)
+API VsmStatus vsm_get_zone_dbuses(VsmClient client, VsmArrayString* keys, VsmArrayString* values)
{
- return getClient(client).vsm_get_container_dbuses(keys, values);
+ return getClient(client).vsm_get_zone_dbuses(keys, values);
}
API VsmStatus vsm_get_zone_ids(VsmClient client, VsmArrayString* array)
return getClient(client).vsm_get_zone_ids(array);
}
-API VsmStatus vsm_get_active_container_id(VsmClient client, VsmString* id)
+API VsmStatus vsm_get_active_zone_id(VsmClient client, VsmString* id)
{
- return getClient(client).vsm_get_active_container_id(id);
+ return getClient(client).vsm_get_active_zone_id(id);
}
API VsmStatus vsm_lookup_zone_by_pid(VsmClient client, int pid, VsmString* id)
return getClient(client).vsm_lookup_zone_by_terminal_id(terminal, id);
}
-API VsmStatus vsm_set_active_container(VsmClient client, const char* id)
+API VsmStatus vsm_set_active_zone(VsmClient client, const char* id)
{
- return getClient(client).vsm_set_active_container(id);
+ return getClient(client).vsm_set_active_zone(id);
}
API VsmStatus vsm_create_zone(VsmClient client, const char* id, const char* tname)
}
API VsmStatus vsm_add_state_callback(VsmClient client,
- VsmContainerDbusStateCallback containerDbusStateCallback,
+ VsmZoneDbusStateCallback zoneDbusStateCallback,
void* data,
VsmSubscriptionId* subscriptionId)
{
- return getClient(client).vsm_add_state_callback(containerDbusStateCallback, data, subscriptionId);
+ return getClient(client).vsm_add_state_callback(zoneDbusStateCallback, data, subscriptionId);
}
API VsmStatus vsm_del_state_callback(VsmClient client, VsmSubscriptionId subscriptionId)
}
API VsmStatus vsm_declare_file(VsmClient client,
- const char* container,
+ const char* zone,
VsmFileType type,
const char* path,
int32_t flags,
mode_t mode)
{
- return getClient(client).vsm_declare_file(container, type, path, flags, mode);
+ return getClient(client).vsm_declare_file(zone, type, path, flags, mode);
}
API VsmStatus vsm_declare_mount(VsmClient client,
const char* source,
- const char* container,
+ const char* zone,
const char* target,
const char* type,
uint64_t flags,
const char* data)
{
- return getClient(client).vsm_declare_mount(source, container, target, type, flags, data);
+ return getClient(client).vsm_declare_mount(source, zone, target, type, flags, data);
}
API VsmStatus vsm_declare_link(VsmClient client,
const char* source,
- const char* container,
+ const char* zone,
const char* target)
{
- return getClient(client).vsm_declare_link(source, container, target);
+ return getClient(client).vsm_declare_link(source, zone, target);
}
-API VsmStatus vsm_notify_active_container(VsmClient client,
+API VsmStatus vsm_notify_active_zone(VsmClient client,
const char* application,
const char* message)
{
- return getClient(client).vsm_notify_active_container(application, message);
+ return getClient(client).vsm_notify_active_zone(application, message);
}
-API VsmStatus vsm_file_move_request(VsmClient client, const char* destContainer, const char* path)
+API VsmStatus vsm_file_move_request(VsmClient client, const char* destZone, const char* path)
{
- return getClient(client).vsm_file_move_request(destContainer, path);
+ return getClient(client).vsm_file_move_request(destZone, path);
}
API VsmStatus vsm_add_notification_callback(VsmClient client,
/**
* @name Host API
*
- * Functions using org.tizen.containers.host.manager D-Bus interface.
+ * Functions using org.tizen.vasum.host.manager D-Bus interface.
*
* @{
*/
/**
- * Container's D-Bus state change callback function signature.
+ * Zone's D-Bus state change callback function signature.
*
- * @param[in] containerId affected container id
+ * @param[in] zoneId affected zone id
* @param[in] dbusAddress new D-Bus address
* @param data custom user's data pointer passed to vsm_add_state_callback() function
*/
-typedef void (*VsmContainerDbusStateCallback)(const char* containerId,
+typedef void (*VsmZoneDbusStateCallback)(const char* zoneId,
const char* dbusAddress,
void* data);
/**
- * Get dbus address of each container.
+ * Get dbus address of each zone.
*
* @param[in] client vasum-server's client
- * @param[out] keys array of containers name
- * @param[out] values array of containers dbus address
+ * @param[out] keys array of zones name
+ * @param[out] values array of zones dbus address
* @return status of this function call
* @post keys[i] corresponds to values[i]
* @remark Use vsm_array_string_free() to free memory occupied by @p keys and @p values.
*/
-VsmStatus vsm_get_container_dbuses(VsmClient client, VsmArrayString* keys, VsmArrayString* values);
+VsmStatus vsm_get_zone_dbuses(VsmClient client, VsmArrayString* keys, VsmArrayString* values);
/**
- * Get containers name.
+ * Get zones name.
*
* @param[in] client vasum-server's client
- * @param[out] array array of containers name
+ * @param[out] array array of zones name
* @return status of this function call
* @remark Use vsm_array_string_free() to free memory occupied by @p array.
*/
VsmStatus vsm_get_zone_ids(VsmClient client, VsmArrayString* array);
/**
- * Get active (foreground) container name.
+ * Get active (foreground) zone name.
*
* @param[in] client vasum-server's client
- * @param[out] id active container name
+ * @param[out] id active zone name
* @return status of this function call
* @remark Use @p vsm_string_free() to free memory occupied by @p id.
*/
-VsmStatus vsm_get_active_container_id(VsmClient client, VsmString* id);
+VsmStatus vsm_get_active_zone_id(VsmClient client, VsmString* id);
/**
- * Get container name of process with given pid.
+ * Get zone name of process with given pid.
*
* @param[in] client vasum-server's client
* @param[in] pid process id
- * @param[out] id active container name
+ * @param[out] id active zone name
* @return status of this function call
* @remark Use @p vsm_string_free() to free memory occupied by @p id.
*/
VsmStatus vsm_lookup_zone_by_terminal_id(VsmClient client, int terminal, VsmString* id);
/**
- * Set active (foreground) container.
+ * Set active (foreground) zone.
*
* @param[in] client vasum-server's client
- * @param[in] id container name
+ * @param[in] id zone name
* @return status of this function call
*/
-VsmStatus vsm_set_active_container(VsmClient client, const char* id);
+VsmStatus vsm_set_active_zone(VsmClient client, const char* id);
/**
- * Create and add container
+ * Create and add zone
*
* @param[in] client vasum-server's client
- * @param[in] id container id
+ * @param[in] id zone id
* @param[in] tname template name, NULL for default
* @return status of this function call
*/
* Remove zone
*
* @param[in] client vasum-server's client
- * @param[in] id container id
+ * @param[in] id zone id
* @param[in] force if 0 data will be kept, otherwise data will be lost
* @return status of this function call
*/
* @note The callback function will be invoked on a different thread.
*
* @param[in] client vasum-server's client
- * @param[in] containerDbusStateCallback callback function
+ * @param[in] zoneDbusStateCallback callback function
* @param[in] data some extra data that will be passed to callback function
* @param[out] subscriptionId subscription identifier that can be used to unsubscribe signal,
* pointer can be NULL.
* @return status of this function call
*/
VsmStatus vsm_add_state_callback(VsmClient client,
- VsmContainerDbusStateCallback containerDbusStateCallback,
+ VsmZoneDbusStateCallback zoneDbusStateCallback,
void* data,
VsmSubscriptionId* subscriptionId);
VsmNetdev* netdev);
/**
- * Create file, directory or pipe in container
+ * Create file, directory or pipe in zone
*
- * Declare file, directory or pipe that will be created while container startup
+ * Declare file, directory or pipe that will be created while zone startup
*
* @param[in] client vasum-server's client
* @param[in] type file type
- * @param[in] container container id
+ * @param[in] zone zone id
* @param[in] path path to file
- * @param[in] flags if O_CREAT bit is set then file will be created in container,
+ * @param[in] flags if O_CREAT bit is set then file will be created in zone,
* otherwise file will by copied from host;
* it is meaningful only when O_CREAT is set
* @param[in] mode mode of file
* @return status of this function call
*/
VsmStatus vsm_declare_file(VsmClient client,
- const char* container,
+ const char* zone,
VsmFileType type,
const char* path,
int32_t flags,
mode_t mode);
/**
- * Create mount point in container
+ * Create mount point in zone
*
- * Declare mount that will be created while container startup
+ * Declare mount that will be created while zone startup
* Parameters are passed to mount system function
*
* @param[in] client vasum-server's client
* @param[in] source device path (path in host)
- * @param[in] container container id
- * @param[in] target mount point (path in container)
+ * @param[in] zone zone id
+ * @param[in] target mount point (path in zone)
* @param[in] type filesystem type
* @param[in] flags mount flags as in mount function
* @patam[in] data additional data as in mount function
*/
VsmStatus vsm_declare_mount(VsmClient client,
const char* source,
- const char* container,
+ const char* zone,
const char* target,
const char* type,
uint64_t flags,
const char* data);
/**
- * Create link in container
+ * Create link in zone
*
- * Declare link that will be created while container startup
+ * Declare link that will be created while zone startup
* Parameters are passed to link system function
*
* @param[in] client vasum-server's client
* @param[in] source path to link source (in host)
- * @param[in] container container id
- * @param[in] target path to link name (in container)
+ * @param[in] zone zone id
+ * @param[in] target path to link name (in zone)
* @return status of this function call
*/
VsmStatus vsm_declare_link(VsmClient client,
const char *source,
- const char* container,
+ const char* zone,
const char *target);
/**
* @name Zone API
*
- * Functions using org.tizen.containers.zone.manager D-Bus interface.
+ * Functions using org.tizen.vasum.zone.manager D-Bus interface.
*
* @{
*/
/**
* Notification callback function signature.
*
- * @param[in] container source container
+ * @param[in] zone source zone
* @param[in] application sending application name
* @param[in] message notification message
* @param data custom user's data pointer passed to vsm_add_notification_callback()
*/
-typedef void (*VsmNotificationCallback)(const char* container,
+typedef void (*VsmNotificationCallback)(const char* zone,
const char* application,
const char* message,
void* data);
/**
- * Send message to active container.
+ * Send message to active zone.
*
* @param[in] client vasum-server's client
* @param[in] application application name
* @param[in] message message
* @return status of this function call
*/
-VsmStatus vsm_notify_active_container(VsmClient client, const char* application, const char* message);
+VsmStatus vsm_notify_active_zone(VsmClient client, const char* application, const char* message);
/**
- * Move file between containers.
+ * Move file between zones.
*
* @param[in] client vasum-server's client
- * @param[in] destContainer destination container id
+ * @param[in] destZone destination zone id
* @param[in] path path to moved file
* @return status of this function call
*/
-VsmStatus vsm_file_move_request(VsmClient client, const char* destContainer, const char* path);
+VsmStatus vsm_file_move_request(VsmClient client, const char* destZone, const char* path);
/**
* Register notification callback function.
}
LxcZone::LxcZone(const std::string& lxcPath, const std::string& zoneName)
- : mContainer(nullptr)
+ : mLxcContainer(nullptr)
{
- mContainer = lxc_container_new(zoneName.c_str(), lxcPath.c_str());
- if (!mContainer) {
+ mLxcContainer = lxc_container_new(zoneName.c_str(), lxcPath.c_str());
+ if (!mLxcContainer) {
LOGE("Could not initialize lxc zone " << zoneName << " in path " << lxcPath);
throw LxcException("Could not initialize lxc zone");
}
LxcZone::~LxcZone()
{
- lxc_container_put(mContainer);
+ lxc_container_put(mLxcContainer);
}
std::string LxcZone::getName() const
{
- return mContainer->name;
+ return mLxcContainer->name;
}
std::string LxcZone::getConfigItem(const std::string& key)
{
char buffer[1024];
- int len = mContainer->get_config_item(mContainer, key.c_str(), buffer, sizeof(buffer));
+ int len = mLxcContainer->get_config_item(mLxcContainer, key.c_str(), buffer, sizeof(buffer));
if (len < 0) {
LOGE("Key '" << key << "' not found in zone " << getName());
throw LxcException("Key not found");
bool LxcZone::isDefined()
{
- return mContainer->is_defined(mContainer);
+ return mLxcContainer->is_defined(mLxcContainer);
}
LxcZone::State LxcZone::getState()
{
- const std::string str = mContainer->state(mContainer);
+ const std::string str = mLxcContainer->state(mLxcContainer);
return STATE_MAP.at(str);
}
#ifdef USE_EXEC
utils::CStringArrayBuilder args;
args.add("lxc-create")
- .add("-n").add(mContainer->name)
+ .add("-n").add(mLxcContainer->name)
.add("-t").add(templatePath.c_str())
- .add("-P").add(mContainer->config_path);
+ .add("-P").add(mLxcContainer->config_path);
while (*argv) {
args.add(*argv++);
refresh();
return true;
#else
- if (!mContainer->create(mContainer,
- templatePath.c_str(),
- NULL, NULL, 0,
- const_cast<char* const*>(argv))) {
+ if (!mLxcContainer->create(mLxcContainer,
+ templatePath.c_str(),
+ NULL, NULL, 0,
+ const_cast<char* const*>(argv))) {
LOGE("Could not create zone " << getName());
return false;
}
bool LxcZone::destroy()
{
- if (!mContainer->destroy(mContainer)) {
+ if (!mLxcContainer->destroy(mLxcContainer)) {
LOGE("Could not destroy zone " << getName());
return false;
}
bool LxcZone::start(const char* const* argv)
{
#ifdef USE_EXEC
- if (mContainer->is_running(mContainer)) {
+ if (mLxcContainer->is_running(mLxcContainer)) {
LOGE("Already started " << getName());
return false;
}
utils::CStringArrayBuilder args;
args.add("lxc-start")
.add("-d")
- .add("-n").add(mContainer->name)
- .add("-P").add(mContainer->config_path)
+ .add("-n").add(mLxcContainer->name)
+ .add("-P").add(mLxcContainer->config_path)
.add("--");
while (*argv) {
refresh();
// we have to check status because lxc-start runs in daemonized mode
- if (!mContainer->is_running(mContainer)) {
+ if (!mLxcContainer->is_running(mLxcContainer)) {
LOGE("Could not start init in zone " << getName());
return false;
}
return true;
#else
- if (mContainer->is_running(mContainer)) {
+ if (mLxcContainer->is_running(mLxcContainer)) {
LOGE("Already started " << getName());
return false;
}
- if (!mContainer->want_daemonize(mContainer, true)) {
+ if (!mLxcContainer->want_daemonize(mLxcContainer, true)) {
LOGE("Could not configure zone " << getName());
return false;
}
- if (!mContainer->start(mContainer, false, const_cast<char* const*>(argv))) {
+ if (!mLxcContainer->start(mLxcContainer, false, const_cast<char* const*>(argv))) {
LOGE("Could not start zone " << getName());
return false;
}
bool LxcZone::stop()
{
- if (!mContainer->stop(mContainer)) {
+ if (!mLxcContainer->stop(mLxcContainer)) {
LOGE("Could not stop zone " << getName());
return false;
}
bool LxcZone::reboot()
{
- if (!mContainer->reboot(mContainer)) {
+ if (!mLxcContainer->reboot(mLxcContainer)) {
LOGE("Could not reboot zone " << getName());
return false;
}
utils::CStringArrayBuilder args;
std::string timeoutStr = std::to_string(timeout);
args.add("lxc-stop")
- .add("-n").add(mContainer->name)
- .add("-P").add(mContainer->config_path)
+ .add("-n").add(mLxcContainer->name)
+ .add("-P").add(mLxcContainer->config_path)
.add("-t").add(timeoutStr.c_str())
.add("--nokill");
LOGW("SetRunLevel failed for zone " + getName());
// fallback for other inits like bash: lxc sends 'lxc.haltsignal' signal to init
- if (!mContainer->shutdown(mContainer, timeout)) {
+ if (!mLxcContainer->shutdown(mLxcContainer, timeout)) {
LOGE("Could not gracefully shutdown zone " << getName() << " in " << timeout << "s");
return false;
}
bool LxcZone::freeze()
{
- if (!mContainer->freeze(mContainer)) {
+ if (!mLxcContainer->freeze(mLxcContainer)) {
LOGE("Could not freeze zone " << getName());
return false;
}
bool LxcZone::unfreeze()
{
- if (!mContainer->unfreeze(mContainer)) {
+ if (!mLxcContainer->unfreeze(mLxcContainer)) {
LOGE("Could not unfreeze zone " << getName());
return false;
}
bool LxcZone::waitForState(State state, int timeout)
{
- if (!mContainer->wait(mContainer, toString(state).c_str(), timeout)) {
+ if (!mLxcContainer->wait(mLxcContainer, toString(state).c_str(), timeout)) {
LOGD("Timeout while waiting for state " << toString(state) << " of zone " << getName());
return false;
}
lxc_attach_options_t options = LXC_ATTACH_OPTIONS_DEFAULT;
pid_t pid;
- int ret = mContainer->attach(mContainer, callback, &runLevel, &options, &pid);
+ int ret = mLxcContainer->attach(mLxcContainer, callback, &runLevel, &options, &pid);
if (ret != 0) {
return false;
}
void LxcZone::refresh()
{
//TODO Consider make LxcZone state-less
- std::string zoneName = mContainer->name;
- std::string lxcPath = mContainer->config_path;
- lxc_container_put(mContainer);
- mContainer = lxc_container_new(zoneName.c_str(), lxcPath.c_str());
+ std::string zoneName = mLxcContainer->name;
+ std::string lxcPath = mLxcContainer->config_path;
+ lxc_container_put(mLxcContainer);
+ mLxcContainer = lxc_container_new(zoneName.c_str(), lxcPath.c_str());
}
/**
- * A class wwapping lxc container
+ * A class wrapping lxc container
*/
class LxcZone {
public:
/**
* LxcZone constructor
- * @param lxcPath path where containers lives
+ * @param lxcPath path where zones lives
* @param zoneName name of zone
*/
LxcZone(const std::string& lxcPath, const std::string& zoneName);
*/
bool unfreeze();
private:
- lxc_container* mContainer;
+ lxc_container* mLxcContainer;
bool setRunLevel(int runLevel);
void refresh();
+++ /dev/null
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-
-<busconfig>
- <policy user="${VASUM_USER}">
- <allow own="org.tizen.containers.zone.daemon"/>
- <allow send_destination="org.tizen.containers.zone.daemon"/>
- <allow receive_sender="org.tizen.containers.zone.daemon"/>
- </policy>
- <policy context="default">
- <allow send_destination="org.tizen.containers.zone.daemon"/>
- <allow receive_sender="org.tizen.containers.zone.daemon"/>
- </policy>
-</busconfig>
+++ /dev/null
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-
-<busconfig>
- <policy user="${VASUM_USER}">
- <allow own="org.tizen.containers.zone"/>
- <allow send_destination="org.tizen.containers.zone"/>
- <allow receive_sender="org.tizen.containers.zone"/>
- </policy>
- <policy context="default">
- <allow send_destination="org.tizen.containers.zone"/>
- <allow receive_sender="org.tizen.containers.zone"/>
- </policy>
-</busconfig>
Source0: %{name}-%{version}.tar.gz
License: Apache-2.0
Group: Security/Other
-Summary: Daemon for managing containers
+Summary: Daemon for managing zones
BuildRequires: cmake
BuildRequires: boost-devel
BuildRequires: libjson-devel >= 0.10
Requires: bridge-utils
%description
-This package provides a daemon used to manage containers - start, stop and switch
-between them. A process from inside a container can request a switch of context
-(display, input devices) to the other container.
+This package provides a daemon used to manage zones - start, stop and switch
+between them. A process from inside a zone can request a switch of context
+(display, input devices) to the other zone.
%files
%manifest packaging/vasum.manifest
%defattr(644,root,root,755)
%attr(755,root,root) %{_bindir}/vasum-server
%dir /etc/vasum
-%dir /etc/vasum/containers
+%dir /etc/vasum/zones
%dir /etc/vasum/lxc-templates
%dir /etc/vasum/templates
%config /etc/vasum/daemon.conf
-%config /etc/vasum/containers/*.conf
+%config /etc/vasum/zones/*.conf
%attr(755,root,root) /etc/vasum/lxc-templates/*.sh
%config /etc/vasum/templates/*.conf
%{_unitdir}/vasum.service
%{_unitdir}/multi-user.target.wants/vasum.service
-/etc/dbus-1/system.d/org.tizen.containers.host.conf
+/etc/dbus-1/system.d/org.tizen.vasum.host.conf
%prep
%setup -q
%{_libdir}/pkgconfig/*.pc
-## Container Support Package ###################################################
+## Zone Support Package ###################################################
# TODO move to a separate repository
-%package container-support
+%package zone-support
Summary: Vasum Support
Group: Security/Other
Conflicts: vasum
-%description container-support
-Containers support installed inside every container.
+%description zone-support
+Zones support installed inside every zone.
-%files container-support
-%manifest packaging/vasum-container-support.manifest
+%files zone-support
+%manifest packaging/vasum-zone-support.manifest
%defattr(644,root,root,755)
-/etc/dbus-1/system.d/org.tizen.containers.zone.conf
+/etc/dbus-1/system.d/org.tizen.vasum.zone.conf
-## Container Daemon Package ####################################################
+## Zone Daemon Package ####################################################
# TODO move to a separate repository
-%package container-daemon
-Summary: Vasum Containers Daemon
+%package zone-daemon
+Summary: Vasum Zones Daemon
Group: Security/Other
-Requires: vasum-container-support = %{version}-%{release}
+Requires: vasum-zone-support = %{version}-%{release}
-%description container-daemon
-Daemon running inside every container.
+%description zone-daemon
+Daemon running inside every zone.
-%files container-daemon
-%manifest packaging/vasum-container-daemon.manifest
+%files zone-daemon
+%manifest packaging/vasum-zone-daemon.manifest
%defattr(644,root,root,755)
-%attr(755,root,root) %{_bindir}/vasum-container-daemon
-/etc/dbus-1/system.d/org.tizen.containers.zone.daemon.conf
+%attr(755,root,root) %{_bindir}/vasum-zone-daemon
+/etc/dbus-1/system.d/org.tizen.vasum.zone.daemon.conf
## Command Line Interface ######################################################
%{_datadir}/vasum/tests
%attr(755,root,root) %{_datadir}/vasum/lxc-templates
%{python_sitelib}/vsm_integration_tests
-/etc/dbus-1/system.d/org.tizen.containers.tests.conf
+/etc/dbus-1/system.d/org.tizen.vasum.tests.conf
namespace vasum {
namespace api {
-const std::string ERROR_FORBIDDEN = "org.tizen.containers.Error.Forbidden";
-const std::string ERROR_FORWARDED = "org.tizen.containers.Error.Forwarded";
-const std::string ERROR_INVALID_ID = "org.tizen.containers.Error.InvalidId";
-const std::string ERROR_INVALID_STATE = "org.tizen.containers.Error.InvalidState";
-const std::string ERROR_INTERNAL = "org.tizen.containers.Error.Internal";
+const std::string ERROR_FORBIDDEN = "org.tizen.vasum.Error.Forbidden";
+const std::string ERROR_FORWARDED = "org.tizen.vasum.Error.Forwarded";
+const std::string ERROR_INVALID_ID = "org.tizen.vasum.Error.InvalidId";
+const std::string ERROR_INVALID_STATE = "org.tizen.vasum.Error.InvalidState";
+const std::string ERROR_INTERNAL = "org.tizen.vasum.Error.Internal";
const std::string METHOD_PROXY_CALL = "ProxyCall";
MESSAGE(STATUS "Installing configs to " ${VSM_CONFIG_INSTALL_DIR})
-FILE(GLOB container_CONF containers/*.conf)
+FILE(GLOB zone_CONF zones/*.conf)
FILE(GLOB admin_CONF lxc-templates/*.sh)
FILE(GLOB template_CONF templates/*.conf)
DESTINATION ${VSM_CONFIG_INSTALL_DIR})
# preprocess d-bus configs
-CONFIGURE_FILE(dbus-1/system.d/org.tizen.containers.host.conf.in
- ${CMAKE_BINARY_DIR}/dbus-1/system.d/org.tizen.containers.host.conf)
+CONFIGURE_FILE(dbus-1/system.d/org.tizen.vasum.host.conf.in
+ ${CMAKE_BINARY_DIR}/dbus-1/system.d/org.tizen.vasum.host.conf)
-INSTALL(FILES ${CMAKE_BINARY_DIR}/dbus-1/system.d/org.tizen.containers.host.conf
+INSTALL(FILES ${CMAKE_BINARY_DIR}/dbus-1/system.d/org.tizen.vasum.host.conf
DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d/)
-INSTALL(FILES ${container_CONF}
- DESTINATION ${VSM_CONFIG_INSTALL_DIR}/containers)
+INSTALL(FILES ${zone_CONF}
+ DESTINATION ${VSM_CONFIG_INSTALL_DIR}/zones)
INSTALL(PROGRAMS ${admin_CONF}
DESTINATION ${VSM_CONFIG_INSTALL_DIR}/lxc-templates)
{
- "containerConfigs" : ["containers/private.conf", "containers/business.conf"],
- "containersPath" : "/opt/usr/containers",
- "containerImagePath" : "/opt/usr/containers/img/system-data.img",
- "containerTemplatePath" : "templates",
- "containerNewConfigPrefix" : "/var/lib/vasum",
- "runMountPointPrefix" : "/var/run/containers",
+ "zoneConfigs" : ["zones/private.conf", "zones/business.conf"],
+ "zonesPath" : "/opt/usr/zones",
+ "zoneImagePath" : "/opt/usr/zones/img/system-data.img",
+ "zoneTemplatePath" : "templates",
+ "zoneNewConfigPrefix" : "/var/lib/vasum",
+ "runMountPointPrefix" : "/var/run/zones",
"foregroundId" : "private",
"defaultId" : "private",
"lxcTemplatePrefix" : "/etc/vasum/lxc-templates",
+++ /dev/null
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-
-<busconfig>
- <policy user="${VASUM_USER}">
- <allow own="org.tizen.containers.host"/>
- <allow send_destination="org.tizen.containers.host"/>
- <allow receive_sender="org.tizen.containers.host"/>
- </policy>
- <!-- temporary -->
- <policy user="root">
- <allow own="org.tizen.containers.host"/>
- <allow send_destination="org.tizen.containers.host"/>
- <allow receive_sender="org.tizen.containers.host"/>
- </policy>
- <policy context="default">
- <allow send_destination="org.tizen.containers.host"/>
- <allow receive_sender="org.tizen.containers.host"/>
- </policy>
-</busconfig>
--- /dev/null
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+
+<busconfig>
+ <policy user="${VASUM_USER}">
+ <allow own="org.tizen.vasum.host"/>
+ <allow send_destination="org.tizen.vasum.host"/>
+ <allow receive_sender="org.tizen.vasum.host"/>
+ </policy>
+ <!-- temporary -->
+ <policy user="root">
+ <allow own="org.tizen.vasum.host"/>
+ <allow send_destination="org.tizen.vasum.host"/>
+ <allow receive_sender="org.tizen.vasum.host"/>
+ </policy>
+ <policy context="default">
+ <allow send_destination="org.tizen.vasum.host"/>
+ <allow receive_sender="org.tizen.vasum.host"/>
+ </policy>
+</busconfig>
# XXX assume rootfs if mounted from iso
-# Prepare container configuration file
+# Prepare zone configuration file
> ${path}/config
cat <<EOF >> ${path}/config
lxc.utsname = ${name}
lxc.tty = 0
lxc.mount.auto = proc sys cgroup
-lxc.mount.entry = /var/run/containers/${name}/run var/run none rw,bind 0 0
+lxc.mount.entry = /var/run/zones/${name}/run var/run none rw,bind 0 0
-# create a separate network per container
+# create a separate network per zone
# - it forbids traffic sniffing (like macvlan in bridge mode)
# - it enables traffic controlling from host using iptables
lxc.network.type = veth
{
cat <<EOF
usage:
- $1 -n|--name=<container_name>
+ $1 -n|--name=<zone_name>
[-p|--path=<path>] [-r|--rootfs=<rootfs>] [-v|--vt=<vt>]
[--ipv4=<ipv4>] [--ipv4-gateway=<ipv4_gateway>] [-h|--help]
Mandatory args:
- -n,--name container name
+ -n,--name zone name
Optional args:
- -p,--path path to container config files, defaults to /var/lib/lxc
- --rootfs path to container rootfs, defaults to /var/lib/lxc/[NAME]/rootfs
- -v,--vt container virtual terminal
- --ipv4 container IP address
- --ipv4-gateway container gateway
+ -p,--path path to zone config files, defaults to /var/lib/lxc
+ --rootfs path to zone rootfs, defaults to /var/lib/lxc/[NAME]/rootfs
+ -v,--vt zone virtual terminal
+ --ipv4 zone IP address
+ --ipv4-gateway zone gateway
-h,--help print help
EOF
return 0
fi
if [ -z $name ]; then
- echo "Container name must be given"
+ echo "Zone name must be given"
exit 1
fi
br_name="virbr-${name}"
-# Prepare container rootfs
+# Prepare zone rootfs
ROOTFS_DIRS="\
${rootfs}/bin \
${rootfs}/dev \
EOF
cat <<EOF >>${path}/systemd/system/weston.ini
-# Weston config for container.
+# Weston config for zone.
[core]
modules=desktop-shell.so
WantedBy=graphical.target
EOF
-# Prepare container configuration file
+# Prepare zone configuration file
cat <<EOF >>${path}/config
lxc.utsname = ${name}
lxc.rootfs = ${rootfs}
lxc.mount.auto = proc sys:rw cgroup
lxc.mount = ${path}/fstab
-# create a separate network per container
+# create a separate network per zone
# - it forbids traffic sniffing (like macvlan in bridge mode)
# - it enables traffic controlling from host using iptables
lxc.network.type = veth
#lxc.hook.post-stop = ${path}/hooks/post-stop.sh
EOF
-# Prepare container hook files
+# Prepare zone hook files
cat <<EOF >>${path}/hooks/pre-start.sh
if [ -z "\$(/usr/sbin/brctl show | /bin/grep -P "${br_name}\t")" ]
then
chmod 770 ${path}/hooks/pre-start.sh
-# Prepare container fstab file
+# Prepare zone fstab file
cat <<EOF >>${path}/fstab
/bin bin none ro,bind 0 0
/etc etc none ro,bind 0 0
+++ /dev/null
-/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * Contact: Jan Olszak <j.olszak@samsung.com>
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License
- */
-
-/**
- * @file
- * @author Jan Olszak (j.olszak@samsung.com)
- * @brief Definition of the class for managing containers
- */
-
-#include "config.hpp"
-
-#include "host-dbus-definitions.hpp"
-#include "common-dbus-definitions.hpp"
-#include "container-dbus-definitions.hpp"
-#include "containers-manager.hpp"
-#include "container-admin.hpp"
-#include "exception.hpp"
-
-#include "utils/paths.hpp"
-#include "logger/logger.hpp"
-#include "config/manager.hpp"
-#include "dbus/exception.hpp"
-#include "utils/fs.hpp"
-#include "utils/img.hpp"
-#include "utils/environment.hpp"
-
-#include <boost/filesystem.hpp>
-#include <boost/regex.hpp>
-#include <boost/exception/diagnostic_information.hpp>
-#include <cassert>
-#include <string>
-#include <climits>
-
-
-namespace vasum {
-
-
-namespace {
-
-bool regexMatchVector(const std::string& str, const std::vector<boost::regex>& v)
-{
- for (const boost::regex& toMatch: v) {
- if (boost::regex_match(str, toMatch)) {
- return true;
- }
- }
-
- return false;
-}
-
-const std::string HOST_ID = "host";
-const std::string CONTAINER_TEMPLATE_CONFIG_PATH = "template.conf";
-
-const boost::regex CONTAINER_NAME_REGEX("~NAME~");
-const boost::regex CONTAINER_IP_THIRD_OCTET_REGEX("~IP~");
-
-const unsigned int CONTAINER_IP_BASE_THIRD_OCTET = 100;
-
-} // namespace
-
-ContainersManager::ContainersManager(const std::string& managerConfigPath): mDetachOnExit(false)
-{
- LOGD("Instantiating ContainersManager object...");
-
- mConfigPath = managerConfigPath;
- config::loadFromFile(mConfigPath, mConfig);
-
- mProxyCallPolicy.reset(new ProxyCallPolicy(mConfig.proxyCallRules));
-
- using namespace std::placeholders;
- mHostConnection.setProxyCallCallback(bind(&ContainersManager::handleProxyCall,
- this, HOST_ID, _1, _2, _3, _4, _5, _6, _7));
-
- mHostConnection.setGetContainerDbusesCallback(bind(
- &ContainersManager::handleGetContainerDbuses, this, _1));
-
- mHostConnection.setGetContainerIdsCallback(bind(&ContainersManager::handleGetContainerIdsCall,
- this, _1));
-
- mHostConnection.setGetActiveContainerIdCallback(bind(&ContainersManager::handleGetActiveContainerIdCall,
- this, _1));
-
- mHostConnection.setGetContainerInfoCallback(bind(&ContainersManager::handleGetContainerInfoCall,
- this, _1, _2));
-
- mHostConnection.setDeclareFileCallback(bind(&ContainersManager::handleDeclareFileCall,
- this, _1, _2, _3, _4, _5, _6));
-
- mHostConnection.setDeclareMountCallback(bind(&ContainersManager::handleDeclareMountCall,
- this, _1, _2, _3, _4, _5, _6, _7));
-
- mHostConnection.setDeclareLinkCallback(bind(&ContainersManager::handleDeclareLinkCall,
- this, _1, _2, _3, _4));
-
- mHostConnection.setSetActiveContainerCallback(bind(&ContainersManager::handleSetActiveContainerCall,
- this, _1, _2));
-
- mHostConnection.setCreateContainerCallback(bind(&ContainersManager::handleCreateContainerCall,
- this, _1, _2));
-
- mHostConnection.setDestroyContainerCallback(bind(&ContainersManager::handleDestroyContainerCall,
- this, _1, _2));
-
- mHostConnection.setLockContainerCallback(bind(&ContainersManager::handleLockContainerCall,
- this, _1, _2));
-
- mHostConnection.setUnlockContainerCallback(bind(&ContainersManager::handleUnlockContainerCall,
- this, _1, _2));
-
- for (auto& containerConfig : mConfig.containerConfigs) {
- createContainer(containerConfig);
- }
-
- // check if default container exists, throw ContainerOperationException if not found
- if (!mConfig.defaultId.empty() && mContainers.find(mConfig.defaultId) == mContainers.end()) {
- LOGE("Provided default container ID " << mConfig.defaultId << " is invalid.");
- throw ContainerOperationException("Provided default container ID " + mConfig.defaultId +
- " is invalid.");
- }
-
- LOGD("ContainersManager object instantiated");
-
- if (mConfig.inputConfig.enabled) {
- LOGI("Registering input monitor [" << mConfig.inputConfig.device.c_str() << "]");
- mSwitchingSequenceMonitor.reset(
- new InputMonitor(mConfig.inputConfig,
- std::bind(&ContainersManager::switchingSequenceMonitorNotify,
- this)));
- }
-
-
-}
-
-ContainersManager::~ContainersManager()
-{
- LOGD("Destroying ContainersManager object...");
-
- if (!mDetachOnExit) {
- try {
- stopAll();
- } catch (ServerException&) {
- LOGE("Failed to stop all of the containers");
- }
- }
-
- LOGD("ContainersManager object destroyed");
-}
-
-void ContainersManager::createContainer(const std::string& containerConfig)
-{
- std::string baseConfigPath = utils::dirName(mConfigPath);
- std::string containerConfigPath = utils::getAbsolutePath(containerConfig, baseConfigPath);
-
- LOGT("Creating Container " << containerConfigPath);
- std::unique_ptr<Container> c(new Container(mConfig.containersPath,
- containerConfigPath,
- mConfig.lxcTemplatePrefix,
- mConfig.runMountPointPrefix));
- const std::string id = c->getId();
- if (id == HOST_ID) {
- throw ContainerOperationException("Cannot use reserved container ID");
- }
-
- using namespace std::placeholders;
- c->setNotifyActiveContainerCallback(bind(&ContainersManager::notifyActiveContainerHandler,
- this, id, _1, _2));
-
- c->setDisplayOffCallback(bind(&ContainersManager::displayOffHandler,
- this, id));
-
- c->setFileMoveRequestCallback(bind(&ContainersManager::handleContainerMoveFileRequest,
- this, id, _1, _2, _3));
-
- c->setProxyCallCallback(bind(&ContainersManager::handleProxyCall,
- this, id, _1, _2, _3, _4, _5, _6, _7));
-
- c->setDbusStateChangedCallback(bind(&ContainersManager::handleDbusStateChanged,
- this, id, _1));
-
- mContainers.insert(ContainerMap::value_type(id, std::move(c)));
-}
-
-void ContainersManager::destroyContainer(const std::string& containerId)
-{
- // TODO mutex for mContainers access
- auto it = mContainers.find(containerId);
- if (it == mContainers.end()) {
- LOGE("Failed to destroy container " << containerId << ": no such container");
- throw ContainerOperationException("No such container");
- }
-
- // TODO give back the focus
- it->second->setDestroyOnExit();
- mContainers.erase(it);
-}
-
-void ContainersManager::focus(const std::string& containerId)
-{
- /* try to access the object first to throw immediately if it doesn't exist */
- ContainerMap::mapped_type& foregroundContainer = mContainers.at(containerId);
-
- if (!foregroundContainer->activateVT()) {
- LOGE("Failed to activate containers VT. Aborting focus.");
- return;
- }
-
- for (auto& container : mContainers) {
- LOGD(container.second->getId() << ": being sent to background");
- container.second->goBackground();
- }
- mConfig.foregroundId = foregroundContainer->getId();
- LOGD(mConfig.foregroundId << ": being sent to foreground");
- foregroundContainer->goForeground();
-}
-
-void ContainersManager::startAll()
-{
- LOGI("Starting all containers");
-
- bool isForegroundFound = false;
-
- for (auto& container : mContainers) {
- container.second->start();
-
- if (container.first == mConfig.foregroundId) {
- isForegroundFound = true;
- LOGI(container.second->getId() << ": set as the foreground container");
- container.second->goForeground();
- }
- }
-
- if (!isForegroundFound) {
- auto foregroundIterator = std::min_element(mContainers.begin(), mContainers.end(),
- [](ContainerMap::value_type &c1, ContainerMap::value_type &c2) {
- return c1.second->getPrivilege() < c2.second->getPrivilege();
- });
-
- if (foregroundIterator != mContainers.end()) {
- mConfig.foregroundId = foregroundIterator->second->getId();
- LOGI(mConfig.foregroundId << ": no foreground container configured, setting one with highest priority");
- foregroundIterator->second->goForeground();
- }
- }
-}
-
-void ContainersManager::stopAll()
-{
- LOGI("Stopping all containers");
-
- for (auto& container : mContainers) {
- container.second->stop();
- }
-}
-
-bool ContainersManager::isPaused(const std::string& containerId)
-{
- auto iter = mContainers.find(containerId);
- if (iter == mContainers.end()) {
- LOGE("No such container id: " << containerId);
- throw ContainerOperationException("No such container");
- }
-
- return iter->second->isPaused();
-}
-
-bool ContainersManager::isRunning(const std::string& containerId)
-{
- auto iter = mContainers.find(containerId);
- if (iter == mContainers.end()) {
- LOGE("No such container id: " << containerId);
- throw ContainerOperationException("No such container");
- }
- return iter->second->isRunning();
-}
-
-std::string ContainersManager::getRunningForegroundContainerId()
-{
- for (auto& container : mContainers) {
- if (container.first == mConfig.foregroundId &&
- container.second->isRunning()) {
- return container.first;
- }
- }
- return std::string();
-}
-
-std::string ContainersManager::getNextToForegroundContainerId()
-{
- // handles case where there is no next container
- if (mContainers.size() < 2) {
- return std::string();
- }
-
- for (auto it = mContainers.begin(); it != mContainers.end(); ++it) {
- if (it->first == mConfig.foregroundId &&
- it->second->isRunning()) {
- auto nextIt = std::next(it);
- if (nextIt != mContainers.end()) {
- return nextIt->first;
- }
- }
- }
- return mContainers.begin()->first;
-}
-
-void ContainersManager::switchingSequenceMonitorNotify()
-{
- LOGI("switchingSequenceMonitorNotify() called");
-
- auto nextContainerId = getNextToForegroundContainerId();
-
- if (!nextContainerId.empty()) {
- focus(nextContainerId);
- }
-}
-
-
-void ContainersManager::setContainersDetachOnExit()
-{
- mDetachOnExit = true;
-
- for (auto& container : mContainers) {
- container.second->setDetachOnExit();
- }
-}
-
-void ContainersManager::notifyActiveContainerHandler(const std::string& caller,
- const std::string& application,
- const std::string& message)
-{
- LOGI("notifyActiveContainerHandler(" << caller << ", " << application << ", " << message
- << ") called");
- try {
- const std::string activeContainer = getRunningForegroundContainerId();
- if (!activeContainer.empty() && caller != activeContainer) {
- mContainers[activeContainer]->sendNotification(caller, application, message);
- }
- } catch(const VasumException&) {
- LOGE("Notification from " << caller << " hasn't been sent");
- }
-}
-
-void ContainersManager::displayOffHandler(const std::string& /*caller*/)
-{
- // get config of currently set container and switch if switchToDefaultAfterTimeout is true
- const std::string activeContainerName = getRunningForegroundContainerId();
- const auto& activeContainer = mContainers.find(activeContainerName);
-
- if (activeContainer != mContainers.end() &&
- activeContainer->second->isSwitchToDefaultAfterTimeoutAllowed()) {
- LOGI("Switching to default container " << mConfig.defaultId);
- focus(mConfig.defaultId);
- }
-}
-
-void ContainersManager::handleContainerMoveFileRequest(const std::string& srcContainerId,
- const std::string& dstContainerId,
- const std::string& path,
- dbus::MethodResultBuilder::Pointer result)
-{
- // TODO: this implementation is only a placeholder.
- // There are too many unanswered questions and security concerns:
- // 1. What about mount namespace, host might not see the source/destination
- // file. The file might be a different file from a host perspective.
- // 2. Copy vs move (speed and security concerns over already opened FDs)
- // 3. Access to source and destination files - DAC, uid/gig
- // 4. Access to source and destintation files - MAC, smack
- // 5. Destination file uid/gid assignment
- // 6. Destination file smack label assignment
- // 7. Verifiability of the source path
-
- // NOTE: other possible implementations include:
- // 1. Sending file descriptors opened directly in each container through DBUS
- // using something like g_dbus_message_set_unix_fd_list()
- // 2. VSM forking and calling setns(MNT) in each container and opening files
- // by itself, then passing FDs to the main process
- // Now when the main process has obtained FDs (by either of those methods)
- // it can do the copying by itself.
-
- LOGI("File move requested\n"
- << "src: " << srcContainerId << "\n"
- << "dst: " << dstContainerId << "\n"
- << "path: " << path);
-
- ContainerMap::const_iterator srcIter = mContainers.find(srcContainerId);
- if (srcIter == mContainers.end()) {
- LOGE("Source container '" << srcContainerId << "' not found");
- return;
- }
- Container& srcContainer = *srcIter->second;
-
- ContainerMap::const_iterator dstIter = mContainers.find(dstContainerId);
- if (dstIter == mContainers.end()) {
- LOGE("Destination container '" << dstContainerId << "' not found");
- result->set(g_variant_new("(s)", api::container::FILE_MOVE_DESTINATION_NOT_FOUND.c_str()));
- return;
- }
- Container& dstContanier = *dstIter->second;
-
- if (srcContainerId == dstContainerId) {
- LOGE("Cannot send a file to yourself");
- result->set(g_variant_new("(s)", api::container::FILE_MOVE_WRONG_DESTINATION.c_str()));
- return;
- }
-
- if (!regexMatchVector(path, srcContainer.getPermittedToSend())) {
- LOGE("Source container has no permissions to send the file: " << path);
- result->set(g_variant_new("(s)", api::container::FILE_MOVE_NO_PERMISSIONS_SEND.c_str()));
- return;
- }
-
- if (!regexMatchVector(path, dstContanier.getPermittedToRecv())) {
- LOGE("Destination container has no permissions to receive the file: " << path);
- result->set(g_variant_new("(s)", api::container::FILE_MOVE_NO_PERMISSIONS_RECEIVE.c_str()));
- return;
- }
-
- namespace fs = boost::filesystem;
- std::string srcPath = fs::absolute(srcContainerId, mConfig.containersPath).string() + path;
- std::string dstPath = fs::absolute(dstContainerId, mConfig.containersPath).string() + path;
-
- if (!utils::moveFile(srcPath, dstPath)) {
- LOGE("Failed to move the file: " << path);
- result->set(g_variant_new("(s)", api::container::FILE_MOVE_FAILED.c_str()));
- } else {
- result->set(g_variant_new("(s)", api::container::FILE_MOVE_SUCCEEDED.c_str()));
- try {
- dstContanier.sendNotification(srcContainerId, path, api::container::FILE_MOVE_SUCCEEDED);
- } catch (ServerException&) {
- LOGE("Notification to '" << dstContainerId << "' has not been sent");
- }
- }
-}
-
-void ContainersManager::handleProxyCall(const std::string& caller,
- const std::string& target,
- const std::string& targetBusName,
- const std::string& targetObjectPath,
- const std::string& targetInterface,
- const std::string& targetMethod,
- GVariant* parameters,
- dbus::MethodResultBuilder::Pointer result)
-{
- if (!mProxyCallPolicy->isProxyCallAllowed(caller,
- target,
- targetBusName,
- targetObjectPath,
- targetInterface,
- targetMethod)) {
- LOGW("Forbidden proxy call; " << caller << " -> " << target << "; " << targetBusName
- << "; " << targetObjectPath << "; " << targetInterface << "; " << targetMethod);
- result->setError(api::ERROR_FORBIDDEN, "Proxy call forbidden");
- return;
- }
-
- LOGI("Proxy call; " << caller << " -> " << target << "; " << targetBusName
- << "; " << targetObjectPath << "; " << targetInterface << "; " << targetMethod);
-
- auto asyncResultCallback = [result](dbus::AsyncMethodCallResult& asyncMethodCallResult) {
- try {
- GVariant* targetResult = asyncMethodCallResult.get();
- result->set(g_variant_new("(v)", targetResult));
- } catch (dbus::DbusException& e) {
- result->setError(api::ERROR_FORWARDED, e.what());
- }
- };
-
- if (target == HOST_ID) {
- mHostConnection.proxyCallAsync(targetBusName,
- targetObjectPath,
- targetInterface,
- targetMethod,
- parameters,
- asyncResultCallback);
- return;
- }
-
- ContainerMap::const_iterator targetIter = mContainers.find(target);
- if (targetIter == mContainers.end()) {
- LOGE("Target container '" << target << "' not found");
- result->setError(api::ERROR_INVALID_ID, "Unknown proxy call target");
- return;
- }
-
- Container& targetContainer = *targetIter->second;
- targetContainer.proxyCallAsync(targetBusName,
- targetObjectPath,
- targetInterface,
- targetMethod,
- parameters,
- asyncResultCallback);
-}
-
-void ContainersManager::handleGetContainerDbuses(dbus::MethodResultBuilder::Pointer result)
-{
- std::vector<GVariant*> entries;
- for (auto& container : mContainers) {
- GVariant* containerId = g_variant_new_string(container.first.c_str());
- GVariant* dbusAddress = g_variant_new_string(container.second->getDbusAddress().c_str());
- GVariant* entry = g_variant_new_dict_entry(containerId, dbusAddress);
- entries.push_back(entry);
- }
- GVariant* dict = g_variant_new_array(G_VARIANT_TYPE("{ss}"), entries.data(), entries.size());
- result->set(g_variant_new("(*)", dict));
-}
-
-void ContainersManager::handleDbusStateChanged(const std::string& containerId,
- const std::string& dbusAddress)
-{
- mHostConnection.signalContainerDbusState(containerId, dbusAddress);
-}
-
-void ContainersManager::handleGetContainerIdsCall(dbus::MethodResultBuilder::Pointer result)
-{
- std::vector<GVariant*> containerIds;
- for(auto& container: mContainers){
- containerIds.push_back(g_variant_new_string(container.first.c_str()));
- }
-
- GVariant* array = g_variant_new_array(G_VARIANT_TYPE("s"),
- containerIds.data(),
- containerIds.size());
- result->set(g_variant_new("(*)", array));
-}
-
-void ContainersManager::handleGetActiveContainerIdCall(dbus::MethodResultBuilder::Pointer result)
-{
- LOGI("GetActiveContainerId call");
- if (!mConfig.foregroundId.empty() && mContainers[mConfig.foregroundId]->isRunning()){
- result->set(g_variant_new("(s)", mConfig.foregroundId.c_str()));
- } else {
- result->set(g_variant_new("(s)", ""));
- }
-}
-
-void ContainersManager::handleGetContainerInfoCall(const std::string& id,
- dbus::MethodResultBuilder::Pointer result)
-{
- LOGI("GetContainerInfo call");
- if (mContainers.count(id) == 0) {
- LOGE("No container with id=" << id);
- result->setError(api::ERROR_INVALID_ID, "No such container id");
- return;
- }
- const auto& container = mContainers[id];
- const char* state;
- //TODO: Use the lookup map.
- if (container->isRunning()) {
- state = "RUNNING";
- } else if (container->isStopped()) {
- state = "STOPPED";
- } else if (container->isPaused()) {
- state = "FROZEN";
- } else {
- LOGE("Unrecognized state of container id=" << id);
- result->setError(api::ERROR_INTERNAL, "Unrecognized state of container");
- return;
- }
- const auto containerPath = boost::filesystem::absolute(id, mConfig.containersPath);
- const auto rootfsDir = boost::filesystem::path("rootfs");
- const auto rootfsPath = containerPath / rootfsDir;
-
- result->set(g_variant_new("((siss))",
- id.c_str(),
- container->getVT(),
- state,
- rootfsPath.string().c_str()));
-}
-
-void ContainersManager::handleDeclareFileCall(const std::string& container,
- const int32_t& type,
- const std::string& path,
- const int32_t& flags,
- const int32_t& mode,
- dbus::MethodResultBuilder::Pointer result)
-{
- LOGI("DeclareFile call");
- try {
- mContainers.at(container)->declareFile(type, path, flags, mode);
- result->setVoid();
- } catch (const std::out_of_range& ex) {
- LOGE("No container with id=" << container);
- result->setError(api::ERROR_INVALID_ID, "No such container id");
- } catch (const config::ConfigException& ex) {
- LOGE("Can't declare file: " << ex.what());
- result->setError(api::ERROR_INTERNAL, "Internal error");
- }
-}
-
-void ContainersManager::handleDeclareMountCall(const std::string& source,
- const std::string& container,
- const std::string& target,
- const std::string& type,
- const uint64_t& flags,
- const std::string& data,
- dbus::MethodResultBuilder::Pointer result)
-{
- LOGI("DeclareMount call");
- try {
- mContainers.at(container)->declareMount(source, target, type, flags, data);
- result->setVoid();
- } catch (const std::out_of_range& ex) {
- LOGE("No container with id=" << container);
- result->setError(api::ERROR_INVALID_ID, "No such container id");
- } catch (const config::ConfigException& ex) {
- LOGE("Can't declare mount: " << ex.what());
- result->setError(api::ERROR_INTERNAL, "Internal error");
- }
-}
-
-void ContainersManager::handleDeclareLinkCall(const std::string& source,
- const std::string& container,
- const std::string& target,
- dbus::MethodResultBuilder::Pointer result)
-{
- LOGI("DeclareLink call");
- try {
- mContainers.at(container)->declareLink(source, target);
- result->setVoid();
- } catch (const std::out_of_range& ex) {
- LOGE("No container with id=" << container);
- result->setError(api::ERROR_INVALID_ID, "No such container id");
- } catch (const config::ConfigException& ex) {
- LOGE("Can't declare link: " << ex.what());
- result->setError(api::ERROR_INTERNAL, "Internal error");
- }
-}
-
-void ContainersManager::handleSetActiveContainerCall(const std::string& id,
- dbus::MethodResultBuilder::Pointer result)
-{
- LOGI("SetActiveContainer call; Id=" << id );
- auto container = mContainers.find(id);
- if (container == mContainers.end()){
- LOGE("No container with id=" << id );
- result->setError(api::ERROR_INVALID_ID, "No such container id");
- return;
- }
-
- if (container->second->isStopped()){
- LOGE("Could not activate a stopped container");
- result->setError(api::host::ERROR_CONTAINER_STOPPED,
- "Could not activate a stopped container");
- return;
- }
-
- focus(id);
- result->setVoid();
-}
-
-
-void ContainersManager::generateNewConfig(const std::string& id,
- const std::string& templatePath,
- const std::string& resultPath)
-{
- namespace fs = boost::filesystem;
-
- std::string resultFileDir = utils::dirName(resultPath);
- if (!fs::exists(resultFileDir)) {
- if (!utils::createEmptyDir(resultFileDir)) {
- LOGE("Unable to create directory for new config.");
- throw ContainerOperationException("Unable to create directory for new config.");
- }
- }
-
- fs::path resultFile(resultPath);
- if (fs::exists(resultFile)) {
- LOGT(resultPath << " already exists, removing");
- fs::remove(resultFile);
- }
-
- std::string config;
- if (!utils::readFileContent(templatePath, config)) {
- LOGE("Failed to read template config file.");
- throw ContainerOperationException("Failed to read template config file.");
- }
-
- std::string resultConfig = boost::regex_replace(config, CONTAINER_NAME_REGEX, id);
-
- // generate third IP octet for network config
- // TODO change algorithm after implementing removeContainer
- std::string thirdOctetStr = std::to_string(CONTAINER_IP_BASE_THIRD_OCTET + mContainers.size() + 1);
- LOGD("IP third octet: " << thirdOctetStr);
- resultConfig = boost::regex_replace(resultConfig, CONTAINER_IP_THIRD_OCTET_REGEX, thirdOctetStr);
-
- if (!utils::saveFileContent(resultPath, resultConfig)) {
- LOGE("Faield to save new config file.");
- throw ContainerOperationException("Failed to save new config file.");
- }
-
- // restrict new config file so that only owner (vasum) can write it
- fs::permissions(resultPath, fs::perms::owner_all |
- fs::perms::group_read |
- fs::perms::others_read);
-}
-
-void ContainersManager::handleCreateContainerCall(const std::string& id,
- dbus::MethodResultBuilder::Pointer result)
-{
- if (id.empty()) {
- LOGE("Failed to add container - invalid name.");
- result->setError(api::ERROR_INVALID_ID, "Invalid name");
- return;
- }
-
- LOGI("Creating container " << id);
-
- // TODO: This solution is temporary. It utilizes direct access to config files when creating new
- // containers. Update this handler when config database will appear.
- namespace fs = boost::filesystem;
-
- // check if container does not exist
- if (mContainers.find(id) != mContainers.end()) {
- LOGE("Cannot create " << id << " container - already exists!");
- result->setError(api::ERROR_INVALID_ID, "Already exists");
- return;
- }
-
- const std::string containerPathStr = utils::createFilePath(mConfig.containersPath, "/", id, "/");
-
- // copy container image if config contains path to image
- LOGT("Image path: " << mConfig.containerImagePath);
- if (!mConfig.containerImagePath.empty()) {
- auto copyImageContentsWrapper = std::bind(&utils::copyImageContents,
- mConfig.containerImagePath,
- containerPathStr);
-
- if (!utils::launchAsRoot(copyImageContentsWrapper)) {
- LOGE("Failed to copy container image.");
- result->setError(api::ERROR_INTERNAL, "Failed to copy container image.");
- return;
- }
- }
-
- // generate paths to new configuration files
- std::string baseDir = utils::dirName(mConfigPath);
- std::string configDir = utils::getAbsolutePath(mConfig.containerNewConfigPrefix, baseDir);
- std::string templateDir = utils::getAbsolutePath(mConfig.containerTemplatePath, baseDir);
-
- std::string configPath = utils::createFilePath(templateDir, "/", CONTAINER_TEMPLATE_CONFIG_PATH);
- std::string newConfigPath = utils::createFilePath(configDir, "/containers/", id + ".conf");
-
- auto removeAllWrapper = [](const std::string& path) -> bool {
- try {
- LOGD("Removing copied data");
- fs::remove_all(fs::path(path));
- } catch(const std::exception& e) {
- LOGW("Failed to remove data: " << boost::diagnostic_information(e));
- }
- return true;
- };
-
- try {
- LOGI("Generating config from " << configPath << " to " << newConfigPath);
- generateNewConfig(id, configPath, newConfigPath);
-
- } catch (VasumException& e) {
- LOGE("Generate config failed: " << e.what());
- utils::launchAsRoot(std::bind(removeAllWrapper, containerPathStr));
- result->setError(api::ERROR_INTERNAL, "Failed to generate config");
- return;
- }
-
- LOGT("Creating new container");
- try {
- createContainer(newConfigPath);
- } catch (VasumException& e) {
- LOGE("Creating new container failed: " << e.what());
- utils::launchAsRoot(std::bind(removeAllWrapper, containerPathStr));
- result->setError(api::ERROR_INTERNAL, "Failed to create container");
- return;
- }
-
- auto resultCallback = [this, id, result](bool succeeded) {
- if (succeeded) {
- focus(id);
- result->setVoid();
- } else {
- LOGE("Failed to start container.");
- // TODO removeContainer
- result->setError(api::ERROR_INTERNAL, "Failed to start container");
- }
- };
- mContainers[id]->startAsync(resultCallback);
-}
-
-void ContainersManager::handleDestroyContainerCall(const std::string& id,
- dbus::MethodResultBuilder::Pointer result)
-{
- if (mContainers.find(id) == mContainers.end()) {
- LOGE("Failed to destroy container - no such container id: " << id);
- result->setError(api::ERROR_INVALID_ID, "No such container id");
- return;
- }
-
- LOGI("Destroying container " << id);
-
- auto destroyer = [id, result, this] {
- try {
- destroyContainer(id);
- } catch (const VasumException& e) {
- LOGE("Error during container destruction: " << e.what());
- result->setError(api::ERROR_INTERNAL, "Failed to destroy container");
- return;
- }
- result->setVoid();
- };
-
- std::thread thread(destroyer);
- thread.detach(); //TODO fix it
-}
-
-void ContainersManager::handleLockContainerCall(const std::string& id,
- dbus::MethodResultBuilder::Pointer result)
-{
- LOGI("LockContainer call; Id=" << id );
- auto iter = mContainers.find(id);
- if (iter == mContainers.end()) {
- LOGE("Failed to lock container - no such container id: " << id);
- result->setError(api::ERROR_INVALID_ID, "No such container id");
- return;
- }
-
- auto& container = *iter->second;
- if (!container.isRunning()) {
- LOGE("Container id=" << id << " is not running.");
- result->setError(api::ERROR_INVALID_STATE, "Container is not running");
- return;
- }
-
- LOGT("Lock container");
- try {
- container.suspend();
- } catch (ContainerOperationException& e) {
- LOGE(e.what());
- result->setError(api::ERROR_INTERNAL, e.what());
- return;
- }
-
- result->setVoid();
-}
-
-void ContainersManager::handleUnlockContainerCall(const std::string& id,
- dbus::MethodResultBuilder::Pointer result)
-{
- LOGI("UnlockContainer call; Id=" << id );
- auto iter = mContainers.find(id);
- if (iter == mContainers.end()) {
- LOGE("Failed to unlock container - no such container id: " << id);
- result->setError(api::ERROR_INVALID_ID, "No such container id");
- return;
- }
-
- auto& container = *iter->second;
- if (!container.isPaused()) {
- LOGE("Container id=" << id << " is not paused.");
- result->setError(api::ERROR_INVALID_STATE, "Container is not paused");
- return;
- }
-
- LOGT("Unlock container");
- try {
- container.resume();
- } catch (ContainerOperationException& e) {
- LOGE(e.what());
- result->setError(api::ERROR_INTERNAL, e.what());
- return;
- }
-
- result->setVoid();
-}
-
-} // namespace vasum
};
/**
- * Error occurred during an attempt to perform an operation on a container,
- * e.g. start, stop a container
+ * Error occurred during an attempt to perform an operation on a zone,
+ * e.g. start, stop a zone
*/
-struct ContainerOperationException: public ServerException {
+struct ZoneOperationException: public ServerException {
- ContainerOperationException(const std::string& error = "") : ServerException(error) {}
+ ZoneOperationException(const std::string& error = "") : ServerException(error) {}
};
/**
- * Exception during performing an operation on a container connection
+ * Exception during performing an operation on a zone connection
*/
-struct ContainerConnectionException: public ServerException {
+struct ZoneConnectionException: public ServerException {
- ContainerConnectionException(const std::string& error = "") : ServerException(error) {}
+ ZoneConnectionException(const std::string& error = "") : ServerException(error) {}
};
/**
* @file fake-power-manager-dbus-definitions.h
* @author Lukasz Kostyra (l.kostyra@samsung.com)
* @brief Declaration of fake dbus definitions from power-manager. Made only to test API in
- * ContainerConnection.
+ * ZoneConnection.
*/
#ifndef FAKE_POWER_MANAGER_DBUS_DEFINITIONS_H
/**
* !!WARNING!!
*
- * This header file is created only to test if API in ContainerConnection works correctly. It should
+ * This header file is created only to test if API in ZoneConnection works correctly. It should
* be removed when power-managers API will be created.
*/
mProxyCallCallback = callback;
}
-void HostConnection::setGetContainerDbusesCallback(const GetContainerDbusesCallback& callback)
+void HostConnection::setGetZoneDbusesCallback(const GetZoneDbusesCallback& callback)
{
- mGetContainerDbusesCallback = callback;
+ mGetZoneDbusesCallback = callback;
}
-void HostConnection::setGetContainerIdsCallback(const GetContainerIdsCallback& callback)
+void HostConnection::setGetZoneIdsCallback(const GetZoneIdsCallback& callback)
{
- mGetContainerIdsCallback = callback;
+ mGetZoneIdsCallback = callback;
}
-void HostConnection::setGetActiveContainerIdCallback(const GetActiveContainerIdCallback& callback)
+void HostConnection::setGetActiveZoneIdCallback(const GetActiveZoneIdCallback& callback)
{
- mGetActiveContainerIdCallback = callback;
+ mGetActiveZoneIdCallback = callback;
}
-void HostConnection::setGetContainerInfoCallback(const GetContainerInfoCallback& callback)
+void HostConnection::setGetZoneInfoCallback(const GetZoneInfoCallback& callback)
{
- mGetContainerInfoCallback = callback;
+ mGetZoneInfoCallback = callback;
}
void HostConnection::setDeclareFileCallback(const DeclareFileCallback& callback)
mDeclareLinkCallback = callback;
}
-void HostConnection::setSetActiveContainerCallback(const SetActiveContainerCallback& callback)
+void HostConnection::setSetActiveZoneCallback(const SetActiveZoneCallback& callback)
{
- mSetActiveContainerCallback = callback;
+ mSetActiveZoneCallback = callback;
}
-void HostConnection::setCreateContainerCallback(const CreateContainerCallback& callback)
+void HostConnection::setCreateZoneCallback(const CreateZoneCallback& callback)
{
- mCreateContainerCallback = callback;
+ mCreateZoneCallback = callback;
}
-void HostConnection::setDestroyContainerCallback(const DestroyContainerCallback& callback)
+void HostConnection::setDestroyZoneCallback(const DestroyZoneCallback& callback)
{
- mDestroyContainerCallback = callback;
+ mDestroyZoneCallback = callback;
}
-void HostConnection::setLockContainerCallback(const LockContainerCallback& callback)
+void HostConnection::setLockZoneCallback(const LockZoneCallback& callback)
{
- mLockContainerCallback = callback;
+ mLockZoneCallback = callback;
}
-void HostConnection::setUnlockContainerCallback(const UnlockContainerCallback& callback)
+void HostConnection::setUnlockZoneCallback(const UnlockZoneCallback& callback)
{
- mUnlockContainerCallback = callback;
+ mUnlockZoneCallback = callback;
}
return;
}
- if (methodName == api::host::METHOD_SET_ACTIVE_CONTAINER) {
+ if (methodName == api::host::METHOD_SET_ACTIVE_ZONE) {
const gchar* id = NULL;
g_variant_get(parameters, "(&s)", &id);
- if (mSetActiveContainerCallback) {
- mSetActiveContainerCallback(id, result);
+ if (mSetActiveZoneCallback) {
+ mSetActiveZoneCallback(id, result);
}
return;
}
- if (methodName == api::host::METHOD_GET_CONTAINER_DBUSES) {
- if (mGetContainerDbusesCallback) {
- mGetContainerDbusesCallback(result);
+ if (methodName == api::host::METHOD_GET_ZONE_DBUSES) {
+ if (mGetZoneDbusesCallback) {
+ mGetZoneDbusesCallback(result);
}
return;
}
return;
}
- if (methodName == api::host::METHOD_GET_CONTAINER_ID_LIST){
- if (mGetContainerIdsCallback){
- mGetContainerIdsCallback(result);
+ if (methodName == api::host::METHOD_GET_ZONE_ID_LIST){
+ if (mGetZoneIdsCallback){
+ mGetZoneIdsCallback(result);
}
return;
}
- if (methodName == api::host::METHOD_GET_ACTIVE_CONTAINER_ID){
- if (mGetActiveContainerIdCallback){
- mGetActiveContainerIdCallback(result);
+ if (methodName == api::host::METHOD_GET_ACTIVE_ZONE_ID){
+ if (mGetActiveZoneIdCallback){
+ mGetActiveZoneIdCallback(result);
}
return;
}
- if (methodName == api::host::METHOD_GET_CONTAINER_INFO){
+ if (methodName == api::host::METHOD_GET_ZONE_INFO){
const gchar* id = NULL;
g_variant_get(parameters, "(&s)", &id);
- if (mGetContainerInfoCallback) {
- mGetContainerInfoCallback(id, result);
+ if (mGetZoneInfoCallback) {
+ mGetZoneInfoCallback(id, result);
}
return;
}
if (methodName == api::host::METHOD_DECLARE_FILE) {
- const gchar* container;
+ const gchar* zone;
int32_t type;
const gchar* path;
int32_t flags;
int32_t mode;
- g_variant_get(parameters, "(&si&sii)", &container, &type, &path, &flags, &mode);
+ g_variant_get(parameters, "(&si&sii)", &zone, &type, &path, &flags, &mode);
if (mDeclareFileCallback) {
- mDeclareFileCallback(container, type, path, flags, mode, result);
+ mDeclareFileCallback(zone, type, path, flags, mode, result);
}
return;
}
if (methodName == api::host::METHOD_DECLARE_MOUNT) {
const gchar* source;
- const gchar* container;
+ const gchar* zone;
const gchar* target;
const gchar* type;
uint64_t flags;
g_variant_get(parameters,
"(&s&s&s&st&s)",
&source,
- &container,
+ &zone,
&target,
&type,
&flags,
&data);
if (mDeclareMountCallback) {
- mDeclareMountCallback(source, container, target, type, flags, data, result);
+ mDeclareMountCallback(source, zone, target, type, flags, data, result);
}
return;
}
if (methodName == api::host::METHOD_DECLARE_LINK) {
const gchar* source;
- const gchar* container;
+ const gchar* zone;
const gchar* target;
- g_variant_get(parameters, "(&s&s&s)", &source, &container, &target);
+ g_variant_get(parameters, "(&s&s&s)", &source, &zone, &target);
if (mDeclareLinkCallback) {
- mDeclareLinkCallback(source, container, target, result);
+ mDeclareLinkCallback(source, zone, target, result);
}
return;
}
- if (methodName == api::host::METHOD_CREATE_CONTAINER) {
+ if (methodName == api::host::METHOD_CREATE_ZONE) {
const gchar* id = NULL;
g_variant_get(parameters, "(&s)", &id);
- if (mCreateContainerCallback){
- mCreateContainerCallback(id, result);
+ if (mCreateZoneCallback){
+ mCreateZoneCallback(id, result);
}
}
- if (methodName == api::host::METHOD_DESTROY_CONTAINER) {
+ if (methodName == api::host::METHOD_DESTROY_ZONE) {
const gchar* id = NULL;
g_variant_get(parameters, "(&s)", &id);
- if (mDestroyContainerCallback){
- mDestroyContainerCallback(id, result);
+ if (mDestroyZoneCallback){
+ mDestroyZoneCallback(id, result);
}
}
- if (methodName == api::host::METHOD_LOCK_CONTAINER) {
+ if (methodName == api::host::METHOD_LOCK_ZONE) {
const gchar* id = NULL;
g_variant_get(parameters, "(&s)", &id);
- if (mLockContainerCallback){
- mLockContainerCallback(id, result);
+ if (mLockZoneCallback){
+ mLockZoneCallback(id, result);
}
}
- if (methodName == api::host::METHOD_UNLOCK_CONTAINER) {
+ if (methodName == api::host::METHOD_UNLOCK_ZONE) {
const gchar* id = NULL;
g_variant_get(parameters, "(&s)", &id);
- if (mUnlockContainerCallback){
- mUnlockContainerCallback(id, result);
+ if (mUnlockZoneCallback){
+ mUnlockZoneCallback(id, result);
}
}
}
callback);
}
-void HostConnection::signalContainerDbusState(const std::string& containerId,
+void HostConnection::signalZoneDbusState(const std::string& zoneId,
const std::string& dbusAddress)
{
- GVariant* parameters = g_variant_new("(ss)", containerId.c_str(), dbusAddress.c_str());
+ GVariant* parameters = g_variant_new("(ss)", zoneId.c_str(), dbusAddress.c_str());
mDbusConnection->emitSignal(api::host::OBJECT_PATH,
api::host::INTERFACE,
- api::host::SIGNAL_CONTAINER_DBUS_STATE,
+ api::host::SIGNAL_ZONE_DBUS_STATE,
parameters);
}
dbus::MethodResultBuilder::Pointer result
)> ProxyCallCallback;
typedef std::function<void(dbus::MethodResultBuilder::Pointer result
- )> GetContainerDbusesCallback;
+ )> GetZoneDbusesCallback;
typedef std::function<void(dbus::MethodResultBuilder::Pointer result
- )> GetContainerIdsCallback;
+ )> GetZoneIdsCallback;
typedef std::function<void(dbus::MethodResultBuilder::Pointer result
- )> GetActiveContainerIdCallback;
+ )> GetActiveZoneIdCallback;
typedef std::function<void(const std::string& id,
dbus::MethodResultBuilder::Pointer result
- )> GetContainerInfoCallback;
- typedef std::function<void(const std::string& container,
+ )> GetZoneInfoCallback;
+ typedef std::function<void(const std::string& zone,
const int32_t& type,
const std::string& path,
const int32_t& flags,
dbus::MethodResultBuilder::Pointer result
)> DeclareFileCallback;
typedef std::function<void(const std::string& source,
- const std::string& container,
+ const std::string& zone,
const std::string& target,
const std::string& type,
const uint64_t& flags,
dbus::MethodResultBuilder::Pointer result
)> DeclareMountCallback;
typedef std::function<void(const std::string& source,
- const std::string& container,
+ const std::string& zone,
const std::string& target,
dbus::MethodResultBuilder::Pointer result
)> DeclareLinkCallback;
typedef std::function<void(const std::string& id,
dbus::MethodResultBuilder::Pointer result
- )> SetActiveContainerCallback;
+ )> SetActiveZoneCallback;
typedef std::function<void(const std::string& id,
dbus::MethodResultBuilder::Pointer result
- )> CreateContainerCallback;
+ )> CreateZoneCallback;
typedef std::function<void(const std::string& id,
dbus::MethodResultBuilder::Pointer result
- )> DestroyContainerCallback;
+ )> DestroyZoneCallback;
typedef std::function<void(const std::string& id,
dbus::MethodResultBuilder::Pointer result
- )> LockContainerCallback;
+ )> LockZoneCallback;
typedef std::function<void(const std::string& id,
dbus::MethodResultBuilder::Pointer result
- )> UnlockContainerCallback;
+ )> UnlockZoneCallback;
/**
* Register proxy call callback
void setProxyCallCallback(const ProxyCallCallback& callback);
/**
- * Register get container dbuses callback
+ * Register get zone dbuses callback
*/
- void setGetContainerDbusesCallback(const GetContainerDbusesCallback& callback);
+ void setGetZoneDbusesCallback(const GetZoneDbusesCallback& callback);
/**
* Send signal describing dbus address state change
*/
- void signalContainerDbusState(const std::string& containerId, const std::string& dbusAddress);
+ void signalZoneDbusState(const std::string& zoneId, const std::string& dbusAddress);
/**
* Register a callback called to get a list of zone ids
*/
- void setGetContainerIdsCallback(const GetContainerIdsCallback& callback);
+ void setGetZoneIdsCallback(const GetZoneIdsCallback& callback);
/**
- * Register a callback called to get the active container id
+ * Register a callback called to get the active zone id
*/
- void setGetActiveContainerIdCallback(const GetContainerIdsCallback& callback);
+ void setGetActiveZoneIdCallback(const GetZoneIdsCallback& callback);
/**
- * Register a callback called to get the container informations
+ * Register a callback called to get the zone informations
*/
- void setGetContainerInfoCallback(const GetContainerInfoCallback& callback);
+ void setGetZoneInfoCallback(const GetZoneInfoCallback& callback);
/**
* Register a callback called to declare file
void setDeclareLinkCallback(const DeclareLinkCallback& callback);
/**
- * Register a callback called to set the active container
+ * Register a callback called to set the active zone
*/
- void setSetActiveContainerCallback(const SetActiveContainerCallback& callback);
+ void setSetActiveZoneCallback(const SetActiveZoneCallback& callback);
/**
- * Register a callback called to create new container
+ * Register a callback called to create new zone
*/
- void setCreateContainerCallback(const CreateContainerCallback& callback);
+ void setCreateZoneCallback(const CreateZoneCallback& callback);
/**
- * Register a callback called to destroy container
+ * Register a callback called to destroy zone
*/
- void setDestroyContainerCallback(const DestroyContainerCallback& callback);
+ void setDestroyZoneCallback(const DestroyZoneCallback& callback);
/**
- * Register a callback called to lock container
+ * Register a callback called to lock zone
*/
- void setLockContainerCallback(const LockContainerCallback& callback);
+ void setLockZoneCallback(const LockZoneCallback& callback);
/**
- * Register a callback called to unlock container
+ * Register a callback called to unlock zone
*/
- void setUnlockContainerCallback(const UnlockContainerCallback& callback);
+ void setUnlockZoneCallback(const UnlockZoneCallback& callback);
/**
* Make a proxy call
bool mNameAcquired;
bool mNameLost;
ProxyCallCallback mProxyCallCallback;
- GetContainerDbusesCallback mGetContainerDbusesCallback;
- GetContainerIdsCallback mGetContainerIdsCallback;
- GetActiveContainerIdCallback mGetActiveContainerIdCallback;
- GetContainerInfoCallback mGetContainerInfoCallback;
+ GetZoneDbusesCallback mGetZoneDbusesCallback;
+ GetZoneIdsCallback mGetZoneIdsCallback;
+ GetActiveZoneIdCallback mGetActiveZoneIdCallback;
+ GetZoneInfoCallback mGetZoneInfoCallback;
DeclareFileCallback mDeclareFileCallback;
DeclareMountCallback mDeclareMountCallback;
DeclareLinkCallback mDeclareLinkCallback;
- SetActiveContainerCallback mSetActiveContainerCallback;
- CreateContainerCallback mCreateContainerCallback;
- DestroyContainerCallback mDestroyContainerCallback;
- LockContainerCallback mLockContainerCallback;
- UnlockContainerCallback mUnlockContainerCallback;
+ SetActiveZoneCallback mSetActiveZoneCallback;
+ CreateZoneCallback mCreateZoneCallback;
+ DestroyZoneCallback mDestroyZoneCallback;
+ LockZoneCallback mLockZoneCallback;
+ UnlockZoneCallback mUnlockZoneCallback;
void onNameAcquired();
void onNameLost();
namespace api {
namespace host {
-const std::string BUS_NAME = "org.tizen.containers.host";
-const std::string OBJECT_PATH = "/org/tizen/containers/host";
-const std::string INTERFACE = "org.tizen.containers.host.manager";
+const std::string BUS_NAME = "org.tizen.vasum.host";
+const std::string OBJECT_PATH = "/org/tizen/vasum/host";
+const std::string INTERFACE = "org.tizen.vasum.host.manager";
-const std::string ERROR_CONTAINER_STOPPED = "org.tizen.containers.host.Error.ContainersStopped";
+const std::string ERROR_ZONE_STOPPED = "org.tizen.vasum.host.Error.ZonesStopped";
-const std::string METHOD_GET_CONTAINER_DBUSES = "GetContainerDbuses";
-const std::string METHOD_GET_CONTAINER_ID_LIST = "GetContainerIds";
-const std::string METHOD_GET_ACTIVE_CONTAINER_ID = "GetActiveContainerId";
-const std::string METHOD_GET_CONTAINER_INFO = "GetContainerInfo";
+const std::string METHOD_GET_ZONE_DBUSES = "GetZoneDbuses";
+const std::string METHOD_GET_ZONE_ID_LIST = "GetZoneIds";
+const std::string METHOD_GET_ACTIVE_ZONE_ID = "GetActiveZoneId";
+const std::string METHOD_GET_ZONE_INFO = "GetZoneInfo";
const std::string METHOD_DECLARE_FILE = "DeclareFile";
const std::string METHOD_DECLARE_MOUNT = "DeclareMount";
const std::string METHOD_DECLARE_LINK = "DeclareLink";
-const std::string METHOD_SET_ACTIVE_CONTAINER = "SetActiveContainer";
-const std::string METHOD_CREATE_CONTAINER = "CreateContainer";
-const std::string METHOD_DESTROY_CONTAINER = "DestroyContainer";
-const std::string METHOD_LOCK_CONTAINER = "LockContainer";
-const std::string METHOD_UNLOCK_CONTAINER = "UnlockContainer";
+const std::string METHOD_SET_ACTIVE_ZONE = "SetActiveZone";
+const std::string METHOD_CREATE_ZONE = "CreateZone";
+const std::string METHOD_DESTROY_ZONE = "DestroyZone";
+const std::string METHOD_LOCK_ZONE = "LockZone";
+const std::string METHOD_UNLOCK_ZONE = "UnlockZone";
-const std::string SIGNAL_CONTAINER_DBUS_STATE = "ContainerDbusState";
+const std::string SIGNAL_ZONE_DBUS_STATE = "ZoneDbusState";
const std::string DEFINITION =
" <arg type='v' name='parameters' direction='in'/>"
" <arg type='v' name='result' direction='out'/>"
" </method>"
- " <method name='" + METHOD_GET_CONTAINER_DBUSES + "'>"
+ " <method name='" + METHOD_GET_ZONE_DBUSES + "'>"
" <arg type='a{ss}' name='dbuses' direction='out'/>"
" </method>"
- " <method name='" + METHOD_GET_CONTAINER_ID_LIST + "'>"
+ " <method name='" + METHOD_GET_ZONE_ID_LIST + "'>"
" <arg type='as' name='result' direction='out'/>"
" </method>"
- " <method name='" + METHOD_GET_ACTIVE_CONTAINER_ID + "'>"
+ " <method name='" + METHOD_GET_ACTIVE_ZONE_ID + "'>"
" <arg type='s' name='result' direction='out'/>"
" </method>"
- " <method name='" + METHOD_GET_CONTAINER_INFO + "'>"
+ " <method name='" + METHOD_GET_ZONE_INFO + "'>"
" <arg type='s' name='id' direction='in'/>"
" <arg type='(siss)' name='result' direction='out'/>"
" </method>"
" <method name='" + METHOD_DECLARE_FILE + "'>"
- " <arg type='s' name='container' direction='in'/>"
+ " <arg type='s' name='zone' direction='in'/>"
" <arg type='i' name='type' direction='in'/>"
" <arg type='s' name='path' direction='in'/>"
" <arg type='i' name='flags' direction='in'/>"
" </method>"
" <method name='" + METHOD_DECLARE_MOUNT + "'>"
" <arg type='s' name='source' direction='in'/>"
- " <arg type='s' name='container' direction='in'/>"
+ " <arg type='s' name='zone' direction='in'/>"
" <arg type='s' name='target' direction='in'/>"
" <arg type='s' name='type' direction='in'/>"
" <arg type='t' name='flags' direction='in'/>"
" </method>"
" <method name='" + METHOD_DECLARE_LINK + "'>"
" <arg type='s' name='source' direction='in'/>"
- " <arg type='s' name='container' direction='in'/>"
+ " <arg type='s' name='zone' direction='in'/>"
" <arg type='s' name='target' direction='in'/>"
" </method>"
- " <method name='" + METHOD_SET_ACTIVE_CONTAINER + "'>"
+ " <method name='" + METHOD_SET_ACTIVE_ZONE + "'>"
" <arg type='s' name='id' direction='in'/>"
" </method>"
- " <method name='" + METHOD_CREATE_CONTAINER + "'>"
+ " <method name='" + METHOD_CREATE_ZONE + "'>"
" <arg type='s' name='id' direction='in'/>"
" </method>"
- " <method name='" + METHOD_DESTROY_CONTAINER + "'>"
+ " <method name='" + METHOD_DESTROY_ZONE + "'>"
" <arg type='s' name='id' direction='in'/>"
" </method>"
- " <method name='" + METHOD_LOCK_CONTAINER + "'>"
+ " <method name='" + METHOD_LOCK_ZONE + "'>"
" <arg type='s' name='id' direction='in'/>"
" </method>"
- " <method name='" + METHOD_UNLOCK_CONTAINER + "'>"
+ " <method name='" + METHOD_UNLOCK_ZONE + "'>"
" <arg type='s' name='id' direction='in'/>"
" </method>"
- " <signal name='" + SIGNAL_CONTAINER_DBUS_STATE + "'>"
- " <arg type='s' name='container'/>"
+ " <signal name='" + SIGNAL_ZONE_DBUS_STATE + "'>"
+ " <arg type='s' name='zone'/>"
" <arg type='s' name='dbusAddress'/>"
" </signal>"
" </interface>"
/**
* @file
* @author Mateusz Malicki (m.malicki2@samsung.com)
- * @brief Declaration of the class for storing container provisioning configuration
+ * @brief Declaration of the class for storing zone provisioning configuration
*/
#include <vector>
-namespace security_containers {
+namespace vasum {
-struct ContainerProvisioning
+struct ZoneProvisioning
{
struct File
)
};
-}
+} // namespace vasum
#endif // SERVER_PROVISIONING_CONFIG_HPP
*/
struct ProxyCallRule {
- std::string caller; ///< caller id (container id or host)
- std::string target; ///< target id (container id or host)
+ std::string caller; ///< caller id (zone id or host)
+ std::string target; ///< target id (zone id or host)
std::string targetBusName; ///< target dbus bus name
std::string targetObjectPath; ///< target dbus object path
std::string targetInterface; ///< target dbus interface
#include "config.hpp"
#include "server.hpp"
-#include "containers-manager.hpp"
+#include "zones-manager.hpp"
#include "exception.hpp"
#include "config/manager.hpp"
LOGI("Starting daemon...");
{
utils::ScopedGlibLoop loop;
- ContainersManager manager(mConfigPath);
+ ZonesManager manager(mConfigPath);
manager.startAll();
LOGI("Daemon started");
gSignalLatch.wait();
- // Detach containers if we triggered an update
+ // Detach zones if we triggered an update
if (gUpdateTriggered) {
- manager.setContainersDetachOnExit();
+ manager.setZonesDetachOnExit();
}
LOGI("Stopping daemon...");
{
namespace fs = boost::filesystem;
- // TODO: currently this config is loaded twice: here and in ContainerManager
- ContainersManagerConfig config;
+ // TODO: currently this config is loaded twice: here and in ZonesManager
+ ZonesManagerConfig config;
config::loadFromFile(configPath, config);
struct passwd* pwd = ::getpwnam(VASUM_USER);
}
}
- // create directory for additional container data (if needed)
- if (!config.containerNewConfigPrefix.empty()) {
- if (!utils::createDir(config.containerNewConfigPrefix, uid, gid,
+ // create directory for additional zone data (if needed)
+ if (!config.zoneNewConfigPrefix.empty()) {
+ if (!utils::createDir(config.zoneNewConfigPrefix, uid, gid,
fs::perms::owner_all |
fs::perms::group_read | fs::perms::group_exe |
fs::perms::others_read | fs::perms::others_exe)) {
}
// INPUT_EVENT_GROUP provides access to /dev/input/event* devices used by InputMonitor.
- // DISK_GROUP provides access to /dev/loop* devices, needed when adding new container to copy
- // containers image
+ // DISK_GROUP provides access to /dev/loop* devices, needed when adding new zone to copy
+ // zones image
if (!utils::setSuppGroups({INPUT_EVENT_GROUP, DISK_GROUP, TTY_GROUP})) {
return false;
}
// CAP_SYS_ADMIN allows to mount tmpfs' for dbus communication at the runtime.
// NOTE: CAP_MAC_OVERRIDE is temporary and must be removed when "smack namespace"
// is introduced. The capability is needed to allow modify SMACK labels of
- // "/var/run/containers/<container>/run" mount point.
+ // "/var/run/zones/<zone>/run" mount point.
// CAP_SYS_TTY_CONFIG is needed to activate virtual terminals through ioctl calls
- // CAP_CHOWN is needed when creating new container from image to set owner/group for each file,
+ // CAP_CHOWN is needed when creating new zone from image to set owner/group for each file,
// directory or symlink
// CAP_SETUID is needed to launch specific funtions as root (see environment.cpp)
return (runAsRoot || utils::dropRoot(uid, gid, {CAP_SYS_ADMIN,
static bool prepareEnvironment(const std::string& configPath, bool runAsRoot);
/**
- * Starts all the containers and blocks until SIGINT, SIGTERM or SIGUSR1
+ * Starts all the zones and blocks until SIGINT, SIGTERM or SIGUSR1
*/
void run();
/**
* @file
* @author Jan Olszak (j.olszak@samsung.com)
- * @brief Implementation of class for administrating one container
+ * @brief Implementation of class for administrating one zone
*/
#include "config.hpp"
-#include "container-admin.hpp"
+#include "zone-admin.hpp"
#include "exception.hpp"
#include "logger/logger.hpp"
namespace {
-// TODO: this should be in container's configuration file
+// TODO: this should be in zone's configuration file
const int SHUTDOWN_WAIT = 10;
} // namespace
const std::uint64_t DEFAULT_CPU_SHARES = 1024;
const std::uint64_t DEFAULT_VCPU_PERIOD_MS = 100000;
-ContainerAdmin::ContainerAdmin(const std::string& containersPath,
+ZoneAdmin::ZoneAdmin(const std::string& zonesPath,
const std::string& lxcTemplatePrefix,
- const ContainerConfig& config)
+ const ZoneConfig& config)
: mConfig(config),
- mZone(containersPath, config.name),
+ mZone(zonesPath, config.name),
mId(mZone.getName()),
mDetachOnExit(false),
mDestroyOnExit(false)
{
- LOGD(mId << ": Instantiating ContainerAdmin object");
+ LOGD(mId << ": Instantiating ZoneAdmin object");
if (!mZone.isDefined()) {
args.add(config.ipv4.c_str());
}
if (!mZone.create(lxcTemplate, args.c_array())) {
- throw ContainerOperationException("Could not create zone");
+ throw ZoneOperationException("Could not create zone");
}
}
}
-ContainerAdmin::~ContainerAdmin()
+ZoneAdmin::~ZoneAdmin()
{
- LOGD(mId << ": Destroying ContainerAdmin object...");
+ LOGD(mId << ": Destroying ZoneAdmin object...");
if (mDestroyOnExit) {
if (!mZone.stop()) {
- LOGE(mId << ": Failed to stop the container");
+ LOGE(mId << ": Failed to stop the zone");
}
if (!mZone.destroy()) {
- LOGE(mId << ": Failed to destroy the container");
+ LOGE(mId << ": Failed to destroy the zone");
}
}
if (!mDetachOnExit) {
// Try to forcefully stop
if (!mZone.stop()) {
- LOGE(mId << ": Failed to stop the container");
+ LOGE(mId << ": Failed to stop the zone");
}
}
- LOGD(mId << ": ContainerAdmin object destroyed");
+ LOGD(mId << ": ZoneAdmin object destroyed");
}
-const std::string& ContainerAdmin::getId() const
+const std::string& ZoneAdmin::getId() const
{
return mId;
}
-void ContainerAdmin::start()
+void ZoneAdmin::start()
{
LOGD(mId << ": Starting...");
if (isRunning()) {
}
if (!mZone.start(args.c_array())) {
- throw ContainerOperationException("Could not start container");
+ throw ZoneOperationException("Could not start zone");
}
LOGD(mId << ": Started");
}
-void ContainerAdmin::stop()
+void ZoneAdmin::stop()
{
LOGD(mId << ": Stopping procedure started...");
if (isStopped()) {
if (!mZone.shutdown(SHUTDOWN_WAIT)) {
// force stop
if (!mZone.stop()) {
- throw ContainerOperationException("Could not stop container");
+ throw ZoneOperationException("Could not stop zone");
}
}
}
-void ContainerAdmin::destroy()
+void ZoneAdmin::destroy()
{
LOGD(mId << ": Destroying procedure started...");
if (!mZone.destroy()) {
- throw ContainerOperationException("Could not destroy container");
+ throw ZoneOperationException("Could not destroy zone");
}
LOGD(mId << ": Destroying procedure ended");
}
-bool ContainerAdmin::isRunning()
+bool ZoneAdmin::isRunning()
{
return mZone.getState() == lxc::LxcZone::State::RUNNING;
}
-bool ContainerAdmin::isStopped()
+bool ZoneAdmin::isStopped()
{
return mZone.getState() == lxc::LxcZone::State::STOPPED;
}
-void ContainerAdmin::suspend()
+void ZoneAdmin::suspend()
{
LOGD(mId << ": Pausing...");
if (!mZone.freeze()) {
- throw ContainerOperationException("Could not pause container");
+ throw ZoneOperationException("Could not pause zone");
}
LOGD(mId << ": Paused");
}
-void ContainerAdmin::resume()
+void ZoneAdmin::resume()
{
LOGD(mId << ": Resuming...");
if (!mZone.unfreeze()) {
- throw ContainerOperationException("Could not resume container");
+ throw ZoneOperationException("Could not resume zone");
}
LOGD(mId << ": Resumed");
}
-bool ContainerAdmin::isPaused()
+bool ZoneAdmin::isPaused()
{
return mZone.getState() == lxc::LxcZone::State::FROZEN;
}
-void ContainerAdmin::setSchedulerLevel(SchedulerLevel sched)
+void ZoneAdmin::setSchedulerLevel(SchedulerLevel sched)
{
switch (sched) {
case SchedulerLevel::FOREGROUND:
}
-void ContainerAdmin::setSchedulerParams(std::uint64_t, std::uint64_t, std::int64_t)
-//void ContainerAdmin::setSchedulerParams(std::uint64_t cpuShares, std::uint64_t vcpuPeriod, std::int64_t vcpuQuota)
+void ZoneAdmin::setSchedulerParams(std::uint64_t, std::uint64_t, std::int64_t)
+//void ZoneAdmin::setSchedulerParams(std::uint64_t cpuShares, std::uint64_t vcpuPeriod, std::int64_t vcpuQuota)
{
// assert(mZone);
//
// virTypedParamsAddLLong(¶msTmp, &numParamsBuff, &maxParams, VIR_DOMAIN_SCHEDULER_VCPU_QUOTA, vcpuQuota);
//
// if (virDomainSetSchedulerParameters(mZone.get(), params.get(), numParamsBuff) < 0) {
-// LOGE(mId << ": Error while setting the container's scheduler params:\n"
+// LOGE(mId << ": Error while setting the zone's scheduler params:\n"
// << libvirt::libvirtFormatError());
-// throw ContainerOperationException();
+// throw ZoneOperationException();
// }
}
-void ContainerAdmin::setDetachOnExit()
+void ZoneAdmin::setDetachOnExit()
{
mDetachOnExit = true;
}
-void ContainerAdmin::setDestroyOnExit()
+void ZoneAdmin::setDestroyOnExit()
{
mDestroyOnExit = true;
}
-std::int64_t ContainerAdmin::getSchedulerQuota()
+std::int64_t ZoneAdmin::getSchedulerQuota()
{
// assert(mZone);
//
// std::unique_ptr<char, void(*)(void*)> type(virDomainGetSchedulerType(mZone.get(), &numParamsBuff), free);
//
// if (type == NULL || numParamsBuff <= 0 || strcmp(type.get(), "posix") != 0) {
-// LOGE(mId << ": Error while getting the container's scheduler type:\n"
+// LOGE(mId << ": Error while getting the zone's scheduler type:\n"
// << libvirt::libvirtFormatError());
-// throw ContainerOperationException();
+// throw ZoneOperationException();
// }
//
// std::unique_ptr<virTypedParameter[]> params(new virTypedParameter[numParamsBuff]);
//
// if (virDomainGetSchedulerParameters(mZone.get(), params.get(), &numParamsBuff) < 0) {
-// LOGE(mId << ": Error while getting the container's scheduler params:\n"
+// LOGE(mId << ": Error while getting the zone's scheduler params:\n"
// << libvirt::libvirtFormatError());
-// throw ContainerOperationException();
+// throw ZoneOperationException();
// }
//
// long long quota;
// numParamsBuff,
// VIR_DOMAIN_SCHEDULER_VCPU_QUOTA,
// "a) <= 0) {
-// LOGE(mId << ": Error while getting the container's scheduler quota param:\n"
+// LOGE(mId << ": Error while getting the zone's scheduler quota param:\n"
// << libvirt::libvirtFormatError());
-// throw ContainerOperationException();
+// throw ZoneOperationException();
// }
//
// return quota;
/**
* @file
* @author Jan Olszak (j.olszak@samsung.com)
- * @brief Declaration of the class for administrating one container
+ * @brief Declaration of the class for administrating one zone
*/
-#ifndef SERVER_CONTAINER_ADMIN_HPP
-#define SERVER_CONTAINER_ADMIN_HPP
+#ifndef SERVER_ZONE_ADMIN_HPP
+#define SERVER_ZONE_ADMIN_HPP
-#include "container-config.hpp"
+#include "zone-config.hpp"
#include "lxc/zone.hpp"
BACKGROUND
};
-class ContainerAdmin {
+class ZoneAdmin {
public:
/**
- * ContainerAdmin constructor
- * @param containersPath directory where containers are defined (lxc configs, rootfs etc)
+ * ZoneAdmin constructor
+ * @param zonesPath directory where zones are defined (lxc configs, rootfs etc)
* @param lxcTemplatePrefix directory where templates are stored
- * @param config containers config
+ * @param config zones config
*/
- ContainerAdmin(const std::string& containersPath,
+ ZoneAdmin(const std::string& zonesPath,
const std::string& lxcTemplatePrefix,
- const ContainerConfig& config);
- virtual ~ContainerAdmin();
+ const ZoneConfig& config);
+ virtual ~ZoneAdmin();
/**
- * Get the container id
+ * Get the zone id
*/
const std::string& getId() const;
/**
- * Boot the container to the background.
+ * Boot the zone to the background.
*/
void start();
/**
- * Try to shutdown the container, if failed, kill it.
+ * Try to shutdown the zone, if failed, kill it.
*/
void stop();
/**
- * Destroy stopped container. In particular it removes whole containers rootfs.
+ * Destroy stopped zone. In particular it removes whole zones rootfs.
*/
void destroy();
/**
- * @return Is the container running?
+ * @return Is the zone running?
*/
bool isRunning();
/**
- * Check if the container is stopped. It's NOT equivalent to !isRunning,
+ * Check if the zone is stopped. It's NOT equivalent to !isRunning,
* because it checks different internal lxc states. There are other states,
- * (e.g. paused) when the container isn't running nor stopped.
+ * (e.g. paused) when the zone isn't running nor stopped.
*
- * @return Is the container stopped?
+ * @return Is the zone stopped?
*/
bool isStopped();
/**
- * Suspends an active container, the process is frozen
+ * Suspends an active zone, the process is frozen
* without further access to CPU resources and I/O,
- * but the memory used by the container
+ * but the memory used by the zone
* at the hypervisor level will stay allocated
*/
void suspend();
/**
- * Resume the container after suspension.
+ * Resume the zone after suspension.
*/
void resume();
/**
- * @return Is the container in a paused state?
+ * @return Is the zone in a paused state?
*/
bool isPaused();
/**
- * Sets the containers scheduler CFS quota.
+ * Sets the zones scheduler CFS quota.
*/
void setSchedulerLevel(SchedulerLevel sched);
/**
- * Set whether container should be detached on exit.
+ * Set whether zone should be detached on exit.
*/
void setDetachOnExit();
/**
- * Set if container should be destroyed on exit.
+ * Set if zone should be destroyed on exit.
*/
void setDestroyOnExit();
std::int64_t getSchedulerQuota();
private:
- const ContainerConfig& mConfig;
+ const ZoneConfig& mConfig;
lxc::LxcZone mZone;
const std::string mId;
bool mDetachOnExit;
} // namespace vasum
-#endif // SERVER_CONTAINER_ADMIN_HPP
+#endif // SERVER_ZONE_ADMIN_HPP
/**
* @file
* @author Michal Witanowski (m.witanowski@samsung.com)
- * @brief Declaration of the class for storing container configuration
+ * @brief Declaration of the class for storing zone configuration
*/
-#ifndef SERVER_CONTAINER_CONFIG_HPP
-#define SERVER_CONTAINER_CONFIG_HPP
+#ifndef SERVER_ZONE_CONFIG_HPP
+#define SERVER_ZONE_CONFIG_HPP
#include "config/fields.hpp"
namespace vasum {
-struct ContainerConfig {
+struct ZoneConfig {
/**
- * Container name
+ * Zone name
*/
std::string name;
std::string ipv4;
/**
- * Privilege of the container.
- * The smaller the value the more important the container
+ * Privilege of the zone.
+ * The smaller the value the more important the zone
*/
int privilege;
/**
- * Number of virtual terminal used by xserver inside container
+ * Number of virtual terminal used by xserver inside zone
*/
int vt;
/**
- * Allow switching to default container after timeout.
- * Setting this to false will disable switching to default container after timeout.
+ * Allow switching to default zone after timeout.
+ * Setting this to false will disable switching to default zone after timeout.
*/
bool switchToDefaultAfterTimeout;
/**
- * Specify, if D-Bus communication with the container will be enabled.
- * Setting this value to "false" will make the zone API not work inside the container.
+ * Specify, if D-Bus communication with the zone will be enabled.
+ * Setting this value to "false" will make the zone API not work inside the zone.
*/
bool enableDbusIntegration;
/**
- * Container's CFS quota in us when it's in the foreground
+ * Zone's CFS quota in us when it's in the foreground
*/
std::int64_t cpuQuotaForeground;
/**
- * Container's CFS quota in us when it's in the background
+ * Zone's CFS quota in us when it's in the background
*/
std::int64_t cpuQuotaBackground;
/**
- * Path to containers dbus unix socket
+ * Path to zones dbus unix socket
*/
std::string runMountPoint;
/**
- * When you move a file out of the container (by move request)
+ * When you move a file out of the zone (by move request)
* its path must match at least one of the regexps in this vector.
*/
std::vector<std::string> permittedToSend;
/**
- * When you move a file to the container (by move request)
+ * When you move a file to the zone (by move request)
* its path must match at least one of the regexps in this vector.
*/
std::vector<std::string> permittedToRecv;
} // namespace vasum
-#endif // SERVER_CONTAINER_CONFIG_HPP
+#endif // SERVER_ZONE_CONFIG_HPP
/**
* @file
* @author Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
- * @brief Implementation of a class for communication transport between container and server
+ * @brief Implementation of a class for communication transport between zone and server
*/
#include "config.hpp"
-#include "container-connection-transport.hpp"
+#include "zone-connection-transport.hpp"
#include "exception.hpp"
#include "utils/file-wait.hpp"
namespace {
// Timeout in ms for waiting for dbus transport.
-// Should be very long to ensure dbus in container is ready.
-// TODO: this should be in container's configuration file
+// Should be very long to ensure dbus in zone is ready.
+// TODO: this should be in zone's configuration file
const unsigned int TRANSPORT_READY_TIMEOUT = 2 * 60 * 1000;
} // namespace
-ContainerConnectionTransport::ContainerConnectionTransport(const std::string& runMountPoint)
+ZoneConnectionTransport::ZoneConnectionTransport(const std::string& runMountPoint)
: mRunMountPoint(runMountPoint), mDetachOnExit(false)
{
if (runMountPoint.empty()) {
boost::filesystem::create_directories(runMountPoint, errorCode);
if (errorCode) {
LOGE("Initialization failed: could not create '" << runMountPoint << "' :" << errorCode);
- throw ContainerConnectionException("Could not create: " + runMountPoint +
+ throw ZoneConnectionException("Could not create: " + runMountPoint +
" :" + errorCode.message());
}
bool isMount = false;
if (!utils::isMountPoint(runMountPoint, isMount)) {
LOGE("Failed to check if " << runMountPoint << " is a mount point.");
- throw ContainerConnectionException("Could not check if " + runMountPoint +
+ throw ZoneConnectionException("Could not check if " + runMountPoint +
" is a mount point.");
}
if (!utils::mountRun(runMountPoint)) {
LOGE("Initialization failed: could not mount " << runMountPoint);
- throw ContainerConnectionException("Could not mount: " + runMountPoint);
+ throw ZoneConnectionException("Could not mount: " + runMountPoint);
}
}
- // if there is no systemd in the container this dir won't be created automatically
+ // if there is no systemd in the zone this dir won't be created automatically
// TODO: will require chown with USER namespace enabled
std::string dbusDirectory = runMountPoint + "/dbus";
boost::filesystem::create_directories(dbusDirectory, errorCode);
if (errorCode) {
LOGE("Initialization failed: could not create '" << dbusDirectory << "' :" << errorCode);
- throw ContainerConnectionException("Could not create: " + dbusDirectory +
+ throw ZoneConnectionException("Could not create: " + dbusDirectory +
" :" + errorCode.message());
}
}
-ContainerConnectionTransport::~ContainerConnectionTransport()
+ZoneConnectionTransport::~ZoneConnectionTransport()
{
if (!mDetachOnExit) {
if (!mRunMountPoint.empty()) {
}
-std::string ContainerConnectionTransport::acquireAddress()
+std::string ZoneConnectionTransport::acquireAddress()
{
if (mRunMountPoint.empty()) {
return std::string();
return "unix:path=" + dbusPath;
}
-void ContainerConnectionTransport::setDetachOnExit()
+void ZoneConnectionTransport::setDetachOnExit()
{
mDetachOnExit = true;
}
/**
* @file
* @author Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
- * @brief Declaration of a class for communication transport between container and server
+ * @brief Declaration of a class for communication transport between zone and server
*/
-#ifndef SERVER_CONTAINER_CONNECTION_TRANSPORT_HPP
-#define SERVER_CONTAINER_CONNECTION_TRANSPORT_HPP
+#ifndef SERVER_ZONE_CONNECTION_TRANSPORT_HPP
+#define SERVER_ZONE_CONNECTION_TRANSPORT_HPP
#include "dbus/connection.hpp"
/**
- * This class provides a communication transport between container and server.
- * The object lifecycle should cover lifecycle of a container.
+ * This class provides a communication transport between zone and server.
+ * The object lifecycle should cover lifecycle of a zone.
*/
-class ContainerConnectionTransport {
+class ZoneConnectionTransport {
public:
- ContainerConnectionTransport(const std::string& runMountPoint);
- ~ContainerConnectionTransport();
+ ZoneConnectionTransport(const std::string& runMountPoint);
+ ~ZoneConnectionTransport();
/**
* Gets dbus addres. Will block until address is available.
} // namespace vasum
-#endif // SERVER_CONTAINER_CONNECTION_TRANSPORT_HPP
+#endif // SERVER_ZONE_CONNECTION_TRANSPORT_HPP
/**
* @file
* @author Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
- * @brief Implementation of a class for communication between container and server
+ * @brief Implementation of a class for communication between zone and server
*/
#include "config.hpp"
-#include "container-connection.hpp"
-#include "container-dbus-definitions.hpp"
+#include "zone-connection.hpp"
+#include "zone-dbus-definitions.hpp"
#include "exception.hpp"
// TODO: Switch to real power-manager dbus defs when they will be implemented in power-manager
#include "fake-power-manager-dbus-definitions.hpp"
// Timeout in ms for waiting for dbus name.
// Can happen if glib loop is busy or not present.
-// TODO: this should be in container's configuration file
+// TODO: this should be in zone's configuration file
const unsigned int NAME_ACQUIRED_TIMEOUT = 5 * 1000;
} // namespace
-ContainerConnection::ContainerConnection(const std::string& address, const OnNameLostCallback& callback)
+ZoneConnection::ZoneConnection(const std::string& address, const OnNameLostCallback& callback)
: mNameAcquired(false)
, mNameLost(false)
{
if (address.empty()) {
- LOGE("Invalid container connection address");
- throw ContainerConnectionException("Invalid container connection address");
+ LOGE("Invalid zone connection address");
+ throw ZoneConnectionException("Invalid zone connection address");
}
LOGT("Connecting to DBUS on " << address);
mDbusConnection = dbus::DbusConnection::create(address);
LOGT("Setting DBUS name");
- mDbusConnection->setName(api::container::BUS_NAME,
- std::bind(&ContainerConnection::onNameAcquired, this),
- std::bind(&ContainerConnection::onNameLost, this));
+ mDbusConnection->setName(api::zone::BUS_NAME,
+ std::bind(&ZoneConnection::onNameAcquired, this),
+ std::bind(&ZoneConnection::onNameLost, this));
if (!waitForNameAndSetCallback(NAME_ACQUIRED_TIMEOUT, callback)) {
- LOGE("Could not acquire dbus name: " << api::container::BUS_NAME);
- throw ContainerConnectionException("Could not acquire dbus name: " + api::container::BUS_NAME);
+ LOGE("Could not acquire dbus name: " << api::zone::BUS_NAME);
+ throw ZoneConnectionException("Could not acquire dbus name: " + api::zone::BUS_NAME);
}
LOGT("Registering DBUS interface");
using namespace std::placeholders;
- mDbusConnection->registerObject(api::container::OBJECT_PATH,
- api::container::DEFINITION,
- std::bind(&ContainerConnection::onMessageCall,
+ mDbusConnection->registerObject(api::zone::OBJECT_PATH,
+ api::zone::DEFINITION,
+ std::bind(&ZoneConnection::onMessageCall,
this,
_1,
_2,
_4,
_5));
- mDbusConnection->signalSubscribe(std::bind(&ContainerConnection::onSignalReceived,
+ mDbusConnection->signalSubscribe(std::bind(&ZoneConnection::onSignalReceived,
this,
_1,
_2,
LOGD("Connected");
}
-ContainerConnection::~ContainerConnection()
+ZoneConnection::~ZoneConnection()
{
}
-bool ContainerConnection::waitForNameAndSetCallback(const unsigned int timeoutMs, const OnNameLostCallback& callback)
+bool ZoneConnection::waitForNameAndSetCallback(const unsigned int timeoutMs, const OnNameLostCallback& callback)
{
std::unique_lock<std::mutex> lock(mNameMutex);
mNameCondition.wait_for(lock,
return mNameAcquired;
}
-void ContainerConnection::onNameAcquired()
+void ZoneConnection::onNameAcquired()
{
std::unique_lock<std::mutex> lock(mNameMutex);
mNameAcquired = true;
mNameCondition.notify_one();
}
-void ContainerConnection::onNameLost()
+void ZoneConnection::onNameLost()
{
std::unique_lock<std::mutex> lock(mNameMutex);
mNameLost = true;
}
}
-void ContainerConnection::setNotifyActiveContainerCallback(
- const NotifyActiveContainerCallback& callback)
+void ZoneConnection::setNotifyActiveZoneCallback(
+ const NotifyActiveZoneCallback& callback)
{
- mNotifyActiveContainerCallback = callback;
+ mNotifyActiveZoneCallback = callback;
}
-void ContainerConnection::setDisplayOffCallback(const DisplayOffCallback& callback)
+void ZoneConnection::setDisplayOffCallback(const DisplayOffCallback& callback)
{
mDisplayOffCallback = callback;
}
-void ContainerConnection::setFileMoveRequestCallback(
+void ZoneConnection::setFileMoveRequestCallback(
const FileMoveRequestCallback& callback)
{
mFileMoveRequestCallback = callback;
}
-void ContainerConnection::setProxyCallCallback(const ProxyCallCallback& callback)
+void ZoneConnection::setProxyCallCallback(const ProxyCallCallback& callback)
{
mProxyCallCallback = callback;
}
-void ContainerConnection::onMessageCall(const std::string& objectPath,
+void ZoneConnection::onMessageCall(const std::string& objectPath,
const std::string& interface,
const std::string& methodName,
GVariant* parameters,
dbus::MethodResultBuilder::Pointer result)
{
- if (objectPath != api::container::OBJECT_PATH || interface != api::container::INTERFACE) {
+ if (objectPath != api::zone::OBJECT_PATH || interface != api::zone::INTERFACE) {
return;
}
- if (methodName == api::container::METHOD_NOTIFY_ACTIVE_CONTAINER) {
+ if (methodName == api::zone::METHOD_NOTIFY_ACTIVE_ZONE) {
const gchar* application = NULL;
const gchar* message = NULL;
g_variant_get(parameters, "(&s&s)", &application, &message);
- if (mNotifyActiveContainerCallback) {
- mNotifyActiveContainerCallback(application, message);
+ if (mNotifyActiveZoneCallback) {
+ mNotifyActiveZoneCallback(application, message);
result->setVoid();
}
}
- if (methodName == api::container::METHOD_FILE_MOVE_REQUEST) {
+ if (methodName == api::zone::METHOD_FILE_MOVE_REQUEST) {
const gchar* destination = NULL;
const gchar* path = NULL;
g_variant_get(parameters, "(&s&s)", &destination, &path);
}
}
-void ContainerConnection::onSignalReceived(const std::string& senderBusName,
+void ZoneConnection::onSignalReceived(const std::string& senderBusName,
const std::string& objectPath,
const std::string& interface,
const std::string& signalName,
}
}
-void ContainerConnection::sendNotification(const std::string& container,
+void ZoneConnection::sendNotification(const std::string& zone,
const std::string& application,
const std::string& message)
{
GVariant* parameters = g_variant_new("(sss)",
- container.c_str(),
+ zone.c_str(),
application.c_str(),
message.c_str());
- mDbusConnection->emitSignal(api::container::OBJECT_PATH,
- api::container::INTERFACE,
- api::container::SIGNAL_NOTIFICATION,
+ mDbusConnection->emitSignal(api::zone::OBJECT_PATH,
+ api::zone::INTERFACE,
+ api::zone::SIGNAL_NOTIFICATION,
parameters);
}
-void ContainerConnection::proxyCallAsync(const std::string& busName,
+void ZoneConnection::proxyCallAsync(const std::string& busName,
const std::string& objectPath,
const std::string& interface,
const std::string& method,
/**
* @file
* @author Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
- * @brief Declaration of a class for communication between container and server
+ * @brief Declaration of a class for communication between zone and server
*/
-#ifndef SERVER_CONTAINER_CONNECTION_HPP
-#define SERVER_CONTAINER_CONNECTION_HPP
+#ifndef SERVER_ZONE_CONNECTION_HPP
+#define SERVER_ZONE_CONNECTION_HPP
#include "dbus/connection.hpp"
namespace vasum {
-class ContainerConnection {
+class ZoneConnection {
public:
typedef std::function<void()> OnNameLostCallback;
typedef std::function<void()> DisplayOffCallback;
- ContainerConnection(const std::string& address, const OnNameLostCallback& callback);
- ~ContainerConnection();
+ ZoneConnection(const std::string& address, const OnNameLostCallback& callback);
+ ~ZoneConnection();
// ------------- API --------------
typedef std::function<void(const std::string& application,
const std::string& message
- )> NotifyActiveContainerCallback;
+ )> NotifyActiveZoneCallback;
typedef std::function<void(const std::string& destination,
const std::string& path,
/**
* Register notification request callback
*/
- void setNotifyActiveContainerCallback(const NotifyActiveContainerCallback& callback);
+ void setNotifyActiveZoneCallback(const NotifyActiveZoneCallback& callback);
/**
* Register callback to handle turning off the display
void setProxyCallCallback(const ProxyCallCallback& callback);
/**
- * Send notification signal to this container
+ * Send notification signal to this zone
*/
- void sendNotification(const std::string& container,
+ void sendNotification(const std::string& zone,
const std::string& application,
const std::string& message);
bool mNameAcquired;
bool mNameLost;
OnNameLostCallback mOnNameLostCallback;
- NotifyActiveContainerCallback mNotifyActiveContainerCallback;
+ NotifyActiveZoneCallback mNotifyActiveZoneCallback;
DisplayOffCallback mDisplayOffCallback;
FileMoveRequestCallback mFileMoveRequestCallback;
ProxyCallCallback mProxyCallCallback;
} // namespace vasum
-#endif // SERVER_CONTAINER_CONNECTION_HPP
+#endif // SERVER_ZONE_CONNECTION_HPP
/**
* @file
* @author Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
- * @brief Container dbus api definitions
+ * @brief Zone dbus api definitions
*/
-#ifndef SERVER_CONTAINER_DBUS_DEFINITIONS_HPP
-#define SERVER_CONTAINER_DBUS_DEFINITIONS_HPP
+#ifndef SERVER_ZONE_DBUS_DEFINITIONS_HPP
+#define SERVER_ZONE_DBUS_DEFINITIONS_HPP
#include "common-dbus-definitions.hpp"
namespace vasum {
namespace api {
-namespace container {
+namespace zone {
-const std::string BUS_NAME = "org.tizen.containers.zone";
-const std::string OBJECT_PATH = "/org/tizen/containers/zone";
-const std::string INTERFACE = "org.tizen.containers.zone.manager";
+const std::string BUS_NAME = "org.tizen.vasum.zone";
+const std::string OBJECT_PATH = "/org/tizen/vasum/zone";
+const std::string INTERFACE = "org.tizen.vasum.zone.manager";
-const std::string METHOD_NOTIFY_ACTIVE_CONTAINER = "NotifyActiveContainer";
+const std::string METHOD_NOTIFY_ACTIVE_ZONE = "NotifyActiveZone";
const std::string METHOD_FILE_MOVE_REQUEST = "FileMoveRequest";
const std::string SIGNAL_NOTIFICATION = "Notification";
const std::string DEFINITION =
"<node>"
" <interface name='" + INTERFACE + "'>"
- " <method name='" + METHOD_NOTIFY_ACTIVE_CONTAINER + "'>"
+ " <method name='" + METHOD_NOTIFY_ACTIVE_ZONE + "'>"
" <arg type='s' name='application' direction='in'/>"
" <arg type='s' name='message' direction='in'/>"
" </method>"
" <arg type='v' name='result' direction='out'/>"
" </method>"
" <signal name='" + SIGNAL_NOTIFICATION + "'>"
- " <arg type='s' name='container'/>"
+ " <arg type='s' name='zone'/>"
" <arg type='s' name='application'/>"
" <arg type='s' name='message'/>"
" </signal>"
" </interface>"
"</node>";
-} // namespace container
+} // namespace zone
} // namespace api
} // namespace vasum
-#endif // SERVER_CONTAINER_DBUS_DEFINITIONS_HPP
+#endif // SERVER_ZONE_DBUS_DEFINITIONS_HPP
/**
* @file
* @author Lukasz Pawelczyk (l.pawelczyk@partner.samsung.com)
- * @brief Implementation of class for managing one container
+ * @brief Implementation of class for managing one zone
*/
#include "config.hpp"
-#include "container.hpp"
+#include "zone.hpp"
#include "base-exception.hpp"
#include "provisioning-config.hpp"
// TODO: move constants to the config file when default values are implemented there
const int RECONNECT_RETRIES = 15;
const int RECONNECT_DELAY = 1 * 1000;
-const std::string CONTAINER_PROVISION_FILE = "provision.conf";
+const std::string ZONE_PROVISION_FILE = "provision.conf";
-void declareUnit(const std::string& file, ContainerProvisioning::Unit&& unit)
+void declareUnit(const std::string& file, ZoneProvisioning::Unit&& unit)
{
// TODO: Add to the dynamic configuration
- ContainerProvisioning config;
+ ZoneProvisioning config;
if (fs::exists(file)) {
config::loadFromFile(file, config);
}
} // namespace
-Container::Container(const std::string& containersPath,
- const std::string& containerConfigPath,
+Zone::Zone(const std::string& zonesPath,
+ const std::string& zoneConfigPath,
const std::string& lxcTemplatePrefix,
const std::string& baseRunMountPointPath)
{
- config::loadFromFile(containerConfigPath, mConfig);
+ config::loadFromFile(zoneConfigPath, mConfig);
for (std::string r: mConfig.permittedToSend) {
mPermittedToSend.push_back(boost::regex(r));
mRunMountPoint = fs::absolute(mConfig.runMountPoint, baseRunMountPointPath).string();
}
- mAdmin.reset(new ContainerAdmin(containersPath, lxcTemplatePrefix, mConfig));
- const fs::path baseProvision = fs::path(containersPath) / mAdmin->getId();
- mProvisionConfig = fs::absolute(CONTAINER_PROVISION_FILE, baseProvision).string();
+ mAdmin.reset(new ZoneAdmin(zonesPath, lxcTemplatePrefix, mConfig));
+ const fs::path baseProvision = fs::path(zonesPath) / mAdmin->getId();
+ mProvisionConfig = fs::absolute(ZONE_PROVISION_FILE, baseProvision).string();
}
-Container::~Container()
+Zone::~Zone()
{
// Make sure all OnNameLostCallbacks get finished and no new will
// get called before proceeding further. This guarantees no race
}
}
-const std::vector<boost::regex>& Container::getPermittedToSend() const
+const std::vector<boost::regex>& Zone::getPermittedToSend() const
{
return mPermittedToSend;
}
-const std::vector<boost::regex>& Container::getPermittedToRecv() const
+const std::vector<boost::regex>& Zone::getPermittedToRecv() const
{
return mPermittedToRecv;
}
-const std::string& Container::getId() const
+const std::string& Zone::getId() const
{
Lock lock(mReconnectMutex);
return mAdmin->getId();
}
-int Container::getPrivilege() const
+int Zone::getPrivilege() const
{
return mConfig.privilege;
}
-void Container::start()
+void Zone::start()
{
Lock lock(mReconnectMutex);
if (mConfig.enableDbusIntegration) {
- mConnectionTransport.reset(new ContainerConnectionTransport(mRunMountPoint));
+ mConnectionTransport.reset(new ZoneConnectionTransport(mRunMountPoint));
}
mAdmin->start();
if (mConfig.enableDbusIntegration) {
goBackground();
}
-void Container::startAsync(const StartAsyncResultCallback& callback)
+void Zone::startAsync(const StartAsyncResultCallback& callback)
{
if (mStartThread.joinable()) {
mStartThread.join();
mStartThread = std::thread(startWrapper);
}
-void Container::stop()
+void Zone::stop()
{
Lock lock(mReconnectMutex);
disconnect();
mConnectionTransport.reset();
}
-void Container::connect()
+void Zone::connect()
{
// assume called under reconnect lock
mDbusAddress = mConnectionTransport->acquireAddress();
- mConnection.reset(new ContainerConnection(mDbusAddress,
- std::bind(&Container::onNameLostCallback, this)));
+ mConnection.reset(new ZoneConnection(mDbusAddress,
+ std::bind(&Zone::onNameLostCallback, this)));
if (mNotifyCallback) {
- mConnection->setNotifyActiveContainerCallback(mNotifyCallback);
+ mConnection->setNotifyActiveZoneCallback(mNotifyCallback);
}
if (mDisplayOffCallback) {
mConnection->setDisplayOffCallback(mDisplayOffCallback);
}
}
-void Container::disconnect()
+void Zone::disconnect()
{
// assume called under reconnect lock
if (mConnection) {
mConnection.reset();
mDbusAddress.clear();
if (mDbusStateChangedCallback) {
- // notify about invalid dbusAddress for this container
+ // notify about invalid dbusAddress for this zone
mDbusStateChangedCallback(std::string());
}
}
}
-std::string Container::getDbusAddress()
+std::string Zone::getDbusAddress()
{
Lock lock(mReconnectMutex);
return mDbusAddress;
}
-int Container::getVT() const
+int Zone::getVT() const
{
return mConfig.vt;
}
-bool Container::activateVT()
+bool Zone::activateVT()
{
Lock lock(mReconnectMutex);
return true;
}
-void Container::goForeground()
+void Zone::goForeground()
{
Lock lock(mReconnectMutex);
mAdmin->setSchedulerLevel(SchedulerLevel::FOREGROUND);
}
-void Container::goBackground()
+void Zone::goBackground()
{
Lock lock(mReconnectMutex);
mAdmin->setSchedulerLevel(SchedulerLevel::BACKGROUND);
}
-void Container::setDetachOnExit()
+void Zone::setDetachOnExit()
{
Lock lock(mReconnectMutex);
mAdmin->setDetachOnExit();
}
}
-void Container::setDestroyOnExit()
+void Zone::setDestroyOnExit()
{
Lock lock(mReconnectMutex);
mAdmin->setDestroyOnExit();
}
-bool Container::isRunning()
+bool Zone::isRunning()
{
Lock lock(mReconnectMutex);
return mAdmin->isRunning();
}
-bool Container::isStopped()
+bool Zone::isStopped()
{
Lock lock(mReconnectMutex);
return mAdmin->isStopped();
}
-void Container::suspend()
+void Zone::suspend()
{
Lock lock(mReconnectMutex);
mAdmin->suspend();
}
-void Container::resume()
+void Zone::resume()
{
Lock lock(mReconnectMutex);
mAdmin->resume();
}
-bool Container::isPaused()
+bool Zone::isPaused()
{
Lock lock(mReconnectMutex);
return mAdmin->isPaused();
}
-bool Container::isSwitchToDefaultAfterTimeoutAllowed() const
+bool Zone::isSwitchToDefaultAfterTimeoutAllowed() const
{
return mConfig.switchToDefaultAfterTimeout;
}
-void Container::onNameLostCallback()
+void Zone::onNameLostCallback()
{
LOGI(getId() << ": A connection to the DBUS server has been lost, reconnecting...");
if (mReconnectThread.joinable()) {
mReconnectThread.join();
}
- mReconnectThread = std::thread(std::bind(&Container::reconnectHandler, this));
+ mReconnectThread = std::thread(std::bind(&Zone::reconnectHandler, this));
}
-void Container::reconnectHandler()
+void Zone::reconnectHandler()
{
{
Lock lock(mReconnectMutex);
}
}
- LOGE(getId() << ": Reconnecting to the DBUS has failed, stopping the container");
+ LOGE(getId() << ": Reconnecting to the DBUS has failed, stopping the zone");
stop();
}
-void Container::setNotifyActiveContainerCallback(const NotifyActiveContainerCallback& callback)
+void Zone::setNotifyActiveZoneCallback(const NotifyActiveZoneCallback& callback)
{
Lock lock(mReconnectMutex);
mNotifyCallback = callback;
if (mConnection) {
- mConnection->setNotifyActiveContainerCallback(mNotifyCallback);
+ mConnection->setNotifyActiveZoneCallback(mNotifyCallback);
}
}
-void Container::sendNotification(const std::string& container,
+void Zone::sendNotification(const std::string& zone,
const std::string& application,
const std::string& message)
{
Lock lock(mReconnectMutex);
if (mConnection) {
- mConnection->sendNotification(container, application, message);
+ mConnection->sendNotification(zone, application, message);
} else {
LOGE(getId() << ": Can't send notification, no connection to DBUS");
}
}
-void Container::setDisplayOffCallback(const DisplayOffCallback& callback)
+void Zone::setDisplayOffCallback(const DisplayOffCallback& callback)
{
Lock lock(mReconnectMutex);
}
}
-void Container::setFileMoveRequestCallback(const FileMoveRequestCallback& callback)
+void Zone::setFileMoveRequestCallback(const FileMoveRequestCallback& callback)
{
Lock lock(mReconnectMutex);
}
}
-void Container::setProxyCallCallback(const ProxyCallCallback& callback)
+void Zone::setProxyCallCallback(const ProxyCallCallback& callback)
{
Lock lock(mReconnectMutex);
}
}
-void Container::setDbusStateChangedCallback(const DbusStateChangedCallback& callback)
+void Zone::setDbusStateChangedCallback(const DbusStateChangedCallback& callback)
{
mDbusStateChangedCallback = callback;
}
-void Container::proxyCallAsync(const std::string& busName,
+void Zone::proxyCallAsync(const std::string& busName,
const std::string& objectPath,
const std::string& interface,
const std::string& method,
}
}
-void Container::declareFile(const int32_t& type,
+void Zone::declareFile(const int32_t& type,
const std::string& path,
const int32_t& flags,
const int32_t& mode)
{
- ContainerProvisioning::Unit unit;
- unit.set(std::move(ContainerProvisioning::File({type, path, flags, mode})));
+ ZoneProvisioning::Unit unit;
+ unit.set(std::move(ZoneProvisioning::File({type, path, flags, mode})));
declareUnit(mProvisionConfig, std::move(unit));
}
-void Container::declareMount(const std::string& source,
+void Zone::declareMount(const std::string& source,
const std::string& target,
const std::string& type,
const int64_t& flags,
const std::string& data)
{
- ContainerProvisioning::Unit unit;
- unit.set(std::move(ContainerProvisioning::Mount({source, target, type, flags, data})));
+ ZoneProvisioning::Unit unit;
+ unit.set(std::move(ZoneProvisioning::Mount({source, target, type, flags, data})));
declareUnit(mProvisionConfig, std::move(unit));
}
-void Container::declareLink(const std::string& source,
+void Zone::declareLink(const std::string& source,
const std::string& target)
{
- ContainerProvisioning::Unit unit;
- unit.set(std::move(ContainerProvisioning::Link({source, target})));
+ ZoneProvisioning::Unit unit;
+ unit.set(std::move(ZoneProvisioning::Link({source, target})));
declareUnit(mProvisionConfig, std::move(unit));
}
/**
* @file
* @author Lukasz Pawelczyk (l.pawelczyk@partner.samsung.com)
- * @brief Declaration of the class for managing one container
+ * @brief Declaration of the class for managing one zone
*/
-#ifndef SERVER_CONTAINER_HPP
-#define SERVER_CONTAINER_HPP
+#ifndef SERVER_ZONE_HPP
+#define SERVER_ZONE_HPP
-#include "container-config.hpp"
-#include "container-admin.hpp"
-#include "container-connection.hpp"
-#include "container-connection-transport.hpp"
+#include "zone-config.hpp"
+#include "zone-admin.hpp"
+#include "zone-connection.hpp"
+#include "zone-connection-transport.hpp"
#include <string>
#include <memory>
namespace vasum {
-class Container {
+class Zone {
public:
/**
- * Container constructor
- * @param containersPath directory where containers are defined (lxc configs, rootfs etc)
- * @param containerConfigPath path for containers config
+ * Zone constructor
+ * @param zonesPath directory where zones are defined (lxc configs, rootfs etc)
+ * @param zoneConfigPath path for zones config
* @param lxcTemplatePrefix directory where templates are stored
* @param baseRunMountPointPath base directory for run mount point
*/
- Container(const std::string& containersPath,
- const std::string& containerConfigPath,
+ Zone(const std::string& zonesPath,
+ const std::string& zoneConfigPath,
const std::string& lxcTemplatePrefix,
const std::string& baseRunMountPointPath);
- Container(Container&&) = default;
- virtual ~Container();
+ Zone(Zone&&) = default;
+ virtual ~Zone();
- typedef ContainerConnection::NotifyActiveContainerCallback NotifyActiveContainerCallback;
- typedef ContainerConnection::DisplayOffCallback DisplayOffCallback;
- typedef ContainerConnection::FileMoveRequestCallback FileMoveRequestCallback;
- typedef ContainerConnection::ProxyCallCallback ProxyCallCallback;
+ typedef ZoneConnection::NotifyActiveZoneCallback NotifyActiveZoneCallback;
+ typedef ZoneConnection::DisplayOffCallback DisplayOffCallback;
+ typedef ZoneConnection::FileMoveRequestCallback FileMoveRequestCallback;
+ typedef ZoneConnection::ProxyCallCallback ProxyCallCallback;
typedef std::function<void(const std::string& address)> DbusStateChangedCallback;
typedef std::function<void(bool succeeded)> StartAsyncResultCallback;
/**
* Returns a vector of regexps defining files permitted to be
- * send to other containers using file move functionality
+ * send to other zones using file move functionality
*/
const std::vector<boost::regex>& getPermittedToSend() const;
/**
* Returns a vector of regexps defining files permitted to be
- * send to other containers using file move functionality
+ * send to other zones using file move functionality
*/
const std::vector<boost::regex>& getPermittedToRecv() const;
- // ContainerAdmin API
+ // ZoneAdmin API
/**
- * Get the container id
+ * Get the zone id
*/
const std::string& getId() const;
/**
- * Get the container privilege
+ * Get the zone privilege
*/
int getPrivilege() const;
/**
- * Boot the container to the background.
+ * Boot the zone to the background.
*/
void start();
/**
- * Boot the container to the background in separate thread. This function immediately exits
- * after container booting is started in another thread.
+ * Boot the zone to the background in separate thread. This function immediately exits
+ * after zone booting is started in another thread.
*
- * @param callback Called after starting the container. Passes bool with result of starting.
+ * @param callback Called after starting the zone. Passes bool with result of starting.
*/
void startAsync(const StartAsyncResultCallback& callback);
/**
- * Try to shutdown the container, if failed, destroy it.
+ * Try to shutdown the zone, if failed, destroy it.
*/
void stop();
/**
- * Activate this container's VT
+ * Activate this zone's VT
*
* @return Was activation successful?
*/
bool activateVT();
/**
- * Setup this container to be put in the foreground.
+ * Setup this zone to be put in the foreground.
* I.e. set appropriate scheduler level.
*/
void goForeground();
/**
- * Setup this container to be put in the background.
+ * Setup this zone to be put in the background.
* I.e. set appropriate scheduler level.
*/
void goBackground();
/**
- * Set if container should be detached on exit.
+ * Set if zone should be detached on exit.
*
- * This sends detach flag to ContainerAdmin object and disables unmounting tmpfs
- * in ContainerConnectionTransport.
+ * This sends detach flag to ZoneAdmin object and disables unmounting tmpfs
+ * in ZoneConnectionTransport.
*/
void setDetachOnExit();
/**
- * Set if container should be destroyed on exit.
+ * Set if zone should be destroyed on exit.
*/
void setDestroyOnExit();
/**
- * @return Is the container running?
+ * @return Is the zone running?
*/
bool isRunning();
/**
- * Check if the container is stopped. It's NOT equivalent to !isRunning,
+ * Check if the zone is stopped. It's NOT equivalent to !isRunning,
* because it checks different internal libvirt's states. There are other states,
- * (e.g. paused) when the container isn't running nor stopped.
+ * (e.g. paused) when the zone isn't running nor stopped.
*
- * @return Is the container stopped?
+ * @return Is the zone stopped?
*/
bool isStopped();
/**
- * Suspend container.
+ * Suspend zone.
*/
void suspend();
/**
- * Resume container.
+ * Resume zone.
*/
void resume();
/**
- * @return Is the container in a paused state?
+ * @return Is the zone in a paused state?
*/
bool isPaused();
- // ContainerConnection API
+ // ZoneConnection API
/**
- * @return Is switching to default container after timeout allowed?
+ * @return Is switching to default zone after timeout allowed?
*/
bool isSwitchToDefaultAfterTimeoutAllowed() const;
/**
* Register notification request callback
*/
- void setNotifyActiveContainerCallback(const NotifyActiveContainerCallback& callback);
+ void setNotifyActiveZoneCallback(const NotifyActiveZoneCallback& callback);
/**
- * Register callback used when switching to default container.
+ * Register callback used when switching to default zone.
*/
void setDisplayOffCallback(const DisplayOffCallback& callback);
void setProxyCallCallback(const ProxyCallCallback& callback);
/**
- * Send notification signal to this container
+ * Send notification signal to this zone
*
- * @param container name of container in which the notification occurred
+ * @param zone name of zone in which the notification occurred
* @param application name of application that cause notification
- * @param message message to be send to container
+ * @param message message to be send to zone
*/
- void sendNotification(const std::string& container,
+ void sendNotification(const std::string& zone,
const std::string& application,
const std::string& message);
int getVT() const;
/**
- * Declare file, directory or pipe that will be created while container startup
+ * Declare file, directory or pipe that will be created while zone startup
*/
void declareFile(const int32_t& type,
const std::string& path,
const int32_t& flags,
const int32_t& mode);
/**
- * Declare mount that will be created while container startup
+ * Declare mount that will be created while zone startup
*/
void declareMount(const std::string& source,
const std::string& target,
const int64_t& flags,
const std::string& data);
/**
- * Declare link that will be created while container startup
+ * Declare link that will be created while zone startup
*/
void declareLink(const std::string& source,
const std::string& target);
private:
- ContainerConfig mConfig;
+ ZoneConfig mConfig;
std::vector<boost::regex> mPermittedToSend;
std::vector<boost::regex> mPermittedToRecv;
- std::unique_ptr<ContainerConnectionTransport> mConnectionTransport;
- std::unique_ptr<ContainerAdmin> mAdmin;
- std::unique_ptr<ContainerConnection> mConnection;
+ std::unique_ptr<ZoneConnectionTransport> mConnectionTransport;
+ std::unique_ptr<ZoneAdmin> mAdmin;
+ std::unique_ptr<ZoneConnection> mConnection;
std::thread mReconnectThread;
std::thread mStartThread;
mutable std::recursive_mutex mReconnectMutex;
- NotifyActiveContainerCallback mNotifyCallback;
+ NotifyActiveZoneCallback mNotifyCallback;
DisplayOffCallback mDisplayOffCallback;
FileMoveRequestCallback mFileMoveCallback;
ProxyCallCallback mProxyCallCallback;
} // namespace vasum
-#endif // SERVER_CONTAINER_HPP
+#endif // SERVER_ZONE_HPP
/**
* @file
* @author Jan Olszak (j.olszak@samsung.com)
- * @brief Declaration of the class for storing container manager configuration
+ * @brief Declaration of the class for storing zone manager configuration
*/
-#ifndef SERVER_CONTAINERS_MANAGER_CONFIG_HPP
-#define SERVER_CONTAINERS_MANAGER_CONFIG_HPP
+#ifndef SERVER_ZONES_MANAGER_CONFIG_HPP
+#define SERVER_ZONES_MANAGER_CONFIG_HPP
#include "config/fields.hpp"
#include "input-monitor-config.hpp"
namespace vasum {
-const std::string CONTAINERS_MANAGER_CONFIG_PATH = "/etc/vasum/config/daemon.conf";
+const std::string ZONES_MANAGER_CONFIG_PATH = "/etc/vasum/config/daemon.conf";
-struct ContainersManagerConfig {
+struct ZonesManagerConfig {
/**
- * List of containers' configs that we manage.
- * File paths can be relative to the ContainerManager config file.
+ * List of zones' configs that we manage.
+ * File paths can be relative to the ZoneManager config file.
*/
- std::vector<std::string> containerConfigs;
+ std::vector<std::string> zoneConfigs;
/**
- * An ID of a currently focused/foreground container.
+ * An ID of a currently focused/foreground zone.
*/
std::string foregroundId;
/**
- * An ID of default container.
+ * An ID of default zone.
*/
std::string defaultId;
/**
- * A path where the containers mount points reside.
+ * A path where the zones mount points reside.
*/
- std::string containersPath;
+ std::string zonesPath;
/**
- * A path where the containers image reside. Empty path means that containers image won't be
- * copied to containersPath when creating new container.
+ * A path where the zones image reside. Empty path means that zones image won't be
+ * copied to zonesPath when creating new zone.
*/
- std::string containerImagePath;
+ std::string zoneImagePath;
/**
- * A path where template configuration files for new containers reside
+ * A path where template configuration files for new zones reside
*/
- std::string containerTemplatePath;
+ std::string zoneTemplatePath;
/**
- * Prefix added to a path for new container configuration files
+ * Prefix added to a path for new zone configuration files
*/
- std::string containerNewConfigPrefix;
+ std::string zoneNewConfigPrefix;
/**
* Path prefix for lxc templates
std::string lxcTemplatePrefix;
/*
- * Parameters describing input device used to switch between containers
+ * Parameters describing input device used to switch between zones
*/
InputConfig inputConfig;
/**
- * Prefix added to a path of "run" tmpfs mount point for each container.
+ * Prefix added to a path of "run" tmpfs mount point for each zone.
*/
std::string runMountPointPrefix;
CONFIG_REGISTER
(
- containerConfigs,
+ zoneConfigs,
foregroundId,
defaultId,
- containersPath,
- containerImagePath,
- containerTemplatePath,
- containerNewConfigPrefix,
+ zonesPath,
+ zoneImagePath,
+ zoneTemplatePath,
+ zoneNewConfigPrefix,
lxcTemplatePrefix,
inputConfig,
runMountPointPrefix,
} // namespace vasum
-#endif // SERVER_CONTAINERS_MANAGER_CONFIG_HPP
+#endif // SERVER_ZONES_MANAGER_CONFIG_HPP
--- /dev/null
+/*
+ * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Contact: Jan Olszak <j.olszak@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License
+ */
+
+/**
+ * @file
+ * @author Jan Olszak (j.olszak@samsung.com)
+ * @brief Definition of the class for managing zones
+ */
+
+#include "config.hpp"
+
+#include "host-dbus-definitions.hpp"
+#include "common-dbus-definitions.hpp"
+#include "zone-dbus-definitions.hpp"
+#include "zones-manager.hpp"
+#include "zone-admin.hpp"
+#include "exception.hpp"
+
+#include "utils/paths.hpp"
+#include "logger/logger.hpp"
+#include "config/manager.hpp"
+#include "dbus/exception.hpp"
+#include "utils/fs.hpp"
+#include "utils/img.hpp"
+#include "utils/environment.hpp"
+
+#include <boost/filesystem.hpp>
+#include <boost/regex.hpp>
+#include <boost/exception/diagnostic_information.hpp>
+#include <cassert>
+#include <string>
+#include <climits>
+
+
+namespace vasum {
+
+
+namespace {
+
+bool regexMatchVector(const std::string& str, const std::vector<boost::regex>& v)
+{
+ for (const boost::regex& toMatch: v) {
+ if (boost::regex_match(str, toMatch)) {
+ return true;
+ }
+ }
+
+ return false;
+}
+
+const std::string HOST_ID = "host";
+const std::string ZONE_TEMPLATE_CONFIG_PATH = "template.conf";
+
+const boost::regex ZONE_NAME_REGEX("~NAME~");
+const boost::regex ZONE_IP_THIRD_OCTET_REGEX("~IP~");
+
+const unsigned int ZONE_IP_BASE_THIRD_OCTET = 100;
+
+} // namespace
+
+ZonesManager::ZonesManager(const std::string& managerConfigPath): mDetachOnExit(false)
+{
+ LOGD("Instantiating ZonesManager object...");
+
+ mConfigPath = managerConfigPath;
+ config::loadFromFile(mConfigPath, mConfig);
+
+ mProxyCallPolicy.reset(new ProxyCallPolicy(mConfig.proxyCallRules));
+
+ using namespace std::placeholders;
+ mHostConnection.setProxyCallCallback(bind(&ZonesManager::handleProxyCall,
+ this, HOST_ID, _1, _2, _3, _4, _5, _6, _7));
+
+ mHostConnection.setGetZoneDbusesCallback(bind(
+ &ZonesManager::handleGetZoneDbuses, this, _1));
+
+ mHostConnection.setGetZoneIdsCallback(bind(&ZonesManager::handleGetZoneIdsCall,
+ this, _1));
+
+ mHostConnection.setGetActiveZoneIdCallback(bind(&ZonesManager::handleGetActiveZoneIdCall,
+ this, _1));
+
+ mHostConnection.setGetZoneInfoCallback(bind(&ZonesManager::handleGetZoneInfoCall,
+ this, _1, _2));
+
+ mHostConnection.setDeclareFileCallback(bind(&ZonesManager::handleDeclareFileCall,
+ this, _1, _2, _3, _4, _5, _6));
+
+ mHostConnection.setDeclareMountCallback(bind(&ZonesManager::handleDeclareMountCall,
+ this, _1, _2, _3, _4, _5, _6, _7));
+
+ mHostConnection.setDeclareLinkCallback(bind(&ZonesManager::handleDeclareLinkCall,
+ this, _1, _2, _3, _4));
+
+ mHostConnection.setSetActiveZoneCallback(bind(&ZonesManager::handleSetActiveZoneCall,
+ this, _1, _2));
+
+ mHostConnection.setCreateZoneCallback(bind(&ZonesManager::handleCreateZoneCall,
+ this, _1, _2));
+
+ mHostConnection.setDestroyZoneCallback(bind(&ZonesManager::handleDestroyZoneCall,
+ this, _1, _2));
+
+ mHostConnection.setLockZoneCallback(bind(&ZonesManager::handleLockZoneCall,
+ this, _1, _2));
+
+ mHostConnection.setUnlockZoneCallback(bind(&ZonesManager::handleUnlockZoneCall,
+ this, _1, _2));
+
+ for (auto& zoneConfig : mConfig.zoneConfigs) {
+ createZone(zoneConfig);
+ }
+
+ // check if default zone exists, throw ZoneOperationException if not found
+ if (!mConfig.defaultId.empty() && mZones.find(mConfig.defaultId) == mZones.end()) {
+ LOGE("Provided default zone ID " << mConfig.defaultId << " is invalid.");
+ throw ZoneOperationException("Provided default zone ID " + mConfig.defaultId +
+ " is invalid.");
+ }
+
+ LOGD("ZonesManager object instantiated");
+
+ if (mConfig.inputConfig.enabled) {
+ LOGI("Registering input monitor [" << mConfig.inputConfig.device.c_str() << "]");
+ mSwitchingSequenceMonitor.reset(
+ new InputMonitor(mConfig.inputConfig,
+ std::bind(&ZonesManager::switchingSequenceMonitorNotify,
+ this)));
+ }
+
+
+}
+
+ZonesManager::~ZonesManager()
+{
+ LOGD("Destroying ZonesManager object...");
+
+ if (!mDetachOnExit) {
+ try {
+ stopAll();
+ } catch (ServerException&) {
+ LOGE("Failed to stop all of the zones");
+ }
+ }
+
+ LOGD("ZonesManager object destroyed");
+}
+
+void ZonesManager::createZone(const std::string& zoneConfig)
+{
+ std::string baseConfigPath = utils::dirName(mConfigPath);
+ std::string zoneConfigPath = utils::getAbsolutePath(zoneConfig, baseConfigPath);
+
+ LOGT("Creating Zone " << zoneConfigPath);
+ std::unique_ptr<Zone> c(new Zone(mConfig.zonesPath,
+ zoneConfigPath,
+ mConfig.lxcTemplatePrefix,
+ mConfig.runMountPointPrefix));
+ const std::string id = c->getId();
+ if (id == HOST_ID) {
+ throw ZoneOperationException("Cannot use reserved zone ID");
+ }
+
+ using namespace std::placeholders;
+ c->setNotifyActiveZoneCallback(bind(&ZonesManager::notifyActiveZoneHandler,
+ this, id, _1, _2));
+
+ c->setDisplayOffCallback(bind(&ZonesManager::displayOffHandler,
+ this, id));
+
+ c->setFileMoveRequestCallback(bind(&ZonesManager::handleZoneMoveFileRequest,
+ this, id, _1, _2, _3));
+
+ c->setProxyCallCallback(bind(&ZonesManager::handleProxyCall,
+ this, id, _1, _2, _3, _4, _5, _6, _7));
+
+ c->setDbusStateChangedCallback(bind(&ZonesManager::handleDbusStateChanged,
+ this, id, _1));
+
+ mZones.insert(ZoneMap::value_type(id, std::move(c)));
+}
+
+void ZonesManager::destroyZone(const std::string& zoneId)
+{
+ // TODO mutex for mZones access
+ auto it = mZones.find(zoneId);
+ if (it == mZones.end()) {
+ LOGE("Failed to destroy zone " << zoneId << ": no such zone");
+ throw ZoneOperationException("No such zone");
+ }
+
+ // TODO give back the focus
+ it->second->setDestroyOnExit();
+ mZones.erase(it);
+}
+
+void ZonesManager::focus(const std::string& zoneId)
+{
+ /* try to access the object first to throw immediately if it doesn't exist */
+ ZoneMap::mapped_type& foregroundZone = mZones.at(zoneId);
+
+ if (!foregroundZone->activateVT()) {
+ LOGE("Failed to activate zones VT. Aborting focus.");
+ return;
+ }
+
+ for (auto& zone : mZones) {
+ LOGD(zone.second->getId() << ": being sent to background");
+ zone.second->goBackground();
+ }
+ mConfig.foregroundId = foregroundZone->getId();
+ LOGD(mConfig.foregroundId << ": being sent to foreground");
+ foregroundZone->goForeground();
+}
+
+void ZonesManager::startAll()
+{
+ LOGI("Starting all zones");
+
+ bool isForegroundFound = false;
+
+ for (auto& zone : mZones) {
+ zone.second->start();
+
+ if (zone.first == mConfig.foregroundId) {
+ isForegroundFound = true;
+ LOGI(zone.second->getId() << ": set as the foreground zone");
+ zone.second->goForeground();
+ }
+ }
+
+ if (!isForegroundFound) {
+ auto foregroundIterator = std::min_element(mZones.begin(), mZones.end(),
+ [](ZoneMap::value_type &c1, ZoneMap::value_type &c2) {
+ return c1.second->getPrivilege() < c2.second->getPrivilege();
+ });
+
+ if (foregroundIterator != mZones.end()) {
+ mConfig.foregroundId = foregroundIterator->second->getId();
+ LOGI(mConfig.foregroundId << ": no foreground zone configured, setting one with highest priority");
+ foregroundIterator->second->goForeground();
+ }
+ }
+}
+
+void ZonesManager::stopAll()
+{
+ LOGI("Stopping all zones");
+
+ for (auto& zone : mZones) {
+ zone.second->stop();
+ }
+}
+
+bool ZonesManager::isPaused(const std::string& zoneId)
+{
+ auto iter = mZones.find(zoneId);
+ if (iter == mZones.end()) {
+ LOGE("No such zone id: " << zoneId);
+ throw ZoneOperationException("No such zone");
+ }
+
+ return iter->second->isPaused();
+}
+
+bool ZonesManager::isRunning(const std::string& zoneId)
+{
+ auto iter = mZones.find(zoneId);
+ if (iter == mZones.end()) {
+ LOGE("No such zone id: " << zoneId);
+ throw ZoneOperationException("No such zone");
+ }
+ return iter->second->isRunning();
+}
+
+std::string ZonesManager::getRunningForegroundZoneId()
+{
+ for (auto& zone : mZones) {
+ if (zone.first == mConfig.foregroundId &&
+ zone.second->isRunning()) {
+ return zone.first;
+ }
+ }
+ return std::string();
+}
+
+std::string ZonesManager::getNextToForegroundZoneId()
+{
+ // handles case where there is no next zone
+ if (mZones.size() < 2) {
+ return std::string();
+ }
+
+ for (auto it = mZones.begin(); it != mZones.end(); ++it) {
+ if (it->first == mConfig.foregroundId &&
+ it->second->isRunning()) {
+ auto nextIt = std::next(it);
+ if (nextIt != mZones.end()) {
+ return nextIt->first;
+ }
+ }
+ }
+ return mZones.begin()->first;
+}
+
+void ZonesManager::switchingSequenceMonitorNotify()
+{
+ LOGI("switchingSequenceMonitorNotify() called");
+
+ auto nextZoneId = getNextToForegroundZoneId();
+
+ if (!nextZoneId.empty()) {
+ focus(nextZoneId);
+ }
+}
+
+
+void ZonesManager::setZonesDetachOnExit()
+{
+ mDetachOnExit = true;
+
+ for (auto& zone : mZones) {
+ zone.second->setDetachOnExit();
+ }
+}
+
+void ZonesManager::notifyActiveZoneHandler(const std::string& caller,
+ const std::string& application,
+ const std::string& message)
+{
+ LOGI("notifyActiveZoneHandler(" << caller << ", " << application << ", " << message
+ << ") called");
+ try {
+ const std::string activeZone = getRunningForegroundZoneId();
+ if (!activeZone.empty() && caller != activeZone) {
+ mZones[activeZone]->sendNotification(caller, application, message);
+ }
+ } catch(const VasumException&) {
+ LOGE("Notification from " << caller << " hasn't been sent");
+ }
+}
+
+void ZonesManager::displayOffHandler(const std::string& /*caller*/)
+{
+ // get config of currently set zone and switch if switchToDefaultAfterTimeout is true
+ const std::string activeZoneName = getRunningForegroundZoneId();
+ const auto& activeZone = mZones.find(activeZoneName);
+
+ if (activeZone != mZones.end() &&
+ activeZone->second->isSwitchToDefaultAfterTimeoutAllowed()) {
+ LOGI("Switching to default zone " << mConfig.defaultId);
+ focus(mConfig.defaultId);
+ }
+}
+
+void ZonesManager::handleZoneMoveFileRequest(const std::string& srcZoneId,
+ const std::string& dstZoneId,
+ const std::string& path,
+ dbus::MethodResultBuilder::Pointer result)
+{
+ // TODO: this implementation is only a placeholder.
+ // There are too many unanswered questions and security concerns:
+ // 1. What about mount namespace, host might not see the source/destination
+ // file. The file might be a different file from a host perspective.
+ // 2. Copy vs move (speed and security concerns over already opened FDs)
+ // 3. Access to source and destination files - DAC, uid/gig
+ // 4. Access to source and destintation files - MAC, smack
+ // 5. Destination file uid/gid assignment
+ // 6. Destination file smack label assignment
+ // 7. Verifiability of the source path
+
+ // NOTE: other possible implementations include:
+ // 1. Sending file descriptors opened directly in each zone through DBUS
+ // using something like g_dbus_message_set_unix_fd_list()
+ // 2. VSM forking and calling setns(MNT) in each zone and opening files
+ // by itself, then passing FDs to the main process
+ // Now when the main process has obtained FDs (by either of those methods)
+ // it can do the copying by itself.
+
+ LOGI("File move requested\n"
+ << "src: " << srcZoneId << "\n"
+ << "dst: " << dstZoneId << "\n"
+ << "path: " << path);
+
+ ZoneMap::const_iterator srcIter = mZones.find(srcZoneId);
+ if (srcIter == mZones.end()) {
+ LOGE("Source zone '" << srcZoneId << "' not found");
+ return;
+ }
+ Zone& srcZone = *srcIter->second;
+
+ ZoneMap::const_iterator dstIter = mZones.find(dstZoneId);
+ if (dstIter == mZones.end()) {
+ LOGE("Destination zone '" << dstZoneId << "' not found");
+ result->set(g_variant_new("(s)", api::zone::FILE_MOVE_DESTINATION_NOT_FOUND.c_str()));
+ return;
+ }
+ Zone& dstContanier = *dstIter->second;
+
+ if (srcZoneId == dstZoneId) {
+ LOGE("Cannot send a file to yourself");
+ result->set(g_variant_new("(s)", api::zone::FILE_MOVE_WRONG_DESTINATION.c_str()));
+ return;
+ }
+
+ if (!regexMatchVector(path, srcZone.getPermittedToSend())) {
+ LOGE("Source zone has no permissions to send the file: " << path);
+ result->set(g_variant_new("(s)", api::zone::FILE_MOVE_NO_PERMISSIONS_SEND.c_str()));
+ return;
+ }
+
+ if (!regexMatchVector(path, dstContanier.getPermittedToRecv())) {
+ LOGE("Destination zone has no permissions to receive the file: " << path);
+ result->set(g_variant_new("(s)", api::zone::FILE_MOVE_NO_PERMISSIONS_RECEIVE.c_str()));
+ return;
+ }
+
+ namespace fs = boost::filesystem;
+ std::string srcPath = fs::absolute(srcZoneId, mConfig.zonesPath).string() + path;
+ std::string dstPath = fs::absolute(dstZoneId, mConfig.zonesPath).string() + path;
+
+ if (!utils::moveFile(srcPath, dstPath)) {
+ LOGE("Failed to move the file: " << path);
+ result->set(g_variant_new("(s)", api::zone::FILE_MOVE_FAILED.c_str()));
+ } else {
+ result->set(g_variant_new("(s)", api::zone::FILE_MOVE_SUCCEEDED.c_str()));
+ try {
+ dstContanier.sendNotification(srcZoneId, path, api::zone::FILE_MOVE_SUCCEEDED);
+ } catch (ServerException&) {
+ LOGE("Notification to '" << dstZoneId << "' has not been sent");
+ }
+ }
+}
+
+void ZonesManager::handleProxyCall(const std::string& caller,
+ const std::string& target,
+ const std::string& targetBusName,
+ const std::string& targetObjectPath,
+ const std::string& targetInterface,
+ const std::string& targetMethod,
+ GVariant* parameters,
+ dbus::MethodResultBuilder::Pointer result)
+{
+ if (!mProxyCallPolicy->isProxyCallAllowed(caller,
+ target,
+ targetBusName,
+ targetObjectPath,
+ targetInterface,
+ targetMethod)) {
+ LOGW("Forbidden proxy call; " << caller << " -> " << target << "; " << targetBusName
+ << "; " << targetObjectPath << "; " << targetInterface << "; " << targetMethod);
+ result->setError(api::ERROR_FORBIDDEN, "Proxy call forbidden");
+ return;
+ }
+
+ LOGI("Proxy call; " << caller << " -> " << target << "; " << targetBusName
+ << "; " << targetObjectPath << "; " << targetInterface << "; " << targetMethod);
+
+ auto asyncResultCallback = [result](dbus::AsyncMethodCallResult& asyncMethodCallResult) {
+ try {
+ GVariant* targetResult = asyncMethodCallResult.get();
+ result->set(g_variant_new("(v)", targetResult));
+ } catch (dbus::DbusException& e) {
+ result->setError(api::ERROR_FORWARDED, e.what());
+ }
+ };
+
+ if (target == HOST_ID) {
+ mHostConnection.proxyCallAsync(targetBusName,
+ targetObjectPath,
+ targetInterface,
+ targetMethod,
+ parameters,
+ asyncResultCallback);
+ return;
+ }
+
+ ZoneMap::const_iterator targetIter = mZones.find(target);
+ if (targetIter == mZones.end()) {
+ LOGE("Target zone '" << target << "' not found");
+ result->setError(api::ERROR_INVALID_ID, "Unknown proxy call target");
+ return;
+ }
+
+ Zone& targetZone = *targetIter->second;
+ targetZone.proxyCallAsync(targetBusName,
+ targetObjectPath,
+ targetInterface,
+ targetMethod,
+ parameters,
+ asyncResultCallback);
+}
+
+void ZonesManager::handleGetZoneDbuses(dbus::MethodResultBuilder::Pointer result)
+{
+ std::vector<GVariant*> entries;
+ for (auto& zone : mZones) {
+ GVariant* zoneId = g_variant_new_string(zone.first.c_str());
+ GVariant* dbusAddress = g_variant_new_string(zone.second->getDbusAddress().c_str());
+ GVariant* entry = g_variant_new_dict_entry(zoneId, dbusAddress);
+ entries.push_back(entry);
+ }
+ GVariant* dict = g_variant_new_array(G_VARIANT_TYPE("{ss}"), entries.data(), entries.size());
+ result->set(g_variant_new("(*)", dict));
+}
+
+void ZonesManager::handleDbusStateChanged(const std::string& zoneId,
+ const std::string& dbusAddress)
+{
+ mHostConnection.signalZoneDbusState(zoneId, dbusAddress);
+}
+
+void ZonesManager::handleGetZoneIdsCall(dbus::MethodResultBuilder::Pointer result)
+{
+ std::vector<GVariant*> zoneIds;
+ for(auto& zone: mZones){
+ zoneIds.push_back(g_variant_new_string(zone.first.c_str()));
+ }
+
+ GVariant* array = g_variant_new_array(G_VARIANT_TYPE("s"),
+ zoneIds.data(),
+ zoneIds.size());
+ result->set(g_variant_new("(*)", array));
+}
+
+void ZonesManager::handleGetActiveZoneIdCall(dbus::MethodResultBuilder::Pointer result)
+{
+ LOGI("GetActiveZoneId call");
+ if (!mConfig.foregroundId.empty() && mZones[mConfig.foregroundId]->isRunning()){
+ result->set(g_variant_new("(s)", mConfig.foregroundId.c_str()));
+ } else {
+ result->set(g_variant_new("(s)", ""));
+ }
+}
+
+void ZonesManager::handleGetZoneInfoCall(const std::string& id,
+ dbus::MethodResultBuilder::Pointer result)
+{
+ LOGI("GetZoneInfo call");
+ if (mZones.count(id) == 0) {
+ LOGE("No zone with id=" << id);
+ result->setError(api::ERROR_INVALID_ID, "No such zone id");
+ return;
+ }
+ const auto& zone = mZones[id];
+ const char* state;
+ //TODO: Use the lookup map.
+ if (zone->isRunning()) {
+ state = "RUNNING";
+ } else if (zone->isStopped()) {
+ state = "STOPPED";
+ } else if (zone->isPaused()) {
+ state = "FROZEN";
+ } else {
+ LOGE("Unrecognized state of zone id=" << id);
+ result->setError(api::ERROR_INTERNAL, "Unrecognized state of zone");
+ return;
+ }
+ const auto zonePath = boost::filesystem::absolute(id, mConfig.zonesPath);
+ const auto rootfsDir = boost::filesystem::path("rootfs");
+ const auto rootfsPath = zonePath / rootfsDir;
+
+ result->set(g_variant_new("((siss))",
+ id.c_str(),
+ zone->getVT(),
+ state,
+ rootfsPath.string().c_str()));
+}
+
+void ZonesManager::handleDeclareFileCall(const std::string& zone,
+ const int32_t& type,
+ const std::string& path,
+ const int32_t& flags,
+ const int32_t& mode,
+ dbus::MethodResultBuilder::Pointer result)
+{
+ LOGI("DeclareFile call");
+ try {
+ mZones.at(zone)->declareFile(type, path, flags, mode);
+ result->setVoid();
+ } catch (const std::out_of_range& ex) {
+ LOGE("No zone with id=" << zone);
+ result->setError(api::ERROR_INVALID_ID, "No such zone id");
+ } catch (const config::ConfigException& ex) {
+ LOGE("Can't declare file: " << ex.what());
+ result->setError(api::ERROR_INTERNAL, "Internal error");
+ }
+}
+
+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,
+ dbus::MethodResultBuilder::Pointer result)
+{
+ LOGI("DeclareMount call");
+ try {
+ mZones.at(zone)->declareMount(source, target, type, flags, data);
+ result->setVoid();
+ } catch (const std::out_of_range& ex) {
+ LOGE("No zone with id=" << zone);
+ result->setError(api::ERROR_INVALID_ID, "No such zone id");
+ } catch (const config::ConfigException& ex) {
+ LOGE("Can't declare mount: " << ex.what());
+ result->setError(api::ERROR_INTERNAL, "Internal error");
+ }
+}
+
+void ZonesManager::handleDeclareLinkCall(const std::string& source,
+ const std::string& zone,
+ const std::string& target,
+ dbus::MethodResultBuilder::Pointer result)
+{
+ LOGI("DeclareLink call");
+ try {
+ mZones.at(zone)->declareLink(source, target);
+ result->setVoid();
+ } catch (const std::out_of_range& ex) {
+ LOGE("No zone with id=" << zone);
+ result->setError(api::ERROR_INVALID_ID, "No such zone id");
+ } catch (const config::ConfigException& ex) {
+ LOGE("Can't declare link: " << ex.what());
+ result->setError(api::ERROR_INTERNAL, "Internal error");
+ }
+}
+
+void ZonesManager::handleSetActiveZoneCall(const std::string& id,
+ dbus::MethodResultBuilder::Pointer result)
+{
+ LOGI("SetActiveZone call; Id=" << id );
+ auto zone = mZones.find(id);
+ if (zone == mZones.end()){
+ LOGE("No zone with id=" << id );
+ result->setError(api::ERROR_INVALID_ID, "No such zone id");
+ return;
+ }
+
+ if (zone->second->isStopped()){
+ LOGE("Could not activate a stopped zone");
+ result->setError(api::host::ERROR_ZONE_STOPPED,
+ "Could not activate a stopped zone");
+ return;
+ }
+
+ focus(id);
+ result->setVoid();
+}
+
+
+void ZonesManager::generateNewConfig(const std::string& id,
+ const std::string& templatePath,
+ const std::string& resultPath)
+{
+ namespace fs = boost::filesystem;
+
+ std::string resultFileDir = utils::dirName(resultPath);
+ if (!fs::exists(resultFileDir)) {
+ if (!utils::createEmptyDir(resultFileDir)) {
+ LOGE("Unable to create directory for new config.");
+ throw ZoneOperationException("Unable to create directory for new config.");
+ }
+ }
+
+ fs::path resultFile(resultPath);
+ if (fs::exists(resultFile)) {
+ LOGT(resultPath << " already exists, removing");
+ fs::remove(resultFile);
+ }
+
+ std::string config;
+ if (!utils::readFileContent(templatePath, config)) {
+ LOGE("Failed to read template config file.");
+ throw ZoneOperationException("Failed to read template config file.");
+ }
+
+ std::string resultConfig = boost::regex_replace(config, ZONE_NAME_REGEX, id);
+
+ // generate third IP octet for network config
+ // TODO change algorithm after implementing removeZone
+ std::string thirdOctetStr = std::to_string(ZONE_IP_BASE_THIRD_OCTET + mZones.size() + 1);
+ LOGD("IP third octet: " << thirdOctetStr);
+ resultConfig = boost::regex_replace(resultConfig, ZONE_IP_THIRD_OCTET_REGEX, thirdOctetStr);
+
+ if (!utils::saveFileContent(resultPath, resultConfig)) {
+ LOGE("Faield to save new config file.");
+ throw ZoneOperationException("Failed to save new config file.");
+ }
+
+ // restrict new config file so that only owner (vasum) can write it
+ fs::permissions(resultPath, fs::perms::owner_all |
+ fs::perms::group_read |
+ fs::perms::others_read);
+}
+
+void ZonesManager::handleCreateZoneCall(const std::string& id,
+ dbus::MethodResultBuilder::Pointer result)
+{
+ if (id.empty()) {
+ LOGE("Failed to add zone - invalid name.");
+ result->setError(api::ERROR_INVALID_ID, "Invalid name");
+ return;
+ }
+
+ LOGI("Creating zone " << id);
+
+ // TODO: This solution is temporary. It utilizes direct access to config files when creating new
+ // zones. Update this handler when config database will appear.
+ namespace fs = boost::filesystem;
+
+ // check if zone does not exist
+ if (mZones.find(id) != mZones.end()) {
+ LOGE("Cannot create " << id << " zone - already exists!");
+ result->setError(api::ERROR_INVALID_ID, "Already exists");
+ return;
+ }
+
+ const std::string zonePathStr = utils::createFilePath(mConfig.zonesPath, "/", id, "/");
+
+ // copy zone image if config contains path to image
+ LOGT("Image path: " << mConfig.zoneImagePath);
+ if (!mConfig.zoneImagePath.empty()) {
+ auto copyImageContentsWrapper = std::bind(&utils::copyImageContents,
+ mConfig.zoneImagePath,
+ zonePathStr);
+
+ if (!utils::launchAsRoot(copyImageContentsWrapper)) {
+ LOGE("Failed to copy zone image.");
+ result->setError(api::ERROR_INTERNAL, "Failed to copy zone image.");
+ return;
+ }
+ }
+
+ // generate paths to new configuration files
+ std::string baseDir = utils::dirName(mConfigPath);
+ std::string configDir = utils::getAbsolutePath(mConfig.zoneNewConfigPrefix, baseDir);
+ std::string templateDir = utils::getAbsolutePath(mConfig.zoneTemplatePath, baseDir);
+
+ std::string configPath = utils::createFilePath(templateDir, "/", ZONE_TEMPLATE_CONFIG_PATH);
+ std::string newConfigPath = utils::createFilePath(configDir, "/zones/", id + ".conf");
+
+ auto removeAllWrapper = [](const std::string& path) -> bool {
+ try {
+ LOGD("Removing copied data");
+ fs::remove_all(fs::path(path));
+ } catch(const std::exception& e) {
+ LOGW("Failed to remove data: " << boost::diagnostic_information(e));
+ }
+ return true;
+ };
+
+ try {
+ LOGI("Generating config from " << configPath << " to " << newConfigPath);
+ generateNewConfig(id, configPath, newConfigPath);
+
+ } catch (VasumException& e) {
+ LOGE("Generate config failed: " << e.what());
+ utils::launchAsRoot(std::bind(removeAllWrapper, zonePathStr));
+ result->setError(api::ERROR_INTERNAL, "Failed to generate config");
+ return;
+ }
+
+ LOGT("Creating new zone");
+ try {
+ createZone(newConfigPath);
+ } catch (VasumException& e) {
+ LOGE("Creating new zone failed: " << e.what());
+ utils::launchAsRoot(std::bind(removeAllWrapper, zonePathStr));
+ result->setError(api::ERROR_INTERNAL, "Failed to create zone");
+ return;
+ }
+
+ auto resultCallback = [this, id, result](bool succeeded) {
+ if (succeeded) {
+ focus(id);
+ result->setVoid();
+ } else {
+ LOGE("Failed to start zone.");
+ // TODO removeZone
+ result->setError(api::ERROR_INTERNAL, "Failed to start zone");
+ }
+ };
+ mZones[id]->startAsync(resultCallback);
+}
+
+void ZonesManager::handleDestroyZoneCall(const std::string& id,
+ dbus::MethodResultBuilder::Pointer result)
+{
+ if (mZones.find(id) == mZones.end()) {
+ LOGE("Failed to destroy zone - no such zone id: " << id);
+ result->setError(api::ERROR_INVALID_ID, "No such zone id");
+ return;
+ }
+
+ LOGI("Destroying zone " << id);
+
+ auto destroyer = [id, result, this] {
+ try {
+ destroyZone(id);
+ } catch (const VasumException& e) {
+ LOGE("Error during zone destruction: " << e.what());
+ result->setError(api::ERROR_INTERNAL, "Failed to destroy zone");
+ return;
+ }
+ result->setVoid();
+ };
+
+ std::thread thread(destroyer);
+ thread.detach(); //TODO fix it
+}
+
+void ZonesManager::handleLockZoneCall(const std::string& id,
+ dbus::MethodResultBuilder::Pointer result)
+{
+ LOGI("LockZone call; Id=" << id );
+ auto iter = mZones.find(id);
+ if (iter == mZones.end()) {
+ LOGE("Failed to lock zone - no such zone id: " << id);
+ result->setError(api::ERROR_INVALID_ID, "No such zone id");
+ return;
+ }
+
+ auto& zone = *iter->second;
+ if (!zone.isRunning()) {
+ LOGE("Zone id=" << id << " is not running.");
+ result->setError(api::ERROR_INVALID_STATE, "Zone is not running");
+ return;
+ }
+
+ LOGT("Lock zone");
+ try {
+ zone.suspend();
+ } catch (ZoneOperationException& e) {
+ LOGE(e.what());
+ result->setError(api::ERROR_INTERNAL, e.what());
+ return;
+ }
+
+ result->setVoid();
+}
+
+void ZonesManager::handleUnlockZoneCall(const std::string& id,
+ dbus::MethodResultBuilder::Pointer result)
+{
+ LOGI("UnlockZone call; Id=" << id );
+ auto iter = mZones.find(id);
+ if (iter == mZones.end()) {
+ LOGE("Failed to unlock zone - no such zone id: " << id);
+ result->setError(api::ERROR_INVALID_ID, "No such zone id");
+ return;
+ }
+
+ auto& zone = *iter->second;
+ if (!zone.isPaused()) {
+ LOGE("Zone id=" << id << " is not paused.");
+ result->setError(api::ERROR_INVALID_STATE, "Zone is not paused");
+ return;
+ }
+
+ LOGT("Unlock zone");
+ try {
+ zone.resume();
+ } catch (ZoneOperationException& e) {
+ LOGE(e.what());
+ result->setError(api::ERROR_INTERNAL, e.what());
+ return;
+ }
+
+ result->setVoid();
+}
+
+} // namespace vasum
/**
* @file
* @author Jan Olszak (j.olszak@samsung.com)
- * @brief Declaration of the class for managing many containers
+ * @brief Declaration of the class for managing many zones
*/
-#ifndef SERVER_CONTAINERS_MANAGER_HPP
-#define SERVER_CONTAINERS_MANAGER_HPP
+#ifndef SERVER_ZONES_MANAGER_HPP
+#define SERVER_ZONES_MANAGER_HPP
-#include "container.hpp"
-#include "containers-manager-config.hpp"
+#include "zone.hpp"
+#include "zones-manager-config.hpp"
#include "host-connection.hpp"
#include "input-monitor.hpp"
#include "proxy-call-policy.hpp"
namespace vasum {
-class ContainersManager final {
+class ZonesManager final {
public:
- ContainersManager(const std::string& managerConfigPath);
- ~ContainersManager();
+ ZonesManager(const std::string& managerConfigPath);
+ ~ZonesManager();
/**
- * Create new container.
+ * Create new zone.
*
- * @param containerConfig config of new container
+ * @param zoneConfig config of new zone
*/
- void createContainer(const std::string& containerConfig);
+ void createZone(const std::string& zoneConfig);
/**
- * Destroy container.
+ * Destroy zone.
*
- * @param containerId id of the container
+ * @param zoneId id of the zone
*/
- void destroyContainer(const std::string& containerId);
+ void destroyZone(const std::string& zoneId);
/**
- * Focus this container, put it to the foreground.
+ * Focus this zone, put it to the foreground.
* Method blocks until the focus is switched.
*
- * @param containerId id of the container
+ * @param zoneId id of the zone
*/
- void focus(const std::string& containerId);
+ void focus(const std::string& zoneId);
/**
- * Start up all the configured containers
+ * Start up all the configured zones
*/
void startAll();
/**
- * Stop all managed containers
+ * Stop all managed zones
*/
void stopAll();
/**
- * @return Is the container in a paused state?
+ * @return Is the zone in a paused state?
*/
- bool isPaused(const std::string& containerId);
+ bool isPaused(const std::string& zoneId);
/**
- * @return Is the container running?
+ * @return Is the zone running?
*/
- bool isRunning(const std::string& containerId);
+ bool isRunning(const std::string& zoneId);
/**
- * @return id of the currently focused/foreground container
+ * @return id of the currently focused/foreground zone
*/
- std::string getRunningForegroundContainerId();
+ std::string getRunningForegroundZoneId();
/**
- * @return id of next to currently focused/foreground container. If currently focused container
- * is last in container map, id of fisrt container from map is returned.
+ * @return id of next to currently focused/foreground zone. If currently focused zone
+ * is last in zone map, id of fisrt zone from map is returned.
*/
- std::string getNextToForegroundContainerId();
+ std::string getNextToForegroundZoneId();
/**
- * Set whether ContainersManager should detach containers on exit
+ * Set whether ZonesManager should detach zones on exit
*/
- void setContainersDetachOnExit();
+ void setZonesDetachOnExit();
private:
- ContainersManagerConfig mConfig;
+ ZonesManagerConfig mConfig;
std::string mConfigPath;
HostConnection mHostConnection;
- // to hold InputMonitor pointer to monitor if container switching sequence is recognized
+ // to hold InputMonitor pointer to monitor if zone switching sequence is recognized
std::unique_ptr<InputMonitor> mSwitchingSequenceMonitor;
std::unique_ptr<ProxyCallPolicy> mProxyCallPolicy;
- typedef std::unordered_map<std::string, std::unique_ptr<Container>> ContainerMap;
- ContainerMap mContainers; // map of containers, id is the key
+ typedef std::unordered_map<std::string, std::unique_ptr<Zone>> ZoneMap;
+ ZoneMap mZones; // map of zones, id is the key
bool mDetachOnExit;
void switchingSequenceMonitorNotify();
const std::string& templatePath,
const std::string& resultPath);
- void notifyActiveContainerHandler(const std::string& caller,
+ void notifyActiveZoneHandler(const std::string& caller,
const std::string& appliaction,
const std::string& message);
void displayOffHandler(const std::string& caller);
- void handleContainerMoveFileRequest(const std::string& srcContainerId,
- const std::string& dstContainerId,
+ void handleZoneMoveFileRequest(const std::string& srcZoneId,
+ const std::string& dstZoneId,
const std::string& path,
dbus::MethodResultBuilder::Pointer result);
void handleProxyCall(const std::string& caller,
const std::string& targetMethod,
GVariant* parameters,
dbus::MethodResultBuilder::Pointer result);
- void handleGetContainerDbuses(dbus::MethodResultBuilder::Pointer result);
- void handleDbusStateChanged(const std::string& containerId, const std::string& dbusAddress);
- void handleGetContainerIdsCall(dbus::MethodResultBuilder::Pointer result);
- void handleGetActiveContainerIdCall(dbus::MethodResultBuilder::Pointer result);
- void handleGetContainerInfoCall(const std::string& id, dbus::MethodResultBuilder::Pointer result);
- void handleDeclareFileCall(const std::string& container,
+ void handleGetZoneDbuses(dbus::MethodResultBuilder::Pointer result);
+ void handleDbusStateChanged(const std::string& zoneId, const std::string& dbusAddress);
+ void handleGetZoneIdsCall(dbus::MethodResultBuilder::Pointer result);
+ void handleGetActiveZoneIdCall(dbus::MethodResultBuilder::Pointer result);
+ void handleGetZoneInfoCall(const std::string& id, dbus::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,
dbus::MethodResultBuilder::Pointer result);
void handleDeclareMountCall(const std::string& source,
- const std::string& container,
+ const std::string& zone,
const std::string& target,
const std::string& type,
const uint64_t& flags,
const std::string& data,
dbus::MethodResultBuilder::Pointer result);
void handleDeclareLinkCall(const std::string& source,
- const std::string& container,
+ const std::string& zone,
const std::string& target,
dbus::MethodResultBuilder::Pointer result);
- void handleSetActiveContainerCall(const std::string& id,
+ void handleSetActiveZoneCall(const std::string& id,
dbus::MethodResultBuilder::Pointer result);
- void handleCreateContainerCall(const std::string& id,
+ void handleCreateZoneCall(const std::string& id,
dbus::MethodResultBuilder::Pointer result);
- void handleDestroyContainerCall(const std::string& id,
+ void handleDestroyZoneCall(const std::string& id,
dbus::MethodResultBuilder::Pointer result);
- void handleLockContainerCall(const std::string& id,
+ void handleLockZoneCall(const std::string& id,
dbus::MethodResultBuilder::Pointer result);
- void handleUnlockContainerCall(const std::string& id,
+ void handleUnlockZoneCall(const std::string& id,
dbus::MethodResultBuilder::Pointer result);
};
} // namespace vasum
-#endif // SERVER_CONTAINERS_MANAGER_HPP
+#endif // SERVER_ZONES_MANAGER_HPP
-'''! Module used to collect list of containers based on the vasum configuration files.
+'''! Module used to collect list of zones based on the vasum configuration files.
@author: Michal Witanowski (m.witanowski@samsung.com)
'''
class ConfigChecker:
'''! This class verifies vasum configuration files and collects dictionary with
- containers existing in the system (name and rootfs path).
+ zones existing in the system (name and rootfs path).
'''
def __parseLibvirtXML(self, path):
- '''! Parses libvirt's configuration in order to extract container name and path.
+ '''! Parses libvirt's configuration in order to extract zone name and path.
@param path Libvirt's zone configuration path
'''
if rootFound:
raise Exception("Multiple root fs mounts found in file: " + path)
else:
- self.containers[name] = source
- print " Container '" + name + "' found at: " + source
+ self.zones[name] = source
+ print " Zone '" + name + "' found at: " + source
rootFound = True
if not rootFound:
- raise Exception("Root directory of '" + name + "' container not specified in XML")
+ raise Exception("Root directory of '" + name + "' zone not specified in XML")
def __init__(self, mainConfigPath):
'''! Parses daemon's JSON configuration files.
@param mainConfigPath Path to the main config "daemon.conf"
'''
- self.containers = {}
- print "Looking for container IDs..."
+ self.zones = {}
+ print "Looking for zone IDs..."
# load main daemon JSON config file
if not os.path.isfile(mainConfigPath):
daemonConfigData = json.load(daemonConfigStr)
daemonConfigDir = os.path.dirname(os.path.abspath(mainConfigPath))
- # get dictionary with containers
- containerConfigPaths = daemonConfigData["containerConfigs"]
- for configPath in containerConfigPaths:
+ # get dictionary with zones
+ zoneConfigPaths = daemonConfigData["zoneConfigs"]
+ for configPath in zoneConfigPaths:
- # open container config file
- containerConfigPath = os.path.join(daemonConfigDir, configPath)
- if not os.path.isfile(containerConfigPath):
- raise Exception(containerConfigPath + " not found. " +
+ # open zone config file
+ zoneConfigPath = os.path.join(daemonConfigDir, configPath)
+ if not os.path.isfile(zoneConfigPath):
+ raise Exception(zoneConfigPath + " not found. " +
"Please verify that vasum is properly installed.")
- with open(containerConfigPath) as containerConfigStr:
- containerConfigData = json.load(containerConfigStr)
+ with open(zoneConfigPath) as zoneConfigStr:
+ zoneConfigData = json.load(zoneConfigStr)
# extract XML config path for libvirt
- libvirtConfigPath = os.path.join(daemonConfigDir, "containers",
- containerConfigData["config"])
+ libvirtConfigPath = os.path.join(daemonConfigDir, "zones",
+ zoneConfigData["config"])
output, ret = vsm_test_utils.launchProc("virt-xml-validate " + libvirtConfigPath)
if ret == 0:
-'''! Module used to test containers' images completeness
+'''! Module used to test zones' images completeness
@author: Michal Witanowski (m.witanowski@samsung.com)
'''
VSM_USER_NAME = "security-containers"
VSM_UID = 377
-DAEMON_DBUS_SOCKET_NAME = "org.tizen.containers.zone"
+DAEMON_DBUS_SOCKET_NAME = "org.tizen.vasum.zone"
-# dbus config file path relative to container's root
+# dbus config file path relative to zone's root
DBUS_CONFIG_PATH = "etc/dbus-1/system.d/" + DAEMON_DBUS_SOCKET_NAME + ".conf"
# main daemon config
DAEMON_CONFIG_PATH = "/etc/vasum/daemon.conf"
-class ContainerImageTestCase(unittest.TestCase):
- '''! Test case class verifying containers' images
+class ZoneImageTestCase(unittest.TestCase):
+ '''! Test case class verifying zones' images
'''
@classmethod
def setUpClass(self):
- '''! Sets up testing environment - collects container names and paths.
+ '''! Sets up testing environment - collects zone names and paths.
'''
self.configChecker = ConfigChecker(DAEMON_CONFIG_PATH)
def test01_vsmUserExistence(self):
'''! Verifies if "vasum" user with an appropriate UID exists within the
- containers.
+ zones.
'''
- for containerName, containerPath in self.configChecker.containers.iteritems():
- # chroot into a container and get UID of the user
- output, ret = vsm_test_utils.launchProc("chroot " + containerPath +
+ for zoneName, zonePath in self.configChecker.zones.iteritems():
+ # chroot into a zone and get UID of the user
+ output, ret = vsm_test_utils.launchProc("chroot " + zonePath +
" /usr/bin/id -u " + VSM_USER_NAME)
self.assertEqual(ret, 0, "User '" + VSM_USER_NAME + "' does not exist in '" +
- containerName + "' container.")
+ zoneName + "' zone.")
# cast to integer to remove white spaces, etc.
uid = int(output)
self.assertEqual(uid, VSM_UID, "Invalid UID of '" + VSM_USER_NAME + "' in '" +
- containerName + "' container: got " + str(uid) +
+ zoneName + "' zone: got " + str(uid) +
", should be " + str(VSM_UID))
def test02_dbusConfig(self):
- '''! Verifies if dbus configuration file exists within containers.
+ '''! Verifies if dbus configuration file exists within zones.
'''
- for containerName, containerPath in self.configChecker.containers.iteritems():
- configPath = os.path.join(containerPath, DBUS_CONFIG_PATH)
+ for zoneName, zonePath in self.configChecker.zones.iteritems():
+ configPath = os.path.join(zonePath, DBUS_CONFIG_PATH)
self.assertTrue(os.path.isfile(configPath), "Dbus configuration not found in '" +
- containerName + "' container")
+ zoneName + "' zone")
tree = ET.parse(configPath)
root = tree.getroot()
DAEMON_DBUS_SOCKET_NAME)
if not (ownCheck and sendDestinationCheck and sendDestinationCheck):
- raise Exception("Invalid dbus configuration in '" + containerName + "' container")
+ raise Exception("Invalid dbus configuration in '" + zoneName + "' zone")
# Test urls
TEST_URL_INTERNET=["www.samsung.com", "www.google.com", "www.oracle.com"]
-# Path to test container
-TEST_CONTAINER_PATH="/opt/usr/containers/private"
+# Path to test zone
+TEST_ZONE_PATH="/opt/usr/zones/private"
# Device Ethernet device
ETHERNET_DEVICE="usb0"
ETHERNET_DEVICE_DETECT=False
-# Test containers
-CONTAINER_T1="business"
-CONTAINER_T2="private"
+# Test zones
+ZONE_T1="business"
+ZONE_T2="private"
-containers=[CONTAINER_T1, CONTAINER_T2]
+zones=[ZONE_T1, ZONE_T2]
# Null device
OUTPUT_TO_NULL_DEVICE=" >/dev/null 2>&1 "
break
# ----------------------------------------------------------
-# The function checks whether test container image is present in system
+# The function checks whether test zone image is present in system
#
def test_guest_image():
- rc = runCommand("/usr/bin/chroot " + TEST_CONTAINER_PATH + " /bin/true")
+ rc = runCommand("/usr/bin/chroot " + TEST_ZONE_PATH + " /bin/true")
if( rc != 0 ):
return 1
return 0
def test_mandatory_toos():
tools =["/usr/bin/ping"]
- root_tools=[TEST_CONTAINER_PATH]
+ root_tools=[TEST_ZONE_PATH]
for i in range(len(tools)):
rc = runCommand("/usr/bin/ls " + root_tools[i] + tools[i])
# ----------------------------------------------------------
# The function performs single internet access test
#
-def internetAccessTest(container):
+def internetAccessTest(zone):
count=0
for item in TEST_URL_INTERNET:
LOG_INFO(" Test for URL : " + item);
- rc = virshCmd("lxc-enter-namespace " + container + \
+ rc = virshCmd("lxc-enter-namespace " + zone + \
" --noseclabel -- /usr/bin/ping -c 3 -W " + \
str(PING_TIME_OUT) + " " + item)
if(rc != 0):
# ----------------------------------------------------------
# The function performs single internet access test
#
-def networkVisibiltyTest(container, dest_ip):
- return virshCmd("lxc-enter-namespace " + container + \
+def networkVisibiltyTest(zone, dest_ip):
+ return virshCmd("lxc-enter-namespace " + zone + \
" --noseclabel -- /usr/bin/ping -c 3 -W " + \
str(PING_TIME_OUT) + " " + dest_ip)
-def printInternetAccessTestStatus(container, testInfo1):
+def printInternetAccessTestStatus(zone, testInfo1):
- text = " Internet access for container: " + container + \
+ text = " Internet access for zone: " + zone + \
"; TCS = " + testInfo1.testItemResult[len(testInfo1.testItemResult)-1]
if(testInfo1.testItemResult[len(testInfo1.testItemResult)-1] == "Success"):
def networkVisibiltyTestStatus(src, dest, ip, testInfo2):
- text = " Container access: " + src + \
+ text = " Zone access: " + src + \
" -> " + dest + \
" [" + ip + "]" + \
"; TCS = " + testInfo2.testItemResult[len(testInfo2.testItemResult)-1]
LOG_ERROR(text)
# ----------------------------------------------------------
-# The function performs test case for two containers - Business and Private.
-# Both containers are mutually isolated and have access to the Internet.
+# The function performs test case for two zones - Business and Private.
+# Both zones are mutually isolated and have access to the Internet.
#
def twoNetworks():
ltestInfo = TestNetworkInfo("Two networks tests")
# 0. Test data
- containers_list = [CONTAINER_T1, CONTAINER_T2]
- dest_containers_list = [CONTAINER_T2, CONTAINER_T1]
+ zones_list = [ZONE_T1, ZONE_T2]
+ dest_zones_list = [ZONE_T2, ZONE_T1]
test_ip_list = [["10.0.101.2"], ["10.0.102.2"]]
test_1_expected_res = [ 0, 0]
test_2_expected_res = [-1, -1]
LOG_INFO(" - Setup device")
# 2. Internet access
- LOG_INFO(" - Two containers environment network test case execution")
+ LOG_INFO(" - Two zones environment network test case execution")
LOG_INFO(" - Internet access test")
- for i in range(len(containers_list)):
+ for i in range(len(zones_list)):
# - Test case info
ltestInfo.testItemType.append("[Two nets] Internet access")
- ltestInfo.testItemName.append(containers_list[i])
- ltestInfo.testItemDescription.append("Internet access test for : " + containers_list[i])
+ ltestInfo.testItemName.append(zones_list[i])
+ ltestInfo.testItemDescription.append("Internet access test for : " + zones_list[i])
# - Perform test
- rc = internetAccessTest(containers_list[i])
+ rc = internetAccessTest(zones_list[i])
# - Test status store
if(test_result(test_1_expected_res[i], rc) == 0):
ltestInfo.testItemResult.append("Error")
# - Print status
- printInternetAccessTestStatus(containers_list[i], ltestInfo)
+ printInternetAccessTestStatus(zones_list[i], ltestInfo)
- # 3. Mutual containers visibility
- LOG_INFO(" - Containers isolation")
- for i in range(len(containers_list)):
+ # 3. Mutual zones visibility
+ LOG_INFO(" - Zones isolation")
+ for i in range(len(zones_list)):
# Interate over destynation ips
dest_ips = test_ip_list[i]
for j in range(len(dest_ips)):
# - Test case info
ltestInfo.testItemType.append("[Two nets] Visibility")
- ltestInfo.testItemName.append(containers_list[i] + "->" + dest_containers_list[i])
- ltestInfo.testItemDescription.append("Container access for : " + containers_list[i])
+ ltestInfo.testItemName.append(zones_list[i] + "->" + dest_zones_list[i])
+ ltestInfo.testItemDescription.append("Zone access for : " + zones_list[i])
# Perform test
- rc = networkVisibiltyTest(containers_list[i], dest_ips[j])
+ rc = networkVisibiltyTest(zones_list[i], dest_ips[j])
# - Test status store
if(test_result(test_2_expected_res[i], rc) == 0):
ltestInfo.testItemResult.append("Error")
# - Print status
- networkVisibiltyTestStatus(containers_list[i], dest_containers_list[i], dest_ips[j], ltestInfo)
+ networkVisibiltyTestStatus(zones_list[i], dest_zones_list[i], dest_ips[j], ltestInfo)
LOG_INFO(" - Clean environment")
# @author Jacek Pielaszkiewicz (j.pielaszkie@samsung.com)
#
-'''! Module used to test network in containers
+'''! Module used to test network in zones
@author: Jacek Pielaszkiewicz (j.pielaszkie@samsung.com)
'''
self.assertTrue(False, "ROOT user is required to run the test")
return
- # 2. Test container images
+ # 2. Test zone images
if(test_guest_image() == 1):
- self.assertTrue(False, "No test container in path :" + TEST_CONTAINER_PATH)
+ self.assertTrue(False, "No test zone in path :" + TEST_ZONE_PATH)
return
# 3. Test mandatory tools
${CMAKE_BINARY_DIR}/ut-client/test-dbus-daemon.conf @ONLY)
FILE(GLOB client_manager_CONF_GEN ${CMAKE_BINARY_DIR}/ut-client/*.conf)
-CONFIGURE_FILE(ut-client/containers/console1-dbus.conf.in
- ${CMAKE_BINARY_DIR}/ut-client/containers/console1-dbus.conf @ONLY)
-CONFIGURE_FILE(ut-client/containers/console2-dbus.conf.in
- ${CMAKE_BINARY_DIR}/ut-client/containers/console2-dbus.conf @ONLY)
-CONFIGURE_FILE(ut-client/containers/console3-dbus.conf.in
- ${CMAKE_BINARY_DIR}/ut-client/containers/console3-dbus.conf @ONLY)
-FILE(GLOB client_container_CONF_GEN ${CMAKE_BINARY_DIR}/ut-client/containers/*.conf)
+CONFIGURE_FILE(ut-client/zones/console1-dbus.conf.in
+ ${CMAKE_BINARY_DIR}/ut-client/zones/console1-dbus.conf @ONLY)
+CONFIGURE_FILE(ut-client/zones/console2-dbus.conf.in
+ ${CMAKE_BINARY_DIR}/ut-client/zones/console2-dbus.conf @ONLY)
+CONFIGURE_FILE(ut-client/zones/console3-dbus.conf.in
+ ${CMAKE_BINARY_DIR}/ut-client/zones/console3-dbus.conf @ONLY)
+FILE(GLOB client_zone_CONF_GEN ${CMAKE_BINARY_DIR}/ut-client/zones/*.conf)
## Install #####################################################################
INSTALL(FILES ${client_manager_CONF_GEN}
DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/client/ut-client)
-INSTALL(FILES ${client_container_CONF_GEN}
- DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/client/ut-client/containers)
+INSTALL(FILES ${client_zone_CONF_GEN}
+ DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/client/ut-client/zones)
{
- "containerConfigs" : ["containers/console1-dbus.conf",
- "containers/console2-dbus.conf",
- "containers/console3-dbus.conf"],
- "foregroundId" : "ut-containers-manager-console1-dbus",
- "defaultId" : "ut-containers-manager-console1-dbus",
- "containersPath" : "/tmp/ut-containers",
- "containerImagePath" : "",
- "containerTemplatePath" : "",
- "containerNewConfigPrefix" : "",
+ "zoneConfigs" : ["zones/console1-dbus.conf",
+ "zones/console2-dbus.conf",
+ "zones/console3-dbus.conf"],
+ "foregroundId" : "ut-zones-manager-console1-dbus",
+ "defaultId" : "ut-zones-manager-console1-dbus",
+ "zonesPath" : "/tmp/ut-zones",
+ "zoneImagePath" : "",
+ "zoneTemplatePath" : "",
+ "zoneNewConfigPrefix" : "",
"runMountPointPrefix" : "",
"lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
"inputConfig" : {"enabled" : false,
"timeWindowMs" : 500},
"proxyCallRules" : [{"caller" : "*",
"target" : "*",
- "targetBusName" : "org.tizen.containers.tests",
+ "targetBusName" : "org.tizen.vasum.tests",
"targetObjectPath" : "*",
"targetInterface" : "*",
"targetMethod" : "*"}]
{
- "name" : "ut-containers-manager-console1-dbus",
+ "name" : "ut-zones-manager-console1-dbus",
"lxcTemplate" : "minimal-dbus.sh",
- "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-containers-manager/ut-dbus.conf --fork; read"],
+ "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/ut-dbus.conf --fork; read"],
"ipv4Gateway" : "",
"ipv4" : "",
"privilege" : 20,
"enableDbusIntegration" : true,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
- "runMountPoint" : "/tmp/ut-run/ut-containers-manager-console1-dbus",
+ "runMountPoint" : "/tmp/ut-run/ut-zones-manager-console1-dbus",
"permittedToSend" : [ "/tmp/.*", "/etc/secret2" ],
"permittedToRecv" : [ "/tmp/.*" ]
}
{
- "name" : "ut-containers-manager-console2-dbus",
+ "name" : "ut-zones-manager-console2-dbus",
"lxcTemplate" : "minimal-dbus.sh",
- "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-containers-manager/ut-dbus.conf --fork; read"],
+ "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/ut-dbus.conf --fork; read"],
"ipv4Gateway" : "",
"ipv4" : "",
"privilege" : 20,
"enableDbusIntegration" : true,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
- "runMountPoint" : "/tmp/ut-run/ut-containers-manager-console2-dbus",
+ "runMountPoint" : "/tmp/ut-run/ut-zones-manager-console2-dbus",
"permittedToSend" : [ "/tmp/.*" ],
"permittedToRecv" : [ "/tmp/.*", "/etc/secret1" ]
}
{
- "name" : "ut-containers-manager-console3-dbus",
+ "name" : "ut-zones-manager-console3-dbus",
"lxcTemplate" : "minimal-dbus.sh",
- "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-containers-manager/ut-dbus.conf --fork; read"],
+ "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/ut-dbus.conf --fork; read"],
"ipv4Gateway" : "",
"ipv4" : "",
"privilege" : 20,
"enableDbusIntegration" : true,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
- "runMountPoint" : "/tmp/ut-run/ut-containers-manager-console3-dbus",
+ "runMountPoint" : "/tmp/ut-run/ut-zones-manager-console3-dbus",
"permittedToSend" : [ "/tmp/.*" ],
"permittedToRecv" : [ "/tmp/.*" ]
}
BOOST_AUTO_TEST_SUITE(ClientUtils)
-BOOST_AUTO_TEST_CASE(ParseContainerIdFromCpuSetTest)
+BOOST_AUTO_TEST_CASE(ParseZoneIdFromCpuSetTest)
{
auto testBad = [](const std::string& input) {
std::string ret;
- BOOST_CHECK(!parseContainerIdFromCpuSet(input, ret));
+ BOOST_CHECK(!parseZoneIdFromCpuSet(input, ret));
};
auto testOK = [](const std::string& input, const std::string& expected) {
std::string ret;
- BOOST_CHECK(parseContainerIdFromCpuSet(input, ret));
+ BOOST_CHECK(parseZoneIdFromCpuSet(input, ret));
BOOST_CHECK_EQUAL(expected, ret);
};
#include "utils/latch.hpp"
#include "utils/scoped-dir.hpp"
-#include "containers-manager.hpp"
-#include "container-dbus-definitions.hpp"
+#include "zones-manager.hpp"
+#include "zone-dbus-definitions.hpp"
#include <map>
#include <string>
const std::string TEST_DBUS_CONFIG_PATH =
VSM_TEST_CONFIG_INSTALL_DIR "/client/ut-client/test-dbus-daemon.conf";
-const std::string CONTAINERS_PATH = "/tmp/ut-containers"; // the same as in daemon.conf
+const std::string ZONES_PATH = "/tmp/ut-zones"; // the same as in daemon.conf
struct Loop {
Loop()
struct Fixture {
Loop loop;
- utils::ScopedDir mContainersPathGuard;
+ utils::ScopedDir mZonesPathGuard;
utils::ScopedDir mRunGuard;
- ContainersManager cm;
+ ZonesManager cm;
Fixture()
- : mContainersPathGuard(CONTAINERS_PATH)
+ : mZonesPathGuard(ZONES_PATH)
, mRunGuard("/tmp/ut-run")
, cm(TEST_DBUS_CONFIG_PATH)
{
const int EVENT_TIMEOUT = 5000; ///< ms
const std::map<std::string, std::string> EXPECTED_DBUSES_STARTED = {
{
- "ut-containers-manager-console1-dbus",
- "unix:path=/tmp/ut-run/ut-containers-manager-console1-dbus/dbus/system_bus_socket"
+ "ut-zones-manager-console1-dbus",
+ "unix:path=/tmp/ut-run/ut-zones-manager-console1-dbus/dbus/system_bus_socket"
},
{
- "ut-containers-manager-console2-dbus",
- "unix:path=/tmp/ut-run/ut-containers-manager-console2-dbus/dbus/system_bus_socket"
+ "ut-zones-manager-console2-dbus",
+ "unix:path=/tmp/ut-run/ut-zones-manager-console2-dbus/dbus/system_bus_socket"
},
{
- "ut-containers-manager-console3-dbus",
- "unix:path=/tmp/ut-run/ut-containers-manager-console3-dbus/dbus/system_bus_socket"
+ "ut-zones-manager-console3-dbus",
+ "unix:path=/tmp/ut-run/ut-zones-manager-console3-dbus/dbus/system_bus_socket"
}
};
vsm_client_free(client);
}
-BOOST_AUTO_TEST_CASE(GetContainerDbusesTest)
+BOOST_AUTO_TEST_CASE(GetZoneDbusesTest)
{
VsmClient client = vsm_client_create();
VsmStatus status = vsm_connect(client);
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
VsmArrayString keys, values;
- status = vsm_get_container_dbuses(client, &keys, &values);
+ status = vsm_get_zone_dbuses(client, &keys, &values);
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
BOOST_CHECK_EQUAL(getArrayStringLength(keys, EXPECTED_DBUSES_STARTED.size() + 1),
BOOST_CHECK_EQUAL(getArrayStringLength(values, EXPECTED_DBUSES_STARTED.size() + 1),
EXPECTED_DBUSES_STARTED.size());
- std::map<std::string, std::string> containers;
- convertDictToMap(keys, values, containers);
- BOOST_CHECK(containers == EXPECTED_DBUSES_STARTED);
+ std::map<std::string, std::string> zones;
+ convertDictToMap(keys, values, zones);
+ BOOST_CHECK(zones == EXPECTED_DBUSES_STARTED);
vsm_array_string_free(keys);
vsm_array_string_free(values);
vsm_client_free(client);
}
-BOOST_AUTO_TEST_CASE(GetContainerIdsTest)
+BOOST_AUTO_TEST_CASE(GetZoneIdsTest)
{
VsmClient client = vsm_client_create();
VsmStatus status = vsm_connect(client);
BOOST_CHECK_EQUAL(getArrayStringLength(values, EXPECTED_DBUSES_STARTED.size() + 1),
EXPECTED_DBUSES_STARTED.size());
- std::set<std::string> containers;
- convertArrayToSet(values, containers);
+ std::set<std::string> zones;
+ convertArrayToSet(values, zones);
- for (const auto& container : containers) {
- BOOST_CHECK(EXPECTED_DBUSES_STARTED.find(container) != EXPECTED_DBUSES_STARTED.cend());
+ for (const auto& zone : zones) {
+ BOOST_CHECK(EXPECTED_DBUSES_STARTED.find(zone) != EXPECTED_DBUSES_STARTED.cend());
}
vsm_array_string_free(values);
vsm_client_free(client);
}
-BOOST_AUTO_TEST_CASE(GetActiveContainerIdTest)
+BOOST_AUTO_TEST_CASE(GetActiveZoneIdTest)
{
VsmClient client = vsm_client_create();
VsmStatus status = vsm_connect(client);
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
- VsmString container;
- status = vsm_get_active_container_id(client, &container);
+ VsmString zone;
+ status = vsm_get_active_zone_id(client, &zone);
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
- BOOST_CHECK_EQUAL(container, cm.getRunningForegroundContainerId());
+ BOOST_CHECK_EQUAL(zone, cm.getRunningForegroundZoneId());
- vsm_string_free(container);
+ vsm_string_free(zone);
vsm_client_free(client);
}
-BOOST_AUTO_TEST_CASE(SetActiveContainerTest)
+BOOST_AUTO_TEST_CASE(SetActiveZoneTest)
{
- const std::string newActiveContainerId = "ut-containers-manager-console2-dbus";
+ const std::string newActiveZoneId = "ut-zones-manager-console2-dbus";
- BOOST_REQUIRE_NE(newActiveContainerId, cm.getRunningForegroundContainerId());
+ BOOST_REQUIRE_NE(newActiveZoneId, cm.getRunningForegroundZoneId());
VsmClient client = vsm_client_create();
VsmStatus status = vsm_connect(client);
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
- status = vsm_set_active_container(client, newActiveContainerId.c_str());
+ status = vsm_set_active_zone(client, newActiveZoneId.c_str());
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
- BOOST_CHECK_EQUAL(newActiveContainerId, cm.getRunningForegroundContainerId());
+ BOOST_CHECK_EQUAL(newActiveZoneId, cm.getRunningForegroundZoneId());
vsm_client_free(client);
}
-BOOST_AUTO_TEST_CASE(CreateContainerTest)
+BOOST_AUTO_TEST_CASE(CreateZoneTest)
{
- const std::string newActiveContainerId = "";
+ const std::string newActiveZoneId = "";
VsmClient client = vsm_client_create();
VsmStatus status = vsm_connect(client);
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
- status = vsm_create_zone(client, newActiveContainerId.c_str(), NULL);
+ status = vsm_create_zone(client, newActiveZoneId.c_str(), NULL);
BOOST_REQUIRE_EQUAL(VSMCLIENT_CUSTOM_ERROR, status);
vsm_client_free(client);
}
-BOOST_AUTO_TEST_CASE(LockUnlockContainerTest)
+BOOST_AUTO_TEST_CASE(LockUnlockZoneTest)
{
- const std::string newActiveContainerId = "ut-containers-manager-console2-dbus";
+ const std::string newActiveZoneId = "ut-zones-manager-console2-dbus";
VsmClient client = vsm_client_create();
VsmStatus status = vsm_connect(client);
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
- status = vsm_lock_zone(client, newActiveContainerId.c_str());
+ status = vsm_lock_zone(client, newActiveZoneId.c_str());
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
- status = vsm_unlock_zone(client, newActiveContainerId.c_str());
+ status = vsm_unlock_zone(client, newActiveZoneId.c_str());
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
vsm_client_free(client);
}
BOOST_AUTO_TEST_CASE(FileMoveRequestTest)
{
const std::string path = "/tmp/fake_path";
- const std::string secondContainer = "fake_container";
+ const std::string secondZone = "fake_zone";
VsmClient client = vsm_client_create();
VsmStatus status = vsm_connect_custom(client, EXPECTED_DBUSES_STARTED.begin()->second.c_str());
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
- status = vsm_file_move_request(client, secondContainer.c_str(), path.c_str());
+ status = vsm_file_move_request(client, secondZone.c_str(), path.c_str());
BOOST_REQUIRE_EQUAL(VSMCLIENT_CUSTOM_ERROR, status);
- BOOST_REQUIRE_EQUAL(api::container::FILE_MOVE_DESTINATION_NOT_FOUND,
+ BOOST_REQUIRE_EQUAL(api::zone::FILE_MOVE_DESTINATION_NOT_FOUND,
vsm_get_status_message(client));
vsm_client_free(client);
}
std::vector< std::tuple<std::string, std::string, std::string> > receivedSignalMsg;
};
- auto callback = [](const char* container,
+ auto callback = [](const char* zone,
const char* application,
const char* message,
void* data) {
CallbackData& callbackData = *reinterpret_cast<CallbackData*>(data);
- callbackData.receivedSignalMsg.push_back(std::make_tuple(container, application, message));
+ callbackData.receivedSignalMsg.push_back(std::make_tuple(zone, application, message));
callbackData.signalReceivedLatch.set();
};
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
}
for (auto& client : clients) {
- VsmStatus status = vsm_notify_active_container(client.second,
+ VsmStatus status = vsm_notify_active_zone(client.second,
MSG_APP.c_str(),
MSG_CONTENT.c_str());
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
}
}
-BOOST_AUTO_TEST_CASE(GetContainerIdByPidTest1)
+BOOST_AUTO_TEST_CASE(GetZoneIdByPidTest1)
{
VsmClient client = vsm_client_create();
- VsmString container;
- VsmStatus status = vsm_lookup_zone_by_pid(client, 1, &container);
+ VsmString zone;
+ VsmStatus status = vsm_lookup_zone_by_pid(client, 1, &zone);
BOOST_REQUIRE_EQUAL(VSMCLIENT_SUCCESS, status);
- BOOST_CHECK_EQUAL(container, std::string("host"));
+ BOOST_CHECK_EQUAL(zone, std::string("host"));
- vsm_string_free(container);
+ vsm_string_free(zone);
vsm_client_free(client);
}
-BOOST_AUTO_TEST_CASE(GetContainerIdByPidTest2)
+BOOST_AUTO_TEST_CASE(GetZoneIdByPidTest2)
{
std::set<std::string> ids;
VsmClient client = vsm_client_create();
for (int n = 0; n < 100000; ++n) {
- VsmString container;
- VsmStatus status = vsm_lookup_zone_by_pid(client, n, &container);
+ VsmString zone;
+ VsmStatus status = vsm_lookup_zone_by_pid(client, n, &zone);
if (status == VSMCLIENT_SUCCESS) {
- ids.insert(container);
- vsm_string_free(container);
+ ids.insert(zone);
+ vsm_string_free(zone);
} else {
BOOST_WARN_MESSAGE(status == VSMCLIENT_INVALID_ARGUMENT, vsm_get_status_message(client));
}
-<!-- This configuration file controls the containers message bus -->
+<!-- This configuration file controls the zones message bus -->
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<type>custom</type>
- <listen>unix:path=/tmp/container_socket</listen>
+ <listen>unix:path=/tmp/zone_socket</listen>
<policy context="default">
<!-- Allow everything to be sent -->
namespace vasum {
-const std::string DBUS_SOCKET_FILE = "/tmp/container_socket";
+const std::string DBUS_SOCKET_FILE = "/tmp/zone_socket";
const std::string DBUS_ADDRESS = "unix:path=" + DBUS_SOCKET_FILE;
const std::string TESTAPI_BUS_NAME = "org.tizen.tests";
LOGE("unknown method; should never happen");
}
} catch (const std::exception& e) {
- result->setError("org.tizen.containers.Error.Test", e.what());
+ result->setError("org.tizen.vasum.Error.Test", e.what());
}
}
public:
ScopedDbusDaemon()
{
- boost::filesystem::remove("/tmp/container_socket");
+ boost::filesystem::remove("/tmp/zone_socket");
mDaemon.start(DBUS_DAEMON_PROC, DBUS_DAEMON_ARGS);
waitForFile(DBUS_SOCKET_FILE, DBUS_DAEMON_TIMEOUT);
}
} else if (methodName == TESTAPI_METHOD_THROW) {
int arg = 0;
g_variant_get(parameters, "(i)", &arg);
- result->setError("org.tizen.containers.Error.Test", "msg: " + std::to_string(arg));
+ result->setError("org.tizen.vasum.Error.Test", "msg: " + std::to_string(arg));
}
};
conn1->registerObject(TESTAPI_OBJECT_PATH, TESTAPI_DEFINITION, handler);
} else if (methodName == TESTAPI_METHOD_THROW) {
int arg = 0;
g_variant_get(parameters, "(i)", &arg);
- result->setError("org.tizen.containers.Error.Test", "msg: " + std::to_string(arg));
+ result->setError("org.tizen.vasum.Error.Test", "msg: " + std::to_string(arg));
}
};
conn1->registerObject(TESTAPI_OBJECT_PATH, TESTAPI_DEFINITION, handler);
esac
done
-# Prepare container rootfs
+# Prepare zone rootfs
ROOTFS_DIRS="\
${rootfs}/bin \
${rootfs}/dev \
"
/bin/mkdir ${ROOTFS_DIRS}
-# Prepare container configuration file
+# Prepare zone configuration file
> ${path}/config
cat <<EOF >> ${path}/config
lxc.utsname = ${name}
esac
done
-# Prepare container rootfs
+# Prepare zone rootfs
ROOTFS_DIRS="\
${rootfs}/bin \
${rootfs}/dev \
"
/bin/mkdir ${ROOTFS_DIRS}
-# Prepare container configuration file
+# Prepare zone configuration file
> ${path}/config
cat <<EOF >> ${path}/config
lxc.utsname = ${name}
MESSAGE(STATUS "Installing configs for the Server Unit Tests to " ${VSM_TEST_CONFIG_INSTALL_DIR})
FILE(GLOB server_manager_CONF ut-server/*.conf)
-FILE(GLOB server_container_CONF ut-server/containers/*.conf)
+FILE(GLOB server_zone_CONF ut-server/zones/*.conf)
-FILE(GLOB manager_manager_CONF ut-containers-manager/*.conf)
-FILE(GLOB manager_container_CONF ut-containers-manager/containers/*.conf)
+FILE(GLOB manager_manager_CONF ut-zones-manager/*.conf)
+FILE(GLOB manager_zone_CONF ut-zones-manager/zones/*.conf)
-FILE(GLOB container_CONF ut-container/*.conf)
-FILE(GLOB container_container_CONF ut-container/containers/*.conf)
+FILE(GLOB zone_CONF ut-zone/*.conf)
+FILE(GLOB zone_zone_CONF ut-zone/zones/*.conf)
-FILE(GLOB admin_container_CONF ut-container-admin/containers/*.conf)
+FILE(GLOB admin_zone_CONF ut-zone-admin/zones/*.conf)
-FILE(GLOB connection_CONF ut-container-connection/*.conf)
+FILE(GLOB connection_CONF ut-zone-connection/*.conf)
## Generate ####################################################################
${CMAKE_BINARY_DIR}/ut-server/buggy-daemon.conf @ONLY)
FILE(GLOB server_manager_CONF_GEN ${CMAKE_BINARY_DIR}/ut-server/*.conf)
-CONFIGURE_FILE(ut-container/containers/test-dbus.conf.in
- ${CMAKE_BINARY_DIR}/ut-container/containers/test-dbus.conf @ONLY)
-FILE(GLOB container_container_CONF_GEN ${CMAKE_BINARY_DIR}/ut-container/containers/*.conf)
-
-CONFIGURE_FILE(ut-containers-manager/test-daemon.conf.in
- ${CMAKE_BINARY_DIR}/ut-containers-manager/test-daemon.conf @ONLY)
-CONFIGURE_FILE(ut-containers-manager/buggy-daemon.conf.in
- ${CMAKE_BINARY_DIR}/ut-containers-manager/buggy-daemon.conf @ONLY)
-CONFIGURE_FILE(ut-containers-manager/buggy-default-daemon.conf.in
- ${CMAKE_BINARY_DIR}/ut-containers-manager/buggy-default-daemon.conf @ONLY)
-CONFIGURE_FILE(ut-containers-manager/buggy-foreground-daemon.conf.in
- ${CMAKE_BINARY_DIR}/ut-containers-manager/buggy-foreground-daemon.conf @ONLY)
-CONFIGURE_FILE(ut-containers-manager/test-dbus-daemon.conf.in
- ${CMAKE_BINARY_DIR}/ut-containers-manager/test-dbus-daemon.conf @ONLY)
-CONFIGURE_FILE(ut-containers-manager/empty-dbus-daemon.conf.in
- ${CMAKE_BINARY_DIR}/ut-containers-manager/empty-dbus-daemon.conf @ONLY)
-FILE(GLOB manager_manager_CONF_GEN ${CMAKE_BINARY_DIR}/ut-containers-manager/*.conf)
-
-CONFIGURE_FILE(ut-containers-manager/containers/console1-dbus.conf.in
- ${CMAKE_BINARY_DIR}/ut-containers-manager/containers/console1-dbus.conf @ONLY)
-CONFIGURE_FILE(ut-containers-manager/containers/console2-dbus.conf.in
- ${CMAKE_BINARY_DIR}/ut-containers-manager/containers/console2-dbus.conf @ONLY)
-CONFIGURE_FILE(ut-containers-manager/containers/console3-dbus.conf.in
- ${CMAKE_BINARY_DIR}/ut-containers-manager/containers/console3-dbus.conf @ONLY)
-FILE(GLOB manager_container_CONF_GEN ${CMAKE_BINARY_DIR}/ut-containers-manager/containers/*.conf)
-
-CONFIGURE_FILE(ut-containers-manager/templates/template.conf.in
- ${CMAKE_BINARY_DIR}/ut-containers-manager/templates/template.conf @ONLY)
-FILE(GLOB manager_container_TEMPLATE_GEN ${CMAKE_BINARY_DIR}/ut-containers-manager/templates/*.conf)
+CONFIGURE_FILE(ut-zone/zones/test-dbus.conf.in
+ ${CMAKE_BINARY_DIR}/ut-zone/zones/test-dbus.conf @ONLY)
+FILE(GLOB zone_zone_CONF_GEN ${CMAKE_BINARY_DIR}/ut-zone/zones/*.conf)
+
+CONFIGURE_FILE(ut-zones-manager/test-daemon.conf.in
+ ${CMAKE_BINARY_DIR}/ut-zones-manager/test-daemon.conf @ONLY)
+CONFIGURE_FILE(ut-zones-manager/buggy-daemon.conf.in
+ ${CMAKE_BINARY_DIR}/ut-zones-manager/buggy-daemon.conf @ONLY)
+CONFIGURE_FILE(ut-zones-manager/buggy-default-daemon.conf.in
+ ${CMAKE_BINARY_DIR}/ut-zones-manager/buggy-default-daemon.conf @ONLY)
+CONFIGURE_FILE(ut-zones-manager/buggy-foreground-daemon.conf.in
+ ${CMAKE_BINARY_DIR}/ut-zones-manager/buggy-foreground-daemon.conf @ONLY)
+CONFIGURE_FILE(ut-zones-manager/test-dbus-daemon.conf.in
+ ${CMAKE_BINARY_DIR}/ut-zones-manager/test-dbus-daemon.conf @ONLY)
+CONFIGURE_FILE(ut-zones-manager/empty-dbus-daemon.conf.in
+ ${CMAKE_BINARY_DIR}/ut-zones-manager/empty-dbus-daemon.conf @ONLY)
+FILE(GLOB manager_manager_CONF_GEN ${CMAKE_BINARY_DIR}/ut-zones-manager/*.conf)
+
+CONFIGURE_FILE(ut-zones-manager/zones/console1-dbus.conf.in
+ ${CMAKE_BINARY_DIR}/ut-zones-manager/zones/console1-dbus.conf @ONLY)
+CONFIGURE_FILE(ut-zones-manager/zones/console2-dbus.conf.in
+ ${CMAKE_BINARY_DIR}/ut-zones-manager/zones/console2-dbus.conf @ONLY)
+CONFIGURE_FILE(ut-zones-manager/zones/console3-dbus.conf.in
+ ${CMAKE_BINARY_DIR}/ut-zones-manager/zones/console3-dbus.conf @ONLY)
+FILE(GLOB manager_zone_CONF_GEN ${CMAKE_BINARY_DIR}/ut-zones-manager/zones/*.conf)
+
+CONFIGURE_FILE(ut-zones-manager/templates/template.conf.in
+ ${CMAKE_BINARY_DIR}/ut-zones-manager/templates/template.conf @ONLY)
+FILE(GLOB manager_zone_TEMPLATE_GEN ${CMAKE_BINARY_DIR}/ut-zones-manager/templates/*.conf)
## Install #####################################################################
DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-server)
INSTALL(FILES ${server_manager_CONF_GEN}
DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-server)
-INSTALL(FILES ${server_container_CONF}
- DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-server/containers)
+INSTALL(FILES ${server_zone_CONF}
+ DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-server/zones)
INSTALL(FILES ${manager_manager_CONF}
- DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-containers-manager)
+ DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zones-manager)
INSTALL(FILES ${manager_manager_CONF_GEN}
- DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-containers-manager)
-INSTALL(FILES ${manager_container_CONF}
- DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-containers-manager/containers)
-INSTALL(FILES ${manager_container_CONF_GEN}
- DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-containers-manager/containers)
-INSTALL(FILES ${manager_container_TEMPLATE_GEN}
- DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-containers-manager/templates)
-
-INSTALL(FILES ${container_CONF}
- DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-container)
-INSTALL(FILES ${container_container_CONF}
- DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-container/containers)
-INSTALL(FILES ${container_container_CONF_GEN}
- DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-container/containers)
-
-INSTALL(FILES ${admin_container_CONF}
- DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-container-admin/containers)
+ DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zones-manager)
+INSTALL(FILES ${manager_zone_CONF}
+ DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zones-manager/zones)
+INSTALL(FILES ${manager_zone_CONF_GEN}
+ DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zones-manager/zones)
+INSTALL(FILES ${manager_zone_TEMPLATE_GEN}
+ DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zones-manager/templates)
+
+INSTALL(FILES ${zone_CONF}
+ DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone)
+INSTALL(FILES ${zone_zone_CONF}
+ DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone/zones)
+INSTALL(FILES ${zone_zone_CONF_GEN}
+ DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone/zones)
+
+INSTALL(FILES ${admin_zone_CONF}
+ DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone-admin/zones)
INSTALL(FILES ${connection_CONF}
- DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-container-connection)
+ DESTINATION ${VSM_TEST_CONFIG_INSTALL_DIR}/server/ut-zone-connection)
-INSTALL(FILES dbus-1/system.d/org.tizen.containers.tests.conf
+INSTALL(FILES dbus-1/system.d/org.tizen.vasum.tests.conf
DESTINATION ${SYSCONF_INSTALL_DIR}/dbus-1/system.d/)
+++ /dev/null
-<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
- "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
-
-<busconfig>
- <policy user="root">
- <allow own="org.tizen.containers.tests"/>
- <allow send_destination="org.tizen.containers.tests"/>
- <allow receive_sender="org.tizen.containers.tests"/>
- </policy>
- <policy context="default">
- <allow send_destination="org.tizen.containers.tests"/>
- <allow receive_sender="org.tizen.containers.tests"/>
- </policy>
-</busconfig>
--- /dev/null
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+
+<busconfig>
+ <policy user="root">
+ <allow own="org.tizen.vasum.tests"/>
+ <allow send_destination="org.tizen.vasum.tests"/>
+ <allow receive_sender="org.tizen.vasum.tests"/>
+ </policy>
+ <policy context="default">
+ <allow send_destination="org.tizen.vasum.tests"/>
+ <allow receive_sender="org.tizen.vasum.tests"/>
+ </policy>
+</busconfig>
+++ /dev/null
-{
- "containerConfigs" : ["containers/console1.conf", "missing/file/path/missing.conf", "containers/console3.conf"],
- "runMountPointPrefix" : "",
- "foregroundId" : "ut-containers-manager-console1",
- "defaultId" : "ut-containers-manager-console1",
- "containersPath" : "/tmp/ut-containers",
- "containerImagePath" : "",
- "containerTemplatePath" : "templates",
- "containerNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-containers-manager/",
- "lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
- "inputConfig" : {"enabled" : false,
- "device" : "/dev/doesnotexist",
- "code" : 139,
- "numberOfEvents" : 2,
- "timeWindowMs" : 500},
- "proxyCallRules" : []
-}
+++ /dev/null
-{
- "containerConfigs" : ["containers/console1.conf", "containers/console2.conf", "containers/console3.conf"],
- "runMountPointPrefix" : "",
- "foregroundId" : "ut-containers-manager-console1",
- "defaultId" : "ut-containers-manager-console1",
- "containersPath" : "/tmp/ut-containers",
- "containerImagePath" : "",
- "containerTemplatePath" : "templates",
- "containerNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-containers-manager/",
- "lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
- "inputConfig" : {"enabled" : false,
- "device" : "/dev/doesnotexist",
- "code" : 139,
- "numberOfEvents" : 2,
- "timeWindowMs" : 500},
- "proxyCallRules" : []
-}
+++ /dev/null
-{
- "containerConfigs" : ["containers/console1-dbus.conf",
- "containers/console2-dbus.conf",
- "containers/console3-dbus.conf"],
- "foregroundId" : "ut-containers-manager-console1-dbus",
- "defaultId" : "ut-containers-manager-console1-dbus",
- "containersPath" : "/tmp/ut-containers",
- "containerImagePath" : "",
- "containerTemplatePath" : "templates",
- "containerNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-containers-manager/",
- "runMountPointPrefix" : "",
- "lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
- "inputConfig" : {"enabled" : false,
- "device" : "/dev/doesnotexist",
- "code" : 139,
- "numberOfEvents" : 2,
- "timeWindowMs" : 500},
- "proxyCallRules" : [{"caller" : "*",
- "target" : "*",
- "targetBusName" : "org.tizen.containers.tests",
- "targetObjectPath" : "*",
- "targetInterface" : "*",
- "targetMethod" : "*"}]
-}
{
- "containerConfigs" : ["containers/container1.conf", "missing/file/path/missing.conf", "containers/container3.conf"],
- "containersPath" : "/tmp/ut-containers",
- "containerImagePath" : "",
- "containerTemplatePath" : "no_need_for_templates_in_this_test",
- "containerNewConfigPrefix" : "",
+ "zoneConfigs" : ["zones/zone1.conf", "missing/file/path/missing.conf", "zones/zone3.conf"],
+ "zonesPath" : "/tmp/ut-zones",
+ "zoneImagePath" : "",
+ "zoneTemplatePath" : "no_need_for_templates_in_this_test",
+ "zoneNewConfigPrefix" : "",
"runMountPointPrefix" : "",
- "foregroundId" : "ut-server-container1",
- "defaultId" : "ut-server-container1",
+ "foregroundId" : "ut-server-zone1",
+ "defaultId" : "ut-server-zone1",
"lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
"inputConfig" : {"enabled" : false,
"device" : "/dev/doesnotexist",
{
- "containerConfigs" : ["containers/container1.conf", "containers/container2.conf", "containers/container3.conf"],
- "containersPath" : "/tmp/ut-containers",
- "containerImagePath" : "",
- "containerTemplatePath" : "no_need_for_templates_in_this_test",
- "containerNewConfigPrefix" : "",
+ "zoneConfigs" : ["zones/zone1.conf", "zones/zone2.conf", "zones/zone3.conf"],
+ "zonesPath" : "/tmp/ut-zones",
+ "zoneImagePath" : "",
+ "zoneTemplatePath" : "no_need_for_templates_in_this_test",
+ "zoneNewConfigPrefix" : "",
"runMountPointPrefix" : "",
- "foregroundId" : "ut-server-container1",
- "defaultId" : "ut-server-container1",
+ "foregroundId" : "ut-server-zone1",
+ "defaultId" : "ut-server-zone1",
"lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
"inputConfig" : {"enabled" : false,
"device" : "gpio-keys.4",
{
- "name" : "ut-server-container1",
+ "name" : "ut-server-zone1",
"lxcTemplate" : "minimal.sh",
"initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
"ipv4Gateway" : "",
{
- "name" : "ut-server-container2",
+ "name" : "ut-server-zone2",
"lxcTemplate" : "minimal.sh",
"initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
"ipv4Gateway" : "",
{
- "name" : "ut-server-container3",
+ "name" : "ut-server-zone3",
"lxcTemplate" : "minimal.sh",
"initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
"ipv4Gateway" : "",
{
- "name" : "ut-container-admin-test",
+ "name" : "ut-zone-admin-test",
"lxcTemplate" : "minimal.sh",
"initWithArgs" : ["/foo"],
"ipv4Gateway" : "",
{
- "name" : "ut-container-admin-test",
+ "name" : "ut-zone-admin-test",
"lxcTemplate" : "missing.sh",
"initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
"ipv4Gateway" : "",
{
- "name" : "ut-container-admin-test",
+ "name" : "ut-zone-admin-test",
"lxcTemplate" : "minimal.sh",
"initWithArgs" : ["/bin/sh"],
"ipv4Gateway" : "",
{
- "name" : "ut-container-admin-test",
+ "name" : "ut-zone-admin-test",
"lxcTemplate" : "minimal.sh",
"initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
"ipv4Gateway" : "",
-<!-- This configuration file controls the containers message bus -->
+<!-- This configuration file controls the zones message bus -->
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<type>custom</type>
- <listen>unix:path=/tmp/ut-container-connection/dbus/system_bus_socket</listen>
+ <listen>unix:path=/tmp/ut-zone-connection/dbus/system_bus_socket</listen>
<policy context="default">
<!-- Allow everything to be sent -->
-<!-- This configuration file controls the containers message bus -->
+<!-- This configuration file controls the zones message bus -->
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
{
- "name" : "ut-container-test",
+ "name" : "ut-zone-test",
"lxcTemplate" : "/buggy/path",
"initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
"ipv4Gateway" : "",
{
- "name" : "ut-container-test-dbus",
+ "name" : "ut-zone-test-dbus",
"lxcTemplate" : "minimal-dbus.sh",
- "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-container/ut-dbus.conf --fork; read"],
+ "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zone/ut-dbus.conf --fork; read"],
"ipv4Gateway" : "",
"ipv4" : "",
"privilege" : 10,
"enableDbusIntegration" : true,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
- "runMountPoint" : "/tmp/ut-run/ut-container-test-dbus",
+ "runMountPoint" : "/tmp/ut-run/ut-zone-test-dbus",
"permittedToSend" : [],
"permittedToRecv" : []
}
{
- "name" : "ut-container-test",
+ "name" : "ut-zone-test",
"lxcTemplate" : "minimal.sh",
"initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
"ipv4Gateway" : "",
--- /dev/null
+{
+ "zoneConfigs" : ["zones/console1.conf", "missing/file/path/missing.conf", "zones/console3.conf"],
+ "runMountPointPrefix" : "",
+ "foregroundId" : "ut-zones-manager-console1",
+ "defaultId" : "ut-zones-manager-console1",
+ "zonesPath" : "/tmp/ut-zones",
+ "zoneImagePath" : "",
+ "zoneTemplatePath" : "templates",
+ "zoneNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/",
+ "lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
+ "inputConfig" : {"enabled" : false,
+ "device" : "/dev/doesnotexist",
+ "code" : 139,
+ "numberOfEvents" : 2,
+ "timeWindowMs" : 500},
+ "proxyCallRules" : []
+}
{
- "containerConfigs" : ["containers/console1.conf", "containers/console2.conf", "containers/console3.conf"],
+ "zoneConfigs" : ["zones/console1.conf", "zones/console2.conf", "zones/console3.conf"],
"runMountPointPrefix" : "",
- "foregroundId" : "ut-containers-manager-console1",
+ "foregroundId" : "ut-zones-manager-console1",
"defaultId" : "in_no_way_there_is_a_valid_id_here",
- "containersPath" : "/tmp/ut-containers",
- "containerImagePath" : "",
- "containerTemplatePath" : "templates",
- "containerNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-containers-manager/",
+ "zonesPath" : "/tmp/ut-zones",
+ "zoneImagePath" : "",
+ "zoneTemplatePath" : "templates",
+ "zoneNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/",
"lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
"inputConfig" : {"enabled" : false,
"device" : "/dev/doesnotexist",
{
- "containerConfigs" : ["containers/console1.conf", "containers/console2.conf", "containers/console3.conf"],
+ "zoneConfigs" : ["zones/console1.conf", "zones/console2.conf", "zones/console3.conf"],
"runMountPointPrefix" : "",
"foregroundId" : "this_id_does_not_exist",
- "defaultId" : "ut-containers-manager-console1",
- "containersPath" : "/tmp/ut-containers",
- "containerImagePath" : "",
- "containerTemplatePath" : "templates",
- "containerNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-containers-manager/",
+ "defaultId" : "ut-zones-manager-console1",
+ "zonesPath" : "/tmp/ut-zones",
+ "zoneImagePath" : "",
+ "zoneTemplatePath" : "templates",
+ "zoneNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/",
"lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
"inputConfig" : {"enabled" : false,
"device" : "/dev/doesnotexist",
{
- "containerConfigs" : [],
+ "zoneConfigs" : [],
"foregroundId" : "",
"defaultId" : "",
- "containersPath" : "/tmp/ut-containers",
- "containerImagePath" : "",
- "containerTemplatePath" : "templates",
- "containerNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-containers-manager/",
+ "zonesPath" : "/tmp/ut-zones",
+ "zoneImagePath" : "",
+ "zoneTemplatePath" : "templates",
+ "zoneNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/",
"runMountPointPrefix" : "",
"lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
"inputConfig" : {"enabled" : false,
"timeWindowMs" : 500},
"proxyCallRules" : [{"caller" : "*",
"target" : "*",
- "targetBusName" : "org.tizen.containers.tests",
+ "targetBusName" : "org.tizen.vasum.tests",
"targetObjectPath" : "*",
"targetInterface" : "*",
"targetMethod" : "*"}]
{
"name" : "~NAME~",
"lxcTemplate" : "minimal-dbus.sh",
- "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-containers-manager/ut-dbus.conf --fork; read"],
+ "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/ut-dbus.conf --fork; read"],
"ipv4Gateway" : "",
"ipv4" : "",
"privilege" : 20,
--- /dev/null
+{
+ "zoneConfigs" : ["zones/console1.conf", "zones/console2.conf", "zones/console3.conf"],
+ "runMountPointPrefix" : "",
+ "foregroundId" : "ut-zones-manager-console1",
+ "defaultId" : "ut-zones-manager-console1",
+ "zonesPath" : "/tmp/ut-zones",
+ "zoneImagePath" : "",
+ "zoneTemplatePath" : "templates",
+ "zoneNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/",
+ "lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
+ "inputConfig" : {"enabled" : false,
+ "device" : "/dev/doesnotexist",
+ "code" : 139,
+ "numberOfEvents" : 2,
+ "timeWindowMs" : 500},
+ "proxyCallRules" : []
+}
--- /dev/null
+{
+ "zoneConfigs" : ["zones/console1-dbus.conf",
+ "zones/console2-dbus.conf",
+ "zones/console3-dbus.conf"],
+ "foregroundId" : "ut-zones-manager-console1-dbus",
+ "defaultId" : "ut-zones-manager-console1-dbus",
+ "zonesPath" : "/tmp/ut-zones",
+ "zoneImagePath" : "",
+ "zoneTemplatePath" : "templates",
+ "zoneNewConfigPrefix" : "@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/",
+ "runMountPointPrefix" : "",
+ "lxcTemplatePrefix" : "@VSM_TEST_LXC_TEMPLATES_INSTALL_DIR@",
+ "inputConfig" : {"enabled" : false,
+ "device" : "/dev/doesnotexist",
+ "code" : 139,
+ "numberOfEvents" : 2,
+ "timeWindowMs" : 500},
+ "proxyCallRules" : [{"caller" : "*",
+ "target" : "*",
+ "targetBusName" : "org.tizen.vasum.tests",
+ "targetObjectPath" : "*",
+ "targetInterface" : "*",
+ "targetMethod" : "*"}]
+}
-<!-- This configuration file controls the containers message bus -->
+<!-- This configuration file controls the zones message bus -->
<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
{
- "name" : "ut-containers-manager-console1-dbus",
+ "name" : "ut-zones-manager-console1-dbus",
"lxcTemplate" : "minimal-dbus.sh",
- "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-containers-manager/ut-dbus.conf --fork; read"],
+ "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/ut-dbus.conf --fork; read"],
"ipv4Gateway" : "",
"ipv4" : "",
"privilege" : 20,
"enableDbusIntegration" : true,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
- "runMountPoint" : "/tmp/ut-run/ut-containers-manager-console1-dbus",
+ "runMountPoint" : "/tmp/ut-run/ut-zones-manager-console1-dbus",
"permittedToSend" : [ "/tmp/.*", "/etc/secret2" ],
"permittedToRecv" : [ "/tmp/.*" ]
}
{
- "name" : "ut-containers-manager-console1",
+ "name" : "ut-zones-manager-console1",
"lxcTemplate" : "minimal.sh",
"initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
"ipv4Gateway" : "",
{
- "name" : "ut-containers-manager-console2-dbus",
+ "name" : "ut-zones-manager-console2-dbus",
"lxcTemplate" : "minimal-dbus.sh",
- "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-containers-manager/ut-dbus.conf --fork; read"],
+ "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/ut-dbus.conf --fork; read"],
"ipv4Gateway" : "",
"ipv4" : "",
"privilege" : 20,
"enableDbusIntegration" : true,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
- "runMountPoint" : "/tmp/ut-run/ut-containers-manager-console2-dbus",
+ "runMountPoint" : "/tmp/ut-run/ut-zones-manager-console2-dbus",
"permittedToSend" : [ "/tmp/.*" ],
"permittedToRecv" : [ "/tmp/.*", "/etc/secret1" ]
}
{
- "name" : "ut-containers-manager-console2",
+ "name" : "ut-zones-manager-console2",
"lxcTemplate" : "minimal.sh",
"initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
"ipv4Gateway" : "",
{
- "name" : "ut-containers-manager-console3-dbus",
+ "name" : "ut-zones-manager-console3-dbus",
"lxcTemplate" : "minimal-dbus.sh",
- "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-containers-manager/ut-dbus.conf --fork; read"],
+ "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; /usr/bin/dbus-daemon --config-file=@VSM_TEST_CONFIG_INSTALL_DIR@/server/ut-zones-manager/ut-dbus.conf --fork; read"],
"ipv4Gateway" : "",
"ipv4" : "",
"privilege" : 20,
"enableDbusIntegration" : true,
"cpuQuotaForeground" : -1,
"cpuQuotaBackground" : 1000,
- "runMountPoint" : "/tmp/ut-run/ut-containers-manager-console3-dbus",
+ "runMountPoint" : "/tmp/ut-run/ut-zones-manager-console3-dbus",
"permittedToSend" : [ "/tmp/.*" ],
"permittedToRecv" : [ "/tmp/.*" ]
}
{
- "name" : "ut-containers-manager-console3",
+ "name" : "ut-zones-manager-console3",
"lxcTemplate" : "minimal.sh",
"initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"],
"ipv4Gateway" : "",
namespace testapi {
-const std::string BUS_NAME = "org.tizen.containers.tests";
-const std::string OBJECT_PATH = "/org/tizen/containers/tests";
+const std::string BUS_NAME = "org.tizen.vasum.tests";
+const std::string OBJECT_PATH = "/org/tizen/vasum/tests";
const std::string INTERFACE = "tests.api";
const std::string METHOD = "Method";
#include <future>
namespace {
-const std::string CONTAINERS_PATH = "/tmp/ut-containers"; // the same as in daemon.conf
+const std::string ZONES_PATH = "/tmp/ut-zones"; // the same as in daemon.conf
struct Fixture {
- vasum::utils::ScopedDir mContainersPathGuard;
+ vasum::utils::ScopedDir mZonesPathGuard;
Fixture()
- : mContainersPathGuard(CONTAINERS_PATH)
+ : mZonesPathGuard(ZONES_PATH)
{}
};
} // namespace
/**
* @file
* @author Jan Olszak (j.olszak@samsung.com)
- * @brief Unit tests of the ContainerAdmin class
+ * @brief Unit tests of the ZoneAdmin class
*/
#include "config.hpp"
#include "ut.hpp"
-#include "container-admin.hpp"
+#include "zone-admin.hpp"
#include "exception.hpp"
#include "utils/glib-loop.hpp"
namespace {
-const std::string TEST_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-container-admin/containers/test.conf";
-const std::string TEST_NO_SHUTDOWN_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-container-admin/containers/test-no-shutdown.conf";
-const std::string BUGGY_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-container-admin/containers/buggy.conf";
-const std::string MISSING_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-container-admin/containers/missing.conf";
-const std::string CONTAINERS_PATH = "/tmp/ut-containers";
+const std::string TEST_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zone-admin/zones/test.conf";
+const std::string TEST_NO_SHUTDOWN_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zone-admin/zones/test-no-shutdown.conf";
+const std::string BUGGY_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zone-admin/zones/buggy.conf";
+const std::string MISSING_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zone-admin/zones/missing.conf";
+const std::string ZONES_PATH = "/tmp/ut-zones";
const std::string LXC_TEMPLATES_PATH = VSM_TEST_LXC_TEMPLATES_INSTALL_DIR;
struct Fixture {
utils::ScopedGlibLoop mLoop;
- utils::ScopedDir mContainersPathGuard;
+ utils::ScopedDir mZonesPathGuard;
- ContainerConfig mConfig;
+ ZoneConfig mConfig;
Fixture()
- : mContainersPathGuard(CONTAINERS_PATH)
+ : mZonesPathGuard(ZONES_PATH)
{}
- std::unique_ptr<ContainerAdmin> create(const std::string& configPath)
+ std::unique_ptr<ZoneAdmin> create(const std::string& configPath)
{
config::loadFromFile(configPath, mConfig);
- return std::unique_ptr<ContainerAdmin>(new ContainerAdmin(CONTAINERS_PATH,
+ return std::unique_ptr<ZoneAdmin>(new ZoneAdmin(ZONES_PATH,
LXC_TEMPLATES_PATH,
mConfig));
}
void ensureStarted()
{
- // wait for containers init to fully start
+ // wait for zones init to fully start
std::this_thread::sleep_for(std::chrono::milliseconds(200));
}
};
} // namespace
-BOOST_FIXTURE_TEST_SUITE(ContainerAdminSuite, Fixture)
+BOOST_FIXTURE_TEST_SUITE(ZoneAdminSuite, Fixture)
BOOST_AUTO_TEST_CASE(ConstructorDestructorTest)
{
BOOST_AUTO_TEST_CASE(MissingConfigTest)
{
- BOOST_REQUIRE_THROW(create(MISSING_CONFIG_PATH), ContainerOperationException);
+ BOOST_REQUIRE_THROW(create(MISSING_CONFIG_PATH), ZoneOperationException);
}
BOOST_AUTO_TEST_CASE(StartTest)
BOOST_AUTO_TEST_CASE(StartBuggyTest)
{
auto admin = create(BUGGY_CONFIG_PATH);
- BOOST_REQUIRE_THROW(admin->start(), ContainerOperationException);
+ BOOST_REQUIRE_THROW(admin->start(), ZoneOperationException);
}
BOOST_AUTO_TEST_CASE(StopShutdownTest)
/**
* @file
* @author Piotr Bartosiewicz (p.bartosiewi@partner.samsung.com)
- * @brief Unit tests of the ContainerConnection class
+ * @brief Unit tests of the ZoneConnection class
*/
#include "config.hpp"
#include "ut.hpp"
-#include "container-connection.hpp"
-#include "container-connection-transport.hpp"
+#include "zone-connection.hpp"
+#include "zone-connection-transport.hpp"
#include "host-dbus-definitions.hpp"
-#include "container-dbus-definitions.hpp"
+#include "zone-dbus-definitions.hpp"
// TODO: Switch to real power-manager dbus defs when they will be implemented in power-manager
#include "fake-power-manager-dbus-definitions.hpp"
#include "utils/fs.hpp"
-BOOST_AUTO_TEST_SUITE(ContainerConnectionSuite)
+BOOST_AUTO_TEST_SUITE(ZoneConnectionSuite)
using namespace vasum;
using namespace vasum::utils;
const char* DBUS_DAEMON_PROC = "/usr/bin/dbus-daemon";
const char* const DBUS_DAEMON_ARGS[] = {
DBUS_DAEMON_PROC,
- "--config-file=" VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-container-connection/ut-dbus.conf",
+ "--config-file=" VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zone-connection/ut-dbus.conf",
"--nofork",
NULL
};
-const std::string TRANSPORT_MOUNT_POINT = "/tmp/ut-container-connection";
+const std::string TRANSPORT_MOUNT_POINT = "/tmp/ut-zone-connection";
const int EVENT_TIMEOUT = 1000;
class ScopedDbusDaemon {
return mTransport.acquireAddress();
}
private:
- ContainerConnectionTransport mTransport;
+ ZoneConnectionTransport mTransport;
ScopedDaemon mDaemon;
};
ScopedGlibLoop loop;
ScopedDbusDaemon dbus;
- BOOST_REQUIRE_NO_THROW(ContainerConnection(dbus.acquireAddress(), nullptr));
+ BOOST_REQUIRE_NO_THROW(ZoneConnection(dbus.acquireAddress(), nullptr));
}
-BOOST_AUTO_TEST_CASE(NotifyActiveContainerApiTest)
+BOOST_AUTO_TEST_CASE(NotifyActiveZoneApiTest)
{
ScopedGlibLoop loop;
ScopedDbusDaemon dbus;
Latch notifyCalled;
- std::unique_ptr<ContainerConnection> connection;
+ std::unique_ptr<ZoneConnection> connection;
- BOOST_REQUIRE_NO_THROW(connection.reset(new ContainerConnection(dbus.acquireAddress(), nullptr)));
+ BOOST_REQUIRE_NO_THROW(connection.reset(new ZoneConnection(dbus.acquireAddress(), nullptr)));
auto callback = [&](const std::string& application, const std::string& message) {
if (application == "testapp" && message == "testmessage") {
notifyCalled.set();
}
};
- connection->setNotifyActiveContainerCallback(callback);
+ connection->setNotifyActiveZoneCallback(callback);
DbusConnection::Pointer client = DbusConnection::create(dbus.acquireAddress());
- client->callMethod(api::container::BUS_NAME,
- api::container::OBJECT_PATH,
- api::container::INTERFACE,
- api::container::METHOD_NOTIFY_ACTIVE_CONTAINER,
+ client->callMethod(api::zone::BUS_NAME,
+ api::zone::OBJECT_PATH,
+ api::zone::INTERFACE,
+ api::zone::METHOD_NOTIFY_ACTIVE_ZONE,
g_variant_new("(ss)", "testapp", "testmessage"),
"()");
BOOST_CHECK(notifyCalled.wait(EVENT_TIMEOUT));
ScopedDbusDaemon dbus;
Latch signalEmitted;
- std::unique_ptr<ContainerConnection> connection;
+ std::unique_ptr<ZoneConnection> connection;
- BOOST_REQUIRE_NO_THROW(connection.reset(new ContainerConnection(dbus.acquireAddress(), nullptr)));
+ BOOST_REQUIRE_NO_THROW(connection.reset(new ZoneConnection(dbus.acquireAddress(), nullptr)));
DbusConnection::Pointer client = DbusConnection::create(dbus.acquireAddress());
const std::string& interface,
const std::string& signalName,
GVariant* parameters) {
- if (objectPath == api::container::OBJECT_PATH &&
- interface == api::container::INTERFACE &&
- signalName == api::container::SIGNAL_NOTIFICATION &&
+ if (objectPath == api::zone::OBJECT_PATH &&
+ interface == api::zone::INTERFACE &&
+ signalName == api::zone::SIGNAL_NOTIFICATION &&
g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) {
- const gchar* container = NULL;
+ const gchar* zone = NULL;
const gchar* application = NULL;
const gchar* message = NULL;
- g_variant_get(parameters, "(&s&s&s)", &container, &application, &message);
- if (container == std::string("testcontainer") &&
+ g_variant_get(parameters, "(&s&s&s)", &zone, &application, &message);
+ if (zone == std::string("testzone") &&
application == std::string("testapp") &&
message == std::string("testmessage")) {
signalEmitted.set();
}
}
};
- client->signalSubscribe(handler, api::container::BUS_NAME);
+ client->signalSubscribe(handler, api::zone::BUS_NAME);
- connection->sendNotification("testcontainer", "testapp", "testmessage");
+ connection->sendNotification("testzone", "testapp", "testmessage");
BOOST_CHECK(signalEmitted.wait(EVENT_TIMEOUT));
}
ScopedDbusDaemon dbus;
Latch displayOffCalled;
- std::unique_ptr<ContainerConnection> connection;
+ std::unique_ptr<ZoneConnection> connection;
- BOOST_REQUIRE_NO_THROW(connection.reset(new ContainerConnection(dbus.acquireAddress(),
+ BOOST_REQUIRE_NO_THROW(connection.reset(new ZoneConnection(dbus.acquireAddress(),
nullptr)));
DbusConnection::Pointer client = DbusConnection::create(dbus.acquireAddress());
/**
* @file
* @author Lukasz Pawelczyk (l.pawelczyk@partner.samsung.com)
- * @brief Unit tests of the Container class
+ * @brief Unit tests of the Zone class
*/
#include "config.hpp"
#include "ut.hpp"
-#include "container.hpp"
+#include "zone.hpp"
#include "exception.hpp"
#include "utils/exception.hpp"
namespace {
-const std::string TEST_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-container/containers/test.conf";
-const std::string TEST_DBUS_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-container/containers/test-dbus.conf";
-const std::string BUGGY_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-container/containers/buggy.conf";
+const std::string TEST_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zone/zones/test.conf";
+const std::string TEST_DBUS_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zone/zones/test-dbus.conf";
+const std::string BUGGY_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zone/zones/buggy.conf";
const std::string MISSING_CONFIG_PATH = "/this/is/a/missing/file/path/config.conf";
-const std::string CONTAINERS_PATH = "/tmp/ut-containers";
+const std::string ZONES_PATH = "/tmp/ut-zones";
const std::string LXC_TEMPLATES_PATH = VSM_TEST_LXC_TEMPLATES_INSTALL_DIR;
struct Fixture {
utils::ScopedGlibLoop mLoop;
- utils::ScopedDir mContainersPathGuard;
+ utils::ScopedDir mZonesPathGuard;
utils::ScopedDir mRunGuard;
Fixture()
- : mContainersPathGuard(CONTAINERS_PATH)
+ : mZonesPathGuard(ZONES_PATH)
{}
- std::unique_ptr<Container> create(const std::string& configPath)
+ std::unique_ptr<Zone> create(const std::string& configPath)
{
- return std::unique_ptr<Container>(new Container(CONTAINERS_PATH,
+ return std::unique_ptr<Zone>(new Zone(ZONES_PATH,
configPath,
LXC_TEMPLATES_PATH,
""));
void ensureStarted()
{
- // wait for containers init to fully start
+ // wait for zones init to fully start
std::this_thread::sleep_for(std::chrono::milliseconds(200));
}
};
} // namespace
-BOOST_FIXTURE_TEST_SUITE(ContainerSuite, Fixture)
+BOOST_FIXTURE_TEST_SUITE(ZoneSuite, Fixture)
BOOST_AUTO_TEST_CASE(ConstructorDestructorTest)
{
BOOST_AUTO_TEST_CASE(BuggyConfigTest)
{
- BOOST_REQUIRE_THROW(create(BUGGY_CONFIG_PATH), ContainerOperationException);
+ BOOST_REQUIRE_THROW(create(BUGGY_CONFIG_PATH), ZoneOperationException);
}
BOOST_AUTO_TEST_CASE(MissingConfigTest)
/**
* @file
* @author Jan Olszak (j.olszak@samsung.com)
- * @brief Unit tests of the ContainersManager class
+ * @brief Unit tests of the ZonesManager class
*/
#include "config.hpp"
#include "ut.hpp"
-#include "containers-manager.hpp"
-#include "containers-manager-config.hpp"
-#include "container-config.hpp"
+#include "zones-manager.hpp"
+#include "zones-manager-config.hpp"
+#include "zone-config.hpp"
#include "provisioning-config.hpp"
-#include "container-dbus-definitions.hpp"
+#include "zone-dbus-definitions.hpp"
#include "host-dbus-definitions.hpp"
#include "test-dbus-definitions.hpp"
// TODO: Switch to real power-manager dbus defs when they will be implemented in power-manager
namespace {
-const std::string TEST_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-containers-manager/test-daemon.conf";
-const std::string TEST_DBUS_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-containers-manager/test-dbus-daemon.conf";
-const std::string EMPTY_DBUS_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-containers-manager/empty-dbus-daemon.conf";
-const std::string BUGGY_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-containers-manager/buggy-daemon.conf";
-const std::string BUGGY_FOREGROUND_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-containers-manager/buggy-foreground-daemon.conf";
-const std::string BUGGY_DEFAULTID_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-containers-manager/buggy-default-daemon.conf";
-const std::string TEST_CONTAINER_CONF_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-containers-manager/containers/";
+const std::string TEST_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zones-manager/test-daemon.conf";
+const std::string TEST_DBUS_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zones-manager/test-dbus-daemon.conf";
+const std::string EMPTY_DBUS_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zones-manager/empty-dbus-daemon.conf";
+const std::string BUGGY_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zones-manager/buggy-daemon.conf";
+const std::string BUGGY_FOREGROUND_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zones-manager/buggy-foreground-daemon.conf";
+const std::string BUGGY_DEFAULTID_CONFIG_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zones-manager/buggy-default-daemon.conf";
+const std::string TEST_ZONE_CONF_PATH = VSM_TEST_CONFIG_INSTALL_DIR "/server/ut-zones-manager/zones/";
const std::string MISSING_CONFIG_PATH = "/this/is/a/missing/file/path/missing-daemon.conf";
const int EVENT_TIMEOUT = 5000;
-const int TEST_DBUS_CONNECTION_CONTAINERS_COUNT = 3;
-const std::string PREFIX_CONSOLE_NAME = "ut-containers-manager-console";
+const int TEST_DBUS_CONNECTION_ZONES_COUNT = 3;
+const std::string PREFIX_CONSOLE_NAME = "ut-zones-manager-console";
const std::string TEST_APP_NAME = "testapp";
const std::string TEST_MESSAGE = "testmessage";
const std::string FILE_CONTENT = "File content\n"
"Line 1\n"
"Line 2\n";
-const std::string NON_EXISTANT_CONTAINER_ID = "NON_EXISTANT_CONTAINER_ID";
-const std::string CONTAINERS_PATH = "/tmp/ut-containers"; // the same as in daemon.conf
+const std::string NON_EXISTANT_ZONE_ID = "NON_EXISTANT_ZONE_ID";
+const std::string ZONES_PATH = "/tmp/ut-zones"; // the same as in daemon.conf
const std::string PROVISON_CONFIG_FILE = "provision.conf";
class DbusAccessory {
void signalSubscribe(const DbusConnection::SignalCallback& callback)
{
- mClient->signalSubscribe(callback, isHost() ? api::host::BUS_NAME : api::container::BUS_NAME);
+ mClient->signalSubscribe(callback, isHost() ? api::host::BUS_NAME : api::zone::BUS_NAME);
}
void emitSignal(const std::string& objectPath,
void callMethodNotify()
{
GVariant* parameters = g_variant_new("(ss)", TEST_APP_NAME.c_str(), TEST_MESSAGE.c_str());
- mClient->callMethod(api::container::BUS_NAME,
- api::container::OBJECT_PATH,
- api::container::INTERFACE,
- api::container::METHOD_NOTIFY_ACTIVE_CONTAINER,
+ mClient->callMethod(api::zone::BUS_NAME,
+ api::zone::OBJECT_PATH,
+ api::zone::INTERFACE,
+ api::zone::METHOD_NOTIFY_ACTIVE_ZONE,
parameters,
"()");
}
std::string callMethodMove(const std::string& dest, const std::string& path)
{
GVariant* parameters = g_variant_new("(ss)", dest.c_str(), path.c_str());
- GVariantPtr result = mClient->callMethod(api::container::BUS_NAME,
- api::container::OBJECT_PATH,
- api::container::INTERFACE,
- api::container::METHOD_FILE_MOVE_REQUEST,
+ GVariantPtr result = mClient->callMethod(api::zone::BUS_NAME,
+ api::zone::OBJECT_PATH,
+ api::zone::INTERFACE,
+ api::zone::METHOD_FILE_MOVE_REQUEST,
parameters,
"(s)");
method.c_str(),
parameters);
GVariantPtr result = mClient->callMethod(isHost() ? api::host::BUS_NAME :
- api::container::BUS_NAME,
+ api::zone::BUS_NAME,
isHost() ? api::host::OBJECT_PATH :
- api::container::OBJECT_PATH,
+ api::zone::OBJECT_PATH,
isHost() ? api::host::INTERFACE :
- api::container::INTERFACE,
+ api::zone::INTERFACE,
api::METHOD_PROXY_CALL,
packedParameters,
"(v)");
return GVariantPtr(unpackedResult, g_variant_unref);
}
- Dbuses callMethodGetContainerDbuses()
+ Dbuses callMethodGetZoneDbuses()
{
assert(isHost());
Dbuses dbuses;
GVariantPtr result = mClient->callMethod(api::host::BUS_NAME,
api::host::OBJECT_PATH,
api::host::INTERFACE,
- api::host::METHOD_GET_CONTAINER_DBUSES,
+ api::host::METHOD_GET_ZONE_DBUSES,
NULL,
"(a{ss})");
GVariant* array = NULL;
dbus::GVariantPtr autounref(array, g_variant_unref);
size_t count = g_variant_n_children(array);
for (size_t n = 0; n < count; ++n) {
- const char* containerId = NULL;
+ const char* zoneId = NULL;
const char* dbusAddress = NULL;
- g_variant_get_child(array, n, "{&s&s}", &containerId, &dbusAddress);
- dbuses.insert(Dbuses::value_type(containerId, dbusAddress));
+ g_variant_get_child(array, n, "{&s&s}", &zoneId, &dbusAddress);
+ dbuses.insert(Dbuses::value_type(zoneId, dbusAddress));
}
return dbuses;
}
- std::vector<std::string> callMethodGetContainerIds()
+ std::vector<std::string> callMethodGetZoneIds()
{
assert(isHost());
GVariantPtr result = mClient->callMethod(api::host::BUS_NAME,
api::host::OBJECT_PATH,
api::host::INTERFACE,
- api::host::METHOD_GET_CONTAINER_ID_LIST,
+ api::host::METHOD_GET_ZONE_ID_LIST,
NULL,
"(as)");
g_variant_get(result.get(), "(*)", &array);
size_t arraySize = g_variant_n_children(array);
- std::vector<std::string> containerIds;
+ std::vector<std::string> zoneIds;
for (size_t i = 0; i < arraySize; ++i) {
const char* id = NULL;
g_variant_get_child(array, i, "&s", &id);
- containerIds.push_back(id);
+ zoneIds.push_back(id);
}
g_variant_unref(array);
- return containerIds;
+ return zoneIds;
}
- std::string callMethodGetActiveContainerId()
+ std::string callMethodGetActiveZoneId()
{
assert(isHost());
GVariantPtr result = mClient->callMethod(api::host::BUS_NAME,
api::host::OBJECT_PATH,
api::host::INTERFACE,
- api::host::METHOD_GET_ACTIVE_CONTAINER_ID,
+ api::host::METHOD_GET_ACTIVE_ZONE_ID,
NULL,
"(s)");
- const char* containerId = NULL;
- g_variant_get(result.get(), "(&s)", &containerId);
- return containerId;
+ const char* zoneId = NULL;
+ g_variant_get(result.get(), "(&s)", &zoneId);
+ return zoneId;
}
- void callMethodSetActiveContainer(const std::string& id)
+ void callMethodSetActiveZone(const std::string& id)
{
assert(isHost());
GVariant* parameters = g_variant_new("(s)", id.c_str());
GVariantPtr result = mClient->callMethod(api::host::BUS_NAME,
api::host::OBJECT_PATH,
api::host::INTERFACE,
- api::host::METHOD_SET_ACTIVE_CONTAINER,
+ api::host::METHOD_SET_ACTIVE_ZONE,
parameters,
"()");
}
- void callMethodDeclareFile(const std::string& container,
+ void callMethodDeclareFile(const std::string& zone,
const int32_t& type,
const std::string& path,
const int32_t& flags,
{
assert(isHost());
GVariant* parameters = g_variant_new("(sisii)",
- container.c_str(),
+ zone.c_str(),
type,
path.c_str(),
flags,
}
void callMethodDeclareMount(const std::string& source,
- const std::string& container,
+ const std::string& zone,
const std::string& target,
const std::string& type,
const uint64_t& flags,
assert(isHost());
GVariant* parameters = g_variant_new("(ssssts)",
source.c_str(),
- container.c_str(),
+ zone.c_str(),
target.c_str(),
type.c_str(),
flags,
}
void callMethodDeclareLink(const std::string& source,
- const std::string& container,
+ const std::string& zone,
const std::string& target)
{
assert(isHost());
GVariant* parameters = g_variant_new("(sss)",
source.c_str(),
- container.c_str(),
+ zone.c_str(),
target.c_str());
GVariantPtr result = mClient->callMethod(api::host::BUS_NAME,
api::host::OBJECT_PATH,
"()");
}
- void callAsyncMethodCreateContainer(const std::string& id,
+ void callAsyncMethodCreateZone(const std::string& id,
const VoidResultCallback& result)
{
auto asyncResult = [result](dbus::AsyncMethodCallResult& asyncMethodCallResult) {
mClient->callMethodAsync(api::host::BUS_NAME,
api::host::OBJECT_PATH,
api::host::INTERFACE,
- api::host::METHOD_CREATE_CONTAINER,
+ api::host::METHOD_CREATE_ZONE,
parameters,
"()",
asyncResult);
}
- void callAsyncMethodDestroyContainer(const std::string& id,
+ void callAsyncMethodDestroyZone(const std::string& id,
const VoidResultCallback& result)
{
auto asyncResult = [result](dbus::AsyncMethodCallResult& asyncMethodCallResult) {
mClient->callMethodAsync(api::host::BUS_NAME,
api::host::OBJECT_PATH,
api::host::INTERFACE,
- api::host::METHOD_DESTROY_CONTAINER,
+ api::host::METHOD_DESTROY_ZONE,
parameters,
"()",
asyncResult);
}
- void callMethodLockContainer(const std::string& id)
+ void callMethodLockZone(const std::string& id)
{
assert(isHost());
GVariant* parameters = g_variant_new("(s)", id.c_str());
GVariantPtr result = mClient->callMethod(api::host::BUS_NAME,
api::host::OBJECT_PATH,
api::host::INTERFACE,
- api::host::METHOD_LOCK_CONTAINER,
+ api::host::METHOD_LOCK_ZONE,
parameters,
"()");
}
- void callMethodUnlockContainer(const std::string& id)
+ void callMethodUnlockZone(const std::string& id)
{
assert(isHost());
GVariant* parameters = g_variant_new("(s)", id.c_str());
GVariantPtr result = mClient->callMethod(api::host::BUS_NAME,
api::host::OBJECT_PATH,
api::host::INTERFACE,
- api::host::METHOD_UNLOCK_CONTAINER,
+ api::host::METHOD_UNLOCK_ZONE,
parameters,
"()");
}
if (isHost()) {
return "unix:path=/var/run/dbus/system_bus_socket";
}
- return "unix:path=/tmp/ut-run/ut-containers-manager-console" + std::to_string(mId) +
+ return "unix:path=/tmp/ut-run/ut-zones-manager-console" + std::to_string(mId) +
"-dbus/dbus/system_bus_socket";
}
};
struct Fixture {
vasum::utils::ScopedGlibLoop mLoop;
- utils::ScopedDir mContainersPathGuard;
+ utils::ScopedDir mZonesPathGuard;
utils::ScopedDir mRunGuard;
Fixture()
- : mContainersPathGuard(CONTAINERS_PATH)
+ : mZonesPathGuard(ZONES_PATH)
, mRunGuard("/tmp/ut-run")
{}
};
-std::string getProvisionConfigPath(const std::string& container)
+std::string getProvisionConfigPath(const std::string& zone)
{
namespace fs = boost::filesystem;
- ContainersManagerConfig managerConfig;
+ ZonesManagerConfig managerConfig;
loadFromFile(TEST_CONFIG_PATH, managerConfig);
- for (const auto& containersPath : managerConfig.containerConfigs) {
- ContainerConfig containerConfig;
- const fs::path configConfigPath = fs::absolute(containersPath,
+ for (const auto& zonesPath : managerConfig.zoneConfigs) {
+ ZoneConfig zoneConfig;
+ const fs::path configConfigPath = fs::absolute(zonesPath,
fs::path(TEST_CONFIG_PATH).parent_path());
- loadFromFile(configConfigPath.string(), containerConfig);
- if (containerConfig.name == container) {
- const fs::path base = fs::path(managerConfig.containersPath) / fs::path(container);
+ loadFromFile(configConfigPath.string(), zoneConfig);
+ if (zoneConfig.name == zone) {
+ const fs::path base = fs::path(managerConfig.zonesPath) / fs::path(zone);
return fs::absolute(PROVISON_CONFIG_FILE, base).string();
}
}
- BOOST_FAIL("There is no provision config file for " + container);
+ BOOST_FAIL("There is no provision config file for " + zone);
return std::string();
}
} // namespace
-BOOST_FIXTURE_TEST_SUITE(ContainersManagerSuite, Fixture)
+BOOST_FIXTURE_TEST_SUITE(ZonesManagerSuite, Fixture)
BOOST_AUTO_TEST_CASE(ConstructorDestructorTest)
{
- std::unique_ptr<ContainersManager> cm;
- cm.reset(new ContainersManager(TEST_CONFIG_PATH));
+ std::unique_ptr<ZonesManager> cm;
+ cm.reset(new ZonesManager(TEST_CONFIG_PATH));
cm.reset();
}
BOOST_AUTO_TEST_CASE(BuggyConfigTest)
{
- BOOST_REQUIRE_THROW(ContainersManager cm(BUGGY_CONFIG_PATH), ConfigException);
+ BOOST_REQUIRE_THROW(ZonesManager cm(BUGGY_CONFIG_PATH), ConfigException);
}
BOOST_AUTO_TEST_CASE(MissingConfigTest)
{
- BOOST_REQUIRE_THROW(ContainersManager cm(MISSING_CONFIG_PATH), ConfigException);
+ BOOST_REQUIRE_THROW(ZonesManager cm(MISSING_CONFIG_PATH), ConfigException);
}
BOOST_AUTO_TEST_CASE(StartAllTest)
{
- ContainersManager cm(TEST_CONFIG_PATH);
+ ZonesManager cm(TEST_CONFIG_PATH);
cm.startAll();
- BOOST_CHECK(cm.getRunningForegroundContainerId() == "ut-containers-manager-console1");
+ BOOST_CHECK(cm.getRunningForegroundZoneId() == "ut-zones-manager-console1");
}
BOOST_AUTO_TEST_CASE(BuggyForegroundTest)
{
- ContainersManager cm(BUGGY_FOREGROUND_CONFIG_PATH);
+ ZonesManager cm(BUGGY_FOREGROUND_CONFIG_PATH);
cm.startAll();
- BOOST_CHECK(cm.getRunningForegroundContainerId() == "ut-containers-manager-console2");
+ BOOST_CHECK(cm.getRunningForegroundZoneId() == "ut-zones-manager-console2");
}
BOOST_AUTO_TEST_CASE(BuggyDefaultTest)
{
- BOOST_REQUIRE_THROW(ContainersManager cm(BUGGY_DEFAULTID_CONFIG_PATH),
- ContainerOperationException);
+ BOOST_REQUIRE_THROW(ZonesManager cm(BUGGY_DEFAULTID_CONFIG_PATH),
+ ZoneOperationException);
}
BOOST_AUTO_TEST_CASE(StopAllTest)
{
- ContainersManager cm(TEST_CONFIG_PATH);
+ ZonesManager cm(TEST_CONFIG_PATH);
cm.startAll();
cm.stopAll();
- BOOST_CHECK(cm.getRunningForegroundContainerId().empty());
+ BOOST_CHECK(cm.getRunningForegroundZoneId().empty());
}
BOOST_AUTO_TEST_CASE(DetachOnExitTest)
{
{
- ContainersManager cm(TEST_CONFIG_PATH);
+ ZonesManager cm(TEST_CONFIG_PATH);
cm.startAll();
- cm.setContainersDetachOnExit();
+ cm.setZonesDetachOnExit();
}
{
- ContainersManager cm(TEST_CONFIG_PATH);
+ ZonesManager cm(TEST_CONFIG_PATH);
cm.startAll();
}
}
BOOST_AUTO_TEST_CASE(FocusTest)
{
- ContainersManager cm(TEST_CONFIG_PATH);
+ ZonesManager cm(TEST_CONFIG_PATH);
cm.startAll();
- cm.focus("ut-containers-manager-console2");
- BOOST_CHECK(cm.getRunningForegroundContainerId() == "ut-containers-manager-console2");
- cm.focus("ut-containers-manager-console1");
- BOOST_CHECK(cm.getRunningForegroundContainerId() == "ut-containers-manager-console1");
- cm.focus("ut-containers-manager-console3");
- BOOST_CHECK(cm.getRunningForegroundContainerId() == "ut-containers-manager-console3");
+ cm.focus("ut-zones-manager-console2");
+ BOOST_CHECK(cm.getRunningForegroundZoneId() == "ut-zones-manager-console2");
+ cm.focus("ut-zones-manager-console1");
+ BOOST_CHECK(cm.getRunningForegroundZoneId() == "ut-zones-manager-console1");
+ cm.focus("ut-zones-manager-console3");
+ BOOST_CHECK(cm.getRunningForegroundZoneId() == "ut-zones-manager-console3");
}
-BOOST_AUTO_TEST_CASE(NotifyActiveContainerTest)
+BOOST_AUTO_TEST_CASE(NotifyActiveZoneTest)
{
- ContainersManager cm(TEST_DBUS_CONFIG_PATH);
+ ZonesManager cm(TEST_DBUS_CONFIG_PATH);
cm.startAll();
Latch signalReceivedLatch;
std::map<int, std::vector<std::string>> signalReceivedSourcesMap;
std::map<int, std::unique_ptr<DbusAccessory>> dbuses;
- for (int i = 1; i <= TEST_DBUS_CONNECTION_CONTAINERS_COUNT; ++i) {
+ for (int i = 1; i <= TEST_DBUS_CONNECTION_ZONES_COUNT; ++i) {
dbuses[i] = std::unique_ptr<DbusAccessory>(new DbusAccessory(i));
}
const std::string& signalName,
GVariant* parameters)
{
- if (objectPath == api::container::OBJECT_PATH &&
- interface == api::container::INTERFACE &&
- signalName == api::container::SIGNAL_NOTIFICATION &&
+ if (objectPath == api::zone::OBJECT_PATH &&
+ interface == api::zone::INTERFACE &&
+ signalName == api::zone::SIGNAL_NOTIFICATION &&
g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) {
- const gchar* container = NULL;
+ const gchar* zone = NULL;
const gchar* application = NULL;
const gchar* message = NULL;
- g_variant_get(parameters, "(&s&s&s)", &container, &application, &message);
- receivedSignalSources.push_back(container);
+ g_variant_get(parameters, "(&s&s&s)", &zone, &application, &message);
+ receivedSignalSources.push_back(zone);
if (application == TEST_APP_NAME && message == TEST_MESSAGE) {
latch.set();
}
};
using namespace std::placeholders;
- for (int i = 1; i <= TEST_DBUS_CONNECTION_CONTAINERS_COUNT; ++i) {
+ for (int i = 1; i <= TEST_DBUS_CONNECTION_ZONES_COUNT; ++i) {
dbuses[i]->signalSubscribe(std::bind(handler,
std::ref(signalReceivedLatch),
std::ref(signalReceivedSourcesMap[i]),
signalReceivedSourcesMap[1].end(),
source), 1);
}
- //check if all signals was received by active container
+ //check if all signals was received by active zone
BOOST_CHECK_EQUAL(signalReceivedSourcesMap[1].size(), dbuses.size() - 1);
- //check if no signals was received by inactive container
+ //check if no signals was received by inactive zone
for (size_t i = 2; i <= dbuses.size(); ++i) {
BOOST_CHECK(signalReceivedSourcesMap[i].empty());
}
BOOST_AUTO_TEST_CASE(DisplayOffTest)
{
- ContainersManager cm(TEST_DBUS_CONFIG_PATH);
+ ZonesManager cm(TEST_DBUS_CONFIG_PATH);
cm.startAll();
std::vector<std::unique_ptr<DbusAccessory>> clients;
- for (int i = 1; i <= TEST_DBUS_CONNECTION_CONTAINERS_COUNT; ++i) {
+ for (int i = 1; i <= TEST_DBUS_CONNECTION_ZONES_COUNT; ++i) {
clients.push_back(std::unique_ptr<DbusAccessory>(new DbusAccessory(i)));
}
std::unique_lock<std::mutex> Lock(Mutex);
std::condition_variable Condition;
auto cond = [&cm]() -> bool {
- return cm.getRunningForegroundContainerId() == "ut-containers-manager-console1-dbus";
+ return cm.getRunningForegroundZoneId() == "ut-zones-manager-console1-dbus";
};
for (auto& client : clients) {
- // TEST SWITCHING TO DEFAULT CONTAINER
- // focus non-default container
- cm.focus("ut-containers-manager-console3-dbus");
+ // TEST SWITCHING TO DEFAULT ZONE
+ // focus non-default zone
+ cm.focus("ut-zones-manager-console3-dbus");
// emit signal from dbus connection
client->emitSignal(fake_power_manager_api::OBJECT_PATH,
fake_power_manager_api::SIGNAL_DISPLAY_OFF,
nullptr);
- // check if default container has focus
+ // check if default zone has focus
BOOST_CHECK(Condition.wait_for(Lock, std::chrono::milliseconds(EVENT_TIMEOUT), cond));
}
}
BOOST_AUTO_TEST_CASE(MoveFileTest)
{
- ContainersManager cm(TEST_DBUS_CONFIG_PATH);
+ ZonesManager cm(TEST_DBUS_CONFIG_PATH);
cm.startAll();
Latch notificationLatch;
const std::string& signalName,
GVariant* parameters)
{
- if (objectPath == api::container::OBJECT_PATH &&
- interface == api::container::INTERFACE &&
- signalName == api::container::SIGNAL_NOTIFICATION &&
+ if (objectPath == api::zone::OBJECT_PATH &&
+ interface == api::zone::INTERFACE &&
+ signalName == api::zone::SIGNAL_NOTIFICATION &&
g_variant_is_of_type(parameters, G_VARIANT_TYPE("(sss)"))) {
const gchar* source = NULL;
}
};
- // subscribe the second (destination) container for notifications
+ // subscribe the second (destination) zone for notifications
dbuses.at(2)->signalSubscribe(handler);
- const std::string TMP = "/tmp/ut-containers";
+ const std::string TMP = "/tmp/ut-zones";
const std::string NO_PATH = "path_doesnt_matter_here";
const std::string BUGGY_PATH = TMP + "/this_file_does_not_exist";
- const std::string BUGGY_CONTAINER = "this-container-does-not-exist";
- const std::string CONTAINER1 = "ut-containers-manager-console1-dbus";
- const std::string CONTAINER2 = "ut-containers-manager-console2-dbus";
- const std::string CONTAINER1PATH = TMP + "/" + CONTAINER1 + TMP;
- const std::string CONTAINER2PATH = TMP + "/" + CONTAINER2 + TMP;
-
- // sending to a non existing container
- BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(BUGGY_CONTAINER, NO_PATH),
- api::container::FILE_MOVE_DESTINATION_NOT_FOUND);
+ const std::string BUGGY_ZONE = "this-zone-does-not-exist";
+ const std::string ZONE1 = "ut-zones-manager-console1-dbus";
+ const std::string ZONE2 = "ut-zones-manager-console2-dbus";
+ const std::string ZONE1PATH = TMP + "/" + ZONE1 + TMP;
+ const std::string ZONE2PATH = TMP + "/" + ZONE2 + TMP;
+
+ // sending to a non existing zone
+ BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(BUGGY_ZONE, NO_PATH),
+ api::zone::FILE_MOVE_DESTINATION_NOT_FOUND);
BOOST_CHECK(notificationLatch.empty());
// sending to self
- BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(CONTAINER1, NO_PATH),
- api::container::FILE_MOVE_WRONG_DESTINATION);
+ BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(ZONE1, NO_PATH),
+ api::zone::FILE_MOVE_WRONG_DESTINATION);
BOOST_CHECK(notificationLatch.empty());
// no permission to send
- BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(CONTAINER2, "/etc/secret1"),
- api::container::FILE_MOVE_NO_PERMISSIONS_SEND);
+ BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(ZONE2, "/etc/secret1"),
+ api::zone::FILE_MOVE_NO_PERMISSIONS_SEND);
BOOST_CHECK(notificationLatch.empty());
// no permission to receive
- BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(CONTAINER2, "/etc/secret2"),
- api::container::FILE_MOVE_NO_PERMISSIONS_RECEIVE);
+ BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(ZONE2, "/etc/secret2"),
+ api::zone::FILE_MOVE_NO_PERMISSIONS_RECEIVE);
BOOST_CHECK(notificationLatch.empty());
// non existing file
- BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(CONTAINER2, BUGGY_PATH),
- api::container::FILE_MOVE_FAILED);
+ BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(ZONE2, BUGGY_PATH),
+ api::zone::FILE_MOVE_FAILED);
BOOST_CHECK(notificationLatch.empty());
// a working scenario
namespace fs = boost::filesystem;
boost::system::error_code ec;
- fs::remove_all(CONTAINER1PATH, ec);
- fs::remove_all(CONTAINER2PATH, ec);
- BOOST_REQUIRE(fs::create_directories(CONTAINER1PATH, ec));
- BOOST_REQUIRE(fs::create_directories(CONTAINER2PATH, ec));
- BOOST_REQUIRE(utils::saveFileContent(CONTAINER1PATH + "/file", FILE_CONTENT));
-
- BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(CONTAINER2, TMP + "/file"),
- api::container::FILE_MOVE_SUCCEEDED);
+ fs::remove_all(ZONE1PATH, ec);
+ fs::remove_all(ZONE2PATH, ec);
+ BOOST_REQUIRE(fs::create_directories(ZONE1PATH, ec));
+ BOOST_REQUIRE(fs::create_directories(ZONE2PATH, ec));
+ BOOST_REQUIRE(utils::saveFileContent(ZONE1PATH + "/file", FILE_CONTENT));
+
+ BOOST_CHECK_EQUAL(dbuses.at(1)->callMethodMove(ZONE2, TMP + "/file"),
+ api::zone::FILE_MOVE_SUCCEEDED);
BOOST_CHECK(notificationLatch.wait(EVENT_TIMEOUT));
BOOST_CHECK(notificationLatch.empty());
- BOOST_CHECK_EQUAL(notificationSource, CONTAINER1);
+ BOOST_CHECK_EQUAL(notificationSource, ZONE1);
BOOST_CHECK_EQUAL(notificationPath, TMP + "/file");
- BOOST_CHECK_EQUAL(notificationRetcode, api::container::FILE_MOVE_SUCCEEDED);
- BOOST_CHECK(!fs::exists(CONTAINER1PATH + "/file"));
- BOOST_CHECK_EQUAL(utils::readFileContent(CONTAINER2PATH + "/file"), FILE_CONTENT);
+ BOOST_CHECK_EQUAL(notificationRetcode, api::zone::FILE_MOVE_SUCCEEDED);
+ BOOST_CHECK(!fs::exists(ZONE1PATH + "/file"));
+ BOOST_CHECK_EQUAL(utils::readFileContent(ZONE2PATH + "/file"), FILE_CONTENT);
- fs::remove_all(CONTAINER1PATH, ec);
- fs::remove_all(CONTAINER2PATH, ec);
+ fs::remove_all(ZONE1PATH, ec);
+ fs::remove_all(ZONE2PATH, ec);
}
BOOST_AUTO_TEST_CASE(AllowSwitchToDefaultTest)
{
- ContainersManager cm(TEST_DBUS_CONFIG_PATH);
+ ZonesManager cm(TEST_DBUS_CONFIG_PATH);
cm.startAll();
std::vector<std::unique_ptr<DbusAccessory>> clients;
- for (int i = 1; i <= TEST_DBUS_CONNECTION_CONTAINERS_COUNT; ++i) {
+ for (int i = 1; i <= TEST_DBUS_CONNECTION_ZONES_COUNT; ++i) {
clients.push_back(std::unique_ptr<DbusAccessory>(new DbusAccessory(i)));
}
std::unique_lock<std::mutex> condLock(condMutex);
std::condition_variable condition;
auto cond = [&cm]() -> bool {
- return cm.getRunningForegroundContainerId() == "ut-containers-manager-console1-dbus";
+ return cm.getRunningForegroundZoneId() == "ut-zones-manager-console1-dbus";
};
for (auto& client : clients) {
- // focus non-default container with allowed switching
- cm.focus("ut-containers-manager-console3-dbus");
+ // focus non-default zone with allowed switching
+ cm.focus("ut-zones-manager-console3-dbus");
// emit signal from dbus connection
client->emitSignal(fake_power_manager_api::OBJECT_PATH,
fake_power_manager_api::SIGNAL_DISPLAY_OFF,
nullptr);
- // check if default container has focus
+ // check if default zone has focus
BOOST_CHECK(condition.wait_for(condLock, std::chrono::milliseconds(EVENT_TIMEOUT), cond));
- // focus non-default container with disabled switching
- cm.focus("ut-containers-manager-console2-dbus");
+ // focus non-default zone with disabled switching
+ cm.focus("ut-zones-manager-console2-dbus");
// emit signal from dbus connection
client->emitSignal(fake_power_manager_api::OBJECT_PATH,
fake_power_manager_api::SIGNAL_DISPLAY_OFF,
nullptr);
- // now default container should not be focused
+ // now default zone should not be focused
BOOST_CHECK(!condition.wait_for(condLock, std::chrono::milliseconds(EVENT_TIMEOUT), cond));
}
}
BOOST_AUTO_TEST_CASE(ProxyCallTest)
{
- ContainersManager cm(TEST_DBUS_CONFIG_PATH);
+ ZonesManager cm(TEST_DBUS_CONFIG_PATH);
cm.startAll();
std::map<int, std::unique_ptr<DbusAccessory>> dbuses;
- for (int i = 0; i <= TEST_DBUS_CONNECTION_CONTAINERS_COUNT; ++i) {
+ for (int i = 0; i <= TEST_DBUS_CONNECTION_ZONES_COUNT; ++i) {
dbuses[i] = std::unique_ptr<DbusAccessory>(new DbusAccessory(i));
}
const int id = dbus.first;
auto handler = [id](const std::string& argument, MethodResultBuilder::Pointer result) {
if (argument.empty()) {
- result->setError("org.tizen.containers.Error.Test", "Test error");
+ result->setError("org.tizen.vasum.Error.Test", "Test error");
} else {
std::string ret = "reply from " + std::to_string(id) + ": " + argument;
result->set(g_variant_new("(s)", ret.c_str()));
dbus.second->registerTestApiObject(handler);
}
- // host -> container2
+ // host -> zone2
BOOST_CHECK_EQUAL("reply from 2: param1",
- dbuses.at(0)->testApiProxyCall("ut-containers-manager-console2-dbus",
+ dbuses.at(0)->testApiProxyCall("ut-zones-manager-console2-dbus",
"param1"));
// host -> host
dbuses.at(0)->testApiProxyCall("host",
"param2"));
- // container1 -> host
+ // zone1 -> host
BOOST_CHECK_EQUAL("reply from 0: param3",
dbuses.at(1)->testApiProxyCall("host",
"param3"));
- // container1 -> container2
+ // zone1 -> zone2
BOOST_CHECK_EQUAL("reply from 2: param4",
- dbuses.at(1)->testApiProxyCall("ut-containers-manager-console2-dbus",
+ dbuses.at(1)->testApiProxyCall("ut-zones-manager-console2-dbus",
"param4"));
- // container2 -> container2
+ // zone2 -> zone2
BOOST_CHECK_EQUAL("reply from 2: param5",
- dbuses.at(2)->testApiProxyCall("ut-containers-manager-console2-dbus",
+ dbuses.at(2)->testApiProxyCall("ut-zones-manager-console2-dbus",
"param5"));
// host -> unknown
namespace {
const DbusAccessory::Dbuses EXPECTED_DBUSES_NO_DBUS = {
- {"ut-containers-manager-console1", ""},
- {"ut-containers-manager-console2", ""},
- {"ut-containers-manager-console3", ""}};
+ {"ut-zones-manager-console1", ""},
+ {"ut-zones-manager-console2", ""},
+ {"ut-zones-manager-console3", ""}};
const DbusAccessory::Dbuses EXPECTED_DBUSES_STOPPED = {
- {"ut-containers-manager-console1-dbus", ""},
- {"ut-containers-manager-console2-dbus", ""},
- {"ut-containers-manager-console3-dbus", ""}};
+ {"ut-zones-manager-console1-dbus", ""},
+ {"ut-zones-manager-console2-dbus", ""},
+ {"ut-zones-manager-console3-dbus", ""}};
const DbusAccessory::Dbuses EXPECTED_DBUSES_STARTED = {
- {"ut-containers-manager-console1-dbus",
- "unix:path=/tmp/ut-run/ut-containers-manager-console1-dbus/dbus/system_bus_socket"},
- {"ut-containers-manager-console2-dbus",
- "unix:path=/tmp/ut-run/ut-containers-manager-console2-dbus/dbus/system_bus_socket"},
- {"ut-containers-manager-console3-dbus",
- "unix:path=/tmp/ut-run/ut-containers-manager-console3-dbus/dbus/system_bus_socket"}};
+ {"ut-zones-manager-console1-dbus",
+ "unix:path=/tmp/ut-run/ut-zones-manager-console1-dbus/dbus/system_bus_socket"},
+ {"ut-zones-manager-console2-dbus",
+ "unix:path=/tmp/ut-run/ut-zones-manager-console2-dbus/dbus/system_bus_socket"},
+ {"ut-zones-manager-console3-dbus",
+ "unix:path=/tmp/ut-run/ut-zones-manager-console3-dbus/dbus/system_bus_socket"}};
} // namespace
-BOOST_AUTO_TEST_CASE(GetContainerDbusesTest)
+BOOST_AUTO_TEST_CASE(GetZoneDbusesTest)
{
DbusAccessory host(DbusAccessory::HOST_ID);
- ContainersManager cm(TEST_DBUS_CONFIG_PATH);
+ ZonesManager cm(TEST_DBUS_CONFIG_PATH);
- BOOST_CHECK(EXPECTED_DBUSES_STOPPED == host.callMethodGetContainerDbuses());
+ BOOST_CHECK(EXPECTED_DBUSES_STOPPED == host.callMethodGetZoneDbuses());
cm.startAll();
- BOOST_CHECK(EXPECTED_DBUSES_STARTED == host.callMethodGetContainerDbuses());
+ BOOST_CHECK(EXPECTED_DBUSES_STARTED == host.callMethodGetZoneDbuses());
cm.stopAll();
- BOOST_CHECK(EXPECTED_DBUSES_STOPPED == host.callMethodGetContainerDbuses());
+ BOOST_CHECK(EXPECTED_DBUSES_STOPPED == host.callMethodGetZoneDbuses());
}
-BOOST_AUTO_TEST_CASE(GetContainerDbusesNoDbusTest)
+BOOST_AUTO_TEST_CASE(GetZoneDbusesNoDbusTest)
{
DbusAccessory host(DbusAccessory::HOST_ID);
- ContainersManager cm(TEST_CONFIG_PATH);
- BOOST_CHECK(EXPECTED_DBUSES_NO_DBUS == host.callMethodGetContainerDbuses());
+ ZonesManager cm(TEST_CONFIG_PATH);
+ BOOST_CHECK(EXPECTED_DBUSES_NO_DBUS == host.callMethodGetZoneDbuses());
cm.startAll();
- BOOST_CHECK(EXPECTED_DBUSES_NO_DBUS == host.callMethodGetContainerDbuses());
+ BOOST_CHECK(EXPECTED_DBUSES_NO_DBUS == host.callMethodGetZoneDbuses());
cm.stopAll();
- BOOST_CHECK(EXPECTED_DBUSES_NO_DBUS == host.callMethodGetContainerDbuses());
+ BOOST_CHECK(EXPECTED_DBUSES_NO_DBUS == host.callMethodGetZoneDbuses());
}
-BOOST_AUTO_TEST_CASE(ContainerDbusesSignalsTest)
+BOOST_AUTO_TEST_CASE(ZoneDbusesSignalsTest)
{
Latch signalLatch;
DbusAccessory::Dbuses collectedDbuses;
GVariant* parameters) {
if (objectPath == api::host::OBJECT_PATH &&
interface == api::host::INTERFACE &&
- signalName == api::host::SIGNAL_CONTAINER_DBUS_STATE) {
+ signalName == api::host::SIGNAL_ZONE_DBUS_STATE) {
- const gchar* containerId = NULL;
+ const gchar* zoneId = NULL;
const gchar* dbusAddress = NULL;
- g_variant_get(parameters, "(&s&s)", &containerId, &dbusAddress);
+ g_variant_get(parameters, "(&s&s)", &zoneId, &dbusAddress);
- collectedDbuses.insert(DbusAccessory::Dbuses::value_type(containerId, dbusAddress));
+ collectedDbuses.insert(DbusAccessory::Dbuses::value_type(zoneId, dbusAddress));
signalLatch.set();
}
};
host.signalSubscribe(onSignal);
{
- ContainersManager cm(TEST_DBUS_CONFIG_PATH);
+ ZonesManager cm(TEST_DBUS_CONFIG_PATH);
BOOST_CHECK(signalLatch.empty());
BOOST_CHECK(collectedDbuses.empty());
cm.startAll();
- BOOST_CHECK(signalLatch.waitForN(TEST_DBUS_CONNECTION_CONTAINERS_COUNT, EVENT_TIMEOUT));
+ BOOST_CHECK(signalLatch.waitForN(TEST_DBUS_CONNECTION_ZONES_COUNT, EVENT_TIMEOUT));
BOOST_CHECK(signalLatch.empty());
BOOST_CHECK(EXPECTED_DBUSES_STARTED == collectedDbuses);
collectedDbuses.clear();
}
- BOOST_CHECK(signalLatch.waitForN(TEST_DBUS_CONNECTION_CONTAINERS_COUNT, EVENT_TIMEOUT));
+ BOOST_CHECK(signalLatch.waitForN(TEST_DBUS_CONNECTION_ZONES_COUNT, EVENT_TIMEOUT));
BOOST_CHECK(signalLatch.empty());
BOOST_CHECK(EXPECTED_DBUSES_STOPPED == collectedDbuses);
}
-BOOST_AUTO_TEST_CASE(GetContainerIdsTest)
+BOOST_AUTO_TEST_CASE(GetZoneIdsTest)
{
- ContainersManager cm(TEST_DBUS_CONFIG_PATH);
+ ZonesManager cm(TEST_DBUS_CONFIG_PATH);
DbusAccessory dbus(DbusAccessory::HOST_ID);
- std::vector<std::string> containerIds = {"ut-containers-manager-console1-dbus",
- "ut-containers-manager-console2-dbus",
- "ut-containers-manager-console3-dbus"};
- std::vector<std::string> returnedIds = dbus.callMethodGetContainerIds();
+ std::vector<std::string> zoneIds = {"ut-zones-manager-console1-dbus",
+ "ut-zones-manager-console2-dbus",
+ "ut-zones-manager-console3-dbus"};
+ std::vector<std::string> returnedIds = dbus.callMethodGetZoneIds();
BOOST_CHECK(std::is_permutation(returnedIds.begin(),
returnedIds.end(),
- containerIds.begin()));
+ zoneIds.begin()));
}
-BOOST_AUTO_TEST_CASE(GetActiveContainerIdTest)
+BOOST_AUTO_TEST_CASE(GetActiveZoneIdTest)
{
- ContainersManager cm(TEST_DBUS_CONFIG_PATH);
+ ZonesManager cm(TEST_DBUS_CONFIG_PATH);
cm.startAll();
DbusAccessory dbus(DbusAccessory::HOST_ID);
- std::vector<std::string> containerIds = {"ut-containers-manager-console1-dbus",
- "ut-containers-manager-console2-dbus",
- "ut-containers-manager-console3-dbus"};
+ std::vector<std::string> zoneIds = {"ut-zones-manager-console1-dbus",
+ "ut-zones-manager-console2-dbus",
+ "ut-zones-manager-console3-dbus"};
- for (std::string& containerId: containerIds){
- cm.focus(containerId);
- BOOST_CHECK(dbus.callMethodGetActiveContainerId() == containerId);
+ for (std::string& zoneId: zoneIds){
+ cm.focus(zoneId);
+ BOOST_CHECK(dbus.callMethodGetActiveZoneId() == zoneId);
}
cm.stopAll();
- BOOST_CHECK(dbus.callMethodGetActiveContainerId() == "");
+ BOOST_CHECK(dbus.callMethodGetActiveZoneId() == "");
}
-BOOST_AUTO_TEST_CASE(SetActiveContainerTest)
+BOOST_AUTO_TEST_CASE(SetActiveZoneTest)
{
- ContainersManager cm(TEST_DBUS_CONFIG_PATH);
+ ZonesManager cm(TEST_DBUS_CONFIG_PATH);
cm.startAll();
DbusAccessory dbus(DbusAccessory::HOST_ID);
- std::vector<std::string> containerIds = {"ut-containers-manager-console1-dbus",
- "ut-containers-manager-console2-dbus",
- "ut-containers-manager-console3-dbus"};
+ std::vector<std::string> zoneIds = {"ut-zones-manager-console1-dbus",
+ "ut-zones-manager-console2-dbus",
+ "ut-zones-manager-console3-dbus"};
- for (std::string& containerId: containerIds){
- dbus.callMethodSetActiveContainer(containerId);
- BOOST_CHECK(dbus.callMethodGetActiveContainerId() == containerId);
+ for (std::string& zoneId: zoneIds){
+ dbus.callMethodSetActiveZone(zoneId);
+ BOOST_CHECK(dbus.callMethodGetActiveZoneId() == zoneId);
}
- BOOST_REQUIRE_THROW(dbus.callMethodSetActiveContainer(NON_EXISTANT_CONTAINER_ID),
+ BOOST_REQUIRE_THROW(dbus.callMethodSetActiveZone(NON_EXISTANT_ZONE_ID),
DbusException);
cm.stopAll();
- BOOST_REQUIRE_THROW(dbus.callMethodSetActiveContainer("ut-containers-manager-console1-dbus"),
+ BOOST_REQUIRE_THROW(dbus.callMethodSetActiveZone("ut-zones-manager-console1-dbus"),
DbusException);
}
-BOOST_AUTO_TEST_CASE(CreateDestroyContainerTest)
+BOOST_AUTO_TEST_CASE(CreateDestroyZoneTest)
{
- const std::string container1 = "test1";
- const std::string container2 = "test2";
- const std::string container3 = "test3";
+ const std::string zone1 = "test1";
+ const std::string zone2 = "test2";
+ const std::string zone3 = "test3";
- ContainersManager cm(EMPTY_DBUS_CONFIG_PATH);
+ ZonesManager cm(EMPTY_DBUS_CONFIG_PATH);
cm.startAll();
- BOOST_CHECK_EQUAL(cm.getRunningForegroundContainerId(), "");
+ BOOST_CHECK_EQUAL(cm.getRunningForegroundZoneId(), "");
Latch callDone;
auto resultCallback = [&]() {
DbusAccessory dbus(DbusAccessory::HOST_ID);
- // create container1
- dbus.callAsyncMethodCreateContainer(container1, resultCallback);
+ // create zone1
+ dbus.callAsyncMethodCreateZone(zone1, resultCallback);
BOOST_REQUIRE(callDone.wait(EVENT_TIMEOUT));
- BOOST_CHECK_EQUAL(cm.getRunningForegroundContainerId(), container1);
+ BOOST_CHECK_EQUAL(cm.getRunningForegroundZoneId(), zone1);
- // create container2
- dbus.callAsyncMethodCreateContainer(container2, resultCallback);
+ // create zone2
+ dbus.callAsyncMethodCreateZone(zone2, resultCallback);
BOOST_REQUIRE(callDone.wait(EVENT_TIMEOUT));
- BOOST_CHECK_EQUAL(cm.getRunningForegroundContainerId(), container2); //TODO is this valid?
+ BOOST_CHECK_EQUAL(cm.getRunningForegroundZoneId(), zone2); //TODO is this valid?
- // create container3
- dbus.callAsyncMethodCreateContainer(container3, resultCallback);
+ // create zone3
+ dbus.callAsyncMethodCreateZone(zone3, resultCallback);
BOOST_REQUIRE(callDone.wait(EVENT_TIMEOUT));
- BOOST_CHECK_EQUAL(cm.getRunningForegroundContainerId(), container3);
+ BOOST_CHECK_EQUAL(cm.getRunningForegroundZoneId(), zone3);
- // destroy container2
- dbus.callAsyncMethodDestroyContainer(container2, resultCallback);
+ // destroy zone2
+ dbus.callAsyncMethodDestroyZone(zone2, resultCallback);
BOOST_REQUIRE(callDone.wait(EVENT_TIMEOUT));
- BOOST_CHECK_EQUAL(cm.getRunningForegroundContainerId(), container3);
+ BOOST_CHECK_EQUAL(cm.getRunningForegroundZoneId(), zone3);
- // destroy container3
- dbus.callAsyncMethodDestroyContainer(container3, resultCallback);
+ // destroy zone3
+ dbus.callAsyncMethodDestroyZone(zone3, resultCallback);
BOOST_REQUIRE(callDone.wait(EVENT_TIMEOUT));
- //BOOST_CHECK_EQUAL(cm.getRunningForegroundContainerId(), container1);//TODO fix it
+ //BOOST_CHECK_EQUAL(cm.getRunningForegroundZoneId(), zone1);//TODO fix it
- // destroy container1
- dbus.callAsyncMethodDestroyContainer(container1, resultCallback);
+ // destroy zone1
+ dbus.callAsyncMethodDestroyZone(zone1, resultCallback);
BOOST_REQUIRE(callDone.wait(EVENT_TIMEOUT));
- BOOST_CHECK_EQUAL(cm.getRunningForegroundContainerId(), "");
+ BOOST_CHECK_EQUAL(cm.getRunningForegroundZoneId(), "");
}
BOOST_AUTO_TEST_CASE(DeclareFile)
{
- const std::string container = EXPECTED_DBUSES_NO_DBUS.begin()->first;
- const std::string provisionConfigPath = getProvisionConfigPath(container);
+ const std::string zone = EXPECTED_DBUSES_NO_DBUS.begin()->first;
+ const std::string provisionConfigPath = getProvisionConfigPath(zone);
- ContainersManager cm(TEST_CONFIG_PATH);
+ ZonesManager cm(TEST_CONFIG_PATH);
DbusAccessory dbus(DbusAccessory::HOST_ID);
- dbus.callMethodDeclareFile(container, 1, "path", 0747, 0777);
- dbus.callMethodDeclareFile(container, 2, "path", 0747, 0777);
+ dbus.callMethodDeclareFile(zone, 1, "path", 0747, 0777);
+ dbus.callMethodDeclareFile(zone, 2, "path", 0747, 0777);
- ContainerProvisioning config;
+ ZoneProvisioning config;
BOOST_REQUIRE_NO_THROW(loadFromFile(provisionConfigPath, config));
BOOST_REQUIRE_EQUAL(config.units.size(), 2);
- BOOST_REQUIRE(config.units[0].is<ContainerProvisioning::File>());
- BOOST_REQUIRE(config.units[1].is<ContainerProvisioning::File>());
- const ContainerProvisioning::File& unit = config.units[0].as<ContainerProvisioning::File>();
+ BOOST_REQUIRE(config.units[0].is<ZoneProvisioning::File>());
+ BOOST_REQUIRE(config.units[1].is<ZoneProvisioning::File>());
+ const ZoneProvisioning::File& unit = config.units[0].as<ZoneProvisioning::File>();
BOOST_CHECK_EQUAL(unit.type, 1);
BOOST_CHECK_EQUAL(unit.path, "path");
BOOST_CHECK_EQUAL(unit.flags, 0747);
BOOST_AUTO_TEST_CASE(DeclareMount)
{
- const std::string container = EXPECTED_DBUSES_NO_DBUS.begin()->first;
- const std::string provisionConfigPath = getProvisionConfigPath(container);
+ const std::string zone = EXPECTED_DBUSES_NO_DBUS.begin()->first;
+ const std::string provisionConfigPath = getProvisionConfigPath(zone);
- ContainersManager cm(TEST_CONFIG_PATH);
+ ZonesManager cm(TEST_CONFIG_PATH);
DbusAccessory dbus(DbusAccessory::HOST_ID);
- dbus.callMethodDeclareMount("/fake/path1", container, "/fake/path2", "tmpfs", 077, "fake");
- dbus.callMethodDeclareMount("/fake/path2", container, "/fake/path2", "tmpfs", 077, "fake");
+ dbus.callMethodDeclareMount("/fake/path1", zone, "/fake/path2", "tmpfs", 077, "fake");
+ dbus.callMethodDeclareMount("/fake/path2", zone, "/fake/path2", "tmpfs", 077, "fake");
- ContainerProvisioning config;
+ ZoneProvisioning config;
BOOST_REQUIRE_NO_THROW(loadFromFile(provisionConfigPath, config));
BOOST_REQUIRE_EQUAL(config.units.size(), 2);
- BOOST_REQUIRE(config.units[0].is<ContainerProvisioning::Mount>());
- BOOST_REQUIRE(config.units[1].is<ContainerProvisioning::Mount>());
- const ContainerProvisioning::Mount& unit = config.units[0].as<ContainerProvisioning::Mount>();
+ BOOST_REQUIRE(config.units[0].is<ZoneProvisioning::Mount>());
+ BOOST_REQUIRE(config.units[1].is<ZoneProvisioning::Mount>());
+ const ZoneProvisioning::Mount& unit = config.units[0].as<ZoneProvisioning::Mount>();
BOOST_CHECK_EQUAL(unit.source, "/fake/path1");
BOOST_CHECK_EQUAL(unit.target, "/fake/path2");
BOOST_CHECK_EQUAL(unit.type, "tmpfs");
BOOST_AUTO_TEST_CASE(DeclareLink)
{
- const std::string container = EXPECTED_DBUSES_NO_DBUS.begin()->first;
- const std::string provisionConfigPath = getProvisionConfigPath(container);
+ const std::string zone = EXPECTED_DBUSES_NO_DBUS.begin()->first;
+ const std::string provisionConfigPath = getProvisionConfigPath(zone);
- ContainersManager cm(TEST_CONFIG_PATH);
+ ZonesManager cm(TEST_CONFIG_PATH);
DbusAccessory dbus(DbusAccessory::HOST_ID);
- dbus.callMethodDeclareLink("/fake/path1", container, "/fake/path2");
- dbus.callMethodDeclareLink("/fake/path2", container, "/fake/path2");
+ dbus.callMethodDeclareLink("/fake/path1", zone, "/fake/path2");
+ dbus.callMethodDeclareLink("/fake/path2", zone, "/fake/path2");
- ContainerProvisioning config;
+ ZoneProvisioning config;
BOOST_REQUIRE_NO_THROW(loadFromFile(provisionConfigPath, config));
BOOST_REQUIRE_EQUAL(config.units.size(), 2);
- BOOST_REQUIRE(config.units[0].is<ContainerProvisioning::Link>());
- BOOST_REQUIRE(config.units[1].is<ContainerProvisioning::Link>());
- const ContainerProvisioning::Link& unit = config.units[0].as<ContainerProvisioning::Link>();
+ BOOST_REQUIRE(config.units[0].is<ZoneProvisioning::Link>());
+ BOOST_REQUIRE(config.units[1].is<ZoneProvisioning::Link>());
+ const ZoneProvisioning::Link& unit = config.units[0].as<ZoneProvisioning::Link>();
BOOST_CHECK_EQUAL(unit.source, "/fake/path1");
BOOST_CHECK_EQUAL(unit.target, "/fake/path2");
}
-BOOST_AUTO_TEST_CASE(LockUnlockContainerTest)
+BOOST_AUTO_TEST_CASE(LockUnlockZoneTest)
{
- ContainersManager cm(TEST_DBUS_CONFIG_PATH);
+ ZonesManager cm(TEST_DBUS_CONFIG_PATH);
cm.startAll();
DbusAccessory dbus(DbusAccessory::HOST_ID);
- std::vector<std::string> containerIds = {"ut-containers-manager-console1-dbus",
- "ut-containers-manager-console2-dbus",
- "ut-containers-manager-console3-dbus"};
+ std::vector<std::string> zoneIds = {"ut-zones-manager-console1-dbus",
+ "ut-zones-manager-console2-dbus",
+ "ut-zones-manager-console3-dbus"};
- for (std::string& containerId: containerIds){
- dbus.callMethodLockContainer(containerId);
- BOOST_CHECK(cm.isPaused(containerId));
- dbus.callMethodUnlockContainer(containerId);
- BOOST_CHECK(cm.isRunning(containerId));
+ for (std::string& zoneId: zoneIds){
+ dbus.callMethodLockZone(zoneId);
+ BOOST_CHECK(cm.isPaused(zoneId));
+ dbus.callMethodUnlockZone(zoneId);
+ BOOST_CHECK(cm.isRunning(zoneId));
}
- BOOST_REQUIRE_THROW(dbus.callMethodLockContainer(NON_EXISTANT_CONTAINER_ID),
+ BOOST_REQUIRE_THROW(dbus.callMethodLockZone(NON_EXISTANT_ZONE_ID),
DbusException);
- BOOST_REQUIRE_THROW(dbus.callMethodUnlockContainer(NON_EXISTANT_CONTAINER_ID),
+ BOOST_REQUIRE_THROW(dbus.callMethodUnlockZone(NON_EXISTANT_ZONE_ID),
DbusException);
cm.stopAll();
- BOOST_REQUIRE_THROW(dbus.callMethodLockContainer("ut-containers-manager-console1-dbus"),
+ BOOST_REQUIRE_THROW(dbus.callMethodLockZone("ut-zones-manager-console1-dbus"),
DbusException);
- BOOST_REQUIRE_THROW(dbus.callMethodUnlockContainer("ut-containers-manager-console1-dbus"),
+ BOOST_REQUIRE_THROW(dbus.callMethodUnlockZone("ut-zones-manager-console1-dbus"),
DbusException);
}
#
MESSAGE(STATUS "")
-MESSAGE(STATUS "Generating makefile for the Container Daemon...")
+MESSAGE(STATUS "Generating makefile for the Zone Daemon...")
FILE(GLOB project_SRCS *.cpp *.hpp)
FILE(GLOB common_SRCS ${COMMON_FOLDER}/dbus/*.cpp ${COMMON_FOLDER}/dbus/*.hpp
${COMMON_FOLDER}/log/*.cpp ${COMMON_FOLDER}/log/*.hpp
${COMMON_FOLDER}/utils/*.cpp ${COMMON_FOLDER}/utils/*.hpp)
## Setup target ################################################################
-SET(CONTAINER_DAEMON_CODENAME "${PROJECT_NAME}-container-daemon")
-ADD_EXECUTABLE(${CONTAINER_DAEMON_CODENAME} ${project_SRCS} ${common_SRCS})
+SET(ZONE_DAEMON_CODENAME "${PROJECT_NAME}-zone-daemon")
+ADD_EXECUTABLE(${ZONE_DAEMON_CODENAME} ${project_SRCS} ${common_SRCS})
## Link libraries ##############################################################
FIND_PACKAGE (Boost COMPONENTS program_options system filesystem)
-PKG_CHECK_MODULES(CONTAINER_DAEMON_DEPS REQUIRED gio-2.0 libsystemd-journal libcap-ng
+PKG_CHECK_MODULES(ZONE_DAEMON_DEPS REQUIRED gio-2.0 libsystemd-journal libcap-ng
libLogger libSimpleDbus libConfig)
INCLUDE_DIRECTORIES(${COMMON_FOLDER})
-INCLUDE_DIRECTORIES(SYSTEM ${CONTAINER_DAEMON_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
-TARGET_LINK_LIBRARIES(${CONTAINER_DAEMON_CODENAME} ${CONTAINER_DAEMON_DEPS_LIBRARIES} ${Boost_LIBRARIES})
+INCLUDE_DIRECTORIES(SYSTEM ${ZONE_DAEMON_DEPS_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
+TARGET_LINK_LIBRARIES(${ZONE_DAEMON_CODENAME} ${ZONE_DAEMON_DEPS_LIBRARIES} ${Boost_LIBRARIES})
## Install #####################################################################
-INSTALL(TARGETS ${CONTAINER_DAEMON_CODENAME} DESTINATION bin)
+INSTALL(TARGETS ${ZONE_DAEMON_CODENAME} DESTINATION bin)
-CONFIGURE_FILE(configs/org.tizen.containers.zone.daemon.conf.in
- ${CMAKE_BINARY_DIR}/configs/org.tizen.containers.zone.daemon.conf)
+CONFIGURE_FILE(configs/org.tizen.vasum.zone.daemon.conf.in
+ ${CMAKE_BINARY_DIR}/configs/org.tizen.vasum.zone.daemon.conf)
-INSTALL(FILES ${CMAKE_BINARY_DIR}/configs/org.tizen.containers.zone.daemon.conf
+INSTALL(FILES ${CMAKE_BINARY_DIR}/configs/org.tizen.vasum.zone.daemon.conf
DESTINATION /etc/dbus-1/system.d/)
--- /dev/null
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+
+<busconfig>
+ <policy user="${VASUM_USER}">
+ <allow own="org.tizen.vasum.zone.daemon"/>
+ <allow send_destination="org.tizen.vasum.zone.daemon"/>
+ <allow receive_sender="org.tizen.vasum.zone.daemon"/>
+ </policy>
+ <policy context="default">
+ <allow send_destination="org.tizen.vasum.zone.daemon"/>
+ <allow receive_sender="org.tizen.vasum.zone.daemon"/>
+ </policy>
+</busconfig>
/**
* @file
* @author Jan Olszak (j.olszak@samsung.com)
- * @brief Dbus API for the Container Daemon
+ * @brief Dbus API for the Zone Daemon
*/
#include "config.hpp"
namespace vasum {
-namespace container_daemon {
+namespace zone_daemon {
namespace {
mDbusConnection = dbus::DbusConnection::createSystem();
LOGD("Setting DBUS name");
- mDbusConnection->setName(container_daemon::api::BUS_NAME,
+ mDbusConnection->setName(zone_daemon::api::BUS_NAME,
std::bind(&DaemonConnection::onNameAcquired, this),
std::bind(&DaemonConnection::onNameLost, this));
if (!waitForNameAndSetCallback(NAME_ACQUIRED_TIMEOUT, nameLostCallback)) {
- LOGE("Could not acquire dbus name: " << container_daemon::api::BUS_NAME);
- throw ContainerDaemonException("Could not acquire dbus name: " + container_daemon::api::BUS_NAME);
+ LOGE("Could not acquire dbus name: " << zone_daemon::api::BUS_NAME);
+ throw ZoneDaemonException("Could not acquire dbus name: " + zone_daemon::api::BUS_NAME);
}
LOGD("Setting callbacks");
LOGD("Registering DBUS interface");
using namespace std::placeholders;
- mDbusConnection->registerObject(container_daemon::api::OBJECT_PATH,
- container_daemon::api::DEFINITION,
+ mDbusConnection->registerObject(zone_daemon::api::OBJECT_PATH,
+ zone_daemon::api::DEFINITION,
std::bind(&DaemonConnection::onMessageCall,
this, _1, _2, _3, _4, _5));
LOGD("Connected");
}
}
-} // namespace container_daemon
+} // namespace zone_daemon
} // namespace vasum
/**
* @file
* @author Jan Olszak (j.olszak@samsung.com)
- * @brief Declaration of a class for communication between container and server
+ * @brief Declaration of a class for communication between zone and server
*/
-#ifndef CONTAINER_DAEMON_DAEMON_CONNECTION_HPP
-#define CONTAINER_DAEMON_DAEMON_CONNECTION_HPP
+#ifndef ZONE_DAEMON_DAEMON_CONNECTION_HPP
+#define ZONE_DAEMON_DAEMON_CONNECTION_HPP
#include "dbus/connection.hpp"
namespace vasum {
-namespace container_daemon {
+namespace zone_daemon {
class DaemonConnection {
};
-} // namespace container_daemon
+} // namespace zone_daemon
} // namespace vasum
-#endif // CONTAINER_DAEMON_DAEMON_CONNECTION_HPP
+#endif // ZONE_DAEMON_DAEMON_CONNECTION_HPP
/**
* @file
* @author Jan Olszak (j.olszak@samsung.com)
- * @brief container-daemon dbus api definitions
+ * @brief zone-daemon dbus api definitions
*/
-#ifndef CONTAINER_DAEMON_DAEMON_DBUS_DEFINITIONS_HPP
-#define CONTAINER_DAEMON_DAEMON_DBUS_DEFINITIONS_HPP
+#ifndef ZONE_DAEMON_DAEMON_DBUS_DEFINITIONS_HPP
+#define ZONE_DAEMON_DAEMON_DBUS_DEFINITIONS_HPP
#include <string>
namespace vasum {
-namespace container_daemon {
+namespace zone_daemon {
namespace api {
-const std::string BUS_NAME = "org.tizen.containers.zone.daemon";
-const std::string OBJECT_PATH = "/org/tizen/containers/zone/daemon";
-const std::string INTERFACE = "org.tizen.containers.zone.daemon";
+const std::string BUS_NAME = "org.tizen.vasum.zone.daemon";
+const std::string OBJECT_PATH = "/org/tizen/vasum/zone/daemon";
+const std::string INTERFACE = "org.tizen.vasum.zone.daemon";
const std::string METHOD_GAIN_FOCUS = "GainFocus";
const std::string METHOD_LOSE_FOCUS = "LoseFocus";
} // namespace api
-} // namespace container_daemon
+} // namespace zone_daemon
} // namespace vasum
-#endif // CONTAINER_DAEMON_DAEMON_DBUS_DEFINITIONS_HPP
+#endif // ZONE_DAEMON_DAEMON_DBUS_DEFINITIONS_HPP
namespace vasum {
-namespace container_daemon {
+namespace zone_daemon {
Daemon::Daemon()
}
-} // namespace container_daemon
+} // namespace zone_daemon
} // namespace vasum
*/
-#ifndef CONTAINER_DAEMON_DAEMON_HPP
-#define CONTAINER_DAEMON_DAEMON_HPP
+#ifndef ZONE_DAEMON_DAEMON_HPP
+#define ZONE_DAEMON_DAEMON_HPP
#include "daemon-connection.hpp"
namespace vasum {
-namespace container_daemon {
+namespace zone_daemon {
class Daemon {
public:
};
-} // namespace container_daemon
+} // namespace zone_daemon
} // namespace vasum
-#endif // CONTAINER_DAEMON_DAEMON_HPP
+#endif // ZONE_DAEMON_DAEMON_HPP
/**
* @file
* @author Jan Olszak (j.olszak@samsung.com)
- * @brief Exceptions for the container-daemon
+ * @brief Exceptions for the zone-daemon
*/
-#ifndef CONTAINER_DAEMON_EXCEPTION_HPP
-#define CONTAINER_DAEMON_EXCEPTION_HPP
+#ifndef ZONE_DAEMON_EXCEPTION_HPP
+#define ZONE_DAEMON_EXCEPTION_HPP
#include "base-exception.hpp"
namespace vasum {
-namespace container_daemon {
+namespace zone_daemon {
/**
- * Base class for exceptions in Vasum Container Daemon
+ * Base class for exceptions in Vasum Zone Daemon
*/
-struct ContainerDaemonException: public VasumException {
+struct ZoneDaemonException: public VasumException {
- ContainerDaemonException(const std::string& error = "") : VasumException(error) {}
+ ZoneDaemonException(const std::string& error = "") : VasumException(error) {}
};
-} // container_daemon
+} // zone_daemon
} // vasum
-#endif // CONTAINER_DAEMON_EXCEPTION_HPP
+#endif // ZONE_DAEMON_EXCEPTION_HPP
namespace {
const std::string PROGRAM_NAME_AND_VERSION =
- "Vasum Containers Daemon " PROGRAM_VERSION;
+ "Vasum Zones Daemon " PROGRAM_VERSION;
} // namespace
}
try {
- container_daemon::Runner daemon;
+ zone_daemon::Runner daemon;
daemon.run();
} catch (std::exception& e) {
namespace vasum {
-namespace container_daemon {
+namespace zone_daemon {
Runner::Runner()
signal(SIGINT, signalHandler);
signal(SIGTERM, signalHandler);
- LOGI("Starting Container Daemon...");
+ LOGI("Starting Zone Daemon...");
{
utils::ScopedGlibLoop loop;
- LOGI("Container Daemon started");
+ LOGI("Zone Daemon started");
// Connects to dbus and registers API
- container_daemon::Daemon daemon;
+ zone_daemon::Daemon daemon;
gSignalLatch.wait();
- LOGI("Stopping Container Daemon...");
+ LOGI("Stopping Zone Daemon...");
}
LOGI("Daemon stopped");
void Runner::terminate()
{
- LOGI("Terminating Container Daemon");
+ LOGI("Terminating Zone Daemon");
gSignalLatch.set();
}
-} // namespace container_daemon
+} // namespace zone_daemon
} // namespace vasum
*/
-#ifndef CONTAINER_DAEMON_RUNNER_HPP
-#define CONTAINER_DAEMON_RUNNER_HPP
+#ifndef ZONE_DAEMON_RUNNER_HPP
+#define ZONE_DAEMON_RUNNER_HPP
namespace vasum {
-namespace container_daemon {
+namespace zone_daemon {
class Runner {
};
-} // namespace container_daemon
+} // namespace zone_daemon
} // namespace vasum
-#endif // CONTAINER_DAEMON_RUNNER_HPP
+#endif // ZONE_DAEMON_RUNNER_HPP
#
MESSAGE(STATUS "")
-MESSAGE(STATUS "Generating makefile for the Container Support...")
+MESSAGE(STATUS "Generating makefile for the Zone Support...")
## Install #####################################################################
-CONFIGURE_FILE(configs/org.tizen.containers.zone.conf.in
- ${CMAKE_BINARY_DIR}/dbus-1/system.d/org.tizen.containers.zone.conf)
+CONFIGURE_FILE(configs/org.tizen.vasum.zone.conf.in
+ ${CMAKE_BINARY_DIR}/dbus-1/system.d/org.tizen.vasum.zone.conf)
-INSTALL(FILES ${CMAKE_BINARY_DIR}/dbus-1/system.d/org.tizen.containers.zone.conf
+INSTALL(FILES ${CMAKE_BINARY_DIR}/dbus-1/system.d/org.tizen.vasum.zone.conf
DESTINATION /etc/dbus-1/system.d/)
--- /dev/null
+<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
+ "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
+
+<busconfig>
+ <policy user="${VASUM_USER}">
+ <allow own="org.tizen.vasum.zone"/>
+ <allow send_destination="org.tizen.vasum.zone"/>
+ <allow receive_sender="org.tizen.vasum.zone"/>
+ </policy>
+ <policy context="default">
+ <allow send_destination="org.tizen.vasum.zone"/>
+ <allow receive_sender="org.tizen.vasum.zone"/>
+ </policy>
+</busconfig>