summaryrefslogtreecommitdiffstats
path: root/utils/src
diff options
context:
space:
mode:
authorSamuel Munilla <smunilla@redhat.com>2016-08-11 14:58:40 -0400
committerSamuel Munilla <smunilla@redhat.com>2016-08-19 13:09:15 -0400
commitc38bd418e0940deb5fb3f57583d1e6d0019962cf (patch)
tree1be456059929a015108e8ebc5ebef2f4c43a4571 /utils/src
parent7435ce713bbd3018192e3b7287ccfc5bf967e290 (diff)
downloadopenshift-c38bd418e0940deb5fb3f57583d1e6d0019962cf.tar.gz
openshift-c38bd418e0940deb5fb3f57583d1e6d0019962cf.tar.bz2
openshift-c38bd418e0940deb5fb3f57583d1e6d0019962cf.tar.xz
openshift-c38bd418e0940deb5fb3f57583d1e6d0019962cf.zip
Bug 1358951 - Error loading config, no such key: 'deployment' when using previously valid answers file
Update the quick installer to automatically convert from the old config file format to the new format.
Diffstat (limited to 'utils/src')
-rw-r--r--utils/src/ooinstall/oo_config.py38
1 files changed, 35 insertions, 3 deletions
diff --git a/utils/src/ooinstall/oo_config.py b/utils/src/ooinstall/oo_config.py
index 69ad2b4c5..cc6f7b041 100644
--- a/utils/src/ooinstall/oo_config.py
+++ b/utils/src/ooinstall/oo_config.py
@@ -165,6 +165,7 @@ class OOConfig(object):
self._set_defaults()
+# pylint: disable=too-many-branches
def _read_config(self):
try:
if os.path.exists(self.config_path):
@@ -176,6 +177,10 @@ class OOConfig(object):
if 'Description' in self.settings:
self._upgrade_legacy_config()
+
+ if loaded_config.get('version', '') == 'v1':
+ loaded_config = self._upgrade_v1_config(loaded_config)
+
try:
host_list = loaded_config['deployment']['hosts']
role_list = loaded_config['deployment']['roles']
@@ -236,9 +241,36 @@ class OOConfig(object):
self.settings['variant'] = 'openshift-enterprise'
self.settings['variant_version'] = '3.0'
- def _upgrade_v1_config(self):
- #TODO write code to upgrade old config
- return
+ def _upgrade_v1_config(self, config):
+ new_config_data = {}
+ new_config_data['deployment'] = {}
+ new_config_data['deployment']['hosts'] = []
+ new_config_data['deployment']['roles'] = {}
+ new_config_data['deployment']['variables'] = {}
+
+ role_list = {}
+
+ if config.get('ansible_ssh_user', False):
+ new_config_data['deployment']['ansible_ssh_user'] = config['ansible_ssh_user']
+
+ for host in config['hosts']:
+ host_props = {}
+ host_props['roles'] = []
+ host_props['connect_to'] = host['connect_to']
+
+ for prop in ['ip', 'public_ip', 'hostname', 'public_hostname', 'containerized', 'preconfigured']:
+ host_props[prop] = host.get(prop, None)
+
+ for role in ['master', 'node', 'master_lb', 'storage', 'etcd']:
+ if host.get(role, False):
+ host_props['roles'].append(role)
+ role_list[role] = ''
+
+ new_config_data['deployment']['hosts'].append(host_props)
+
+ new_config_data['deployment']['roles'] = role_list
+
+ return new_config_data
def _set_defaults(self):