Revision c4feafe8

b/daemons/ganeti-watcher
85 85
  """Run the watcher hooks.
86 86

  
87 87
  """
88
  hooks_dir = os.path.join(constants.HOOKS_BASE_DIR,
89
                           constants.HOOKS_NAME_WATCHER)
88
  hooks_dir = utils.PathJoin(constants.HOOKS_BASE_DIR,
89
                             constants.HOOKS_NAME_WATCHER)
90 90

  
91 91
  try:
92 92
    results = utils.RunParts(hooks_dir)
b/lib/backend.py
163 163
    exclude = [os.path.normpath(i) for i in exclude]
164 164

  
165 165
  for rel_name in utils.ListVisibleFiles(path):
166
    full_name = os.path.normpath(os.path.join(path, rel_name))
166
    full_name = utils.PathJoin(path, rel_name)
167 167
    if full_name in exclude:
168 168
      continue
169 169
    if os.path.isfile(full_name) and not os.path.islink(full_name):
......
907 907

  
908 908

  
909 909
def _GetBlockDevSymlinkPath(instance_name, idx):
910
  return os.path.join(constants.DISK_LINKS_DIR,
911
                      "%s:%d" % (instance_name, idx))
910
  return utils.PathJoin(constants.DISK_LINKS_DIR,
911
                        "%s:%d" % (instance_name, idx))
912 912

  
913 913

  
914 914
def _SymlinkBlockDev(instance_name, device_path, idx):
......
1995 1995
  export_env['EXPORT_DEVICE'] = real_disk.dev_path
1996 1996
  export_env['EXPORT_INDEX'] = str(idx)
1997 1997

  
1998
  destdir = os.path.join(constants.EXPORT_DIR, instance.name + ".new")
1998
  destdir = utils.PathJoin(constants.EXPORT_DIR, instance.name + ".new")
1999 1999
  destfile = disk.physical_id[1]
2000 2000

  
2001 2001
  # the target command is built out of three individual commands,
......
2035 2035
  @rtype: None
2036 2036

  
2037 2037
  """
2038
  destdir = os.path.join(constants.EXPORT_DIR, instance.name + ".new")
2039
  finaldestdir = os.path.join(constants.EXPORT_DIR, instance.name)
2038
  destdir = utils.PathJoin(constants.EXPORT_DIR, instance.name + ".new")
2039
  finaldestdir = utils.PathJoin(constants.EXPORT_DIR, instance.name)
2040 2040

  
2041 2041
  config = objects.SerializableConfigParser()
2042 2042

  
......
2079 2079

  
2080 2080
  config.set(constants.INISECT_INS, 'disk_count' , '%d' % disk_total)
2081 2081

  
2082
  utils.WriteFile(os.path.join(destdir, constants.EXPORT_CONF_FILE),
2082
  utils.WriteFile(utils.PathJoin(destdir, constants.EXPORT_CONF_FILE),
2083 2083
                  data=config.Dumps())
2084 2084
  shutil.rmtree(finaldestdir, True)
2085 2085
  shutil.move(destdir, finaldestdir)
......
2096 2096
      export info
2097 2097

  
2098 2098
  """
2099
  cff = os.path.join(dest, constants.EXPORT_CONF_FILE)
2099
  cff = utils.PathJoin(dest, constants.EXPORT_CONF_FILE)
2100 2100

  
2101 2101
  config = objects.SerializableConfigParser()
2102 2102
  config.read(cff)
......
2179 2179
  @rtype: None
