Merge "Ensure non-default FLAGS.logfile_mode is properly converted to an octet."

This commit is contained in:
Jenkins
2011-10-14 19:19:41 +00:00
committed by Gerrit Code Review
2 changed files with 4 additions and 3 deletions

View File

@@ -351,7 +351,7 @@ DEFINE_string('lock_path', os.path.join(os.path.dirname(__file__), '../'),
'Directory for lock files') 'Directory for lock files')
DEFINE_string('logdir', None, 'output to a per-service log file in named ' DEFINE_string('logdir', None, 'output to a per-service log file in named '
'directory') 'directory')
DEFINE_integer('logfile_mode', 0644, 'Default file mode of the logs.') DEFINE_string('logfile_mode', '0644', 'Default file mode of the logs.')
DEFINE_string('sqlite_db', 'nova.sqlite', 'file name for sqlite') DEFINE_string('sqlite_db', 'nova.sqlite', 'file name for sqlite')
DEFINE_string('sql_connection', DEFINE_string('sql_connection',
'sqlite:///$state_path/$sqlite_db', 'sqlite:///$state_path/$sqlite_db',

View File

@@ -259,9 +259,10 @@ class NovaRootLogger(NovaLogger):
self.addHandler(self.filelog) self.addHandler(self.filelog)
self.logpath = logpath self.logpath = logpath
mode = int(FLAGS.logfile_mode, 8)
st = os.stat(self.logpath) st = os.stat(self.logpath)
if st.st_mode != (stat.S_IFREG | FLAGS.logfile_mode): if st.st_mode != (stat.S_IFREG | mode):
os.chmod(self.logpath, FLAGS.logfile_mode) os.chmod(self.logpath, mode)
else: else:
self.removeHandler(self.filelog) self.removeHandler(self.filelog)
self.addHandler(self.streamlog) self.addHandler(self.streamlog)