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 Mateusz Malicki (m.malicki2@samsung.com)
21 * @brief ContainerImpl main class
24 #ifndef LXCPP_CONTAINER_IMPL_HPP
25 #define LXCPP_CONTAINER_IMPL_HPP
27 #include <sys/types.h>
30 #include "lxcpp/container-config.hpp"
31 #include "lxcpp/container.hpp"
32 #include "lxcpp/namespace.hpp"
36 class ContainerImpl : public virtual Container {
38 ContainerImpl(const std::string &name, const std::string &path);
39 ContainerImpl(pid_t guardPid);
43 const std::string& getName() const;
44 const std::string& getRootPath() const;
46 pid_t getGuardPid() const;
47 pid_t getInitPid() const;
49 const std::vector<std::string>& getInit();
50 void setInit(const std::vector<std::string> &init);
52 void setLogger(const logger::LogType type,
53 const logger::LogLevel level,
54 const std::string &arg);
56 void setTerminalCount(const unsigned int count);
58 void setNamespaces(const int namespaces);
59 int getNamespaces() const;
69 void attach(const std::vector<std::string>& argv,
70 const std::string& cwdInContainer);
72 bool isRunning() const;
74 // Network interfaces setup/config
76 * adds interface configration.
77 * throws NetworkException if zoneif name already on list
79 void addInterfaceConfig(const std::string& hostif,
80 const std::string& zoneif,
82 const std::vector<InetAddr>& addrs,
84 void addInetConfig(const std::string& ifname, const InetAddr& addr);
86 // Network interfaces (runtime)
87 std::vector<std::string> getInterfaces() const;
88 NetworkInterfaceInfo getInterfaceInfo(const std::string& ifname) const;
89 void createInterface(const std::string& hostif,
90 const std::string& zoneif,
93 void moveInterface(const std::string& ifname);
94 void destroyInterface(const std::string& ifname);
95 void setUp(const std::string& ifname);
96 void setDown(const std::string& ifname);
97 void addInetAddr(const std::string& ifname, const InetAddr& addr);
98 void delInetAddr(const std::string& ifname, const InetAddr& addr);
101 void declareFile(const provision::File::Type type,
102 const std::string& path,
105 const FileVector& getFiles() const;
106 void removeFile(const provision::File& item);
108 void declareMount(const std::string& source,
109 const std::string& target,
110 const std::string& type,
112 const std::string& data);
113 const MountVector& getMounts() const;
114 void removeMount(const provision::Mount& item);
116 void declareLink(const std::string& source,
117 const std::string& target);
118 const LinkVector& getLinks() const;
119 void removeLink(const provision::Link& item);
122 ContainerConfig mConfig;
127 #endif // LXCPP_CONTAINER_IMPL_HPP