aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin André <m.andre@redhat.com>2017-07-03 14:48:16 +0200
committerMartin André <m.andre@redhat.com>2017-07-03 17:22:35 +0200
commit39daa5a45290398e5d49b052a44fc5eb8f06935f (patch)
treec107be2018bae0c0086d8c645478100a46660282
parentf26b1ba0b362e9091141f0fad2f7b91edc40ac11 (diff)
downloadkolla-39daa5a45290398e5d49b052a44fc5eb8f06935f.tar.gz
kolla-39daa5a45290398e5d49b052a44fc5eb8f06935f.zip
Improve logging of set_configs.py
Remove duplicate logging for file copying, and clarify some log messages. Change-Id: I4dfaffa62f79a32a7fd6060b92ccb119f657f854
-rw-r--r--docker/base/set_configs.py17
1 files changed, 9 insertions, 8 deletions
diff --git a/docker/base/set_configs.py b/docker/base/set_configs.py
index 229090817..2992f6508 100644
--- a/docker/base/set_configs.py
+++ b/docker/base/set_configs.py
@@ -74,16 +74,16 @@ class ConfigFile(object):
def _copy_file(self, source, dest):
self._delete_path(dest)
# dest endswith / means copy the <source> to <dest> folder
- LOG.info('Copying file from %s to %s', source, dest)
+ LOG.info('Copying %s to %s', source, dest)
shutil.copy(source, dest)
self._set_properties(source, dest)
def _merge_directories(self, source, dest):
- LOG.info('Copying %s to %s', source, dest)
if os.path.isdir(source):
if os.path.exists(dest) and not os.path.isdir(dest):
self._delete_path(dest)
if not os.path.isdir(dest):
+ LOG.info('Creating directory %s', dest)
os.makedirs(dest)
self._set_properties(source, dest)
@@ -97,11 +97,10 @@ class ConfigFile(object):
def _delete_path(self, path):
if not os.path.exists(path):
return
+ LOG.info('Deleting %s', path)
if os.path.isdir(path):
- LOG.info('Deleting dir %s', path)
shutil.rmtree(path)
else:
- LOG.info('Deleting file %s', path)
os.remove(path)
def _create_parent_dirs(self, path):
@@ -188,7 +187,7 @@ class ConfigFile(object):
actual_perm = oct(dir_stat.st_mode)[-4:]
if self.perm != actual_perm:
LOG.error('Dest dir does not have expected perm: %s,'
- ' acutal %s', self.perm, actual_perm)
+ ' actual %s', self.perm, actual_perm)
return False
for file_ in files:
full_path = os.path.join(root, file_)
@@ -334,13 +333,14 @@ def handle_permissions(config):
def set_perms(path, uid, gid, perm):
LOG.info('Setting permission for %s', path)
if not os.path.exists(path):
- LOG.warning('file %s do not exist', path)
+ LOG.warning('%s does not exist', path)
return
try:
os.chown(path, uid, gid)
except OSError:
- LOG.exception('Set permission failed for %s', path)
+ LOG.exception('Failed to change ownership of %s to %s:%s',
+ path, uid, gid)
if perm:
# NOTE(Jeffrey4l): py3 need '0oXXX' format for octal literals,
@@ -352,7 +352,8 @@ def handle_permissions(config):
try:
os.chmod(path, perm)
except OSError:
- LOG.exception('Set permission failed for %s', path)
+ LOG.exception('Failed to set permission of %s to %s',
+ path, perm)
for dest in glob.glob(path):
set_perms(dest, uid, gid, perm)