TT#160855 patch: don't use static match for PRO/CARRIER

* use ngcpcfg environment variables to match files
* same approach as tt2-process

Change-Id: I396dcc71a09cd6b9d51ddfcb7e3e84461c6e1667
mr10.4
ngcp-config 4 years ago committed by Víctor Seva
parent aec2f54e75
commit 063b139dd2

@ -37,15 +37,28 @@ patch_search() {
local name="$1"
shift # remove the first 'patchtt/customtt'
local files=("$@")
log_debug "Searching for ${name} files (requested '${files[*]}')"
local fileslist
fileslist=$(mktemp)
local a="\.sp[12]?"
local b="\.(web|db|prx|lb|slb)[0-9]+[ab]?"
local awk_regexp=".*${name}\.tt2(${a}|${b})?$"
local regexp=""
local hosts=()
if [ -n "${HOST_FILE:-}" ]; then
hosts+=("${HOST_FILE}")
fi
if [ -n "${PAIR_FILE:-}" ]; then
hosts+=("${PAIR_FILE}")
fi
if [ -n "${HA_FILE:-}" ]; then
hosts+=("${HA_FILE}")
fi
for val in "${hosts[@]}"; do
regexp="${regexp}|\\${val}"
done
local awk_regexp=".*${name}\.tt2$"
if [ -n "${regexp}" ]; then
awk_regexp=".*${name}\.tt2(${regexp#|})?$"
fi
log_debug "Searching for ${name} files (requested '${files[*]}') awk_regexp:${awk_regexp}"
for dir in ${CONFIG_POOL} ; do
[ -n "${dir}" ] || log_error "${dir} doesn't exist"

@ -43,4 +43,7 @@
[ -n "${NETWORK_CONFIG_GROUP:-}" ] || NETWORK_CONFIG_GROUP="_ngcp-admin"
[ -n "${NETWORK_CONFIG_CHMOD:-}" ] || NETWORK_CONFIG_CHMOD="0660"
[ -n "${HOST_FILE:-}" ] || HOST_FILE='.web01a'
[ -n "${PAIR_FILE:-}" ] || PAIR_FILE='.web01'
## END OF FILE #################################################################

@ -46,4 +46,7 @@
[ -n "${NETWORK_CONFIG_GROUP:-}" ] || NETWORK_CONFIG_GROUP="_ngcp-admin"
[ -n "${NETWORK_CONFIG_CHMOD:-}" ] || NETWORK_CONFIG_CHMOD="0660"
[ -n "${HOST_FILE:-}" ] || HOST_FILE='.web01a'
[ -n "${PAIR_FILE:-}" ] || PAIR_FILE='.web01'
## END OF FILE #################################################################

@ -41,4 +41,6 @@
[ -n "${NETWORK_CONFIG_GROUP:-}" ] || NETWORK_CONFIG_GROUP="_ngcp-admin"
[ -n "${NETWORK_CONFIG_CHMOD:-}" ] || NETWORK_CONFIG_CHMOD="0660"
[ -n "${HA_FILE:-}" ] || HA_FILE='.sp1'
## END OF FILE #################################################################

@ -43,4 +43,6 @@
[ -n "${NETWORK_CONFIG_GROUP:-}" ] || NETWORK_CONFIG_GROUP="_ngcp-admin"
[ -n "${NETWORK_CONFIG_CHMOD:-}" ] || NETWORK_CONFIG_CHMOD="0660"
[ -n "${HA_FILE:-}" ] || HA_FILE='.sp1'
## END OF FILE #################################################################

@ -43,4 +43,6 @@
[ -n "${NETWORK_CONFIG_GROUP:-}" ] || NETWORK_CONFIG_GROUP="_ngcp-admin"
[ -n "${NETWORK_CONFIG_CHMOD:-}" ] || NETWORK_CONFIG_CHMOD="0660"
[ -n "${HA_FILE:-}" ] || HA_FILE='.sp1'
## END OF FILE #################################################################

@ -50,3 +50,8 @@ echo "CONSTANTS_CONFIG_CHMOD=${CONSTANTS_CONFIG_CHMOD:-}"
echo "NETWORK_CONFIG_USER=${NETWORK_CONFIG_USER:-}"
echo "NETWORK_CONFIG_GROUP=${NETWORK_CONFIG_GROUP:-}"
echo "NETWORK_CONFIG_CHMOD=${NETWORK_CONFIG_CHMOD:-}"
# fake values from ngcpcfg-ha
echo "HA_FILE=${HA_FILE:-}"
echo "HOST_FILE=${HOST_FILE:-}"
echo "PAIR_FILE=${PAIR_FILE:-}"

@ -1,7 +1,7 @@
#!/usr/bin/env py.test-3
import shutil
from pathlib import Path
import pytest
from fixtures.fs import check_output
@ -376,7 +376,11 @@ def test_patch_action_build_generate_and_overwrite_customtt_file(ngcpcfg, ngcpcf
# * overwrite old/available customtt files
# * build proper config using new customtt files
env, cfg = ngcpcfg()
env, cfg = ngcpcfg(
env={
"NGCPCFG": "fixtures/ngcpcfg_pro.cfg",
},
)
template_pool = Path(cfg["TEMPLATE_POOL_BASE"]).joinpath("etc")
shutil.rmtree(template_pool)
apt_path = template_pool.joinpath("apt/apt.conf.d")
@ -512,7 +516,11 @@ def test_patch_action_build_generate_all_file(ngcpcfg, ngcpcfgcli):
# the same as test 'test_patch_action_build_generate_and_overwrite_customtt_file'
# while build all available files
env, cfg = ngcpcfg()
env, cfg = ngcpcfg(
env={
"NGCPCFG": "fixtures/ngcpcfg_pro.cfg",
},
)
template_pool = Path(cfg["TEMPLATE_POOL_BASE"]).joinpath("etc")
shutil.rmtree(template_pool)
apt_path = template_pool.joinpath("apt/apt.conf.d")

Loading…
Cancel
Save