2180 2180

  
2181 2181
  """
2182
  target = os.path.join(constants.EXPORT_DIR, export)
2182
  target = utils.PathJoin(constants.EXPORT_DIR, export)
2183 2183

  
2184 2184
  try:
2185 2185
    shutil.rmtree(target)
b/lib/cmdlib.py
5866 5866
          self.needed_locks[locking.LEVEL_NODE].append(src_node)
5867 5867
        if not os.path.isabs(src_path):
5868 5868
          self.op.src_path = src_path = \
5869
            os.path.join(constants.EXPORT_DIR, src_path)
5869
            utils.PathJoin(constants.EXPORT_DIR, src_path)
5870 5870

  
5871 5871
      # On import force_variant must be True, because if we forced it at
5872 5872
      # initial install, our only chance when importing it back is that it
......
5974 5974
          if src_path in exp_list[node].payload:
5975 5975
            found = True
5976 5976
            self.op.src_node = src_node = node
5977
            self.op.src_path = src_path = os.path.join(constants.EXPORT_DIR,
5978
                                                       src_path)
5977
            self.op.src_path = src_path = utils.PathJoin(constants.EXPORT_DIR,
5978
                                                         src_path)
5979 5979
            break
5980 5980
        if not found:
5981 5981
          raise errors.OpPrereqError("No export found for relative path %s" %
......
6012 6012
        if export_info.has_option(constants.INISECT_INS, option):
6013 6013
          # FIXME: are the old os-es, disk sizes, etc. useful?
6014 6014
          export_name = export_info.get(constants.INISECT_INS, option)
6015
          image = os.path.join(src_path, export_name)
6015
          image = utils.PathJoin(src_path, export_name)
6016 6016
          disk_images.append(image)
6017 6017
        else:
6018 6018
          disk_images.append(False)
......
6148 6148
      string_file_storage_dir = self.op.file_storage_dir
6149 6149

  
6150 6150
    # build the full file storage dir path
6151
    file_storage_dir = os.path.normpath(os.path.join(
6152
                                        self.cfg.GetFileStorageDir(),
6153
                                        string_file_storage_dir, instance))
6151
    file_storage_dir = utils.PathJoin(self.cfg.GetFileStorageDir(),
6152
                                      string_file_storage_dir, instance)
6154 6153

  
6155 6154

  
6156 6155
    disks = _GenerateDiskTemplate(self,
b/lib/config.py
885 885
        # rename the file paths in logical and physical id
886 886
        file_storage_dir = os.path.dirname(os.path.dirname(disk.logical_id[1]))
887 887
        disk.physical_id = disk.logical_id = (disk.logical_id[0],
888
                                              os.path.join(file_storage_dir,
889
                                                           inst.name,
890
                                                           disk.iv_name))
888
                                              utils.PathJoin(file_storage_dir,
889
                                                             inst.name,
890
                                                             disk.iv_name))
891 891

  
892 892
    self._config_data.instances[inst.name] = inst
893 893
    self._WriteConfig()
b/lib/hypervisor/hv_chroot.py
110 110

  
111 111
    """
112 112
    return [name for name in os.listdir(self._ROOT_DIR)
113
            if self._IsDirLive(os.path.join(self._ROOT_DIR, name))]
113
            if self._IsDirLive(utils.PathJoin(self._ROOT_DIR, name))]
114 114

  
115 115
  def GetInstanceInfo(self, instance_name):
116 116
    """Get instance properties.
......
134 134
    """
135 135
    data = []
136 136
    for file_name in os.listdir(self._ROOT_DIR):
137
      path = os.path.join(self._ROOT_DIR, file_name)
137
      path = utils.PathJoin(self._ROOT_DIR, file_name)
138 138
      if self._IsDirLive(path):
139 139
        data.append((file_name, 0, 0, 0, 0, 0))
140 140
    return data
b/lib/jqueue.py
882 882
    @return: the path to the job file
883 883

  
884 884
    """
885
    return os.path.join(constants.QUEUE_DIR, "job-%s" % job_id)
885
    return utils.PathJoin(constants.QUEUE_DIR, "job-%s" % job_id)
886 886

  
887 887
  @classmethod
888 888
  def _GetArchivedJobPath(cls, job_id):
......
895 895

  
896 896
    """
897 897
    path = "%s/job-%s" % (cls._GetArchiveDirectory(job_id), job_id)
