Revision 9dae41ad
b/daemons/ganeti-masterd | ||
---|---|---|
463 | 463 |
dirs = [(constants.RUN_GANETI_DIR, constants.RUN_DIRS_MODE), |
464 | 464 |
(constants.SOCKET_DIR, constants.SOCKET_DIR_MODE), |
465 | 465 |
] |
466 |
for dir_name, mode in dirs: |
|
467 |
try: |
|
468 |
os.mkdir(dir_name, mode) |
|
469 |
except EnvironmentError, err: |
|
470 |
if err.errno != errno.EEXIST: |
|
471 |
raise errors.GenericError("Cannot create needed directory" |
|
472 |
" '%s': %s" % (constants.SOCKET_DIR, err)) |
|
473 |
if not os.path.isdir(dir_name): |
|
474 |
raise errors.GenericError("%s is not a directory" % dir_name) |
|
466 |
utils.EnsureDirs(dirs) |
|
475 | 467 |
|
476 | 468 |
# This is safe to do as the pid file guarantees against |
477 | 469 |
# concurrent execution. |
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: |
b/lib/bootstrap.py | ||
---|---|---|
205 | 205 |
raise errors.OpPrereqError("Init.d script '%s' missing or not" |
206 | 206 |
" executable." % constants.NODE_INITD_SCRIPT) |
207 | 207 |
|
208 |
dirs = [(constants.RUN_GANETI_DIR, constants.RUN_DIRS_MODE)] |
|
209 |
utils.EnsureDirs(dirs) |
|
210 |
|
|
208 | 211 |
utils.ForceDictType(beparams, constants.BES_PARAMETER_TYPES) |
209 | 212 |
# hvparams is a mapping of hypervisor->hvparams dict |
210 | 213 |
for hv_name, hv_params in hvparams.iteritems(): |
b/lib/utils.py | ||
---|---|---|
1182 | 1182 |
return sha.new(os.urandom(64)).hexdigest() |
1183 | 1183 |
|
1184 | 1184 |
|
1185 |
def EnsureDirs(dirs): |
|
1186 |
"""Make required directories, if they don't exist. |
|
1187 |
|
|
1188 |
@param dirs: list of tuples (dir_name, dir_mode) |
|
1189 |
@type dirs: list of (string, integer) |
|
1190 |
|
|
1191 |
""" |
|
1192 |
for dir_name, dir_mode in dirs: |
|
1193 |
try: |
|
1194 |
os.mkdir(dir_name, mode) |
|
1195 |
except EnvironmentError, err: |
|
1196 |
if err.errno != errno.EEXIST: |
|
1197 |
raise errors.GenericError("Cannot create needed directory" |
|
1198 |
" '%s': %s" % (dir_name, err)) |
|
1199 |
if not os.path.isdir(dir_name): |
|
1200 |
raise errors.GenericError("%s is not a directory" % dir_name) |
|
1201 |
|
|
1202 |
|
|
1185 | 1203 |
def ReadFile(file_name, size=None): |
1186 | 1204 |
"""Reads a file. |
1187 | 1205 |
|
Also available in: Unified diff