Apache Mesos
paths.hpp
Go to the documentation of this file.
1 // Licensed to the Apache Software Foundation (ASF) under one
2 // or more contributor license agreements. See the NOTICE file
3 // distributed with this work for additional information
4 // regarding copyright ownership. The ASF licenses this file
5 // to you under the Apache License, Version 2.0 (the
6 // "License"); you may not use this file except in compliance
7 // with the License. You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 
17 #ifndef __ISOLATOR_CNI_PATHS_HPP__
18 #define __ISOLATOR_CNI_PATHS_HPP__
19 
20 #include <list>
21 #include <string>
22 
23 #include <mesos/mesos.hpp>
24 
25 #include <stout/try.hpp>
26 
27 namespace mesos {
28 namespace internal {
29 namespace slave {
30 namespace cni {
31 namespace paths {
32 
33 // The root directory where we keep the information of CNI networks that each
34 // container joins. The layout is as follows:
35 // /var/run/mesos/isolators/network/cni/
36 // |- <ID of Container1>/
37 // | |-- ns -> /proc/<pid>/ns/net (bind mount)
38 // | |-- <Name of CNI network 1>/
39 // | | |-- network.conf (JSON file to keep the CNI network configuration)
40 // | | |-- ifname1/
41 // | | |-- network.info (JSON file to keep the output of CNI plugin)
42 // | |-- <Name of CNI network 2>/
43 // | | |-- network.conf
44 // | |-- ifname2/
45 // | |-- network.info
46 // |-- <ID of ContainerID 2>/
47 // | ...
48 constexpr char ROOT_DIR[] = "/var/run/mesos/isolators/network/cni";
49 
50 
51 std::string getContainerDir(
52  const std::string& rootDir,
53  const ContainerID& containerId);
54 
55 
56 std::string getNamespacePath(
57  const std::string& rootDir,
58  const ContainerID& containerId);
59 
60 
61 std::string getNetworkDir(
62  const std::string& rootDir,
63  const ContainerID& containerId,
64  const std::string& networkName);
65 
66 
68  const std::string& rootDir,
69  const ContainerID& containerId);
70 
71 
72 std::string getNetworkConfigPath(
73  const std::string& rootDir,
74  const ContainerID& containerId,
75  const std::string& networkName);
76 
77 
78 std::string getInterfaceDir(
79  const std::string& rootDir,
80  const ContainerID& containerId,
81  const std::string& networkName,
82  const std::string& ifName);
83 
84 
86  const std::string& rootDir,
87  const ContainerID& containerId,
88  const std::string& networkName);
89 
90 
91 std::string getNetworkInfoPath(
92  const std::string& rootDir,
93  const ContainerID& containerId,
94  const std::string& networkName,
95  const std::string& ifName);
96 
97 } // namespace paths {
98 } // namespace cni {
99 } // namespace slave {
100 } // namespace internal {
101 } // namespace mesos {
102 
103 #endif // __ISOLATOR_CNI_PATHS_HPP__
Definition: check.hpp:33
std::string getNetworkInfoPath(const std::string &rootDir, const ContainerID &containerId, const std::string &networkName, const std::string &ifName)
std::string paths()
Definition: os.hpp:137
std::string getInterfaceDir(const std::string &rootDir, const ContainerID &containerId, const std::string &networkName, const std::string &ifName)
Try< std::list< std::string > > getInterfaces(const std::string &rootDir, const ContainerID &containerId, const std::string &networkName)
Try< std::list< std::string > > getNetworkNames(const std::string &rootDir, const ContainerID &containerId)
Definition: spec.hpp:26
std::string getContainerDir(const std::string &rootDir, const ContainerID &containerId)
std::string getNetworkConfigPath(const std::string &rootDir, const ContainerID &containerId, const std::string &networkName)
Definition: attributes.hpp:24
std::string getNamespacePath(const std::string &rootDir, const ContainerID &containerId)
constexpr char ROOT_DIR[]
Definition: paths.hpp:48
std::string getNetworkDir(const std::string &rootDir, const ContainerID &containerId, const std::string &networkName)