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 Container interface
24 #ifndef LXCPP_CONTAINER_HPP
25 #define LXCPP_CONTAINER_HPP
27 #include "lxcpp/network-config.hpp"
28 #include "lxcpp/provision-config.hpp"
29 #include "lxcpp/logger-config.hpp"
31 #include <sys/types.h>
39 struct NetworkInterfaceInfo {
40 const std::string ifname;
41 const NetStatus status;
42 const std::string macaddr;
45 const std::vector<InetAddr> addrs;
50 virtual ~Container() {};
53 virtual const std::string& getName() const = 0;
54 virtual const std::string& getRootPath() const = 0;
56 virtual pid_t getGuardPid() const = 0;
57 virtual pid_t getInitPid() const = 0;
59 virtual const std::vector<std::string>& getInit() = 0;
60 virtual void setInit(const std::vector<std::string> &init) = 0;
62 virtual void setLogger(const logger::LogType type,
63 const logger::LogLevel level,
64 const std::string &arg = "") = 0;
66 virtual void setTerminalCount(const unsigned int count) = 0;
68 virtual void setNamespaces(const int namespaces) = 0;
69 virtual int getNamespaces() const = 0;
72 virtual void start() = 0;
73 virtual void stop() = 0;
74 virtual void freeze() = 0;
75 virtual void unfreeze() = 0;
76 virtual void reboot() = 0;
79 virtual void attach(const std::vector<std::string>& argv,
80 const std::string& cwdInContainer) = 0;
81 virtual void console() = 0;
82 virtual bool isRunning() const = 0;
84 // Network interfaces setup/config
85 virtual void addInterfaceConfig(const std::string& hostif,
86 const std::string& zoneif,
88 const std::vector<InetAddr>& addrs,
89 MacVLanMode mode) = 0;
90 virtual void addInetConfig(const std::string& ifname, const InetAddr& addr) = 0;
92 // Network interfaces (runtime)
93 virtual std::vector<std::string> getInterfaces() const = 0;
94 virtual NetworkInterfaceInfo getInterfaceInfo(const std::string& ifname) const = 0;
95 virtual void createInterface(const std::string& hostif,
96 const std::string& zoneif,
98 MacVLanMode mode) = 0;
99 virtual void destroyInterface(const std::string& ifname) = 0;
100 virtual void moveInterface(const std::string& ifname) = 0;
101 virtual void setUp(const std::string& ifname) = 0;
102 virtual void setDown(const std::string& ifname) = 0;
103 virtual void addInetAddr(const std::string& ifname, const InetAddr& addr) = 0;
104 virtual void delInetAddr(const std::string& ifname, const InetAddr& addr) = 0;
107 virtual void declareFile(const provision::File::Type type,
108 const std::string& path,
110 const int32_t mode) = 0;
111 virtual const FileVector& getFiles() const = 0;
112 virtual void removeFile(const provision::File& item) = 0;
114 virtual void declareMount(const std::string& source,
115 const std::string& target,
116 const std::string& type,
118 const std::string& data) = 0;
119 virtual const MountVector& getMounts() const = 0;
120 virtual void removeMount(const provision::Mount& item) = 0;
122 virtual void declareLink(const std::string& source,
123 const std::string& target) = 0;
124 virtual const LinkVector& getLinks() const = 0;
125 virtual void removeLink(const provision::Link& item) = 0;
130 #endif // LXCPP_CONTAINER_HPP