Revision 9340cc2b

b/lib/vcluster.py
21 21

  
22 22
"""Module containing utilities for virtual clusters.
23 23

  
24
Most functions manipulate file system paths and are no-ops when the environment
25
variables C{GANETI_ROOTDIR} and C{GANETI_HOSTNAME} are not set. See the
26
functions' docstrings for details.
24 27

  
25 28
"""
26 29

  
......
81 84
def _PreparePaths(rootdir, hostname):
82 85
  """Checks if the root directory and hostname are acceptable.
83 86

  
87
  The (node-specific) root directory must have the hostname as its last
88
  component. The parent directory then becomes the cluster-wide root directory.
89
  This is necessary as some components must be able to predict the root path on
90
  a remote node (e.g. copying files via scp).
91

  
84 92
  @type rootdir: string
85 93
  @param rootdir: Root directory (from environment)
86 94
  @type hostname: string
......
139 147
                     _basedir=_VIRT_BASEDIR, _noderoot=_VIRT_NODEROOT):
140 148
  """Replaces the node-specific root directory in a path.
141 149

  
142
  Replaces it with the root directory for another node.
150
  Replaces it with the root directory for another node. Assuming
151
  C{/tmp/vcluster/node1} is the root directory for C{node1}, the result will be
152
  C{/tmp/vcluster/node3} for C{node3} (as long as a root directory is specified
153
  in the environment).
143 154

  
144 155
  """
145 156
  if _basedir:
......
168 179
  """Adds a node-specific prefix to a path in a virtual cluster.
169 180

  
170 181
  Returned path includes user-specified root directory if specified in
171
  environment.
182
  environment. As an example, the path C{/var/lib/ganeti} becomes
183
  C{/tmp/vcluster/node1/var/lib/ganeti} if C{/tmp/vcluster/node1} is the root
184
  directory specified in the environment.
172 185

  
173 186
  """
174 187
  assert os.path.isabs(path)
......
186 199
def _RemoveNodePrefix(path, _noderoot=_VIRT_NODEROOT):
187 200
  """Removes the node-specific prefix from a path.
188 201

  
202
  This is the opposite of L{AddNodePrefix} and removes a node-local prefix
203
  path.
204

  
189 205
  """
190 206
  assert os.path.isabs(path)
191 207

  
......
215 231

  
216 232
  A path is "virtualized" by stripping it of its node-specific directory and
217 233
  prepending a prefix (L{_VIRT_PATH_PREFIX}). Use L{LocalizeVirtualPath} to
218
  undo the process.
234
  undo the process. Virtual paths are meant to be transported via RPC.
219 235

  
220 236
  """
221 237
  assert os.path.isabs(path)
......
231 247

  
232 248
  A "virtualized" path consists of a prefix (L{LocalizeVirtualPath}) and a
233 249
  local path. This function adds the node-specific directory to the local path.
250
  Virtual paths are meant to be transported via RPC.
234 251

  
235 252
  """
236 253
  assert os.path.isabs(path)

Also available in: Unified diff