2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Contact: Mateusz Malicki <m.malicki2@samsung.com>
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License
21 * @author Mateusz Malicki (m.malicki2@samsung.com)
22 * @brief Declaration of the class for managing zone provision
26 #ifndef SERVER_ZONE_PROVISION_HPP
27 #define SERVER_ZONE_PROVISION_HPP
29 #include "zone-provision-config.hpp"
39 * Class is responsible for prepare filesystem for zone
40 * It allows to create directories, files, mount points and copying files from host
46 * ZoneProvision constructor
47 * @param rootPath zone root path
48 * @param configPath path to config with defaults
49 * @param dbPath path to database
50 * @param dbPrefix database prefix
51 * @param validLinkPrefixes valid link prefixes
53 ZoneProvision(const std::string& rootPath,
54 const std::string& configPath,
55 const std::string& dbPath,
56 const std::string& dbPrefix,
57 const std::vector<std::string>& validLinkPrefixes);
60 ZoneProvision(const ZoneProvision&) = delete;
61 ZoneProvision& operator=(const ZoneProvision&) = delete;
62 ZoneProvision(ZoneProvision&&) = default;
65 * Declare file, directory or pipe that will be created while zone startup
67 std::string declareFile(const int32_t& type,
68 const std::string& path,
72 * Declare mount that will be created while zone startup
74 std::string declareMount(const std::string& source,
75 const std::string& target,
76 const std::string& type,
78 const std::string& data);
80 * Declare link that will be created while zone startup
82 std::string declareLink(const std::string& source,
83 const std::string& target);
85 void start() noexcept;
89 * List all provisioned resources
91 std::vector<std::string> list() const;
96 * @param item resource to be removed (as in list())
98 void remove(const std::string& item);
101 ZoneProvisioningConfig mProvisioningConfig;
102 std::string mRootPath;
104 std::string mDbPrefix;
105 std::vector<std::string> mValidLinkPrefixes;
106 std::list<ZoneProvisioningConfig::Provision> mProvisioned;
108 void saveProvisioningConfig();
109 std::string declareProvision(ZoneProvisioningConfig::Provision&& provision);
111 void mount(const ZoneProvisioningConfig::Mount& config);
112 void umount(const ZoneProvisioningConfig::Mount& config);
113 void file(const ZoneProvisioningConfig::File& config);
114 void link(const ZoneProvisioningConfig::Link& config);
116 static std::string getId(const ZoneProvisioningConfig::File& file);
117 static std::string getId(const ZoneProvisioningConfig::Mount& mount);
118 static std::string getId(const ZoneProvisioningConfig::Link& link);
119 static std::string getId(const ZoneProvisioningConfig::Provision& provision);
124 #endif // SERVER_ZONE_PROVISION_HPP