Revision 3b721842

b/lib/backend.py
1217 1217
          " log file:\n%s", result.fail_reason, "\n".join(lines), log=False)
1218 1218

  
1219 1219

  
1220
def _GetBlockDevSymlinkPath(instance_name, idx):
1221
  return utils.PathJoin(pathutils.DISK_LINKS_DIR, "%s%s%d" %
1222
                        (instance_name, constants.DISK_SEPARATOR, idx))
1220
def _GetBlockDevSymlinkPath(instance_name, idx, _dir=None):
1221
  """Returns symlink path for block device.
1222

  
1223
  """
1224
  if _dir is None:
1225
    _dir = pathutils.DISK_LINKS_DIR
1226

  
1227
  return utils.PathJoin(_dir,
1228
                        ("%s%s%s" %
1229
                         (instance_name, constants.DISK_SEPARATOR, idx)))
1223 1230

  
1224 1231

  
1225 1232
def _SymlinkBlockDev(instance_name, device_path, idx):
b/test/py/ganeti.backend_unittest.py
517 517
      self.assertEqual(os.stat(self.filename).st_mode & 0777, 0644)
518 518

  
519 519

  
520
class TestGetBlockDevSymlinkPath(unittest.TestCase):
521
  def setUp(self):
522
    self.tmpdir = tempfile.mkdtemp()
523

  
524
  def tearDown(self):
525
    shutil.rmtree(self.tmpdir)
526

  
527
  def _Test(self, name, idx):
528
    self.assertEqual(backend._GetBlockDevSymlinkPath(name, idx,
529
                                                     _dir=self.tmpdir),
530
                     ("%s/%s%s%s" % (self.tmpdir, name,
531
                                     constants.DISK_SEPARATOR, idx)))
532

  
533
  def test(self):
534
    for idx in range(100):
535
      self._Test("inst1.example.com", idx)
536

  
537

  
520 538
if __name__ == "__main__":
521 539
  testutils.GanetiTestProgram()

Also available in: Unified diff