From dd287165d63faa6f22989639a7d2ad9503563333 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Fri, 22 Jul 2022 14:02:31 +0200 Subject: [PATCH] TT#168102 check: Add a YAML schema and validation for instances.yml Change-Id: I5134d10b7b438e2d6ce60d838034df68e4bc71cb (cherry picked from commit c27e56ce86be0bd8a95ab7cb4d5447b43898b1ef) --- Makefile | 1 + debian/ngcp-ngcpcfg.install | 1 + schemas/instances.yml | 17 +++++++++++++++++ scripts/check | 5 +++-- 4 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 schemas/instances.yml diff --git a/Makefile b/Makefile index 02148b43..33c54ddf 100644 --- a/Makefile +++ b/Makefile @@ -16,6 +16,7 @@ PERL_SCRIPTS = \ sbin/ngcp-sync-grants \ # EOL YAML_SCHEMAS = \ + schemas/instances.yml \ schemas/sites.yml \ # EOL RESULTS ?= results diff --git a/debian/ngcp-ngcpcfg.install b/debian/ngcp-ngcpcfg.install index 7b80a78c..113bded8 100644 --- a/debian/ngcp-ngcpcfg.install +++ b/debian/ngcp-ngcpcfg.install @@ -20,6 +20,7 @@ sbin/ngcp-network-validator usr/sbin/ sbin/ngcp-sync-constants usr/sbin/ sbin/ngcp-sync-grants usr/sbin/ sbin/ngcpcfg usr/sbin/ +schemas/instances.yml usr/share/ngcp-ngcpcfg/schemas/ schemas/sites.yml usr/share/ngcp-ngcpcfg/schemas/ scripts/apply usr/share/ngcp-ngcpcfg/scripts/ scripts/build usr/share/ngcp-ngcpcfg/scripts/ diff --git a/schemas/instances.yml b/schemas/instances.yml new file mode 100644 index 00000000..8b5df091 --- /dev/null +++ b/schemas/instances.yml @@ -0,0 +1,17 @@ +name: instances.yml +desc: Kwalify schema for NGCP instances.yml +type: map +mapping: + "sources": + type: seq + required: yes + sequence: + - type: map + required: yes + mapping: + "orig": { type: str, required: yes, + desc: "Specify the original service pathname." } + "dest": { type: str, required: yes, + desc: "Specify the destination service pathname." } + "label": { type: str, required: yes, + desc: "Specify service label." } diff --git a/scripts/check b/scripts/check index 9501da1b..7835dc0e 100755 --- a/scripts/check +++ b/scripts/check @@ -172,7 +172,7 @@ validate_config() { local schema case "${name}" in - sites.yml) + sites.yml|instances.yml) if ! [ -e "${f}" ]; then continue fi @@ -275,7 +275,8 @@ check_shared_storage() { if [ "$*" = "" ] ; then SITES_FILE="${SITES_FILE:-${NGCPCTL_MAIN}/sites.yml}" - config_files="${NGCPCTL_CONFIG:-} ${NODE_CONFIG:-} ${PAIR_CONFIG:-} ${HOST_CONFIG:-} ${LOCAL_CONFIG:-} ${NETWORK_CONFIG:-} ${EXTRA_CONFIG_FILES[*]} ${CONSTANTS_CONFIG:-} ${SITES_FILE:-}" + INSTANCES_FILE="${INSTANCES_FILE:-${NGCPCTL_MAIN}/instances.yml}" + config_files="${NGCPCTL_CONFIG:-} ${NODE_CONFIG:-} ${PAIR_CONFIG:-} ${HOST_CONFIG:-} ${LOCAL_CONFIG:-} ${NETWORK_CONFIG:-} ${EXTRA_CONFIG_FILES[*]} ${CONSTANTS_CONFIG:-} ${SITES_FILE:-} ${INSTANCES_FILE:-}" else config_files="$*" fi