diff options
Diffstat (limited to 'tools')
-rwxr-xr-x | tools/process-templates.py | 28 | ||||
-rwxr-xr-x | tools/roles-data-generate-samples.sh | 26 | ||||
-rwxr-xr-x | tools/roles-data-generate.py | 49 | ||||
-rwxr-xr-x | tools/roles-data-validation.sh | 48 | ||||
-rwxr-xr-x | tools/yaml-validate.py | 4 |
5 files changed, 147 insertions, 8 deletions
diff --git a/tools/process-templates.py b/tools/process-templates.py index 69ed96a6..badc1426 100755 --- a/tools/process-templates.py +++ b/tools/process-templates.py @@ -138,19 +138,33 @@ def process_templates(template_path, role_data_path, output_dir, print("jinja2 rendering roles %s" % "," .join(role_names)) for role in role_names: - j2_data = {'role': role} - # (dprince) For the undercloud installer we don't - # want to have heat check nova/glance API's - if r_map[role].get('disable_constraints', False): - j2_data['disable_constraints'] = True + j2_data = {'role': r_map[role]} out_f = "-".join( [role.lower(), os.path.basename(f).replace('.role.j2.yaml', '.yaml')]) out_f_path = os.path.join(out_dir, out_f) if not (out_f_path in excl_templates): - _j2_render_to_file(template_data, j2_data, - out_f_path, overwrite) + if '{{role.name}}' in template_data: + j2_data = {'role': r_map[role], + 'networks': network_data} + _j2_render_to_file(template_data, j2_data, + out_f_path, overwrite) + else: + # Backwards compatibility with templates + # that specify {{role}} vs {{role.name}} + j2_data = {'role': role, + 'networks': network_data} + # (dprince) For the undercloud installer we + # don'twant to have heat check nova/glance + # API's + if r_map[role].get('disable_constraints', + False): + j2_data['disable_constraints'] = True + _j2_render_to_file( + template_data,j2_data, + out_f_path, overwrite) + else: print('skipping rendering of %s' % out_f_path) elif f.endswith('.j2.yaml'): diff --git a/tools/roles-data-generate-samples.sh b/tools/roles-data-generate-samples.sh new file mode 100755 index 00000000..cb370dcc --- /dev/null +++ b/tools/roles-data-generate-samples.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# +# Copyright 2017 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +set -e + +SCRIPT_DIR=$(cd `dirname $0` && pwd -P) +OUTPUT_DIR=${OUTPUT_DIR:-$(cd "${SCRIPT_DIR}/../" && pwd -P)} + +echo "Generating ${OUTPUT_DIR}/roles_data.yaml" +$SCRIPT_DIR/roles-data-generate.py Controller Compute BlockStorage ObjectStorage CephStorage > $OUTPUT_DIR/roles_data.yaml + +echo "Generating ${OUTPUT_DIR}/roles_data_undercloud.yaml" +$SCRIPT_DIR/roles-data-generate.py Undercloud > $OUTPUT_DIR/roles_data_undercloud.yaml diff --git a/tools/roles-data-generate.py b/tools/roles-data-generate.py new file mode 100755 index 00000000..0b768744 --- /dev/null +++ b/tools/roles-data-generate.py @@ -0,0 +1,49 @@ +#!/usr/bin/env python +# +# Copyright 2017 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# + +import argparse +import collections +import os +import sys + +from tripleo_common.utils import roles as rolesutils + +__tht_root_dir = os.path.dirname(os.path.dirname(__file__)) +__tht_roles_dir = os.path.join(__tht_root_dir, 'roles') + + +def parse_opts(argv): + parser = argparse.ArgumentParser( + description='Generate roles_data.yaml for requested roles. NOTE: ' + 'This is a stripped down version of what is provided by ' + 'the tripleoclient. The tripleoclient should be used for ' + 'additional functionality.') + parser.add_argument('--roles-path', metavar='<roles directory>', + help="Filesystem path containing the roles yaml files", + default=__tht_roles_dir) + parser.add_argument('roles', nargs="+", metavar='<role>', + help='List of roles to use to generate the ' + 'roles_data.yaml file') + opts = parser.parse_args(argv[1:]) + + return opts + +opts = parse_opts(sys.argv) + +roles = collections.OrderedDict.fromkeys(opts.roles) +print(rolesutils.generate_roles_data_from_directory(opts.roles_path, + roles.keys())) diff --git a/tools/roles-data-validation.sh b/tools/roles-data-validation.sh new file mode 100755 index 00000000..7c5786e1 --- /dev/null +++ b/tools/roles-data-validation.sh @@ -0,0 +1,48 @@ +#!/bin/bash +# +# Copyright 2017 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. +# +set -e + +SCRIPT_DIR=$(cd `dirname $0` && pwd -P) +THT_DIR=${OUTPUT_DIR:-$(cd "${SCRIPT_DIR}/../" && pwd -P)} +TMPDIR=$(mktemp -d) + +function do_cleanup { + rm -rf $TMPDIR +} +trap do_cleanup EXIT + +function check_diff { + local thtfile=$1 + local genfile=$2 + echo -n "Performing diff on $thtfile $genfile... " + diff $thtfile $genfile > $TMPDIR/diff_results + if [ $? = 1 ]; then + echo "ERROR: Generated roles file not match the current ${thtfile}" + echo "Please make sure to update the appropriate roles/* files." + echo "Here is the diff ${thtfile} ${genfile}" + cat $TMPDIR/diff_results + exit 1 + fi + echo "OK!" +} + +OUTPUT_DIR=$TMPDIR +source $SCRIPT_DIR/roles-data-generate-samples.sh + +set +e +check_diff $THT_DIR/roles_data.yaml $TMPDIR/roles_data.yaml +check_diff $THT_DIR/roles_data_undercloud.yaml $TMPDIR/roles_data_undercloud.yaml diff --git a/tools/yaml-validate.py b/tools/yaml-validate.py index 674449f5..e9581a2d 100755 --- a/tools/yaml-validate.py +++ b/tools/yaml-validate.py @@ -38,7 +38,7 @@ OPTIONAL_DOCKER_SECTIONS = ['docker_puppet_tasks', 'upgrade_tasks', 'metadata_settings', 'kolla_config'] REQUIRED_DOCKER_PUPPET_CONFIG_SECTIONS = ['config_volume', 'step_config', 'config_image'] -OPTIONAL_DOCKER_PUPPET_CONFIG_SECTIONS = [ 'puppet_tags' ] +OPTIONAL_DOCKER_PUPPET_CONFIG_SECTIONS = [ 'puppet_tags', 'volumes' ] # Mapping of parameter names to a list of the fields we should _not_ enforce # consistency across files on. This should only contain parameters whose # definition we cannot change for backwards compatibility reasons. New @@ -337,6 +337,8 @@ param_map = {} for base_path in path_args: if os.path.isdir(base_path): for subdir, dirs, files in os.walk(base_path): + if '.tox' in dirs: + dirs.remove('.tox') for f in files: if f.endswith('.yaml') and not f.endswith('.j2.yaml'): file_path = os.path.join(subdir, f) |