898
    return os.path.join(constants.JOB_QUEUE_ARCHIVE_DIR, path)
898
    return utils.PathJoin(constants.JOB_QUEUE_ARCHIVE_DIR, path)
899 899

  
900 900
  @classmethod
901 901
  def _ExtractJobID(cls, name):
b/lib/ssh.py
52 52
  if not user_dir:
53 53
    raise errors.OpExecError("Cannot resolve home of user %s" % user)
54 54

  
55
  ssh_dir = os.path.join(user_dir, ".ssh")
55
  ssh_dir = utils.PathJoin(user_dir, ".ssh")
56 56
  if not os.path.lexists(ssh_dir):
57 57
    if mkdir:
58 58
      try:
......
63 63
  elif not os.path.isdir(ssh_dir):
64 64
    raise errors.OpExecError("path ~%s/.ssh is not a directory" % user)
65 65

  
66
  return [os.path.join(ssh_dir, base)
66
  return [utils.PathJoin(ssh_dir, base)
67 67
          for base in ["id_dsa", "id_dsa.pub", "authorized_keys"]]
68 68

  
69 69

  
b/lib/utils.py
310 310
    return rr
311 311

  
312 312
  for relname in sorted(dir_contents):
313
    fname = os.path.join(dir_name, relname)
313
    fname = PathJoin(dir_name, relname)
314 314
    if not (os.path.isfile(fname) and os.access(fname, os.X_OK) and
315 315
            constants.EXT_PLUGIN_MASK.match(relname) is not None):
316 316
      rr.append((relname, constants.RUNPARTS_SKIP, None))
......
1607 1607
      daemon name
1608 1608

  
1609 1609
  """
1610
  return os.path.join(constants.RUN_GANETI_DIR, "%s.pid" % name)
1610
  return PathJoin(constants.RUN_GANETI_DIR, "%s.pid" % name)
1611 1611

  
1612 1612

  
1613 1613
def EnsureDaemon(name):
......
2106 2106

  
2107 2107
  for (curpath, _, files) in os.walk(path):
2108 2108
    for filename in files:
2109
      st = os.lstat(os.path.join(curpath, filename))
2109
      st = os.lstat(PathJoin(curpath, filename))
2110 2110
      size += st.st_size
2111 2111

  
2112 2112
  return BytesToMebibyte(size)
b/tools/burnin
23 23

  
24 24
"""
25 25

  
26
import os
27 26
import sys
28 27
import optparse
29 28
import time
......
658 657
                                           shutdown=True)
659 658
      rem_op = opcodes.OpRemoveInstance(instance_name=instance,
660 659
                                        ignore_failures=True)
661
      imp_dir = os.path.join(constants.EXPORT_DIR, full_name)
660
      imp_dir = utils.PathJoin(constants.EXPORT_DIR, full_name)
662 661
      imp_op = opcodes.OpCreateInstance(instance_name=instance,
663 662
                                        disks = [ {"size": size}
664 663
                                                  for size in self.disk_size],
b/tools/cluster-merge
125 125
                                 " key from %s. Fail reason: %s; output: %s" %
126 126
                                 (cluster, result.fail_reason, result.output))
127 127

  
128
      key_path = os.path.join(self.work_dir, cluster)
128
      key_path = utils.PathJoin(self.work_dir, cluster)
129 129
      utils.WriteFile(key_path, mode=0600, data=result.stdout)
130 130

  
131 131
      result = self._RunCmd(cluster, "gnt-node list -o name --no-header",
......
254 254
                                 (data.cluster, result.fail_reason,
255 255
                                  result.output))
256 256

  
257
      data.config_path = os.path.join(self.work_dir, "%s_config.data" %
258
                                                     data.cluster)
257
      data.config_path = utils.PathJoin(self.work_dir, "%s_config.data" %
258
                                        data.cluster)
259 259
      utils.WriteFile(data.config_path, data=result.stdout)
260 260

  
261 261
  # R0201: Method could be a function

Also available in: Unified diff