in theory, finish bin/cdist-object-explorer-all

Signed-off-by: Nico Schottelius <nico@kr.ethz.ch>
This commit is contained in:
Nico Schottelius 2011-02-24 21:24:21 +01:00
parent 16ac8117b2
commit 39b2976f9a
3 changed files with 27 additions and 15 deletions

View File

@ -38,6 +38,7 @@ set -u
: ${__cdist_name_manifest:=manifest}
: ${__cdist_name_manifest_dir:=manifests}
: ${__cdist_name_object:=object}
: ${__cdist_name_objects:=objects}
: ${__cdist_name_object_id:=object_id}
: ${__cdist_name_out_dir:=out}
: ${__cdist_name_conf_dir:=conf}
@ -56,7 +57,6 @@ set -u
# Name of the base directory containing the initial manifests
: ${__cdist_name_manifests:=manifests}
: ${__cdist_name_object:=objects}
: ${__cdist_name_params:=parameters}
: ${__cdist_name_params_required:=required}
@ -96,6 +96,7 @@ __cdist_sane_regexp='[A-Za-z0-9]*[-A-Za-z0-9_]*'
# Remote out
: ${__cdist_remote_out_dir:=$__cdist_remote_base_dir/$__cdist_name_out_dir}
: ${__cdist_remote_out_explorer_dir:=$__cdist_remote_out_dir/$__cdist_name_explorer}
: ${__cdist_remote_out_object_base_dir:=$__cdist_remote_out_dir/$__cdist_name_object}
# Tempfiles
__cdist_tmp_dir=$(mktemp -d "/tmp/cdist.XXXXXXXXXXXX")
@ -145,7 +146,11 @@ __cdist_usage()
__cdist_type_has_explorer()
{
echo "${__cdist_type_dir}/${__cdist_type_current}"
# We only create output, if there's at least one explorer
# and can thus be used as a boolean ;-)
if [ -d "$(__cdist_type_explorer_dir "$1")" ]; then
ls -1 "$(__cdist_type_explorer_dir "$1")"
fi
}
__cdist_type_mydir()
@ -193,6 +198,16 @@ __cdist_object_param_dir()
echo "${__cdist_object_base_dir}/$1/$__cdist_name_params}"
}
__cdist_object_type_explorer_dir()
{
echo "${__cdist_object_base_dir}/$1/$__cdist_name_explorer}"
}
__cdist_remote_object_type_explorer_dir()
{
echo "${__cdist_remote_object_base_dir}/$1/$__cdist_name_explorer}"
}
__cdist_remote_object_param_dir()
{
echo "${__cdist_remote_object_base_dir}/$1/$__cdist_name_params}"

View File

@ -70,16 +70,10 @@ while read object; do
set -- "$@" "$object"
done < "$object_listing"
# For every object of a type that has explorers, execute the explorers
# and retrieve the results
while [ $# -gt 0 ]; do
# NEW CODE
object="$1"; shift
object_id="$(__cdist_object_id_from_object "$object")"
type="$(__cdist_type_from_object "$object")"
type_explorer_dir="$(__cdist_remote_type_explorer_dir "$object")"
object_explorer_out_dir="$(__cdist_out_type_explorer_dir "$object")"
remote_object_explorer_out_dir="$(__cdist_remote_out_type_explorer_dir "$object")"
# Always copy object parameters (looks weired if done only for the ones with explorer)
# Really always?
@ -89,12 +83,15 @@ while [ $# -gt 0 ]; do
# If so, run explorers on remote side
if [ "$has_explorer" ]; then
cdist-run-remote "$__cdist_target_host" cdist-remote-explorer-run \
"$__cdist_name_var_type_explorer" "$type_explorer_dir" \
"$remote_object_explorer_out_dir"
cdist-run-remote "$__cdist_target_host" \
cdist-remote-explorer-run \
"$__cdist_name_var_type_explorer" \
"$(__cdist_remote_type_explorer_dir "$type")" \
"$(__cdist_remote_object_type_explorer_dir "$object")"
# Copy back results
cdist-dir pull "$__cdist_target_host" \
"$remote_object_explorer_out_dir" "$object_explorer_out_dir"
cdist-dir pull "$__cdist_target_host" \
"$(__cdist_remote_object_type_explorer_dir "$object")" \
"$(__cdist_object_type_explorer_dir "$object")"
fi
done

View File

@ -25,8 +25,8 @@
#
. cdist-config
if [ $# -lt 3 ]; then
__cdist_usage "<variable name> <explorer dir> <out dir> [explorer args]"
if [ $# -ne 3 ]; then
__cdist_usage "<variable name> <explorer dir> <out dir>"
fi
set -ue