diff options
author | Samuel Munilla <smunilla@redhat.com> | 2016-08-25 11:12:22 -0400 |
---|---|---|
committer | Samuel Munilla <smunilla@redhat.com> | 2016-09-29 15:43:34 -0400 |
commit | 92a9e5547af1c77751fe04ef9f3b849d0885ed03 (patch) | |
tree | 4c443fd2abb4e8bebe3bdaa5f1cb6d1440ad8328 /utils/src/ooinstall/oo_config.py | |
parent | cd922e0f4a1370118c0e2fd60230a68d74b47095 (diff) | |
download | openshift-92a9e5547af1c77751fe04ef9f3b849d0885ed03.tar.gz openshift-92a9e5547af1c77751fe04ef9f3b849d0885ed03.tar.bz2 openshift-92a9e5547af1c77751fe04ef9f3b849d0885ed03.tar.xz openshift-92a9e5547af1c77751fe04ef9f3b849d0885ed03.zip |
a-o-i: Allow better setting of host level variables
Allow the user to set arbitrary variables directly under the host item instead of
in under an 'other_variables' item.
Diffstat (limited to 'utils/src/ooinstall/oo_config.py')
-rw-r--r-- | utils/src/ooinstall/oo_config.py | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py index 8c5f3396b..697ac9c08 100644 --- a/utils/src/ooinstall/oo_config.py +++ b/utils/src/ooinstall/oo_config.py @@ -26,6 +26,19 @@ DEPLOYMENT_VARIABLES_BLACKLIST = [ 'roles', ] +HOST_VARIABLES_BLACKLIST = [ + 'ip', + 'public_ip', + 'hostname', + 'public_hostname', + 'node_labels', + 'containerized', + 'preconfigured', + 'schedulable', + 'other_variables', + 'roles', +] + DEFAULT_REQUIRED_FACTS = ['ip', 'public_ip', 'hostname', 'public_hostname'] PRECONFIGURED_REQUIRED_FACTS = ['hostname', 'public_hostname'] @@ -66,7 +79,7 @@ class Host(object): self.containerized = kwargs.get('containerized', False) self.node_labels = kwargs.get('node_labels', '') - # allowable roles: master, node, etcd, storage, master_lb, new + # allowable roles: master, node, etcd, storage, master_lb self.roles = kwargs.get('roles', []) self.other_variables = kwargs.get('other_variables', {}) @@ -86,11 +99,13 @@ class Host(object): d = {} for prop in ['ip', 'hostname', 'public_ip', 'public_hostname', 'connect_to', - 'preconfigured', 'containerized', 'schedulable', 'roles', 'node_labels', - 'other_variables']: + 'preconfigured', 'containerized', 'schedulable', 'roles', 'node_labels', ]: # If the property is defined (not None or False), export it: if getattr(self, prop): d[prop] = getattr(self, prop) + for variable, value in self.other_variables.iteritems(): + d[variable] = value + return d def is_master(self): @@ -202,7 +217,6 @@ class OOConfig(object): role_list = loaded_config['deployment']['roles'] except KeyError as e: print_read_config_error("No such key: {}".format(e), self.config_path) - print "Error loading config, required key missing: {}".format(e) sys.exit(0) for setting in CONFIG_PERSIST_SETTINGS: @@ -237,6 +251,10 @@ class OOConfig(object): # Parse the hosts into DTO objects: for host in host_list: + host['other_variables'] = {} + for variable, value in host.iteritems(): + if variable not in HOST_VARIABLES_BLACKLIST: + host['other_variables'][variable] = value self.deployment.hosts.append(Host(**host)) # Parse the roles into Objects |