Revision 8adbffaa
b/daemons/ganeti-noded | ||
---|---|---|
648 | 648 |
return options, args |
649 | 649 |
|
650 | 650 |
|
651 |
def EnsureRuntimeEnvironment(): |
|
652 |
"""Ensure our run-time environment is complete. |
|
653 |
|
|
654 |
Currently this creates directories which could be missing, either |
|
655 |
due to directories being on a tmpfs mount, or due to incomplete |
|
656 |
packaging. |
|
657 |
|
|
658 |
""" |
|
659 |
dirs = [(val, 0755) for val in constants.SUB_RUN_DIRS] |
|
660 |
dirs.append((constants.LOG_OS_DIR, 0750)) |
|
661 |
for dir_name, dir_mode in dirs: |
|
662 |
if not os.path.exists(dir_name): |
|
663 |
try: |
|
664 |
os.mkdir(dir_name, dir_mode) |
|
665 |
except EnvironmentError, err: |
|
666 |
if err.errno != errno.EEXIST: |
|
667 |
print ("Node setup wrong, cannot create directory '%s': %s" % |
|
668 |
(dir_name, err)) |
|
669 |
sys.exit(5) |
|
670 |
if not os.path.isdir(dir_name): |
|
671 |
print ("Node setup wrong, '%s' is not a directory" % dir_name) |
|
672 |
sys.exit(5) |
|
673 |
|
|
674 |
|
|
651 | 675 |
def main(): |
652 | 676 |
"""Main function for the node daemon. |
653 | 677 |
|
... | ... | |
668 | 692 |
print "Cluster configuration incomplete: '%s'" % str(err) |
669 | 693 |
sys.exit(5) |
670 | 694 |
|
671 |
# create the various SUB_RUN_DIRS, if not existing, so that we handle the |
|
672 |
# situation where RUN_DIR is tmpfs |
|
673 |
for dir_name in constants.SUB_RUN_DIRS: |
|
674 |
if not os.path.exists(dir_name): |
|
675 |
try: |
|
676 |
os.mkdir(dir_name, 0755) |
|
677 |
except EnvironmentError, err: |
|
678 |
if err.errno != errno.EEXIST: |
|
679 |
print ("Node setup wrong, cannot create directory %s: %s" % |
|
680 |
(dir_name, err)) |
|
681 |
sys.exit(5) |
|
682 |
if not os.path.isdir(dir_name): |
|
683 |
print ("Node setup wrong, %s is not a directory" % dir_name) |
|
684 |
sys.exit(5) |
|
695 |
EnsureRuntimeEnvironment() |
|
685 | 696 |
|
686 | 697 |
# become a daemon |
687 | 698 |
if options.fork: |
Also available in: Unified diff