aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-12-18 12:35:24 +0000
committerGerrit Code Review <review@openstack.org>2015-12-18 12:35:24 +0000
commit64a39a6cecba2b83d8c355bf0edc0a9f42167df5 (patch)
treed4c73fb49d8e90f82ec5c80767e2253571e25cce
parent50f4bc52ee7559a489c54ed45799a21e329734f8 (diff)
parent735deace15bcdebff95d527aff3466bd6dfd3825 (diff)
downloadkolla-64a39a6cecba2b83d8c355bf0edc0a9f42167df5.tar.gz
kolla-64a39a6cecba2b83d8c355bf0edc0a9f42167df5.zip
Merge "Simplify logic of set_configs.py a little bit"
-rw-r--r--docker/base/set_configs.py33
1 files changed, 9 insertions, 24 deletions
diff --git a/docker/base/set_configs.py b/docker/base/set_configs.py
index f76d0e99f..ab84d8838 100644
--- a/docker/base/set_configs.py
+++ b/docker/base/set_configs.py
@@ -67,12 +67,8 @@ def validate_source(data):
def is_zk_transport(path):
- if path.startswith('zk://'):
- return True
- if os.environ.get("KOLLA_ZK_HOSTS") is not None:
- return True
-
- return False
+ return path.startswith('zk://') or \
+ os.environ.get("KOLLA_ZK_HOSTS") is not None
@contextlib.contextmanager
@@ -175,14 +171,9 @@ def set_permissions(data):
# Give config file proper perms.
try:
os.chown(file_, uid, gid)
- except OSError as e:
- LOG.error('While trying to chown {} received error: {}'.format(
- file_, e))
- sys.exit(1)
- try:
os.chmod(file_, perm)
except OSError as e:
- LOG.error('While trying to chmod {} received error: {}'.format(
+ LOG.error('Error while setting permissions for {}: {}'.format(
file_, e))
sys.exit(1)
@@ -192,15 +183,13 @@ def set_permissions(data):
# Check for user and group id in the environment.
try:
- uid = getpwnam(owner).pw_uid
+ user = getpwnam(owner)
except KeyError:
LOG.error('The specified user does not exist: {}'.format(owner))
sys.exit(1)
- try:
- gid = getpwnam(owner).pw_gid
- except KeyError:
- LOG.error('The specified group does not exist: {}'.format(owner))
- sys.exit(1)
+
+ uid = user.pw_uid
+ gid = user.pw_gid
# Set permissions on the top level dir or file
set_perms(dest, uid, gid, perm)
@@ -266,12 +255,8 @@ def load_config():
def execute_config_strategy():
- try:
- config_strategy = os.environ.get("KOLLA_CONFIG_STRATEGY")
- LOG.info('Kolla config strategy set to: {}'.format(config_strategy))
- except KeyError:
- LOG.error("KOLLA_CONFIG_STRATEGY is not set properly.")
- sys.exit(1)
+ config_strategy = os.environ.get("KOLLA_CONFIG_STRATEGY")
+ LOG.info('Kolla config strategy set to: {}'.format(config_strategy))
if config_strategy == "COPY_ALWAYS":
load_config()