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>
46 // |- staging (staging mount point)
47 // |- target (mount point)
48 
49 
51 {
52  std::string type;
53  std::string name;
54  ContainerID containerId;
55 };
56 
57 
58 struct VolumePath
59 {
60  std::string type;
61  std::string name;
62  std::string volumeId;
63 };
64 
65 
67  const std::string& rootDir,
68  const std::string& type,
69  const std::string& name);
70 
71 
72 std::string getContainerPath(
73  const std::string& rootDir,
74  const std::string& type,
75  const std::string& name,
76  const ContainerID& containerId);
77 
78 
80  const std::string& rootDir,
81  const std::string& dir);
82 
83 
84 std::string getContainerInfoPath(
85  const std::string& rootDir,
86  const std::string& type,
87  const std::string& name,
88  const ContainerID& containerId);
89 
90 
91 std::string getEndpointDirSymlinkPath(
92  const std::string& rootDir,
93  const std::string& type,
94  const std::string& name,
95  const ContainerID& containerId);
96 
97 
98 // Returns the resolved path to the endpoint socket, even if the socket
99 // file itself does not exist. Creates and symlinks the endpoint
100 // directory if necessary.
102  const std::string& rootDir,
103  const std::string& type,
104  const std::string& name,
105  const ContainerID& containerId);
106 
107 
109  const std::string& rootDir,
110  const std::string& type,
111  const std::string& name);
112 
113 
114 std::string getVolumePath(
115  const std::string& rootDir,
116  const std::string& type,
117  const std::string& name,
118  const std::string& volumeId);
119 
120 
122  const std::string& rootDir,
123  const std::string& dir);
124 
125 
126 std::string getVolumeStatePath(
127  const std::string& rootDir,
128  const std::string& type,
129  const std::string& name,
130  const std::string& volumeId);
131 
132 
133 std::string getMountRootDir(
134  const std::string& rootDir,
135  const std::string& type,
136  const std::string& name);
137 
138 
139 std::string getMountStagingPath(
140  const std::string& mountRootDir,
141  const std::string& volumeId);
142 
143 
144 std::string getMountTargetPath(
145  const std::string& mountRootDir,
146  const std::string& volumeId);
147 
148 } // namespace paths {
149 } // namespace csi {
150 } // namespace mesos {
151 
152 #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:61
Definition: check.hpp:33
std::string getEndpointDirSymlinkPath(const std::string &rootDir, const std::string &type, const std::string &name, const ContainerID &containerId)
std::string volumeId
Definition: paths.hpp:62
std::string paths()
Definition: os.hpp:137
Definition: utils.hpp:37
std::string type
Definition: paths.hpp:52
std::string getMountTargetPath(const std::string &mountRootDir, const std::string &volumeId)
std::string getMountStagingPath(const std::string &mountRootDir, const std::string &volumeId)
std::string type
Definition: paths.hpp:60
std::string name
Definition: paths.hpp:53
Try< ContainerPath > parseContainerPath(const std::string &rootDir, const std::string &dir)
std::string getVolumePath(const std::string &rootDir, const std::string &type, const std::string &name, const std::string &volumeId)
Definition: paths.hpp:58
std::string getVolumeStatePath(const std::string &rootDir, const std::string &type, const std::string &name, const std::string &volumeId)
Definition: spec.hpp:26
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< VolumePath > parseVolumePath(const std::string &rootDir, const std::string &dir)
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)
Definition: paths.hpp:50
ContainerID containerId
Definition: paths.hpp:54