def generate_node_upgrade_script(installed_cluster_version, config_path=CONFIG_PATH): if installed_cluster_version is None: print('Must provide the version of the cluster upgrading from') return 1 config = Config(config_path) try: gen_out = config_util.onprem_generate(config) except ValidationError as e: validation = normalize_config_validation_exception(e) print_messages(validation) return 1 except ExhibitorTLSBootstrapError as e: log.error('Failed to bootstrap Exhibitor TLS') for i, error in enumerate(e.errors): return log.error("{}: {}".format(i + 1, error)) return 1 config_util.make_serve_dir(gen_out) # generate the upgrade script upgrade.generate_node_upgrade_script(gen_out, installed_cluster_version) return 0
def test_normalize_config_validation_exception(): errors = { 'key': {'message': 'test'}, } validation_error = ValidationError(errors=errors, unset=set(['one', 'two'])) normalized = config.normalize_config_validation_exception(validation_error) expected = { 'key': 'test', 'one': 'Must set one, no way to calculate value.', 'two': 'Must set two, no way to calculate value.', } assert expected == normalized
def test_normalize_config_validation_exception(): errors = { 'key': { 'message': 'test' }, } validation_error = ValidationError(errors=errors, unset=set(['one', 'two'])) normalized = config.normalize_config_validation_exception(validation_error) expected = { 'key': 'test', 'one': 'Must set one, no way to calculate value.', 'two': 'Must set two, no way to calculate value.', } assert expected == normalized
def do_configure(config_path=CONFIG_PATH): """Returns error code :param config_path: path to config.yaml :type config_path: string | CONFIG_PATH (genconf/config.yaml) """ config = Config(config_path) try: gen_out = config_util.onprem_generate(config) except ValidationError as e: validation = normalize_config_validation_exception(e) print_messages(validation) return 1 config_util.make_serve_dir(gen_out) return 0
def generate_node_upgrade_script(installed_cluster_version, config_path=CONFIG_PATH): if installed_cluster_version is None: print('Must provide the version of the cluster upgrading from') return 1 config = Config(config_path) try: gen_out = config_util.onprem_generate(config) except ValidationError as e: validation = normalize_config_validation_exception(e) print_messages(validation) return 1 config_util.make_serve_dir(gen_out) # generate the upgrade script upgrade.generate_node_upgrade_script(gen_out, installed_cluster_version) return 0
def do_configure(config_path=CONFIG_PATH): """Returns error code :param config_path: path to config.yaml :type config_path: string | CONFIG_PATH (genconf/config.yaml) """ config = Config(config_path) try: gen_out = config_util.onprem_generate(config) except ValidationError as e: validation = normalize_config_validation_exception(e) print_messages(validation) return 1 except ExhibitorTLSBootstrapError as e: log.error('Failed to bootstrap Exhibitor TLS') for i, error in enumerate(e.errors): return log.error("{}: {}".format(i + 1, error)) return 1 config_util.make_serve_dir(gen_out) return 0