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 #include "slave/flags.hpp"
28 
29 namespace mesos {
30 namespace internal {
31 namespace slave {
32 namespace cni {
33 namespace paths {
34 
35 // The root directory where we keep the information of CNI networks that each
36 // container joins. The layout is as follows:
37 // /<work_dir|runtime_dir>/isolators/network/cni/
38 // |- <ID of Container1>/
39 // | |-- ns -> /proc/<pid>/ns/net (bind mount)
40 // | |-- <Name of CNI network 1>/
41 // | | |-- network.conf (JSON file to keep the CNI network configuration)
42 // | | |-- ifname1/
43 // | | |-- network.info (JSON file to keep the output of CNI plugin)
44 // | |-- <Name of CNI network 2>/
45 // | | |-- network.conf
46 // | |-- ifname2/
47 // | |-- network.info
48 // |-- <ID of ContainerID 2>/
49 // | ...
50 constexpr char CNI_DIR[] = "isolators/network/cni";
51 
52 
53 std::string getCniRootDir(const Flags& flags);
54 
55 
56 std::string getContainerDir(
57  const std::string& rootDir,
58  const ContainerID& containerId);
59 
60 
61 std::string getNamespacePath(
62  const std::string& rootDir,
63  const ContainerID& containerId);
64 
65 
66 std::string getNetworkDir(
67  const std::string& rootDir,
68  const ContainerID& containerId,
69  const std::string& networkName);
70 
71 
73  const std::string& rootDir,
74  const ContainerID& containerId);
75 
76 
77 std::string getNetworkConfigPath(
78  const std::string& rootDir,
79  const ContainerID& containerId,
80  const std::string& networkName);
81 
82 
83 std::string getInterfaceDir(
84  const std::string& rootDir,
85  const ContainerID& containerId,
86  const std::string& networkName,
87  const std::string& ifName);
88 
89 
91  const std::string& rootDir,
92  const ContainerID& containerId,
93  const std::string& networkName);
94 
95 
96 std::string getNetworkInfoPath(
97  const std::string& rootDir,
98  const ContainerID& containerId,
99  const std::string& networkName,
100  const std::string& ifName);
101 
102 } // namespace paths {
103 } // namespace cni {
104 } // namespace slave {
105 } // namespace internal {
106 } // namespace mesos {
107 
108 #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:138
std::string getInterfaceDir(const std::string &rootDir, const ContainerID &containerId, const std::string &networkName, const std::string &ifName)
Definition: flags.hpp:39
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: agent.hpp:25
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
constexpr char CNI_DIR[]
Definition: paths.hpp:50
std::string getNamespacePath(const std::string &rootDir, const ContainerID &containerId)
std::string getNetworkDir(const std::string &rootDir, const ContainerID &containerId, const std::string &networkName)
std::string getCniRootDir(const Flags &flags)
Definition: parse.hpp:33