2 * Copyright (C) 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License version 2.1 as published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 * @author Maciej Karpiuk (m.karpiuk2@samsung.com)
21 * @brief Provisioning configuration
26 #include "lxcpp/container-config.hpp"
28 using namespace lxcpp;
29 using namespace provision;
31 void ProvisionConfig::addFile(const File& newFile)
33 auto it = std::find(files.begin(), files.end(), newFile);
34 if (it != files.end()) {
35 const std::string msg =
36 "Can't add file. Provision already exists: " + newFile.getId();
38 throw ProvisionException(msg);
40 files.push_back(newFile);
43 const FileVector& ProvisionConfig::getFiles() const
48 void ProvisionConfig::removeFile(const File& item)
50 const auto it = std::find(files.begin(), files.end(), item);
51 if (it == files.end()) {
52 const std::string msg = "Can't find provision: " + item.getId();
54 throw ProvisionException(msg);
60 void ProvisionConfig::addMount(const Mount& newMount)
62 auto it = std::find(mounts.begin(), mounts.end(), newMount);
63 if (it != mounts.end()) {
64 const std::string msg =
65 "Can't add mount. Provision already exists: " + newMount.getId();
67 throw ProvisionException(msg);
69 mounts.push_back(newMount);
72 const MountVector& ProvisionConfig::getMounts() const
77 void ProvisionConfig::removeMount(const Mount& item)
79 const auto it = std::find(mounts.begin(), mounts.end(), item);
80 if (it == mounts.end()) {
81 const std::string msg = "Can't find provision: " + item.getId();
83 throw ProvisionException(msg);
89 void ProvisionConfig::addLink(const Link& newLink)
91 auto it = std::find(links.begin(), links.end(), newLink);
92 if (it != links.end()) {
93 const std::string msg =
94 "Can't add link. Provision already exists: " + newLink.getId();
96 throw ProvisionException(msg);
98 links.push_back(newLink);
101 const LinkVector& ProvisionConfig::getLinks() const
106 void ProvisionConfig::removeLink(const Link& item)
108 const auto it = std::find(links.begin(), links.end(), item);
109 if (it == links.end()) {
110 const std::string msg = "Can't find provision: " + item.getId();
112 throw ProvisionException(msg);