Skip to content
Snippets Groups Projects
Commit 735deace authored by Martin André's avatar Martin André
Browse files

Simplify logic of set_configs.py a little bit

TrivialFix

Change-Id: Ic1c9fc76f4a5725ee76460c727197a96fe5d5359
parent 03fd08d8
No related branches found
No related tags found
No related merge requests found
...@@ -69,12 +69,8 @@ def validate_source(data): ...@@ -69,12 +69,8 @@ def validate_source(data):
def is_zk_transport(path): def is_zk_transport(path):
if path.startswith('zk://'): return path.startswith('zk://') or \
return True os.environ.get("KOLLA_ZK_HOSTS") is not None
if os.environ.get("KOLLA_ZK_HOSTS") is not None:
return True
return False
@contextlib.contextmanager @contextlib.contextmanager
...@@ -177,14 +173,9 @@ def set_permissions(data): ...@@ -177,14 +173,9 @@ def set_permissions(data):
# Give config file proper perms. # Give config file proper perms.
try: try:
os.chown(file_, uid, gid) 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) os.chmod(file_, perm)
except OSError as e: except OSError as e:
LOG.error('While trying to chmod {} received error: {}'.format( LOG.error('Error while setting permissions for {}: {}'.format(
file_, e)) file_, e))
sys.exit(1) sys.exit(1)
...@@ -194,15 +185,13 @@ def set_permissions(data): ...@@ -194,15 +185,13 @@ def set_permissions(data):
# Check for user and group id in the environment. # Check for user and group id in the environment.
try: try:
uid = getpwnam(owner).pw_uid user = getpwnam(owner)
except KeyError: except KeyError:
LOG.error('The specified user does not exist: {}'.format(owner)) LOG.error('The specified user does not exist: {}'.format(owner))
sys.exit(1) sys.exit(1)
try:
gid = getpwnam(owner).pw_gid uid = user.pw_uid
except KeyError: gid = user.pw_gid
LOG.error('The specified group does not exist: {}'.format(owner))
sys.exit(1)
# Set permissions on the top level dir or file # Set permissions on the top level dir or file
set_perms(dest, uid, gid, perm) set_perms(dest, uid, gid, perm)
...@@ -268,12 +257,8 @@ def load_config(): ...@@ -268,12 +257,8 @@ def load_config():
def execute_config_strategy(): def execute_config_strategy():
try: config_strategy = os.environ.get("KOLLA_CONFIG_STRATEGY")
config_strategy = os.environ.get("KOLLA_CONFIG_STRATEGY") LOG.info('Kolla config strategy set to: {}'.format(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)
if config_strategy == "COPY_ALWAYS": if config_strategy == "COPY_ALWAYS":
load_config() load_config()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment