From b4ca234cdffa223952b54037d62e0387878d5fde Mon Sep 17 00:00:00 2001 From: Dariusz Michaluk Date: Mon, 8 Dec 2014 14:04:46 +0100 Subject: [PATCH] Rename containers to zones [Bug/Feature] N/A [Cause] N/A [Solution] N/A [Verification] Build, install, run tests Change-Id: I3d9eb8894c1d236061a0abe35691be6c57839702 Signed-off-by: Dariusz Michaluk --- CMakeLists.txt | 8 +- cli/command-line-interface.cpp | 4 +- cli/command-line-interface.hpp | 6 +- cli/main.cpp | 38 +- client/utils.cpp | 2 +- client/utils.hpp | 2 +- client/vasum-client-impl.cpp | 96 +-- client/vasum-client-impl.hpp | 26 +- client/vasum-client.cpp | 36 +- client/vasum-client.h | 92 +-- common/lxc/zone.cpp | 70 +- common/lxc/zone.hpp | 6 +- .../org.tizen.containers.zone.daemon.conf.in | 14 - .../configs/org.tizen.containers.zone.conf.in | 14 - ...support.manifest => vasum-zone-daemon.manifest} | 0 ...daemon.manifest => vasum-zone-support.manifest} | 0 packaging/vasum.spec | 50 +- server/common-dbus-definitions.hpp | 10 +- server/configs/CMakeLists.txt | 12 +- server/configs/daemon.conf | 12 +- .../system.d/org.tizen.containers.host.conf.in | 20 - .../dbus-1/system.d/org.tizen.vasum.host.conf.in | 20 + server/configs/lxc-templates/template.sh | 6 +- .../configs/lxc-templates/tizen-common-wayland.sh | 28 +- server/configs/{containers => zones}/business.conf | 0 server/configs/{containers => zones}/private.conf | 0 server/containers-manager.cpp | 888 --------------------- server/exception.hpp | 14 +- server/fake-power-manager-dbus-definitions.hpp | 4 +- server/host-connection.cpp | 114 +-- server/host-connection.hpp | 78 +- server/host-dbus-definitions.hpp | 56 +- server/provisioning-config.hpp | 8 +- server/proxy-call-config.hpp | 4 +- server/server.cpp | 26 +- server/server.hpp | 2 +- server/{container-admin.cpp => zone-admin.cpp} | 84 +- server/{container-admin.hpp => zone-admin.hpp} | 56 +- server/{container-config.hpp => zone-config.hpp} | 36 +- ...transport.cpp => zone-connection-transport.cpp} | 26 +- ...transport.hpp => zone-connection-transport.hpp} | 18 +- ...ontainer-connection.cpp => zone-connection.cpp} | 78 +- ...ontainer-connection.hpp => zone-connection.hpp} | 24 +- ...s-definitions.hpp => zone-dbus-definitions.hpp} | 24 +- server/{container.cpp => zone.cpp} | 122 +-- server/{container.hpp => zone.hpp} | 120 +-- ...manager-config.hpp => zones-manager-config.hpp} | 54 +- server/zones-manager.cpp | 888 +++++++++++++++++++++ .../{containers-manager.hpp => zones-manager.hpp} | 102 +-- .../image_tests/config_checker.py | 38 +- tests/integration_tests/image_tests/image_tests.py | 34 +- .../network_tests/network_common.py | 66 +- .../network_tests/network_tests.py | 6 +- tests/unit_tests/client/configs/CMakeLists.txt | 18 +- .../configs/ut-client/test-dbus-daemon.conf.in | 20 +- .../{containers => zones}/console1-dbus.conf.in | 6 +- .../configs/ut-client/zones}/console2-dbus.conf.in | 6 +- .../{containers => zones}/console3-dbus.conf.in | 6 +- tests/unit_tests/client/ut-client-utils.cpp | 6 +- tests/unit_tests/client/ut-client.cpp | 110 +-- .../dbus/configs/ut-connection/ut-dbus.conf | 4 +- tests/unit_tests/dbus/test-common.hpp | 2 +- tests/unit_tests/dbus/test-server.cpp | 2 +- tests/unit_tests/dbus/ut-connection.cpp | 6 +- tests/unit_tests/lxc/templates/minimal-dbus.sh | 4 +- tests/unit_tests/lxc/templates/minimal.sh | 4 +- tests/unit_tests/server/configs/CMakeLists.txt | 116 +-- .../system.d/org.tizen.containers.tests.conf | 14 - .../dbus-1/system.d/org.tizen.vasum.tests.conf | 14 + .../ut-containers-manager/buggy-daemon.conf.in | 17 - .../ut-containers-manager/test-daemon.conf.in | 17 - .../ut-containers-manager/test-dbus-daemon.conf.in | 24 - .../server/configs/ut-server/buggy-daemon.conf.in | 14 +- .../server/configs/ut-server/test-daemon.conf.in | 14 +- .../container1.conf => zones/zone1.conf} | 2 +- .../container2.conf => zones/zone2.conf} | 2 +- .../container3.conf => zones/zone3.conf} | 2 +- .../containers => ut-zone-admin/zones}/buggy.conf | 2 +- .../zones}/missing.conf | 2 +- .../zones}/test-no-shutdown.conf | 2 +- .../containers => ut-zone-admin/zones}/test.conf | 2 +- .../ut-dbus.conf | 4 +- .../ut-dbus.conf | 2 +- .../containers => ut-zone/zones}/buggy.conf | 2 +- .../containers => ut-zone/zones}/test-dbus.conf.in | 6 +- .../containers => ut-zone/zones}/test.conf | 2 +- .../configs/ut-zones-manager/buggy-daemon.conf.in | 17 + .../buggy-default-daemon.conf.in | 12 +- .../buggy-foreground-daemon.conf.in | 12 +- .../empty-dbus-daemon.conf.in | 12 +- .../templates/template.conf.in | 2 +- .../configs/ut-zones-manager/test-daemon.conf.in | 17 + .../ut-zones-manager/test-dbus-daemon.conf.in | 24 + .../ut-dbus.conf | 2 +- .../zones}/console1-dbus.conf.in | 6 +- .../zones}/console1.conf | 2 +- .../ut-zones-manager/zones}/console2-dbus.conf.in | 6 +- .../zones}/console2.conf | 2 +- .../zones}/console3-dbus.conf.in | 6 +- .../zones}/console3.conf | 2 +- tests/unit_tests/server/test-dbus-definitions.hpp | 4 +- tests/unit_tests/server/ut-server.cpp | 6 +- .../{ut-container-admin.cpp => ut-zone-admin.cpp} | 32 +- ...ainer-connection.cpp => ut-zone-connection.cpp} | 58 +- .../server/{ut-container.cpp => ut-zone.cpp} | 26 +- ...containers-manager.cpp => ut-zones-manager.cpp} | 580 +++++++------- {container-daemon => zone-daemon}/CMakeLists.txt | 20 +- .../configs/org.tizen.vasum.zone.daemon.conf.in | 14 + .../daemon-connection.cpp | 16 +- .../daemon-connection.hpp | 12 +- .../daemon-dbus-definitions.hpp | 18 +- {container-daemon => zone-daemon}/daemon.cpp | 4 +- {container-daemon => zone-daemon}/daemon.hpp | 10 +- {container-daemon => zone-daemon}/exception.hpp | 18 +- {container-daemon => zone-daemon}/main.cpp | 4 +- {container-daemon => zone-daemon}/runner.cpp | 14 +- {container-daemon => zone-daemon}/runner.hpp | 10 +- {container-support => zone-support}/CMakeLists.txt | 8 +- zone-support/configs/org.tizen.vasum.zone.conf.in | 14 + 119 files changed, 2493 insertions(+), 2493 deletions(-) delete mode 100644 container-daemon/configs/org.tizen.containers.zone.daemon.conf.in delete mode 100644 container-support/configs/org.tizen.containers.zone.conf.in rename packaging/{vasum-container-support.manifest => vasum-zone-daemon.manifest} (100%) rename packaging/{vasum-container-daemon.manifest => vasum-zone-support.manifest} (100%) delete mode 100644 server/configs/dbus-1/system.d/org.tizen.containers.host.conf.in create mode 100644 server/configs/dbus-1/system.d/org.tizen.vasum.host.conf.in rename server/configs/{containers => zones}/business.conf (100%) rename server/configs/{containers => zones}/private.conf (100%) delete mode 100644 server/containers-manager.cpp rename server/{container-admin.cpp => zone-admin.cpp} (71%) rename server/{container-admin.hpp => zone-admin.hpp} (60%) rename server/{container-config.hpp => zone-config.hpp} (70%) rename server/{container-connection-transport.cpp => zone-connection-transport.cpp} (77%) rename server/{container-connection-transport.hpp => zone-connection-transport.hpp} (73%) rename server/{container-connection.cpp => zone-connection.cpp} (72%) rename server/{container-connection.hpp => zone-connection.hpp} (85%) rename server/{container-dbus-definitions.hpp => zone-dbus-definitions.hpp} (85%) rename server/{container.cpp => zone.cpp} (72%) rename server/{container.hpp => zone.hpp} (61%) rename server/{containers-manager-config.hpp => zones-manager-config.hpp} (57%) create mode 100644 server/zones-manager.cpp rename server/{containers-manager.hpp => zones-manager.hpp} (56%) rename tests/unit_tests/client/configs/ut-client/{containers => zones}/console1-dbus.conf.in (73%) rename tests/unit_tests/{server/configs/ut-containers-manager/containers => client/configs/ut-client/zones}/console2-dbus.conf.in (73%) rename tests/unit_tests/client/configs/ut-client/{containers => zones}/console3-dbus.conf.in (72%) delete mode 100644 tests/unit_tests/server/configs/dbus-1/system.d/org.tizen.containers.tests.conf create mode 100644 tests/unit_tests/server/configs/dbus-1/system.d/org.tizen.vasum.tests.conf delete mode 100644 tests/unit_tests/server/configs/ut-containers-manager/buggy-daemon.conf.in delete mode 100644 tests/unit_tests/server/configs/ut-containers-manager/test-daemon.conf.in delete mode 100644 tests/unit_tests/server/configs/ut-containers-manager/test-dbus-daemon.conf.in rename tests/unit_tests/server/configs/ut-server/{containers/container1.conf => zones/zone1.conf} (91%) rename tests/unit_tests/server/configs/ut-server/{containers/container2.conf => zones/zone2.conf} (91%) rename tests/unit_tests/server/configs/ut-server/{containers/container3.conf => zones/zone3.conf} (91%) rename tests/unit_tests/server/configs/{ut-container-admin/containers => ut-zone-admin/zones}/buggy.conf (90%) rename tests/unit_tests/server/configs/{ut-container-admin/containers => ut-zone-admin/zones}/missing.conf (91%) rename tests/unit_tests/server/configs/{ut-container-admin/containers => ut-zone-admin/zones}/test-no-shutdown.conf (90%) rename tests/unit_tests/server/configs/{ut-container-admin/containers => ut-zone-admin/zones}/test.conf (91%) rename tests/unit_tests/server/configs/{ut-container-connection => ut-zone-connection}/ut-dbus.conf (76%) rename tests/unit_tests/server/configs/{ut-containers-manager => ut-zone}/ut-dbus.conf (89%) rename tests/unit_tests/server/configs/{ut-container/containers => ut-zone/zones}/buggy.conf (92%) rename tests/unit_tests/server/configs/{ut-container/containers => ut-zone/zones}/test-dbus.conf.in (75%) rename tests/unit_tests/server/configs/{ut-container/containers => ut-zone/zones}/test.conf (92%) create mode 100644 tests/unit_tests/server/configs/ut-zones-manager/buggy-daemon.conf.in rename tests/unit_tests/server/configs/{ut-containers-manager => ut-zones-manager}/buggy-default-daemon.conf.in (51%) rename tests/unit_tests/server/configs/{ut-containers-manager => ut-zones-manager}/buggy-foreground-daemon.conf.in (50%) rename tests/unit_tests/server/configs/{ut-containers-manager => ut-zones-manager}/empty-dbus-daemon.conf.in (65%) rename tests/unit_tests/server/configs/{ut-containers-manager => ut-zones-manager}/templates/template.conf.in (90%) create mode 100644 tests/unit_tests/server/configs/ut-zones-manager/test-daemon.conf.in create mode 100644 tests/unit_tests/server/configs/ut-zones-manager/test-dbus-daemon.conf.in rename tests/unit_tests/server/configs/{ut-container => ut-zones-manager}/ut-dbus.conf (89%) rename tests/unit_tests/server/configs/{ut-containers-manager/containers => ut-zones-manager/zones}/console1-dbus.conf.in (73%) rename tests/unit_tests/server/configs/{ut-containers-manager/containers => ut-zones-manager/zones}/console1.conf (90%) rename tests/unit_tests/{client/configs/ut-client/containers => server/configs/ut-zones-manager/zones}/console2-dbus.conf.in (73%) rename tests/unit_tests/server/configs/{ut-containers-manager/containers => ut-zones-manager/zones}/console2.conf (90%) rename tests/unit_tests/server/configs/{ut-containers-manager/containers => ut-zones-manager/zones}/console3-dbus.conf.in (72%) rename tests/unit_tests/server/configs/{ut-containers-manager/containers => ut-zones-manager/zones}/console3.conf (90%) rename tests/unit_tests/server/{ut-container-admin.cpp => ut-zone-admin.cpp} (80%) rename tests/unit_tests/server/{ut-container-connection.cpp => ut-zone-connection.cpp} (75%) rename tests/unit_tests/server/{ut-container.cpp => ut-zone.cpp} (78%) rename tests/unit_tests/server/{ut-containers-manager.cpp => ut-zones-manager.cpp} (62%) rename {container-daemon => zone-daemon}/CMakeLists.txt (65%) create mode 100644 zone-daemon/configs/org.tizen.vasum.zone.daemon.conf.in rename {container-daemon => zone-daemon}/daemon-connection.cpp (88%) rename {container-daemon => zone-daemon}/daemon-connection.hpp (87%) rename {container-daemon => zone-daemon}/daemon-dbus-definitions.hpp (71%) rename {container-daemon => zone-daemon}/daemon.cpp (96%) rename {container-daemon => zone-daemon}/daemon.hpp (87%) rename {container-daemon => zone-daemon}/exception.hpp (66%) rename {container-daemon => zone-daemon}/main.cpp (97%) rename {container-daemon => zone-daemon}/runner.cpp (85%) rename {container-daemon => zone-daemon}/runner.hpp (87%) rename {container-support => zone-support}/CMakeLists.txt (80%) create mode 100644 zone-support/configs/org.tizen.vasum.zone.conf.in diff --git a/CMakeLists.txt b/CMakeLists.txt index b302d18..588f066 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,8 +91,8 @@ ENDIF(NOT DEFINED PYTHON_SITELIB) 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) @@ -126,8 +126,8 @@ SET(VSM_DATA_INSTALL_DIR ${SHARE_INSTALL_PREFIX}/vasum) 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}) diff --git a/cli/command-line-interface.cpp b/cli/command-line-interface.cpp index ca75d25..d7d8439 100644 --- a/cli/command-line-interface.cpp +++ b/cli/command-line-interface.cpp @@ -132,7 +132,7 @@ void CommandLineInterface::execute(int pos, int argc, const char** argv) } -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; @@ -140,7 +140,7 @@ void set_active_container(int pos, int argc, const char** argv) 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) diff --git a/cli/command-line-interface.hpp b/cli/command-line-interface.hpp index 6ff4fb0..d2fe6be 100644 --- a/cli/command-line-interface.hpp +++ b/cli/command-line-interface.hpp @@ -97,11 +97,11 @@ private: }; /** - * 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 diff --git a/cli/main.cpp b/cli/main.cpp index c2e8ad8..e837d86 100644 --- a/cli/main.cpp +++ b/cli/main.cpp @@ -34,51 +34,51 @@ using namespace vasum::cli; std::map 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"}} } } }; diff --git a/client/utils.cpp b/client/utils.cpp index d6157c4..a5ff48e 100644 --- a/client/utils.cpp +++ b/client/utils.cpp @@ -117,7 +117,7 @@ bool parseNewLibvirtFormat(const std::string& cpuset, std::string& id) } // 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"; diff --git a/client/utils.hpp b/client/utils.hpp index b86cc20..d6b4057 100644 --- a/client/utils.hpp +++ b/client/utils.hpp @@ -27,6 +27,6 @@ #include -bool parseContainerIdFromCpuSet(const std::string& cpuset, std::string& id); +bool parseZoneIdFromCpuSet(const std::string& cpuset, std::string& id); #endif // VASUM_CLIENT_UTILS_HPP diff --git a/client/vasum-client-impl.cpp b/client/vasum-client-impl.cpp index e228409..c16c9d2 100644 --- a/client/vasum-client-impl.cpp +++ b/client/vasum-client-impl.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include @@ -46,9 +46,9 @@ namespace { 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 gGlibLoop; @@ -317,14 +317,14 @@ VsmStatus Client::vsm_get_status() noexcept 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); @@ -345,7 +345,7 @@ VsmStatus Client::vsm_get_zone_ids(VsmArrayString* array) noexcept GVariant* out; VsmStatus ret = callMethod(HOST_INTERFACE, - api::host::METHOD_GET_CONTAINER_ID_LIST, + api::host::METHOD_GET_ZONE_ID_LIST, NULL, "(as)", &out); @@ -360,13 +360,13 @@ VsmStatus Client::vsm_get_zone_ids(VsmArrayString* array) noexcept 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); @@ -393,13 +393,13 @@ VsmStatus Client::vsm_lookup_zone_by_pid(int pid, VsmString* id) noexcept 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(); } @@ -412,7 +412,7 @@ VsmStatus Client::vsm_lookup_zone_by_id(const char* id, VsmZone* zone) noexcept 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); @@ -433,12 +433,12 @@ VsmStatus Client::vsm_lookup_zone_by_terminal_id(int, VsmString*) noexcept 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 @@ -450,14 +450,14 @@ 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 @@ -477,7 +477,7 @@ VsmStatus Client::vsm_lock_zone(const char* id) 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 @@ -485,25 +485,25 @@ 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); } @@ -573,7 +573,7 @@ VsmStatus Client::vsm_lookup_netdev_by_name(const char*, const char*, VsmNetdev* 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, @@ -581,14 +581,14 @@ VsmStatus Client::vsm_declare_file(const char* container, { 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, @@ -601,45 +601,45 @@ VsmStatus Client::vsm_declare_mount(const char *source, 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); @@ -649,7 +649,7 @@ VsmStatus Client::vsm_file_move_request(const char* destContainer, const char* p } 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(); @@ -665,15 +665,15 @@ VsmStatus Client::vsm_add_notification_callback(VsmNotificationCallback notifica 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); } diff --git a/client/vasum-client-impl.hpp b/client/vasum-client-impl.hpp index f507c0a..18eb726 100644 --- a/client/vasum-client-impl.hpp +++ b/client/vasum-client-impl.hpp @@ -104,9 +104,9 @@ public: 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 @@ -114,9 +114,9 @@ public: 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 @@ -134,9 +134,9 @@ public: 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 @@ -171,7 +171,7 @@ public: /** * @see ::vsm_add_state_callback */ - VsmStatus vsm_add_state_callback(VsmContainerDbusStateCallback containerDbusStateCallback, + VsmStatus vsm_add_state_callback(VsmZoneDbusStateCallback zoneDbusStateCallback, void* data, VsmSubscriptionId* subscriptionId) noexcept; @@ -250,7 +250,7 @@ public: /** * @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, @@ -260,7 +260,7 @@ public: * @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, @@ -269,18 +269,18 @@ public: * @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 diff --git a/client/vasum-client.cpp b/client/vasum-client.cpp index c366a8e..2102432 100644 --- a/client/vasum-client.cpp +++ b/client/vasum-client.cpp @@ -118,9 +118,9 @@ API VsmStatus vsm_get_status(VsmClient client) 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) @@ -128,9 +128,9 @@ 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) @@ -148,9 +148,9 @@ API VsmStatus vsm_lookup_zone_by_terminal_id(VsmClient client, int terminal, Vsm 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) @@ -184,11 +184,11 @@ API VsmStatus vsm_unlock_zone(VsmClient client, const char* id) } 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) @@ -273,46 +273,46 @@ API VsmStatus vsm_lookup_netdev_by_name(VsmClient client, } 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, diff --git a/client/vasum-client.h b/client/vasum-client.h index b8137eb..3e1f66d 100644 --- a/client/vasum-client.h +++ b/client/vasum-client.h @@ -282,60 +282,60 @@ void vsm_netdev_free(VsmNetdev netdev); /** * @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. */ @@ -364,19 +364,19 @@ VsmStatus vsm_lookup_zone_by_id(VsmClient client, const char* id, VsmZone* zone) 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 */ @@ -386,7 +386,7 @@ VsmStatus vsm_create_zone(VsmClient client, const char* id, const char* tname); * 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 */ @@ -434,14 +434,14 @@ VsmStatus vsm_unlock_zone(VsmClient client, const char* id); * @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); @@ -591,37 +591,37 @@ VsmStatus vsm_lookup_netdev_by_name(VsmClient client, 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 @@ -629,27 +629,27 @@ VsmStatus vsm_declare_file(VsmClient client, */ 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); @@ -659,7 +659,7 @@ VsmStatus vsm_declare_link(VsmClient client, /** * @name Zone API * - * Functions using org.tizen.containers.zone.manager D-Bus interface. + * Functions using org.tizen.vasum.zone.manager D-Bus interface. * * @{ */ @@ -667,34 +667,34 @@ VsmStatus vsm_declare_link(VsmClient client, /** * 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. diff --git a/common/lxc/zone.cpp b/common/lxc/zone.cpp index ceded4b..b142de4 100644 --- a/common/lxc/zone.cpp +++ b/common/lxc/zone.cpp @@ -83,10 +83,10 @@ std::string LxcZone::toString(State state) } 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"); } @@ -94,18 +94,18 @@ LxcZone::LxcZone(const std::string& lxcPath, const std::string& zoneName) 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"); @@ -115,12 +115,12 @@ std::string LxcZone::getConfigItem(const std::string& key) 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); } @@ -129,9 +129,9 @@ bool LxcZone::create(const std::string& templatePath, const char* const* argv) #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++); @@ -145,10 +145,10 @@ bool LxcZone::create(const std::string& templatePath, const char* const* argv) refresh(); return true; #else - if (!mContainer->create(mContainer, - templatePath.c_str(), - NULL, NULL, 0, - const_cast(argv))) { + if (!mLxcContainer->create(mLxcContainer, + templatePath.c_str(), + NULL, NULL, 0, + const_cast(argv))) { LOGE("Could not create zone " << getName()); return false; } @@ -158,7 +158,7 @@ bool LxcZone::create(const std::string& templatePath, const char* const* argv) bool LxcZone::destroy() { - if (!mContainer->destroy(mContainer)) { + if (!mLxcContainer->destroy(mLxcContainer)) { LOGE("Could not destroy zone " << getName()); return false; } @@ -168,7 +168,7 @@ bool LxcZone::destroy() 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; } @@ -176,8 +176,8 @@ bool LxcZone::start(const char* const* argv) 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) { @@ -192,21 +192,21 @@ bool LxcZone::start(const char* const* 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(argv))) { + if (!mLxcContainer->start(mLxcContainer, false, const_cast(argv))) { LOGE("Could not start zone " << getName()); return false; } @@ -216,7 +216,7 @@ bool LxcZone::start(const char* const* argv) bool LxcZone::stop() { - if (!mContainer->stop(mContainer)) { + if (!mLxcContainer->stop(mLxcContainer)) { LOGE("Could not stop zone " << getName()); return false; } @@ -225,7 +225,7 @@ bool LxcZone::stop() bool LxcZone::reboot() { - if (!mContainer->reboot(mContainer)) { + if (!mLxcContainer->reboot(mLxcContainer)) { LOGE("Could not reboot zone " << getName()); return false; } @@ -247,8 +247,8 @@ bool LxcZone::shutdown(int timeout) 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"); @@ -271,7 +271,7 @@ bool LxcZone::shutdown(int timeout) 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; } @@ -281,7 +281,7 @@ bool LxcZone::shutdown(int timeout) bool LxcZone::freeze() { - if (!mContainer->freeze(mContainer)) { + if (!mLxcContainer->freeze(mLxcContainer)) { LOGE("Could not freeze zone " << getName()); return false; } @@ -290,7 +290,7 @@ bool LxcZone::freeze() bool LxcZone::unfreeze() { - if (!mContainer->unfreeze(mContainer)) { + if (!mLxcContainer->unfreeze(mLxcContainer)) { LOGE("Could not unfreeze zone " << getName()); return false; } @@ -299,7 +299,7 @@ bool LxcZone::unfreeze() 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; } @@ -315,7 +315,7 @@ bool LxcZone::setRunLevel(int runLevel) 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; } @@ -329,10 +329,10 @@ bool LxcZone::setRunLevel(int runLevel) 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()); } diff --git a/common/lxc/zone.hpp b/common/lxc/zone.hpp index 9b29f6f..1573c7d 100644 --- a/common/lxc/zone.hpp +++ b/common/lxc/zone.hpp @@ -35,7 +35,7 @@ namespace lxc { /** - * A class wwapping lxc container + * A class wrapping lxc container */ class LxcZone { public: @@ -52,7 +52,7 @@ 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); @@ -137,7 +137,7 @@ public: */ bool unfreeze(); private: - lxc_container* mContainer; + lxc_container* mLxcContainer; bool setRunLevel(int runLevel); void refresh(); diff --git a/container-daemon/configs/org.tizen.containers.zone.daemon.conf.in b/container-daemon/configs/org.tizen.containers.zone.daemon.conf.in deleted file mode 100644 index f66921a..0000000 --- a/container-daemon/configs/org.tizen.containers.zone.daemon.conf.in +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - diff --git a/container-support/configs/org.tizen.containers.zone.conf.in b/container-support/configs/org.tizen.containers.zone.conf.in deleted file mode 100644 index 384c8c6..0000000 --- a/container-support/configs/org.tizen.containers.zone.conf.in +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - diff --git a/packaging/vasum-container-support.manifest b/packaging/vasum-zone-daemon.manifest similarity index 100% rename from packaging/vasum-container-support.manifest rename to packaging/vasum-zone-daemon.manifest diff --git a/packaging/vasum-container-daemon.manifest b/packaging/vasum-zone-support.manifest similarity index 100% rename from packaging/vasum-container-daemon.manifest rename to packaging/vasum-zone-support.manifest diff --git a/packaging/vasum.spec b/packaging/vasum.spec index 74114e3..78db5de 100644 --- a/packaging/vasum.spec +++ b/packaging/vasum.spec @@ -15,7 +15,7 @@ Release: 0 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 @@ -32,25 +32,25 @@ Requires(post): libcap-tools 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 @@ -150,37 +150,37 @@ Development package including the header files for the client library %{_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 ###################################################### @@ -221,4 +221,4 @@ Unit tests for both: server and client and integration tests. %{_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 diff --git a/server/common-dbus-definitions.hpp b/server/common-dbus-definitions.hpp index de355b3..178f363 100644 --- a/server/common-dbus-definitions.hpp +++ b/server/common-dbus-definitions.hpp @@ -30,11 +30,11 @@ 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"; diff --git a/server/configs/CMakeLists.txt b/server/configs/CMakeLists.txt index cb4d003..b5c9286 100644 --- a/server/configs/CMakeLists.txt +++ b/server/configs/CMakeLists.txt @@ -19,7 +19,7 @@ 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) @@ -33,14 +33,14 @@ INSTALL(FILES daemon.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) diff --git a/server/configs/daemon.conf b/server/configs/daemon.conf index 7a0f8c1..714640e 100644 --- a/server/configs/daemon.conf +++ b/server/configs/daemon.conf @@ -1,10 +1,10 @@ { - "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", diff --git a/server/configs/dbus-1/system.d/org.tizen.containers.host.conf.in b/server/configs/dbus-1/system.d/org.tizen.containers.host.conf.in deleted file mode 100644 index 948a731..0000000 --- a/server/configs/dbus-1/system.d/org.tizen.containers.host.conf.in +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/server/configs/dbus-1/system.d/org.tizen.vasum.host.conf.in b/server/configs/dbus-1/system.d/org.tizen.vasum.host.conf.in new file mode 100644 index 0000000..81f9540 --- /dev/null +++ b/server/configs/dbus-1/system.d/org.tizen.vasum.host.conf.in @@ -0,0 +1,20 @@ + + + + + + + + + + + + + + + + + + + diff --git a/server/configs/lxc-templates/template.sh b/server/configs/lxc-templates/template.sh index 531ec30..c73bd01 100755 --- a/server/configs/lxc-templates/template.sh +++ b/server/configs/lxc-templates/template.sh @@ -25,7 +25,7 @@ br_name="virbr-${name}" # XXX assume rootfs if mounted from iso -# Prepare container configuration file +# Prepare zone configuration file > ${path}/config cat <> ${path}/config lxc.utsname = ${name} @@ -39,9 +39,9 @@ lxc.pts = 256 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 diff --git a/server/configs/lxc-templates/tizen-common-wayland.sh b/server/configs/lxc-templates/tizen-common-wayland.sh index 002e1f7..ed2df9b 100755 --- a/server/configs/lxc-templates/tizen-common-wayland.sh +++ b/server/configs/lxc-templates/tizen-common-wayland.sh @@ -22,17 +22,17 @@ usage() { cat < + $1 -n|--name= [-p|--path=] [-r|--rootfs=] [-v|--vt=] [--ipv4=] [--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 @@ -66,7 +66,7 @@ if [ "$(id -u)" != "0" ]; then fi if [ -z $name ]; then - echo "Container name must be given" + echo "Zone name must be given" exit 1 fi @@ -77,7 +77,7 @@ fi br_name="virbr-${name}" -# Prepare container rootfs +# Prepare zone rootfs ROOTFS_DIRS="\ ${rootfs}/bin \ ${rootfs}/dev \ @@ -181,7 +181,7 @@ XDG_CONFIG_HOME=/etc/systemd/system EOF cat <>${path}/systemd/system/weston.ini -# Weston config for container. +# Weston config for zone. [core] modules=desktop-shell.so @@ -290,7 +290,7 @@ RestartSec=10 WantedBy=graphical.target EOF -# Prepare container configuration file +# Prepare zone configuration file cat <>${path}/config lxc.utsname = ${name} lxc.rootfs = ${rootfs} @@ -343,7 +343,7 @@ lxc.kmsg = 0 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 @@ -358,7 +358,7 @@ lxc.hook.pre-start = ${path}/hooks/pre-start.sh #lxc.hook.post-stop = ${path}/hooks/post-stop.sh EOF -# Prepare container hook files +# Prepare zone hook files cat <>${path}/hooks/pre-start.sh if [ -z "\$(/usr/sbin/brctl show | /bin/grep -P "${br_name}\t")" ] then @@ -375,7 +375,7 @@ EOF chmod 770 ${path}/hooks/pre-start.sh -# Prepare container fstab file +# Prepare zone fstab file cat <>${path}/fstab /bin bin none ro,bind 0 0 /etc etc none ro,bind 0 0 diff --git a/server/configs/containers/business.conf b/server/configs/zones/business.conf similarity index 100% rename from server/configs/containers/business.conf rename to server/configs/zones/business.conf diff --git a/server/configs/containers/private.conf b/server/configs/zones/private.conf similarity index 100% rename from server/configs/containers/private.conf rename to server/configs/zones/private.conf diff --git a/server/containers-manager.cpp b/server/containers-manager.cpp deleted file mode 100644 index fa3f157..0000000 --- a/server/containers-manager.cpp +++ /dev/null @@ -1,888 +0,0 @@ -/* - * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved - * - * Contact: Jan Olszak - * - * 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 -#include -#include -#include -#include -#include - - -namespace vasum { - - -namespace { - -bool regexMatchVector(const std::string& str, const std::vector& 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 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 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 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 diff --git a/server/exception.hpp b/server/exception.hpp index 55d7727..09eaaef 100644 --- a/server/exception.hpp +++ b/server/exception.hpp @@ -41,20 +41,20 @@ struct ServerException: public VasumException { }; /** - * 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) {} }; /** diff --git a/server/fake-power-manager-dbus-definitions.hpp b/server/fake-power-manager-dbus-definitions.hpp index f24bc81..0abeb73 100644 --- a/server/fake-power-manager-dbus-definitions.hpp +++ b/server/fake-power-manager-dbus-definitions.hpp @@ -20,7 +20,7 @@ * @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 @@ -29,7 +29,7 @@ /** * !!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. */ diff --git a/server/host-connection.cpp b/server/host-connection.cpp index 37eaeba..1eed929 100644 --- a/server/host-connection.cpp +++ b/server/host-connection.cpp @@ -110,24 +110,24 @@ void HostConnection::setProxyCallCallback(const ProxyCallCallback& callback) 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) @@ -145,29 +145,29 @@ void HostConnection::setDeclareLinkCallback(const DeclareLinkCallback& 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; } @@ -181,19 +181,19 @@ void HostConnection::onMessageCall(const std::string& objectPath, 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; } @@ -227,47 +227,47 @@ void HostConnection::onMessageCall(const std::string& objectPath, 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; @@ -275,63 +275,63 @@ void HostConnection::onMessageCall(const std::string& objectPath, 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); } } } @@ -352,13 +352,13 @@ void HostConnection::proxyCallAsync(const std::string& busName, 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); } diff --git a/server/host-connection.hpp b/server/host-connection.hpp index b5f581c..68e3a73 100644 --- a/server/host-connection.hpp +++ b/server/host-connection.hpp @@ -52,15 +52,15 @@ public: dbus::MethodResultBuilder::Pointer result )> ProxyCallCallback; typedef std::function GetContainerDbusesCallback; + )> GetZoneDbusesCallback; typedef std::function GetContainerIdsCallback; + )> GetZoneIdsCallback; typedef std::function GetActiveContainerIdCallback; + )> GetActiveZoneIdCallback; typedef std::function GetContainerInfoCallback; - typedef std::function GetZoneInfoCallback; + typedef std::function DeclareFileCallback; typedef std::function DeclareMountCallback; typedef std::function DeclareLinkCallback; typedef std::function SetActiveContainerCallback; + )> SetActiveZoneCallback; typedef std::function CreateContainerCallback; + )> CreateZoneCallback; typedef std::function DestroyContainerCallback; + )> DestroyZoneCallback; typedef std::function LockContainerCallback; + )> LockZoneCallback; typedef std::function UnlockContainerCallback; + )> UnlockZoneCallback; /** * Register proxy call callback @@ -102,29 +102,29 @@ public: 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 @@ -142,29 +142,29 @@ public: 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 @@ -183,18 +183,18 @@ private: 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(); diff --git a/server/host-dbus-definitions.hpp b/server/host-dbus-definitions.hpp index 15ace0d..998c720 100644 --- a/server/host-dbus-definitions.hpp +++ b/server/host-dbus-definitions.hpp @@ -32,26 +32,26 @@ namespace vasum { 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 = @@ -66,21 +66,21 @@ const std::string DEFINITION = " " " " " " - " " + " " " " " " - " " + " " " " " " - " " + " " " " " " - " " + " " " " " " " " " " - " " + " " " " " " " " @@ -88,7 +88,7 @@ const std::string DEFINITION = " " " " " " - " " + " " " " " " " " @@ -96,26 +96,26 @@ const std::string DEFINITION = " " " " " " - " " + " " " " " " - " " + " " " " " " - " " + " " " " " " - " " + " " " " " " - " " + " " " " " " - " " + " " " " " " - " " - " " + " " + " " " " " " " " diff --git a/server/provisioning-config.hpp b/server/provisioning-config.hpp index e5cf456..5a9f5ff 100644 --- a/server/provisioning-config.hpp +++ b/server/provisioning-config.hpp @@ -19,7 +19,7 @@ /** * @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 */ @@ -32,9 +32,9 @@ #include -namespace security_containers { +namespace vasum { -struct ContainerProvisioning +struct ZoneProvisioning { struct File @@ -101,6 +101,6 @@ struct ContainerProvisioning ) }; -} +} // namespace vasum #endif // SERVER_PROVISIONING_CONFIG_HPP diff --git a/server/proxy-call-config.hpp b/server/proxy-call-config.hpp index 3bb734c..e062eaf 100644 --- a/server/proxy-call-config.hpp +++ b/server/proxy-call-config.hpp @@ -39,8 +39,8 @@ namespace vasum { */ 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 diff --git a/server/server.cpp b/server/server.cpp index f2d70c1..d9a1628 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -25,7 +25,7 @@ #include "config.hpp" #include "server.hpp" -#include "containers-manager.hpp" +#include "zones-manager.hpp" #include "exception.hpp" #include "config/manager.hpp" @@ -109,16 +109,16 @@ void Server::run() 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..."); @@ -146,8 +146,8 @@ bool Server::prepareEnvironment(const std::string& configPath, bool runAsRoot) { 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); @@ -169,9 +169,9 @@ bool Server::prepareEnvironment(const std::string& configPath, bool runAsRoot) } } - // 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)) { @@ -186,8 +186,8 @@ bool Server::prepareEnvironment(const std::string& configPath, bool runAsRoot) } // 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; } @@ -195,9 +195,9 @@ bool Server::prepareEnvironment(const std::string& configPath, bool runAsRoot) // 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//run" mount point. + // "/var/run/zones//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, diff --git a/server/server.hpp b/server/server.hpp index 525eb23..009a468 100644 --- a/server/server.hpp +++ b/server/server.hpp @@ -45,7 +45,7 @@ public: 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(); diff --git a/server/container-admin.cpp b/server/zone-admin.cpp similarity index 71% rename from server/container-admin.cpp rename to server/zone-admin.cpp index e00fd71..42c71ea 100644 --- a/server/container-admin.cpp +++ b/server/zone-admin.cpp @@ -19,12 +19,12 @@ /** * @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" @@ -38,7 +38,7 @@ namespace vasum { 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 @@ -46,16 +46,16 @@ const int SHUTDOWN_WAIT = 10; 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()) { @@ -72,43 +72,43 @@ ContainerAdmin::ContainerAdmin(const std::string& containersPath, 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()) { @@ -125,14 +125,14 @@ void ContainerAdmin::start() } 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()) { @@ -143,7 +143,7 @@ void ContainerAdmin::stop() if (!mZone.shutdown(SHUTDOWN_WAIT)) { // force stop if (!mZone.stop()) { - throw ContainerOperationException("Could not stop container"); + throw ZoneOperationException("Could not stop zone"); } } @@ -151,57 +151,57 @@ void ContainerAdmin::stop() } -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: @@ -222,8 +222,8 @@ void ContainerAdmin::setSchedulerLevel(SchedulerLevel sched) } -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); // @@ -239,23 +239,23 @@ void ContainerAdmin::setSchedulerParams(std::uint64_t, std::uint64_t, std::int64 // 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); // @@ -263,17 +263,17 @@ std::int64_t ContainerAdmin::getSchedulerQuota() // std::unique_ptr 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 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; @@ -281,9 +281,9 @@ std::int64_t ContainerAdmin::getSchedulerQuota() // 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; diff --git a/server/container-admin.hpp b/server/zone-admin.hpp similarity index 60% rename from server/container-admin.hpp rename to server/zone-admin.hpp index 050d9d9..1d31ab4 100644 --- a/server/container-admin.hpp +++ b/server/zone-admin.hpp @@ -19,14 +19,14 @@ /** * @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" @@ -38,85 +38,85 @@ enum class SchedulerLevel { 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(); @@ -127,7 +127,7 @@ public: std::int64_t getSchedulerQuota(); private: - const ContainerConfig& mConfig; + const ZoneConfig& mConfig; lxc::LxcZone mZone; const std::string mId; bool mDetachOnExit; @@ -140,4 +140,4 @@ private: } // namespace vasum -#endif // SERVER_CONTAINER_ADMIN_HPP +#endif // SERVER_ZONE_ADMIN_HPP diff --git a/server/container-config.hpp b/server/zone-config.hpp similarity index 70% rename from server/container-config.hpp rename to server/zone-config.hpp index d9331b3..b801af8 100644 --- a/server/container-config.hpp +++ b/server/zone-config.hpp @@ -19,12 +19,12 @@ /** * @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" @@ -35,10 +35,10 @@ namespace vasum { -struct ContainerConfig { +struct ZoneConfig { /** - * Container name + * Zone name */ std::string name; @@ -63,51 +63,51 @@ struct ContainerConfig { 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 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 permittedToRecv; @@ -134,4 +134,4 @@ struct ContainerConfig { } // namespace vasum -#endif // SERVER_CONTAINER_CONFIG_HPP +#endif // SERVER_ZONE_CONFIG_HPP diff --git a/server/container-connection-transport.cpp b/server/zone-connection-transport.cpp similarity index 77% rename from server/container-connection-transport.cpp rename to server/zone-connection-transport.cpp index bbbfdcf..d209705 100644 --- a/server/container-connection-transport.cpp +++ b/server/zone-connection-transport.cpp @@ -19,12 +19,12 @@ /** * @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" @@ -39,14 +39,14 @@ namespace vasum { 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()) { @@ -56,14 +56,14 @@ ContainerConnectionTransport::ContainerConnectionTransport(const std::string& ru 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."); } @@ -72,23 +72,23 @@ ContainerConnectionTransport::ContainerConnectionTransport(const std::string& ru 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()) { @@ -100,7 +100,7 @@ ContainerConnectionTransport::~ContainerConnectionTransport() } -std::string ContainerConnectionTransport::acquireAddress() +std::string ZoneConnectionTransport::acquireAddress() { if (mRunMountPoint.empty()) { return std::string(); @@ -115,7 +115,7 @@ std::string ContainerConnectionTransport::acquireAddress() return "unix:path=" + dbusPath; } -void ContainerConnectionTransport::setDetachOnExit() +void ZoneConnectionTransport::setDetachOnExit() { mDetachOnExit = true; } diff --git a/server/container-connection-transport.hpp b/server/zone-connection-transport.hpp similarity index 73% rename from server/container-connection-transport.hpp rename to server/zone-connection-transport.hpp index 5e7c9e8..5729389 100644 --- a/server/container-connection-transport.hpp +++ b/server/zone-connection-transport.hpp @@ -19,12 +19,12 @@ /** * @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" @@ -33,13 +33,13 @@ namespace vasum { /** - * 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. @@ -60,4 +60,4 @@ private: } // namespace vasum -#endif // SERVER_CONTAINER_CONNECTION_TRANSPORT_HPP +#endif // SERVER_ZONE_CONNECTION_TRANSPORT_HPP diff --git a/server/container-connection.cpp b/server/zone-connection.cpp similarity index 72% rename from server/container-connection.cpp rename to server/zone-connection.cpp index 8e18590..35341b3 100644 --- a/server/container-connection.cpp +++ b/server/zone-connection.cpp @@ -19,13 +19,13 @@ /** * @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" @@ -39,39 +39,39 @@ namespace { // 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, @@ -79,7 +79,7 @@ ContainerConnection::ContainerConnection(const std::string& address, const OnNam _4, _5)); - mDbusConnection->signalSubscribe(std::bind(&ContainerConnection::onSignalReceived, + mDbusConnection->signalSubscribe(std::bind(&ZoneConnection::onSignalReceived, this, _1, _2, @@ -91,11 +91,11 @@ ContainerConnection::ContainerConnection(const std::string& address, const OnNam 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 lock(mNameMutex); mNameCondition.wait_for(lock, @@ -110,14 +110,14 @@ bool ContainerConnection::waitForNameAndSetCallback(const unsigned int timeoutMs return mNameAcquired; } -void ContainerConnection::onNameAcquired() +void ZoneConnection::onNameAcquired() { std::unique_lock lock(mNameMutex); mNameAcquired = true; mNameCondition.notify_one(); } -void ContainerConnection::onNameLost() +void ZoneConnection::onNameLost() { std::unique_lock lock(mNameMutex); mNameLost = true; @@ -128,49 +128,49 @@ void ContainerConnection::onNameLost() } } -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); @@ -208,7 +208,7 @@ void ContainerConnection::onMessageCall(const std::string& objectPath, } } -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, @@ -225,21 +225,21 @@ void ContainerConnection::onSignalReceived(const std::string& senderBusName, } } -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, diff --git a/server/container-connection.hpp b/server/zone-connection.hpp similarity index 85% rename from server/container-connection.hpp rename to server/zone-connection.hpp index cb41b7f..78b6e56 100644 --- a/server/container-connection.hpp +++ b/server/zone-connection.hpp @@ -19,12 +19,12 @@ /** * @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" @@ -35,20 +35,20 @@ namespace vasum { -class ContainerConnection { +class ZoneConnection { public: typedef std::function OnNameLostCallback; typedef std::function DisplayOffCallback; - ContainerConnection(const std::string& address, const OnNameLostCallback& callback); - ~ContainerConnection(); + ZoneConnection(const std::string& address, const OnNameLostCallback& callback); + ~ZoneConnection(); // ------------- API -------------- typedef std::function NotifyActiveContainerCallback; + )> NotifyActiveZoneCallback; typedef std::function" - " " + " " " " " " " " @@ -70,16 +70,16 @@ const std::string DEFINITION = " " " " " " - " " + " " " " " " " " " " ""; -} // namespace container +} // namespace zone } // namespace api } // namespace vasum -#endif // SERVER_CONTAINER_DBUS_DEFINITIONS_HPP +#endif // SERVER_ZONE_DBUS_DEFINITIONS_HPP diff --git a/server/container.cpp b/server/zone.cpp similarity index 72% rename from server/container.cpp rename to server/zone.cpp index b3be5a5..2e4573c 100644 --- a/server/container.cpp +++ b/server/zone.cpp @@ -19,12 +19,12 @@ /** * @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" @@ -50,12 +50,12 @@ typedef std::lock_guard Lock; // 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); } @@ -65,12 +65,12 @@ void declareUnit(const std::string& file, ContainerProvisioning::Unit&& unit) } // 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)); @@ -83,12 +83,12 @@ Container::Container(const std::string& containersPath, 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 @@ -107,32 +107,32 @@ Container::~Container() } } -const std::vector& Container::getPermittedToSend() const +const std::vector& Zone::getPermittedToSend() const { return mPermittedToSend; } -const std::vector& Container::getPermittedToRecv() const +const std::vector& 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) { @@ -144,7 +144,7 @@ void Container::start() goBackground(); } -void Container::startAsync(const StartAsyncResultCallback& callback) +void Zone::startAsync(const StartAsyncResultCallback& callback) { if (mStartThread.joinable()) { mStartThread.join(); @@ -168,7 +168,7 @@ void Container::startAsync(const StartAsyncResultCallback& callback) mStartThread = std::thread(startWrapper); } -void Container::stop() +void Zone::stop() { Lock lock(mReconnectMutex); disconnect(); @@ -176,14 +176,14 @@ void Container::stop() 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); @@ -199,31 +199,31 @@ void Container::connect() } } -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); @@ -234,19 +234,19 @@ bool Container::activateVT() 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(); @@ -255,58 +255,58 @@ void Container::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); @@ -333,32 +333,32 @@ void Container::reconnectHandler() } } - 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); @@ -368,7 +368,7 @@ void Container::setDisplayOffCallback(const DisplayOffCallback& callback) } } -void Container::setFileMoveRequestCallback(const FileMoveRequestCallback& callback) +void Zone::setFileMoveRequestCallback(const FileMoveRequestCallback& callback) { Lock lock(mReconnectMutex); @@ -378,7 +378,7 @@ void Container::setFileMoveRequestCallback(const FileMoveRequestCallback& callba } } -void Container::setProxyCallCallback(const ProxyCallCallback& callback) +void Zone::setProxyCallCallback(const ProxyCallCallback& callback) { Lock lock(mReconnectMutex); @@ -388,12 +388,12 @@ void Container::setProxyCallCallback(const ProxyCallCallback& callback) } } -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, @@ -413,34 +413,34 @@ void Container::proxyCallAsync(const std::string& busName, } } -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)); } diff --git a/server/container.hpp b/server/zone.hpp similarity index 61% rename from server/container.hpp rename to server/zone.hpp index 88f5171..5ee95af 100644 --- a/server/container.hpp +++ b/server/zone.hpp @@ -19,17 +19,17 @@ /** * @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 #include @@ -40,148 +40,148 @@ 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 DbusStateChangedCallback; typedef std::function 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& 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& 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); @@ -191,13 +191,13 @@ public: 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); @@ -232,14 +232,14 @@ public: 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, @@ -247,22 +247,22 @@ public: 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 mPermittedToSend; std::vector mPermittedToRecv; - std::unique_ptr mConnectionTransport; - std::unique_ptr mAdmin; - std::unique_ptr mConnection; + std::unique_ptr mConnectionTransport; + std::unique_ptr mAdmin; + std::unique_ptr mConnection; std::thread mReconnectThread; std::thread mStartThread; mutable std::recursive_mutex mReconnectMutex; - NotifyActiveContainerCallback mNotifyCallback; + NotifyActiveZoneCallback mNotifyCallback; DisplayOffCallback mDisplayOffCallback; FileMoveRequestCallback mFileMoveCallback; ProxyCallCallback mProxyCallCallback; @@ -280,4 +280,4 @@ private: } // namespace vasum -#endif // SERVER_CONTAINER_HPP +#endif // SERVER_ZONE_HPP diff --git a/server/containers-manager-config.hpp b/server/zones-manager-config.hpp similarity index 57% rename from server/containers-manager-config.hpp rename to server/zones-manager-config.hpp index 58509a8..1838d25 100644 --- a/server/containers-manager-config.hpp +++ b/server/zones-manager-config.hpp @@ -19,12 +19,12 @@ /** * @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" @@ -37,46 +37,46 @@ 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 containerConfigs; + std::vector 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 @@ -84,12 +84,12 @@ struct ContainersManagerConfig { 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; @@ -100,13 +100,13 @@ struct ContainersManagerConfig { CONFIG_REGISTER ( - containerConfigs, + zoneConfigs, foregroundId, defaultId, - containersPath, - containerImagePath, - containerTemplatePath, - containerNewConfigPrefix, + zonesPath, + zoneImagePath, + zoneTemplatePath, + zoneNewConfigPrefix, lxcTemplatePrefix, inputConfig, runMountPointPrefix, @@ -118,4 +118,4 @@ struct ContainersManagerConfig { } // namespace vasum -#endif // SERVER_CONTAINERS_MANAGER_CONFIG_HPP +#endif // SERVER_ZONES_MANAGER_CONFIG_HPP diff --git a/server/zones-manager.cpp b/server/zones-manager.cpp new file mode 100644 index 0000000..6744c30 --- /dev/null +++ b/server/zones-manager.cpp @@ -0,0 +1,888 @@ +/* + * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: Jan Olszak + * + * 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 +#include +#include +#include +#include +#include + + +namespace vasum { + + +namespace { + +bool regexMatchVector(const std::string& str, const std::vector& 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 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 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 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 diff --git a/server/containers-manager.hpp b/server/zones-manager.hpp similarity index 56% rename from server/containers-manager.hpp rename to server/zones-manager.hpp index b9773e9..2fc0305 100644 --- a/server/containers-manager.hpp +++ b/server/zones-manager.hpp @@ -19,15 +19,15 @@ /** * @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" @@ -40,79 +40,79 @@ 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 mSwitchingSequenceMonitor; std::unique_ptr mProxyCallPolicy; - typedef std::unordered_map> ContainerMap; - ContainerMap mContainers; // map of containers, id is the key + typedef std::unordered_map> ZoneMap; + ZoneMap mZones; // map of zones, id is the key bool mDetachOnExit; void switchingSequenceMonitorNotify(); @@ -120,12 +120,12 @@ private: 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, @@ -136,37 +136,37 @@ private: 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); }; @@ -174,4 +174,4 @@ private: } // namespace vasum -#endif // SERVER_CONTAINERS_MANAGER_HPP +#endif // SERVER_ZONES_MANAGER_HPP diff --git a/tests/integration_tests/image_tests/config_checker.py b/tests/integration_tests/image_tests/config_checker.py index 035c460..0d47b8e 100644 --- a/tests/integration_tests/image_tests/config_checker.py +++ b/tests/integration_tests/image_tests/config_checker.py @@ -1,4 +1,4 @@ -'''! 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) ''' @@ -11,11 +11,11 @@ from pprint import pprint 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 ''' @@ -43,20 +43,20 @@ class ConfigChecker: 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): @@ -66,21 +66,21 @@ class ConfigChecker: 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: diff --git a/tests/integration_tests/image_tests/image_tests.py b/tests/integration_tests/image_tests/image_tests.py index 79f72e8..6898bdc 100644 --- a/tests/integration_tests/image_tests/image_tests.py +++ b/tests/integration_tests/image_tests/image_tests.py @@ -1,4 +1,4 @@ -'''! Module used to test containers' images completeness +'''! Module used to test zones' images completeness @author: Michal Witanowski (m.witanowski@samsung.com) ''' @@ -12,50 +12,50 @@ import xml.etree.ElementTree as ET 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() @@ -85,4 +85,4 @@ class ContainerImageTestCase(unittest.TestCase): 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") diff --git a/tests/integration_tests/network_tests/network_common.py b/tests/integration_tests/network_tests/network_common.py index 3432c88..945b255 100755 --- a/tests/integration_tests/network_tests/network_common.py +++ b/tests/integration_tests/network_tests/network_common.py @@ -28,18 +28,18 @@ DEBUG_COMMAND=False # 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 " @@ -125,10 +125,10 @@ def runCommandAndReadOutput(cmd): 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 @@ -154,7 +154,7 @@ def getActiveEthernetDevice(): 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]) @@ -180,11 +180,11 @@ def test_result(expected_result, result): # ---------------------------------------------------------- # 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): @@ -198,14 +198,14 @@ def internetAccessTest(container): # ---------------------------------------------------------- # 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"): @@ -215,7 +215,7 @@ def printInternetAccessTestStatus(container, testInfo1): def networkVisibiltyTestStatus(src, dest, ip, testInfo2): - text = " Container access: " + src + \ + text = " Zone access: " + src + \ " -> " + dest + \ " [" + ip + "]" + \ "; TCS = " + testInfo2.testItemResult[len(testInfo2.testItemResult)-1] @@ -226,15 +226,15 @@ def networkVisibiltyTestStatus(src, dest, ip, testInfo2): 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] @@ -243,17 +243,17 @@ def twoNetworks(): 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): @@ -264,22 +264,22 @@ def twoNetworks(): 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): @@ -290,7 +290,7 @@ def twoNetworks(): 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") diff --git a/tests/integration_tests/network_tests/network_tests.py b/tests/integration_tests/network_tests/network_tests.py index fb10195..980830e 100644 --- a/tests/integration_tests/network_tests/network_tests.py +++ b/tests/integration_tests/network_tests/network_tests.py @@ -16,7 +16,7 @@ # @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) ''' @@ -35,9 +35,9 @@ class NetworkTestCase(unittest.TestCase): 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 diff --git a/tests/unit_tests/client/configs/CMakeLists.txt b/tests/unit_tests/client/configs/CMakeLists.txt index c4bbda2..8742612 100644 --- a/tests/unit_tests/client/configs/CMakeLists.txt +++ b/tests/unit_tests/client/configs/CMakeLists.txt @@ -24,16 +24,16 @@ CONFIGURE_FILE(ut-client/test-dbus-daemon.conf.in ${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) diff --git a/tests/unit_tests/client/configs/ut-client/test-dbus-daemon.conf.in b/tests/unit_tests/client/configs/ut-client/test-dbus-daemon.conf.in index 33a8a0d..1b90e67 100644 --- a/tests/unit_tests/client/configs/ut-client/test-dbus-daemon.conf.in +++ b/tests/unit_tests/client/configs/ut-client/test-dbus-daemon.conf.in @@ -1,13 +1,13 @@ { - "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, @@ -17,7 +17,7 @@ "timeWindowMs" : 500}, "proxyCallRules" : [{"caller" : "*", "target" : "*", - "targetBusName" : "org.tizen.containers.tests", + "targetBusName" : "org.tizen.vasum.tests", "targetObjectPath" : "*", "targetInterface" : "*", "targetMethod" : "*"}] diff --git a/tests/unit_tests/client/configs/ut-client/containers/console1-dbus.conf.in b/tests/unit_tests/client/configs/ut-client/zones/console1-dbus.conf.in similarity index 73% rename from tests/unit_tests/client/configs/ut-client/containers/console1-dbus.conf.in rename to tests/unit_tests/client/configs/ut-client/zones/console1-dbus.conf.in index 4bf616c..72fbdbf 100644 --- a/tests/unit_tests/client/configs/ut-client/containers/console1-dbus.conf.in +++ b/tests/unit_tests/client/configs/ut-client/zones/console1-dbus.conf.in @@ -1,7 +1,7 @@ { - "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, @@ -10,7 +10,7 @@ "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/.*" ] } diff --git a/tests/unit_tests/server/configs/ut-containers-manager/containers/console2-dbus.conf.in b/tests/unit_tests/client/configs/ut-client/zones/console2-dbus.conf.in similarity index 73% rename from tests/unit_tests/server/configs/ut-containers-manager/containers/console2-dbus.conf.in rename to tests/unit_tests/client/configs/ut-client/zones/console2-dbus.conf.in index 4ca2215..1386878 100644 --- a/tests/unit_tests/server/configs/ut-containers-manager/containers/console2-dbus.conf.in +++ b/tests/unit_tests/client/configs/ut-client/zones/console2-dbus.conf.in @@ -1,7 +1,7 @@ { - "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, @@ -10,7 +10,7 @@ "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" ] } diff --git a/tests/unit_tests/client/configs/ut-client/containers/console3-dbus.conf.in b/tests/unit_tests/client/configs/ut-client/zones/console3-dbus.conf.in similarity index 72% rename from tests/unit_tests/client/configs/ut-client/containers/console3-dbus.conf.in rename to tests/unit_tests/client/configs/ut-client/zones/console3-dbus.conf.in index f3d8385..f91754f 100644 --- a/tests/unit_tests/client/configs/ut-client/containers/console3-dbus.conf.in +++ b/tests/unit_tests/client/configs/ut-client/zones/console3-dbus.conf.in @@ -1,7 +1,7 @@ { - "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, @@ -10,7 +10,7 @@ "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/.*" ] } diff --git a/tests/unit_tests/client/ut-client-utils.cpp b/tests/unit_tests/client/ut-client-utils.cpp index 334d7bf..140238a 100644 --- a/tests/unit_tests/client/ut-client-utils.cpp +++ b/tests/unit_tests/client/ut-client-utils.cpp @@ -30,16 +30,16 @@ 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); }; diff --git a/tests/unit_tests/client/ut-client.cpp b/tests/unit_tests/client/ut-client.cpp index ec38228..e8060be 100644 --- a/tests/unit_tests/client/ut-client.cpp +++ b/tests/unit_tests/client/ut-client.cpp @@ -29,8 +29,8 @@ #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 #include @@ -47,7 +47,7 @@ namespace { 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() @@ -62,13 +62,13 @@ struct 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) { @@ -79,16 +79,16 @@ struct Fixture { const int EVENT_TIMEOUT = 5000; ///< ms const std::map 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" } }; @@ -136,13 +136,13 @@ BOOST_AUTO_TEST_CASE(NotRunningServerTest) 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), @@ -150,15 +150,15 @@ BOOST_AUTO_TEST_CASE(GetContainerDbusesTest) BOOST_CHECK_EQUAL(getArrayStringLength(values, EXPECTED_DBUSES_STARTED.size() + 1), EXPECTED_DBUSES_STARTED.size()); - std::map containers; - convertDictToMap(keys, values, containers); - BOOST_CHECK(containers == EXPECTED_DBUSES_STARTED); + std::map 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); @@ -169,68 +169,68 @@ BOOST_AUTO_TEST_CASE(GetContainerIdsTest) BOOST_CHECK_EQUAL(getArrayStringLength(values, EXPECTED_DBUSES_STARTED.size() + 1), EXPECTED_DBUSES_STARTED.size()); - std::set containers; - convertArrayToSet(values, containers); + std::set 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); } @@ -238,14 +238,14 @@ BOOST_AUTO_TEST_CASE(LockUnlockContainerTest) 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); } @@ -260,12 +260,12 @@ BOOST_AUTO_TEST_CASE(NotificationTest) std::vector< std::tuple > receivedSignalMsg; }; - auto callback = [](const char* container, + auto callback = [](const char* zone, const char* application, const char* message, void* data) { CallbackData& callbackData = *reinterpret_cast(data); - callbackData.receivedSignalMsg.push_back(std::make_tuple(container, application, message)); + callbackData.receivedSignalMsg.push_back(std::make_tuple(zone, application, message)); callbackData.signalReceivedLatch.set(); }; @@ -285,7 +285,7 @@ BOOST_AUTO_TEST_CASE(NotificationTest) 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); @@ -305,30 +305,30 @@ BOOST_AUTO_TEST_CASE(NotificationTest) } } -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 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)); } diff --git a/tests/unit_tests/dbus/configs/ut-connection/ut-dbus.conf b/tests/unit_tests/dbus/configs/ut-connection/ut-dbus.conf index 7b56fa4..f3bf58c 100644 --- a/tests/unit_tests/dbus/configs/ut-connection/ut-dbus.conf +++ b/tests/unit_tests/dbus/configs/ut-connection/ut-dbus.conf @@ -1,11 +1,11 @@ - + custom - unix:path=/tmp/container_socket + unix:path=/tmp/zone_socket diff --git a/tests/unit_tests/dbus/test-common.hpp b/tests/unit_tests/dbus/test-common.hpp index 5e93699..ae76d82 100644 --- a/tests/unit_tests/dbus/test-common.hpp +++ b/tests/unit_tests/dbus/test-common.hpp @@ -31,7 +31,7 @@ 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"; diff --git a/tests/unit_tests/dbus/test-server.cpp b/tests/unit_tests/dbus/test-server.cpp index c5f6ab8..a0fee4c 100644 --- a/tests/unit_tests/dbus/test-server.cpp +++ b/tests/unit_tests/dbus/test-server.cpp @@ -142,7 +142,7 @@ void DbusTestServer::onMessageCall(const std::string& objectPath, 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()); } } diff --git a/tests/unit_tests/dbus/ut-connection.cpp b/tests/unit_tests/dbus/ut-connection.cpp index fa8a620..3e335ed 100644 --- a/tests/unit_tests/dbus/ut-connection.cpp +++ b/tests/unit_tests/dbus/ut-connection.cpp @@ -65,7 +65,7 @@ class ScopedDbusDaemon { 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); } @@ -338,7 +338,7 @@ BOOST_AUTO_TEST_CASE(MethodCallTest) } 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); @@ -402,7 +402,7 @@ BOOST_AUTO_TEST_CASE(MethodAsyncCallTest) } 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); diff --git a/tests/unit_tests/lxc/templates/minimal-dbus.sh b/tests/unit_tests/lxc/templates/minimal-dbus.sh index 82c76e8..fb61eb3 100755 --- a/tests/unit_tests/lxc/templates/minimal-dbus.sh +++ b/tests/unit_tests/lxc/templates/minimal-dbus.sh @@ -19,7 +19,7 @@ do esac done -# Prepare container rootfs +# Prepare zone rootfs ROOTFS_DIRS="\ ${rootfs}/bin \ ${rootfs}/dev \ @@ -41,7 +41,7 @@ ${rootfs}/var/run " /bin/mkdir ${ROOTFS_DIRS} -# Prepare container configuration file +# Prepare zone configuration file > ${path}/config cat <> ${path}/config lxc.utsname = ${name} diff --git a/tests/unit_tests/lxc/templates/minimal.sh b/tests/unit_tests/lxc/templates/minimal.sh index 873277e..0450d1a 100755 --- a/tests/unit_tests/lxc/templates/minimal.sh +++ b/tests/unit_tests/lxc/templates/minimal.sh @@ -19,7 +19,7 @@ do esac done -# Prepare container rootfs +# Prepare zone rootfs ROOTFS_DIRS="\ ${rootfs}/bin \ ${rootfs}/dev \ @@ -39,7 +39,7 @@ ${rootfs}/opt " /bin/mkdir ${ROOTFS_DIRS} -# Prepare container configuration file +# Prepare zone configuration file > ${path}/config cat <> ${path}/config lxc.utsname = ${name} diff --git a/tests/unit_tests/server/configs/CMakeLists.txt b/tests/unit_tests/server/configs/CMakeLists.txt index 9979c1b..4a9edbe 100644 --- a/tests/unit_tests/server/configs/CMakeLists.txt +++ b/tests/unit_tests/server/configs/CMakeLists.txt @@ -20,17 +20,17 @@ 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 #################################################################### @@ -40,35 +40,35 @@ CONFIGURE_FILE(ut-server/buggy-daemon.conf.in ${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 ##################################################################### @@ -76,32 +76,32 @@ INSTALL(FILES ${server_manager_CONF} 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/) diff --git a/tests/unit_tests/server/configs/dbus-1/system.d/org.tizen.containers.tests.conf b/tests/unit_tests/server/configs/dbus-1/system.d/org.tizen.containers.tests.conf deleted file mode 100644 index be6c6d6..0000000 --- a/tests/unit_tests/server/configs/dbus-1/system.d/org.tizen.containers.tests.conf +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - diff --git a/tests/unit_tests/server/configs/dbus-1/system.d/org.tizen.vasum.tests.conf b/tests/unit_tests/server/configs/dbus-1/system.d/org.tizen.vasum.tests.conf new file mode 100644 index 0000000..b818da9 --- /dev/null +++ b/tests/unit_tests/server/configs/dbus-1/system.d/org.tizen.vasum.tests.conf @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/tests/unit_tests/server/configs/ut-containers-manager/buggy-daemon.conf.in b/tests/unit_tests/server/configs/ut-containers-manager/buggy-daemon.conf.in deleted file mode 100644 index c3ec37b..0000000 --- a/tests/unit_tests/server/configs/ut-containers-manager/buggy-daemon.conf.in +++ /dev/null @@ -1,17 +0,0 @@ -{ - "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" : [] -} diff --git a/tests/unit_tests/server/configs/ut-containers-manager/test-daemon.conf.in b/tests/unit_tests/server/configs/ut-containers-manager/test-daemon.conf.in deleted file mode 100644 index 25890e6..0000000 --- a/tests/unit_tests/server/configs/ut-containers-manager/test-daemon.conf.in +++ /dev/null @@ -1,17 +0,0 @@ -{ - "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" : [] -} diff --git a/tests/unit_tests/server/configs/ut-containers-manager/test-dbus-daemon.conf.in b/tests/unit_tests/server/configs/ut-containers-manager/test-dbus-daemon.conf.in deleted file mode 100644 index 19a9f60..0000000 --- a/tests/unit_tests/server/configs/ut-containers-manager/test-dbus-daemon.conf.in +++ /dev/null @@ -1,24 +0,0 @@ -{ - "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" : "*"}] -} diff --git a/tests/unit_tests/server/configs/ut-server/buggy-daemon.conf.in b/tests/unit_tests/server/configs/ut-server/buggy-daemon.conf.in index 55479b7..8ea6cb8 100644 --- a/tests/unit_tests/server/configs/ut-server/buggy-daemon.conf.in +++ b/tests/unit_tests/server/configs/ut-server/buggy-daemon.conf.in @@ -1,12 +1,12 @@ { - "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", diff --git a/tests/unit_tests/server/configs/ut-server/test-daemon.conf.in b/tests/unit_tests/server/configs/ut-server/test-daemon.conf.in index 57fb7a1..24e1c4e 100644 --- a/tests/unit_tests/server/configs/ut-server/test-daemon.conf.in +++ b/tests/unit_tests/server/configs/ut-server/test-daemon.conf.in @@ -1,12 +1,12 @@ { - "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", diff --git a/tests/unit_tests/server/configs/ut-server/containers/container1.conf b/tests/unit_tests/server/configs/ut-server/zones/zone1.conf similarity index 91% rename from tests/unit_tests/server/configs/ut-server/containers/container1.conf rename to tests/unit_tests/server/configs/ut-server/zones/zone1.conf index 995efb4..898eef2 100644 --- a/tests/unit_tests/server/configs/ut-server/containers/container1.conf +++ b/tests/unit_tests/server/configs/ut-server/zones/zone1.conf @@ -1,5 +1,5 @@ { - "name" : "ut-server-container1", + "name" : "ut-server-zone1", "lxcTemplate" : "minimal.sh", "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"], "ipv4Gateway" : "", diff --git a/tests/unit_tests/server/configs/ut-server/containers/container2.conf b/tests/unit_tests/server/configs/ut-server/zones/zone2.conf similarity index 91% rename from tests/unit_tests/server/configs/ut-server/containers/container2.conf rename to tests/unit_tests/server/configs/ut-server/zones/zone2.conf index 1e9b3b7..8f4687a 100644 --- a/tests/unit_tests/server/configs/ut-server/containers/container2.conf +++ b/tests/unit_tests/server/configs/ut-server/zones/zone2.conf @@ -1,5 +1,5 @@ { - "name" : "ut-server-container2", + "name" : "ut-server-zone2", "lxcTemplate" : "minimal.sh", "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"], "ipv4Gateway" : "", diff --git a/tests/unit_tests/server/configs/ut-server/containers/container3.conf b/tests/unit_tests/server/configs/ut-server/zones/zone3.conf similarity index 91% rename from tests/unit_tests/server/configs/ut-server/containers/container3.conf rename to tests/unit_tests/server/configs/ut-server/zones/zone3.conf index 47396f5..fdb958f 100644 --- a/tests/unit_tests/server/configs/ut-server/containers/container3.conf +++ b/tests/unit_tests/server/configs/ut-server/zones/zone3.conf @@ -1,5 +1,5 @@ { - "name" : "ut-server-container3", + "name" : "ut-server-zone3", "lxcTemplate" : "minimal.sh", "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"], "ipv4Gateway" : "", diff --git a/tests/unit_tests/server/configs/ut-container-admin/containers/buggy.conf b/tests/unit_tests/server/configs/ut-zone-admin/zones/buggy.conf similarity index 90% rename from tests/unit_tests/server/configs/ut-container-admin/containers/buggy.conf rename to tests/unit_tests/server/configs/ut-zone-admin/zones/buggy.conf index ffa8652..320dc00 100644 --- a/tests/unit_tests/server/configs/ut-container-admin/containers/buggy.conf +++ b/tests/unit_tests/server/configs/ut-zone-admin/zones/buggy.conf @@ -1,5 +1,5 @@ { - "name" : "ut-container-admin-test", + "name" : "ut-zone-admin-test", "lxcTemplate" : "minimal.sh", "initWithArgs" : ["/foo"], "ipv4Gateway" : "", diff --git a/tests/unit_tests/server/configs/ut-container-admin/containers/missing.conf b/tests/unit_tests/server/configs/ut-zone-admin/zones/missing.conf similarity index 91% rename from tests/unit_tests/server/configs/ut-container-admin/containers/missing.conf rename to tests/unit_tests/server/configs/ut-zone-admin/zones/missing.conf index 686dde2..9aaf464 100644 --- a/tests/unit_tests/server/configs/ut-container-admin/containers/missing.conf +++ b/tests/unit_tests/server/configs/ut-zone-admin/zones/missing.conf @@ -1,5 +1,5 @@ { - "name" : "ut-container-admin-test", + "name" : "ut-zone-admin-test", "lxcTemplate" : "missing.sh", "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"], "ipv4Gateway" : "", diff --git a/tests/unit_tests/server/configs/ut-container-admin/containers/test-no-shutdown.conf b/tests/unit_tests/server/configs/ut-zone-admin/zones/test-no-shutdown.conf similarity index 90% rename from tests/unit_tests/server/configs/ut-container-admin/containers/test-no-shutdown.conf rename to tests/unit_tests/server/configs/ut-zone-admin/zones/test-no-shutdown.conf index 307afd5..b3b0141 100644 --- a/tests/unit_tests/server/configs/ut-container-admin/containers/test-no-shutdown.conf +++ b/tests/unit_tests/server/configs/ut-zone-admin/zones/test-no-shutdown.conf @@ -1,5 +1,5 @@ { - "name" : "ut-container-admin-test", + "name" : "ut-zone-admin-test", "lxcTemplate" : "minimal.sh", "initWithArgs" : ["/bin/sh"], "ipv4Gateway" : "", diff --git a/tests/unit_tests/server/configs/ut-container-admin/containers/test.conf b/tests/unit_tests/server/configs/ut-zone-admin/zones/test.conf similarity index 91% rename from tests/unit_tests/server/configs/ut-container-admin/containers/test.conf rename to tests/unit_tests/server/configs/ut-zone-admin/zones/test.conf index 76f4a70..ae046e5 100644 --- a/tests/unit_tests/server/configs/ut-container-admin/containers/test.conf +++ b/tests/unit_tests/server/configs/ut-zone-admin/zones/test.conf @@ -1,5 +1,5 @@ { - "name" : "ut-container-admin-test", + "name" : "ut-zone-admin-test", "lxcTemplate" : "minimal.sh", "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"], "ipv4Gateway" : "", diff --git a/tests/unit_tests/server/configs/ut-container-connection/ut-dbus.conf b/tests/unit_tests/server/configs/ut-zone-connection/ut-dbus.conf similarity index 76% rename from tests/unit_tests/server/configs/ut-container-connection/ut-dbus.conf rename to tests/unit_tests/server/configs/ut-zone-connection/ut-dbus.conf index b0a2d18..d60e774 100644 --- a/tests/unit_tests/server/configs/ut-container-connection/ut-dbus.conf +++ b/tests/unit_tests/server/configs/ut-zone-connection/ut-dbus.conf @@ -1,11 +1,11 @@ - + custom - unix:path=/tmp/ut-container-connection/dbus/system_bus_socket + unix:path=/tmp/ut-zone-connection/dbus/system_bus_socket diff --git a/tests/unit_tests/server/configs/ut-containers-manager/ut-dbus.conf b/tests/unit_tests/server/configs/ut-zone/ut-dbus.conf similarity index 89% rename from tests/unit_tests/server/configs/ut-containers-manager/ut-dbus.conf rename to tests/unit_tests/server/configs/ut-zone/ut-dbus.conf index 520a14f..2e0488d 100644 --- a/tests/unit_tests/server/configs/ut-containers-manager/ut-dbus.conf +++ b/tests/unit_tests/server/configs/ut-zone/ut-dbus.conf @@ -1,4 +1,4 @@ - + diff --git a/tests/unit_tests/server/configs/ut-container/containers/buggy.conf b/tests/unit_tests/server/configs/ut-zone/zones/buggy.conf similarity index 92% rename from tests/unit_tests/server/configs/ut-container/containers/buggy.conf rename to tests/unit_tests/server/configs/ut-zone/zones/buggy.conf index 2af10da..55586b4 100644 --- a/tests/unit_tests/server/configs/ut-container/containers/buggy.conf +++ b/tests/unit_tests/server/configs/ut-zone/zones/buggy.conf @@ -1,5 +1,5 @@ { - "name" : "ut-container-test", + "name" : "ut-zone-test", "lxcTemplate" : "/buggy/path", "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"], "ipv4Gateway" : "", diff --git a/tests/unit_tests/server/configs/ut-container/containers/test-dbus.conf.in b/tests/unit_tests/server/configs/ut-zone/zones/test-dbus.conf.in similarity index 75% rename from tests/unit_tests/server/configs/ut-container/containers/test-dbus.conf.in rename to tests/unit_tests/server/configs/ut-zone/zones/test-dbus.conf.in index 1992140..4f8e6db 100644 --- a/tests/unit_tests/server/configs/ut-container/containers/test-dbus.conf.in +++ b/tests/unit_tests/server/configs/ut-zone/zones/test-dbus.conf.in @@ -1,7 +1,7 @@ { - "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, @@ -10,7 +10,7 @@ "enableDbusIntegration" : true, "cpuQuotaForeground" : -1, "cpuQuotaBackground" : 1000, - "runMountPoint" : "/tmp/ut-run/ut-container-test-dbus", + "runMountPoint" : "/tmp/ut-run/ut-zone-test-dbus", "permittedToSend" : [], "permittedToRecv" : [] } diff --git a/tests/unit_tests/server/configs/ut-container/containers/test.conf b/tests/unit_tests/server/configs/ut-zone/zones/test.conf similarity index 92% rename from tests/unit_tests/server/configs/ut-container/containers/test.conf rename to tests/unit_tests/server/configs/ut-zone/zones/test.conf index 1264669..a8f9692 100644 --- a/tests/unit_tests/server/configs/ut-container/containers/test.conf +++ b/tests/unit_tests/server/configs/ut-zone/zones/test.conf @@ -1,5 +1,5 @@ { - "name" : "ut-container-test", + "name" : "ut-zone-test", "lxcTemplate" : "minimal.sh", "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"], "ipv4Gateway" : "", diff --git a/tests/unit_tests/server/configs/ut-zones-manager/buggy-daemon.conf.in b/tests/unit_tests/server/configs/ut-zones-manager/buggy-daemon.conf.in new file mode 100644 index 0000000..f2bcbb9 --- /dev/null +++ b/tests/unit_tests/server/configs/ut-zones-manager/buggy-daemon.conf.in @@ -0,0 +1,17 @@ +{ + "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" : [] +} diff --git a/tests/unit_tests/server/configs/ut-containers-manager/buggy-default-daemon.conf.in b/tests/unit_tests/server/configs/ut-zones-manager/buggy-default-daemon.conf.in similarity index 51% rename from tests/unit_tests/server/configs/ut-containers-manager/buggy-default-daemon.conf.in rename to tests/unit_tests/server/configs/ut-zones-manager/buggy-default-daemon.conf.in index 6390378..90b9107 100644 --- a/tests/unit_tests/server/configs/ut-containers-manager/buggy-default-daemon.conf.in +++ b/tests/unit_tests/server/configs/ut-zones-manager/buggy-default-daemon.conf.in @@ -1,12 +1,12 @@ { - "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", diff --git a/tests/unit_tests/server/configs/ut-containers-manager/buggy-foreground-daemon.conf.in b/tests/unit_tests/server/configs/ut-zones-manager/buggy-foreground-daemon.conf.in similarity index 50% rename from tests/unit_tests/server/configs/ut-containers-manager/buggy-foreground-daemon.conf.in rename to tests/unit_tests/server/configs/ut-zones-manager/buggy-foreground-daemon.conf.in index fb1490c..49c4c2d 100644 --- a/tests/unit_tests/server/configs/ut-containers-manager/buggy-foreground-daemon.conf.in +++ b/tests/unit_tests/server/configs/ut-zones-manager/buggy-foreground-daemon.conf.in @@ -1,12 +1,12 @@ { - "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", diff --git a/tests/unit_tests/server/configs/ut-containers-manager/empty-dbus-daemon.conf.in b/tests/unit_tests/server/configs/ut-zones-manager/empty-dbus-daemon.conf.in similarity index 65% rename from tests/unit_tests/server/configs/ut-containers-manager/empty-dbus-daemon.conf.in rename to tests/unit_tests/server/configs/ut-zones-manager/empty-dbus-daemon.conf.in index 97e70d8..4e20535 100644 --- a/tests/unit_tests/server/configs/ut-containers-manager/empty-dbus-daemon.conf.in +++ b/tests/unit_tests/server/configs/ut-zones-manager/empty-dbus-daemon.conf.in @@ -1,11 +1,11 @@ { - "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, @@ -15,7 +15,7 @@ "timeWindowMs" : 500}, "proxyCallRules" : [{"caller" : "*", "target" : "*", - "targetBusName" : "org.tizen.containers.tests", + "targetBusName" : "org.tizen.vasum.tests", "targetObjectPath" : "*", "targetInterface" : "*", "targetMethod" : "*"}] diff --git a/tests/unit_tests/server/configs/ut-containers-manager/templates/template.conf.in b/tests/unit_tests/server/configs/ut-zones-manager/templates/template.conf.in similarity index 90% rename from tests/unit_tests/server/configs/ut-containers-manager/templates/template.conf.in rename to tests/unit_tests/server/configs/ut-zones-manager/templates/template.conf.in index 8e2292a..15185d6 100644 --- a/tests/unit_tests/server/configs/ut-containers-manager/templates/template.conf.in +++ b/tests/unit_tests/server/configs/ut-zones-manager/templates/template.conf.in @@ -1,7 +1,7 @@ { "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, diff --git a/tests/unit_tests/server/configs/ut-zones-manager/test-daemon.conf.in b/tests/unit_tests/server/configs/ut-zones-manager/test-daemon.conf.in new file mode 100644 index 0000000..d72c440 --- /dev/null +++ b/tests/unit_tests/server/configs/ut-zones-manager/test-daemon.conf.in @@ -0,0 +1,17 @@ +{ + "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" : [] +} diff --git a/tests/unit_tests/server/configs/ut-zones-manager/test-dbus-daemon.conf.in b/tests/unit_tests/server/configs/ut-zones-manager/test-dbus-daemon.conf.in new file mode 100644 index 0000000..72b3523 --- /dev/null +++ b/tests/unit_tests/server/configs/ut-zones-manager/test-dbus-daemon.conf.in @@ -0,0 +1,24 @@ +{ + "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" : "*"}] +} diff --git a/tests/unit_tests/server/configs/ut-container/ut-dbus.conf b/tests/unit_tests/server/configs/ut-zones-manager/ut-dbus.conf similarity index 89% rename from tests/unit_tests/server/configs/ut-container/ut-dbus.conf rename to tests/unit_tests/server/configs/ut-zones-manager/ut-dbus.conf index 520a14f..2e0488d 100644 --- a/tests/unit_tests/server/configs/ut-container/ut-dbus.conf +++ b/tests/unit_tests/server/configs/ut-zones-manager/ut-dbus.conf @@ -1,4 +1,4 @@ - + diff --git a/tests/unit_tests/server/configs/ut-containers-manager/containers/console1-dbus.conf.in b/tests/unit_tests/server/configs/ut-zones-manager/zones/console1-dbus.conf.in similarity index 73% rename from tests/unit_tests/server/configs/ut-containers-manager/containers/console1-dbus.conf.in rename to tests/unit_tests/server/configs/ut-zones-manager/zones/console1-dbus.conf.in index 4bf616c..72fbdbf 100644 --- a/tests/unit_tests/server/configs/ut-containers-manager/containers/console1-dbus.conf.in +++ b/tests/unit_tests/server/configs/ut-zones-manager/zones/console1-dbus.conf.in @@ -1,7 +1,7 @@ { - "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, @@ -10,7 +10,7 @@ "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/.*" ] } diff --git a/tests/unit_tests/server/configs/ut-containers-manager/containers/console1.conf b/tests/unit_tests/server/configs/ut-zones-manager/zones/console1.conf similarity index 90% rename from tests/unit_tests/server/configs/ut-containers-manager/containers/console1.conf rename to tests/unit_tests/server/configs/ut-zones-manager/zones/console1.conf index 1ca1e5f..3e88c3d 100644 --- a/tests/unit_tests/server/configs/ut-containers-manager/containers/console1.conf +++ b/tests/unit_tests/server/configs/ut-zones-manager/zones/console1.conf @@ -1,5 +1,5 @@ { - "name" : "ut-containers-manager-console1", + "name" : "ut-zones-manager-console1", "lxcTemplate" : "minimal.sh", "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"], "ipv4Gateway" : "", diff --git a/tests/unit_tests/client/configs/ut-client/containers/console2-dbus.conf.in b/tests/unit_tests/server/configs/ut-zones-manager/zones/console2-dbus.conf.in similarity index 73% rename from tests/unit_tests/client/configs/ut-client/containers/console2-dbus.conf.in rename to tests/unit_tests/server/configs/ut-zones-manager/zones/console2-dbus.conf.in index 4ca2215..1386878 100644 --- a/tests/unit_tests/client/configs/ut-client/containers/console2-dbus.conf.in +++ b/tests/unit_tests/server/configs/ut-zones-manager/zones/console2-dbus.conf.in @@ -1,7 +1,7 @@ { - "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, @@ -10,7 +10,7 @@ "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" ] } diff --git a/tests/unit_tests/server/configs/ut-containers-manager/containers/console2.conf b/tests/unit_tests/server/configs/ut-zones-manager/zones/console2.conf similarity index 90% rename from tests/unit_tests/server/configs/ut-containers-manager/containers/console2.conf rename to tests/unit_tests/server/configs/ut-zones-manager/zones/console2.conf index 155910b..22f7a39 100644 --- a/tests/unit_tests/server/configs/ut-containers-manager/containers/console2.conf +++ b/tests/unit_tests/server/configs/ut-zones-manager/zones/console2.conf @@ -1,5 +1,5 @@ { - "name" : "ut-containers-manager-console2", + "name" : "ut-zones-manager-console2", "lxcTemplate" : "minimal.sh", "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"], "ipv4Gateway" : "", diff --git a/tests/unit_tests/server/configs/ut-containers-manager/containers/console3-dbus.conf.in b/tests/unit_tests/server/configs/ut-zones-manager/zones/console3-dbus.conf.in similarity index 72% rename from tests/unit_tests/server/configs/ut-containers-manager/containers/console3-dbus.conf.in rename to tests/unit_tests/server/configs/ut-zones-manager/zones/console3-dbus.conf.in index f3d8385..f91754f 100644 --- a/tests/unit_tests/server/configs/ut-containers-manager/containers/console3-dbus.conf.in +++ b/tests/unit_tests/server/configs/ut-zones-manager/zones/console3-dbus.conf.in @@ -1,7 +1,7 @@ { - "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, @@ -10,7 +10,7 @@ "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/.*" ] } diff --git a/tests/unit_tests/server/configs/ut-containers-manager/containers/console3.conf b/tests/unit_tests/server/configs/ut-zones-manager/zones/console3.conf similarity index 90% rename from tests/unit_tests/server/configs/ut-containers-manager/containers/console3.conf rename to tests/unit_tests/server/configs/ut-zones-manager/zones/console3.conf index a144c79..2f99f23 100644 --- a/tests/unit_tests/server/configs/ut-containers-manager/containers/console3.conf +++ b/tests/unit_tests/server/configs/ut-zones-manager/zones/console3.conf @@ -1,5 +1,5 @@ { - "name" : "ut-containers-manager-console3", + "name" : "ut-zones-manager-console3", "lxcTemplate" : "minimal.sh", "initWithArgs" : ["/bin/sh", "-c", "trap exit SIGTERM; read"], "ipv4Gateway" : "", diff --git a/tests/unit_tests/server/test-dbus-definitions.hpp b/tests/unit_tests/server/test-dbus-definitions.hpp index 9099c11..01fbb93 100644 --- a/tests/unit_tests/server/test-dbus-definitions.hpp +++ b/tests/unit_tests/server/test-dbus-definitions.hpp @@ -32,8 +32,8 @@ namespace vasum { 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"; diff --git a/tests/unit_tests/server/ut-server.cpp b/tests/unit_tests/server/ut-server.cpp index cc178db..75b894a 100644 --- a/tests/unit_tests/server/ut-server.cpp +++ b/tests/unit_tests/server/ut-server.cpp @@ -35,13 +35,13 @@ #include 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 diff --git a/tests/unit_tests/server/ut-container-admin.cpp b/tests/unit_tests/server/ut-zone-admin.cpp similarity index 80% rename from tests/unit_tests/server/ut-container-admin.cpp rename to tests/unit_tests/server/ut-zone-admin.cpp index fb97d6e..0cd2ddf 100644 --- a/tests/unit_tests/server/ut-container-admin.cpp +++ b/tests/unit_tests/server/ut-zone-admin.cpp @@ -20,13 +20,13 @@ /** * @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" @@ -37,34 +37,34 @@ using namespace vasum; 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 create(const std::string& configPath) + std::unique_ptr create(const std::string& configPath) { config::loadFromFile(configPath, mConfig); - return std::unique_ptr(new ContainerAdmin(CONTAINERS_PATH, + return std::unique_ptr(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)); } }; @@ -72,7 +72,7 @@ struct Fixture { } // namespace -BOOST_FIXTURE_TEST_SUITE(ContainerAdminSuite, Fixture) +BOOST_FIXTURE_TEST_SUITE(ZoneAdminSuite, Fixture) BOOST_AUTO_TEST_CASE(ConstructorDestructorTest) { @@ -82,7 +82,7 @@ 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) @@ -98,7 +98,7 @@ 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) diff --git a/tests/unit_tests/server/ut-container-connection.cpp b/tests/unit_tests/server/ut-zone-connection.cpp similarity index 75% rename from tests/unit_tests/server/ut-container-connection.cpp rename to tests/unit_tests/server/ut-zone-connection.cpp index 9a65aab..a93b469 100644 --- a/tests/unit_tests/server/ut-container-connection.cpp +++ b/tests/unit_tests/server/ut-zone-connection.cpp @@ -20,16 +20,16 @@ /** * @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" @@ -41,7 +41,7 @@ #include "utils/fs.hpp" -BOOST_AUTO_TEST_SUITE(ContainerConnectionSuite) +BOOST_AUTO_TEST_SUITE(ZoneConnectionSuite) using namespace vasum; using namespace vasum::utils; @@ -52,12 +52,12 @@ namespace { 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 { @@ -73,7 +73,7 @@ public: return mTransport.acquireAddress(); } private: - ContainerConnectionTransport mTransport; + ZoneConnectionTransport mTransport; ScopedDaemon mDaemon; }; @@ -132,31 +132,31 @@ BOOST_AUTO_TEST_CASE(ConstructorDestructorConnectTest) 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 connection; + std::unique_ptr 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)); @@ -168,9 +168,9 @@ BOOST_AUTO_TEST_CASE(SignalNotificationApiTest) ScopedDbusDaemon dbus; Latch signalEmitted; - std::unique_ptr connection; + std::unique_ptr 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()); @@ -179,25 +179,25 @@ BOOST_AUTO_TEST_CASE(SignalNotificationApiTest) 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)); } @@ -208,9 +208,9 @@ BOOST_AUTO_TEST_CASE(SignalDisplayOffApiTest) ScopedDbusDaemon dbus; Latch displayOffCalled; - std::unique_ptr connection; + std::unique_ptr 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()); diff --git a/tests/unit_tests/server/ut-container.cpp b/tests/unit_tests/server/ut-zone.cpp similarity index 78% rename from tests/unit_tests/server/ut-container.cpp rename to tests/unit_tests/server/ut-zone.cpp index 4c4c305..7d80d66 100644 --- a/tests/unit_tests/server/ut-container.cpp +++ b/tests/unit_tests/server/ut-zone.cpp @@ -20,13 +20,13 @@ /** * @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" @@ -45,25 +45,25 @@ using namespace config; 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 create(const std::string& configPath) + std::unique_ptr create(const std::string& configPath) { - return std::unique_ptr(new Container(CONTAINERS_PATH, + return std::unique_ptr(new Zone(ZONES_PATH, configPath, LXC_TEMPLATES_PATH, "")); @@ -71,7 +71,7 @@ struct Fixture { 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)); } }; @@ -79,7 +79,7 @@ struct Fixture { } // namespace -BOOST_FIXTURE_TEST_SUITE(ContainerSuite, Fixture) +BOOST_FIXTURE_TEST_SUITE(ZoneSuite, Fixture) BOOST_AUTO_TEST_CASE(ConstructorDestructorTest) { @@ -89,7 +89,7 @@ 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) diff --git a/tests/unit_tests/server/ut-containers-manager.cpp b/tests/unit_tests/server/ut-zones-manager.cpp similarity index 62% rename from tests/unit_tests/server/ut-containers-manager.cpp rename to tests/unit_tests/server/ut-zones-manager.cpp index 4b45186..33d7c50 100644 --- a/tests/unit_tests/server/ut-containers-manager.cpp +++ b/tests/unit_tests/server/ut-zones-manager.cpp @@ -20,17 +20,17 @@ /** * @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 @@ -64,24 +64,24 @@ using namespace dbus; 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 { @@ -138,7 +138,7 @@ public: 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, @@ -152,10 +152,10 @@ public: 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, "()"); } @@ -163,10 +163,10 @@ public: 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)"); @@ -225,11 +225,11 @@ public: 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)"); @@ -238,14 +238,14 @@ public: 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; @@ -253,21 +253,21 @@ public: 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 callMethodGetContainerIds() + std::vector 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)"); @@ -275,46 +275,46 @@ public: g_variant_get(result.get(), "(*)", &array); size_t arraySize = g_variant_n_children(array); - std::vector containerIds; + std::vector 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, @@ -322,7 +322,7 @@ public: { assert(isHost()); GVariant* parameters = g_variant_new("(sisii)", - container.c_str(), + zone.c_str(), type, path.c_str(), flags, @@ -336,7 +336,7 @@ public: } 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, @@ -345,7 +345,7 @@ public: assert(isHost()); GVariant* parameters = g_variant_new("(ssssts)", source.c_str(), - container.c_str(), + zone.c_str(), target.c_str(), type.c_str(), flags, @@ -359,13 +359,13 @@ public: } 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, @@ -375,7 +375,7 @@ public: "()"); } - void callAsyncMethodCreateContainer(const std::string& id, + void callAsyncMethodCreateZone(const std::string& id, const VoidResultCallback& result) { auto asyncResult = [result](dbus::AsyncMethodCallResult& asyncMethodCallResult) { @@ -388,13 +388,13 @@ public: 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) { @@ -407,32 +407,32 @@ public: 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, "()"); } @@ -454,7 +454,7 @@ private: 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"; } }; @@ -468,120 +468,120 @@ std::function expectedMessage(const std::string& me 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 cm; - cm.reset(new ContainersManager(TEST_CONFIG_PATH)); + std::unique_ptr 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> signalReceivedSourcesMap; std::map> 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(new DbusAccessory(i)); } @@ -593,16 +593,16 @@ BOOST_AUTO_TEST_CASE(NotifyActiveContainerTest) 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(); } @@ -610,7 +610,7 @@ BOOST_AUTO_TEST_CASE(NotifyActiveContainerTest) }; 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]), @@ -629,9 +629,9 @@ BOOST_AUTO_TEST_CASE(NotifyActiveContainerTest) 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()); } @@ -641,11 +641,11 @@ BOOST_AUTO_TEST_CASE(NotifyActiveContainerTest) BOOST_AUTO_TEST_CASE(DisplayOffTest) { - ContainersManager cm(TEST_DBUS_CONFIG_PATH); + ZonesManager cm(TEST_DBUS_CONFIG_PATH); cm.startAll(); std::vector> 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(new DbusAccessory(i))); } @@ -657,13 +657,13 @@ BOOST_AUTO_TEST_CASE(DisplayOffTest) std::unique_lock 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, @@ -671,14 +671,14 @@ BOOST_AUTO_TEST_CASE(DisplayOffTest) 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; @@ -697,9 +697,9 @@ BOOST_AUTO_TEST_CASE(MoveFileTest) 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; @@ -714,73 +714,73 @@ BOOST_AUTO_TEST_CASE(MoveFileTest) } }; - // 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> 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(new DbusAccessory(i))); } @@ -792,12 +792,12 @@ BOOST_AUTO_TEST_CASE(AllowSwitchToDefaultTest) std::unique_lock 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, @@ -805,11 +805,11 @@ BOOST_AUTO_TEST_CASE(AllowSwitchToDefaultTest) 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, @@ -817,18 +817,18 @@ BOOST_AUTO_TEST_CASE(AllowSwitchToDefaultTest) 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> 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(new DbusAccessory(i)); } @@ -838,7 +838,7 @@ BOOST_AUTO_TEST_CASE(ProxyCallTest) 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())); @@ -847,9 +847,9 @@ BOOST_AUTO_TEST_CASE(ProxyCallTest) 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 @@ -857,19 +857,19 @@ BOOST_AUTO_TEST_CASE(ProxyCallTest) 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 @@ -895,48 +895,48 @@ BOOST_AUTO_TEST_CASE(ProxyCallTest) 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; @@ -950,13 +950,13 @@ BOOST_AUTO_TEST_CASE(ContainerDbusesSignalsTest) 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(); } }; @@ -964,95 +964,95 @@ BOOST_AUTO_TEST_CASE(ContainerDbusesSignalsTest) 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 containerIds = {"ut-containers-manager-console1-dbus", - "ut-containers-manager-console2-dbus", - "ut-containers-manager-console3-dbus"}; - std::vector returnedIds = dbus.callMethodGetContainerIds(); + std::vector zoneIds = {"ut-zones-manager-console1-dbus", + "ut-zones-manager-console2-dbus", + "ut-zones-manager-console3-dbus"}; + std::vector 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 containerIds = {"ut-containers-manager-console1-dbus", - "ut-containers-manager-console2-dbus", - "ut-containers-manager-console3-dbus"}; + std::vector 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 containerIds = {"ut-containers-manager-console1-dbus", - "ut-containers-manager-console2-dbus", - "ut-containers-manager-console3-dbus"}; + std::vector 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 = [&]() { @@ -1061,54 +1061,54 @@ BOOST_AUTO_TEST_CASE(CreateDestroyContainerTest) 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()); - BOOST_REQUIRE(config.units[1].is()); - const ContainerProvisioning::File& unit = config.units[0].as(); + BOOST_REQUIRE(config.units[0].is()); + BOOST_REQUIRE(config.units[1].is()); + const ZoneProvisioning::File& unit = config.units[0].as(); BOOST_CHECK_EQUAL(unit.type, 1); BOOST_CHECK_EQUAL(unit.path, "path"); BOOST_CHECK_EQUAL(unit.flags, 0747); @@ -1117,20 +1117,20 @@ BOOST_AUTO_TEST_CASE(DeclareFile) 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()); - BOOST_REQUIRE(config.units[1].is()); - const ContainerProvisioning::Mount& unit = config.units[0].as(); + BOOST_REQUIRE(config.units[0].is()); + BOOST_REQUIRE(config.units[1].is()); + const ZoneProvisioning::Mount& unit = config.units[0].as(); BOOST_CHECK_EQUAL(unit.source, "/fake/path1"); BOOST_CHECK_EQUAL(unit.target, "/fake/path2"); BOOST_CHECK_EQUAL(unit.type, "tmpfs"); @@ -1140,51 +1140,51 @@ BOOST_AUTO_TEST_CASE(DeclareMount) 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()); - BOOST_REQUIRE(config.units[1].is()); - const ContainerProvisioning::Link& unit = config.units[0].as(); + BOOST_REQUIRE(config.units[0].is()); + BOOST_REQUIRE(config.units[1].is()); + const ZoneProvisioning::Link& unit = config.units[0].as(); 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 containerIds = {"ut-containers-manager-console1-dbus", - "ut-containers-manager-console2-dbus", - "ut-containers-manager-console3-dbus"}; + std::vector 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); } diff --git a/container-daemon/CMakeLists.txt b/zone-daemon/CMakeLists.txt similarity index 65% rename from container-daemon/CMakeLists.txt rename to zone-daemon/CMakeLists.txt index d702c8e..3fd611f 100644 --- a/container-daemon/CMakeLists.txt +++ b/zone-daemon/CMakeLists.txt @@ -18,32 +18,32 @@ # 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/) diff --git a/zone-daemon/configs/org.tizen.vasum.zone.daemon.conf.in b/zone-daemon/configs/org.tizen.vasum.zone.daemon.conf.in new file mode 100644 index 0000000..7b24276 --- /dev/null +++ b/zone-daemon/configs/org.tizen.vasum.zone.daemon.conf.in @@ -0,0 +1,14 @@ + + + + + + + + + + + + + diff --git a/container-daemon/daemon-connection.cpp b/zone-daemon/daemon-connection.cpp similarity index 88% rename from container-daemon/daemon-connection.cpp rename to zone-daemon/daemon-connection.cpp index be171e1..94a84a8 100644 --- a/container-daemon/daemon-connection.cpp +++ b/zone-daemon/daemon-connection.cpp @@ -19,7 +19,7 @@ /** * @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" @@ -32,7 +32,7 @@ namespace vasum { -namespace container_daemon { +namespace zone_daemon { namespace { @@ -53,13 +53,13 @@ DaemonConnection::DaemonConnection(const NameLostCallback& nameLostCallback, 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"); @@ -69,8 +69,8 @@ DaemonConnection::DaemonConnection(const NameLostCallback& nameLostCallback, 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"); @@ -138,5 +138,5 @@ void DaemonConnection::onMessageCall(const std::string& objectPath, } } -} // namespace container_daemon +} // namespace zone_daemon } // namespace vasum diff --git a/container-daemon/daemon-connection.hpp b/zone-daemon/daemon-connection.hpp similarity index 87% rename from container-daemon/daemon-connection.hpp rename to zone-daemon/daemon-connection.hpp index 8b39f02..7ac7012 100644 --- a/container-daemon/daemon-connection.hpp +++ b/zone-daemon/daemon-connection.hpp @@ -19,12 +19,12 @@ /** * @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" @@ -33,7 +33,7 @@ namespace vasum { -namespace container_daemon { +namespace zone_daemon { class DaemonConnection { @@ -72,8 +72,8 @@ private: }; -} // namespace container_daemon +} // namespace zone_daemon } // namespace vasum -#endif // CONTAINER_DAEMON_DAEMON_CONNECTION_HPP +#endif // ZONE_DAEMON_DAEMON_CONNECTION_HPP diff --git a/container-daemon/daemon-dbus-definitions.hpp b/zone-daemon/daemon-dbus-definitions.hpp similarity index 71% rename from container-daemon/daemon-dbus-definitions.hpp rename to zone-daemon/daemon-dbus-definitions.hpp index 057abeb..96c88b4 100644 --- a/container-daemon/daemon-dbus-definitions.hpp +++ b/zone-daemon/daemon-dbus-definitions.hpp @@ -19,22 +19,22 @@ /** * @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 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"; @@ -51,8 +51,8 @@ const std::string DEFINITION = } // namespace api -} // namespace container_daemon +} // namespace zone_daemon } // namespace vasum -#endif // CONTAINER_DAEMON_DAEMON_DBUS_DEFINITIONS_HPP +#endif // ZONE_DAEMON_DAEMON_DBUS_DEFINITIONS_HPP diff --git a/container-daemon/daemon.cpp b/zone-daemon/daemon.cpp similarity index 96% rename from container-daemon/daemon.cpp rename to zone-daemon/daemon.cpp index 3955140..0ded40a 100644 --- a/container-daemon/daemon.cpp +++ b/zone-daemon/daemon.cpp @@ -30,7 +30,7 @@ namespace vasum { -namespace container_daemon { +namespace zone_daemon { Daemon::Daemon() @@ -62,5 +62,5 @@ void Daemon::onLoseFocusCallback() } -} // namespace container_daemon +} // namespace zone_daemon } // namespace vasum diff --git a/container-daemon/daemon.hpp b/zone-daemon/daemon.hpp similarity index 87% rename from container-daemon/daemon.hpp rename to zone-daemon/daemon.hpp index 0821e70..92dcccf 100644 --- a/container-daemon/daemon.hpp +++ b/zone-daemon/daemon.hpp @@ -23,8 +23,8 @@ */ -#ifndef CONTAINER_DAEMON_DAEMON_HPP -#define CONTAINER_DAEMON_DAEMON_HPP +#ifndef ZONE_DAEMON_DAEMON_HPP +#define ZONE_DAEMON_DAEMON_HPP #include "daemon-connection.hpp" @@ -32,7 +32,7 @@ namespace vasum { -namespace container_daemon { +namespace zone_daemon { class Daemon { public: @@ -47,8 +47,8 @@ private: }; -} // namespace container_daemon +} // namespace zone_daemon } // namespace vasum -#endif // CONTAINER_DAEMON_DAEMON_HPP +#endif // ZONE_DAEMON_DAEMON_HPP diff --git a/container-daemon/exception.hpp b/zone-daemon/exception.hpp similarity index 66% rename from container-daemon/exception.hpp rename to zone-daemon/exception.hpp index 011b189..a281910 100644 --- a/container-daemon/exception.hpp +++ b/zone-daemon/exception.hpp @@ -19,30 +19,30 @@ /** * @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 diff --git a/container-daemon/main.cpp b/zone-daemon/main.cpp similarity index 97% rename from container-daemon/main.cpp rename to zone-daemon/main.cpp index 0a8a2b9..846f431 100644 --- a/container-daemon/main.cpp +++ b/zone-daemon/main.cpp @@ -50,7 +50,7 @@ namespace po = boost::program_options; namespace { const std::string PROGRAM_NAME_AND_VERSION = - "Vasum Containers Daemon " PROGRAM_VERSION; + "Vasum Zones Daemon " PROGRAM_VERSION; } // namespace @@ -113,7 +113,7 @@ int main(int argc, char* argv[]) } try { - container_daemon::Runner daemon; + zone_daemon::Runner daemon; daemon.run(); } catch (std::exception& e) { diff --git a/container-daemon/runner.cpp b/zone-daemon/runner.cpp similarity index 85% rename from container-daemon/runner.cpp rename to zone-daemon/runner.cpp index dfa73c1..8d00361 100644 --- a/container-daemon/runner.cpp +++ b/zone-daemon/runner.cpp @@ -35,7 +35,7 @@ namespace vasum { -namespace container_daemon { +namespace zone_daemon { Runner::Runner() @@ -64,17 +64,17 @@ void Runner::run() 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"); @@ -82,9 +82,9 @@ void Runner::run() void Runner::terminate() { - LOGI("Terminating Container Daemon"); + LOGI("Terminating Zone Daemon"); gSignalLatch.set(); } -} // namespace container_daemon +} // namespace zone_daemon } // namespace vasum diff --git a/container-daemon/runner.hpp b/zone-daemon/runner.hpp similarity index 87% rename from container-daemon/runner.hpp rename to zone-daemon/runner.hpp index e68fa0f..1a88530 100644 --- a/container-daemon/runner.hpp +++ b/zone-daemon/runner.hpp @@ -23,12 +23,12 @@ */ -#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 { @@ -49,8 +49,8 @@ public: }; -} // namespace container_daemon +} // namespace zone_daemon } // namespace vasum -#endif // CONTAINER_DAEMON_RUNNER_HPP +#endif // ZONE_DAEMON_RUNNER_HPP diff --git a/container-support/CMakeLists.txt b/zone-support/CMakeLists.txt similarity index 80% rename from container-support/CMakeLists.txt rename to zone-support/CMakeLists.txt index 79bdb9c..bee0fbd 100644 --- a/container-support/CMakeLists.txt +++ b/zone-support/CMakeLists.txt @@ -18,13 +18,13 @@ # 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/) diff --git a/zone-support/configs/org.tizen.vasum.zone.conf.in b/zone-support/configs/org.tizen.vasum.zone.conf.in new file mode 100644 index 0000000..fdf0305 --- /dev/null +++ b/zone-support/configs/org.tizen.vasum.zone.conf.in @@ -0,0 +1,14 @@ + + + + + + + + + + + + + -- 2.7.4