diff options
-rw-r--r-- | utils/src/ooinstall/oo_config.py | 38 | ||||
-rw-r--r-- | utils/test/cli_installer_tests.py | 1 | ||||
-rw-r--r-- | utils/test/fixture.py | 1 |
3 files changed, 37 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): diff --git a/utils/test/cli_installer_tests.py b/utils/test/cli_installer_tests.py index 0556e52a1..8e4c3c4c6 100644 --- a/utils/test/cli_installer_tests.py +++ b/utils/test/cli_installer_tests.py @@ -101,6 +101,7 @@ MOCK_FACTS_QUICKHA = { # Missing connect_to on some hosts: BAD_CONFIG = """ variant: %s +version: v2 deployment: ansible_ssh_user: root hosts: diff --git a/utils/test/fixture.py b/utils/test/fixture.py index b2a0a7134..a883e5c56 100644 --- a/utils/test/fixture.py +++ b/utils/test/fixture.py @@ -12,6 +12,7 @@ SAMPLE_CONFIG = """ variant: %s variant_version: 3.3 master_routingconfig_subdomain: example.com +version: v2 deployment: ansible_ssh_user: root hosts: |