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 __CSI_PATHS_HPP__
18 #define __CSI_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 csi {
29 namespace paths {
30 
31 // The file system layout is as follows:
32 //
33 // root (<work_dir>/csi/)
34 // |-- <type>
35 // |-- <name>
36 // |-- containers
37 // | |-- <container_id>
38 // | |-- container.info
39 // | |-- endpoint (symlink to /tmp/mesos-csi-XXXXXX)
40 // | |-- endpoint.sock
41 // |-- volumes
42 // | |-- <volume_id>
43 // | |-- volume.state
44 // |-- mounts
45 // |-- <volume_id> (mount point)
46 
47 
48 struct VolumePath
49 {
50  std::string type;
51  std::string name;
52  std::string volumeId;
53 };
54 
55 
57  const std::string& rootDir,
58  const std::string& type,
59  const std::string& name);
60 
61 
62 std::string getContainerPath(
63  const std::string& rootDir,
64  const std::string& type,
65  const std::string& name,
66  const ContainerID& containerId);
67 
68 
69 std::string getContainerInfoPath(
70  const std::string& rootDir,
71  const std::string& type,
72  const std::string& name,
73  const ContainerID& containerId);
74 
75 
76 std::string getEndpointDirSymlinkPath(
77  const std::string& rootDir,
78  const std::string& type,
79  const std::string& name,
80  const ContainerID& containerId);
81 
82 
83 // Returns the resolved path to the endpoint socket, even if the socket
84 // file itself does not exist. Creates and symlinks the endpoint
85 // directory if necessary.
87  const std::string& rootDir,
88  const std::string& type,
89  const std::string& name,
90  const ContainerID& containerId);
91 
92 
94  const std::string& rootDir,
95  const std::string& type,
96  const std::string& name);
97 
98 
99 std::string getVolumePath(
100  const std::string& rootDir,
101  const std::string& type,
102  const std::string& name,
103  const std::string& volumeId);
104 
105 
107  const std::string& rootDir,
108  const std::string& dir);
109 
110 
111 std::string getVolumeStatePath(
112  const std::string& rootDir,
113  const std::string& type,
114  const std::string& name,
115  const std::string& volumeId);
116 
117 
118 std::string getMountRootDir(
119  const std::string& rootDir,
120  const std::string& type,
121  const std::string& name);
122 
123 
124 std::string getMountPath(
125  const std::string& rootDir,
126  const std::string& type,
127  const std::string& name,
128  const std::string& volumeId);
129 
130 } // namespace paths {
131 } // namespace csi {
132 } // namespace mesos {
133 
134 #endif // __CSI_PATHS_HPP__
std::string getMountRootDir(const std::string &rootDir, const std::string &type, const std::string &name)
Try< std::list< std::string > > getVolumePaths(const std::string &rootDir, const std::string &type, const std::string &name)
std::string name
Definition: paths.hpp:51
Definition: try.hpp:34
std::string getEndpointDirSymlinkPath(const std::string &rootDir, const std::string &type, const std::string &name, const ContainerID &containerId)
std::string volumeId
Definition: paths.hpp:52
std::string paths()
Definition: os.hpp:136
std::string type
Definition: paths.hpp:50
std::string getVolumePath(const std::string &rootDir, const std::string &type, const std::string &name, const std::string &volumeId)
Definition: paths.hpp:48
std::string getVolumeStatePath(const std::string &rootDir, const std::string &type, const std::string &name, const std::string &volumeId)
Try< std::string > getEndpointSocketPath(const std::string &rootDir, const std::string &type, const std::string &name, const ContainerID &containerId)
std::string getContainerInfoPath(const std::string &rootDir, const std::string &type, const std::string &name, const ContainerID &containerId)
Try< uint32_t > type(const std::string &path)
Try< VolumePath > parseVolumePath(const std::string &rootDir, const std::string &dir)
std::string getMountPath(const std::string &rootDir, const std::string &type, const std::string &name, const std::string &volumeId)
Try< std::list< std::string > > getContainerPaths(const std::string &rootDir, const std::string &type, const std::string &name)
std::string getContainerPath(const std::string &rootDir, const std::string &type, const std::string &name, const ContainerID &containerId)
constexpr const char * name
Definition: shell.hpp:41