From cd54edf52750b7d770468a31947ec3d5dc385a91 Mon Sep 17 00:00:00 2001 From: Alexandru Avadanii Date: Mon, 15 Jan 2018 01:33:02 +0100 Subject: [PATCH] [PDF] check-jinja: Filter-out incompatible PDF/IA While checking all PDFs against all installers, some mandatory requirements are sometimes not met: - minimum cluster nodes (e.g. Apex requires 5 nodes, 1 PDF has 3); - minimum interface count (e.g. Compass requires min 3 NICs, some PDFs only have two interfaces or less); The added filter is far from ideal: - node requirements are based on the latest (not highest) index used by the installer adapter to accomodate special handling of 3-node cluster in Daisy templates; - interface req is based on the average interfaces/node, with quite some margin - this is a very loose mechanism; With this in, `check-jinja` has a return code of 0 (note that yamllint failures of output files are not affecting the return code). Change-Id: I43ade3567bf3026069ff93eca17abc212fab211c Signed-off-by: Alexandru Avadanii --- config/utils/check-jinja2.sh | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/config/utils/check-jinja2.sh b/config/utils/check-jinja2.sh index 3c5e5163..1001b156 100755 --- a/config/utils/check-jinja2.sh +++ b/config/utils/check-jinja2.sh @@ -27,11 +27,29 @@ done # Iterate all PDFs, check with each installer adapter, log results while IFS= read -r lab_config; do SUMMARY+="\n${lab_config#labs/};" + lab_nodes=$(grep -ce 'node:' "${lab_config}") + lab_tmacs=$(grep -ce 'mac_address:' "${lab_config}") + ((lab_amacs=lab_tmacs/lab_nodes)); ((lab_nodes-=1)) echo "###################### ${lab_config} ######################" for adapter in ${INSTALLER_ADAPTERS}; do pdf_inst=0 pdf_inst_pass=0 pdf_yaml_pass=0 + ia_nodes=$(grep -hPo 'nodes\W+\K\d+' -R "${adapter}" | tail -1) + ia_rmacs=$(grep -hPo 'interfaces\W+\K\d+' -R "${adapter}" | sort | tail -1) + ((ia_nodes+=1)); ((ia_rmacs+=1)) + if [[ ${ia_nodes} -gt ${lab_nodes} ]]; then + SUMMARY+='-;' + echo -n "[GENERATE] [SKIP] $(basename "${adapter}") requires at least" + echo -e " ${ia_nodes} nodes, but found only ${lab_nodes}, skipping.\n" + continue + fi + if [[ ${ia_rmacs} -ge ${lab_amacs} ]]; then + SUMMARY+='-;' + echo -n "[GENERATE] [SKIP] $(basename "${adapter}") requires at least" + echo -e " ${ia_rmacs} nics, but found ~ ${lab_amacs}, skipping.\n" + continue + fi while IFS= read -r jinja_template; do pdf_gen_cmd="${GEN_CFG} -y ${lab_config} -j ${jinja_template}" if ${pdf_gen_cmd} > "${TMPF}"; then -- 2.16.6