From 39b2976f9ae70265236526213e30542c3f54d0a1 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Thu, 24 Feb 2011 21:24:21 +0100 Subject: [PATCH] in theory, finish bin/cdist-object-explorer-all Signed-off-by: Nico Schottelius --- bin/cdist-config | 19 +++++++++++++++++-- bin/cdist-object-explorer-all | 19 ++++++++----------- bin/cdist-remote-explorer-run | 4 ++-- 3 files changed, 27 insertions(+), 15 deletions(-) diff --git a/bin/cdist-config b/bin/cdist-config index c9df6cad..5f712bff 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -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}" diff --git a/bin/cdist-object-explorer-all b/bin/cdist-object-explorer-all index cabc6bf3..82222943 100755 --- a/bin/cdist-object-explorer-all +++ b/bin/cdist-object-explorer-all @@ -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 diff --git a/bin/cdist-remote-explorer-run b/bin/cdist-remote-explorer-run index 50d5357e..7064a323 100755 --- a/bin/cdist-remote-explorer-run +++ b/bin/cdist-remote-explorer-run @@ -25,8 +25,8 @@ # . cdist-config -if [ $# -lt 3 ]; then - __cdist_usage " [explorer args]" +if [ $# -ne 3 ]; then + __cdist_usage " " fi set -ue