|
|
@@ -2,7 +2,8 @@ |
|
|
|
|
|
|
|
### |
|
|
|
# Script requirments: |
|
|
|
# apt-get install -y python-yaml virtualenv git |
|
|
|
#apt-get install -y python-yaml virtualenv git |
|
|
|
|
|
|
|
set -e |
|
|
|
[ -n "$DEBUG" ] && set -x |
|
|
|
|
|
|
@@ -42,9 +43,11 @@ log_err() { |
|
|
|
|
|
|
|
setup_virtualenv() { |
|
|
|
log_info "Setting up Python virtualenv" |
|
|
|
dependency_check virtualenv |
|
|
|
virtualenv $VENV_DIR |
|
|
|
source ${VENV_DIR}/bin/activate |
|
|
|
pip install salt${PIP_SALT_VERSION} |
|
|
|
pip install jsonschema |
|
|
|
if [[ -f ${CURDIR}/pip_requirements.txt ]]; then |
|
|
|
pip install -r ${CURDIR}/pip_requirements.txt |
|
|
|
fi |
|
|
@@ -108,6 +111,7 @@ fetch_dependency() { |
|
|
|
dep_root="${DEPSDIR}/$(basename $dep_source .git)" |
|
|
|
dep_metadata="${dep_root}/metadata.yml" |
|
|
|
|
|
|
|
dependency_check git |
|
|
|
[ -d $dep_root ] && { log_info "Dependency $dep_name already fetched"; return 0; } |
|
|
|
|
|
|
|
log_info "Fetching dependency $dep_name" |
|
|
@@ -200,19 +204,30 @@ real_run() { |
|
|
|
} |
|
|
|
|
|
|
|
run_model_validate(){ |
|
|
|
[[ -d ${SCHEMARDIR} ]] || { log_err "${SCHEMARDIR} not found!"; return 1; } |
|
|
|
# model validator require py modules |
|
|
|
fetch_dependency "salt:https://github.com/salt-formulas/salt-formula-salt" |
|
|
|
link_modules |
|
|
|
# Rendered Example: |
|
|
|
# salt-call --local -c /test1/maas/tests/build/salt --id=maas_cluster modelschema.model_validate maas cluster |
|
|
|
for role in ${SCHEMARDIR}/*.yaml; do |
|
|
|
state_name=$(basename "${role%*.yaml}") |
|
|
|
minion_id="${state_name}" |
|
|
|
# in case debug-reruns, usefull to make cleanup |
|
|
|
[ -n "$DEBUG" ] && { salt_run saltutil.clear_cache; salt_run saltutil.refresh_pillar; salt_run saltutil.sync_all; } |
|
|
|
salt_run -m ${DEPSDIR}/salt-formula-salt --id=${minion_id} modelschema.model_validate ${FORMULA_NAME} ${state_name} || { log_err "Execution of ${FORMULA_NAME}.${state_name} failed"; exit 1 ; } |
|
|
|
done |
|
|
|
if [ -d ${SCHEMARDIR} ]; then |
|
|
|
# model validator require py modules |
|
|
|
fetch_dependency "salt:https://github.com/salt-formulas/salt-formula-salt" |
|
|
|
link_modules |
|
|
|
# Rendered Example: |
|
|
|
# salt-call --local -c /test1/maas/tests/build/salt --id=maas_cluster modelschema.model_validate maas cluster |
|
|
|
for role in ${SCHEMARDIR}/*.yaml; do |
|
|
|
state_name=$(basename "${role%*.yaml}") |
|
|
|
minion_id="${state_name}" |
|
|
|
# in case debug-reruns, usefull to make cleanup |
|
|
|
[ -n "$DEBUG" ] && { salt_run saltutil.clear_cache; salt_run saltutil.refresh_pillar; salt_run saltutil.sync_all; } |
|
|
|
salt_run -m ${DEPSDIR}/salt-formula-salt --id=${minion_id} modelschema.model_validate ${FORMULA_NAME} ${state_name} || { log_err "Execution of ${FORMULA_NAME}.${state_name} failed"; exit 1 ; } |
|
|
|
done |
|
|
|
else |
|
|
|
log_err "${SCHEMARDIR} not found!"; |
|
|
|
fi |
|
|
|
} |
|
|
|
|
|
|
|
dependency_check() { |
|
|
|
local DEPENDENCY_COMMANDS=$* |
|
|
|
|
|
|
|
for DEPENDENCY_COMMAND in $DEPENDENCY_COMMANDS; do |
|
|
|
which $DEPENDENCY_COMMAND > /dev/null || ( log_err "Command \"$DEPENDENCY_COMMAND\" can not be found in default path."; exit 1; ) |
|
|
|
done |
|
|
|
} |
|
|
|
|
|
|
|
_atexit() { |
|
|
@@ -256,4 +271,4 @@ case $1 in |
|
|
|
run |
|
|
|
run_model_validate |
|
|
|
;; |
|
|
|
esac |
|
|
|
esac |