Revision 9dae41ad daemons/ganeti-noded

b/daemons/ganeti-noded
735 735
  return options, args
736 736

  
737 737

  
738
def EnsureRuntimeEnvironment():
739
  """Ensure our run-time environment is complete.
740

  
741
  Currently this creates directories which could be missing, either
742
  due to directories being on a tmpfs mount, or due to incomplete
743
  packaging.
744

  
745
  """
746
  dirs = [(val, constants.RUN_DIRS_MODE) for val in constants.SUB_RUN_DIRS]
747
  dirs.append((constants.LOG_OS_DIR, 0750))
748
  dirs.append((constants.LOCK_DIR, 1777))
749
  for dir_name, dir_mode in dirs:
750
    if not os.path.exists(dir_name):
751
      try:
752
        os.mkdir(dir_name, dir_mode)
753
      except EnvironmentError, err:
754
        if err.errno != errno.EEXIST:
755
          print ("Node setup wrong, cannot create directory '%s': %s" %
756
                 (dir_name, err))
757
          sys.exit(5)
758
    if not os.path.isdir(dir_name):
759
      print ("Node setup wrong, '%s' is not a directory" % dir_name)
760
      sys.exit(5)
761

  
762

  
763 738
def main():
764 739
  """Main function for the node daemon.
765 740

  
......
783 758
    print "Cluster configuration incomplete: '%s'" % str(err)
784 759
    sys.exit(5)
785 760

  
786
  EnsureRuntimeEnvironment()
761
  dirs = [(val, constants.RUN_DIRS_MODE) for val in constants.SUB_RUN_DIRS]
762
  dirs.append((constants.LOG_OS_DIR, 0750))
763
  dirs.append((constants.LOCK_DIR, 1777))
764
  utils.EnsureDirs(dirs)
787 765

  
788 766
  # become a daemon
789 767
  if options.fork:

Also available in: Unified diff