From 61b7b6867167a7d5a377f7ede31b0d92ed3bd47f Mon Sep 17 00:00:00 2001 From: Steven Armstrong Date: Wed, 30 Mar 2011 22:46:49 +0200 Subject: [PATCH] split explorer/manifest and gencode runcode into to 2 steps Signed-off-by: Steven Armstrong --- bin/cdist-config | 6 +++ bin/cdist-deploy-to | 3 +- ...{cdist-object-run-all => cdist-object-all} | 8 ++-- bin/cdist-object-process | 48 +++++++++++++++++++ bin/cdist-object-run | 6 +-- 5 files changed, 62 insertions(+), 9 deletions(-) rename bin/{cdist-object-run-all => cdist-object-all} (88%) create mode 100755 bin/cdist-object-process diff --git a/bin/cdist-config b/bin/cdist-config index 9cd3a53c..393a963b 100755 --- a/bin/cdist-config +++ b/bin/cdist-config @@ -55,6 +55,7 @@ __cdist_abs_myname="$__cdist_abs_mydir/$__cdist_myname" : ${__cdist_name_manifest:=manifest} : ${__cdist_name_object:=object} : ${__cdist_name_object_finished:=done} +: ${__cdist_name_object_processed:=processed} : ${__cdist_name_object_id:=object_id} : ${__cdist_name_object_source:=source} : ${__cdist_name_objects_created:=.objects_created} @@ -194,6 +195,11 @@ __cdist_object_code() echo "$(__cdist_object_dir "$1")/${__cdist_name_code}" } +__cdist_object_processed() +{ + echo "$(__cdist_object_dir "$1")/${__cdist_name_object_processed}" +} + __cdist_object_finished() { echo "$(__cdist_object_dir "$1")/${__cdist_name_object_finished}" diff --git a/bin/cdist-deploy-to b/bin/cdist-deploy-to index e44ceff4..aeae3b6c 100755 --- a/bin/cdist-deploy-to +++ b/bin/cdist-deploy-to @@ -49,7 +49,8 @@ cdist-dir push "$__cdist_target_host" "${__cdist_abs_mydir}" "${__cdist_remote_b cdist-explorer-run-global "$__cdist_target_host" cdist-manifest-run-init "$__cdist_target_host" -cdist-object-run-all "$__cdist_target_host" +cdist-object-all "$__cdist_target_host" cdist-object-process +cdist-object-all "$__cdist_target_host" cdist-object-run cdist-cache "$__cdist_target_host" echo "cdist $__cdist_version: Successfully finished run on $__cdist_target_host" diff --git a/bin/cdist-object-run-all b/bin/cdist-object-all similarity index 88% rename from bin/cdist-object-run-all rename to bin/cdist-object-all index c646ab16..28df0613 100755 --- a/bin/cdist-object-run-all +++ b/bin/cdist-object-all @@ -19,14 +19,15 @@ # along with cdist. If not, see . # # -# Run cdist-object-run for each created object. +# Run the given command for each created object. # . cdist-config -[ $# -eq 1 ] || __cdist_usage "" +[ $# -eq 2 ] || __cdist_usage " " set -eu __cdist_target_host="$1"; shift +__cdist_command="$1"; shift __cdist_objects="$__cdist_tmp_dir/objects" @@ -47,7 +48,6 @@ while [ -f "$__cdist_objects_created" ]; do while [ $# -gt 0 ]; do __cdist_object="$1"; shift - # Process the object - cdist-object-run "$__cdist_target_host" "$__cdist_object" + $__cdist_command "$__cdist_target_host" "$__cdist_object" done done diff --git a/bin/cdist-object-process b/bin/cdist-object-process new file mode 100755 index 00000000..371f3737 --- /dev/null +++ b/bin/cdist-object-process @@ -0,0 +1,48 @@ +#!/bin/sh +# +# 2011 Nico Schottelius (nico-cdist at schottelius.org) +# 2011 Steven Armstrong (steven-cdist at armstrong.cc) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see . +# +# +# For the given object: +# - run type explorers +# - run type manifest +# + +. cdist-config +[ $# -eq 2 ] || __cdist_usage " " +set -eu + +__cdist_target_host="$1"; shift +__cdist_object="$1"; shift +__cdist_object_dir="$(__cdist_object_dir "$__cdist_object")" +[ -d "$__cdist_object_dir" ] || __cdist_exit_err "Requested object is not defined: $__cdist_object" + +# Export to non-core for use in manifest and gencode scripts +export $__cdist_name_var_self=$__cdist_object + +__cdist_object_processed="$(__cdist_object_processed "$__cdist_object")" +if [ ! -f "$__cdist_object_processed" ]; then + echo + echo "Processing object $__cdist_object" + cdist-object-explorer-run "$__cdist_target_host" "$__cdist_object" + cdist-object-manifest-run "$__cdist_target_host" "$__cdist_object" + + # Mark this object as done + touch "$__cdist_object_processed" +fi diff --git a/bin/cdist-object-run b/bin/cdist-object-run index e3fc1629..b49c8c2d 100755 --- a/bin/cdist-object-run +++ b/bin/cdist-object-run @@ -39,8 +39,6 @@ __cdist_object_dir="$(__cdist_object_dir "$__cdist_object")" # Export to non-core for use in manifest and gencode scripts export $__cdist_name_var_self=$__cdist_object -__cdist_type="$(__cdist_type_from_object "$__cdist_object")" - __cdist_object_finished="$(__cdist_object_finished "$__cdist_object")" if [ ! -f "$__cdist_object_finished" ]; then @@ -62,8 +60,8 @@ if [ ! -f "$__cdist_object_finished" ]; then echo echo "Running object $__cdist_object" - cdist-object-explorer-run "$__cdist_target_host" "$__cdist_object" - cdist-object-manifest-run "$__cdist_target_host" "$__cdist_object" + #cdist-object-explorer-run "$__cdist_target_host" "$__cdist_object" + #cdist-object-manifest-run "$__cdist_target_host" "$__cdist_object" cdist-object-gencode-run "$__cdist_target_host" "$__cdist_object" cdist-object-push "$__cdist_target_host" "$__cdist_object" cdist-object-code-run "$__cdist_target_host" "$__cdist_object"