diff --git a/.gitignore b/.gitignore
index 09621d750..0317230df 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,6 +20,7 @@ site/content/generic_methods.md
site/pelican-bootstrap3/templates/includes/generic_methods.html
site/content/index.md
site/output/*
+site/cache/*
site/*.pid
*.pyc
*.swp
diff --git a/Makefile b/Makefile
index 30ae8786b..5fe3d4cc3 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,51 @@
-all: clean test doc
+#####################################################################################
+# Copyright 2015 Normation SAS
+#####################################################################################
+#
+# This program 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, Version 3.
+#
+# This program 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 this program. If not, see .
+#
+#####################################################################################
+
+
+DESTDIR = /usr
+INSTALL := $(shell type ginstall >/dev/null 2>&1 && echo ginstall || echo install)
+CP_A := cp -rp
+
+all: install
+
+# no dependency
+depend: localdepends
+localdepends:
+
+build: doc doc/ncf.1
+
+# Install ncf in DESTDIR
+install: build
+ mkdir -p $(DESTDIR)
+ mkdir -p $(DESTDIR)/share/doc/ncf
+ $(CP_A) doc $(DESTDIR)/share/doc/ncf/
+ $(CP_A) examples $(DESTDIR)/share/doc/ncf/
+ $(INSTALL) -m 644 README.md $(DESTDIR)/share/doc/ncf/
+ mkdir -p $(DESTDIR)/share/ncf
+ $(CP_A) tree $(DESTDIR)/share/ncf/
+ $(CP_A) tools $(DESTDIR)/share/ncf/
+ $(CP_A) builder $(DESTDIR)/share/ncf/
+ $(CP_A) api $(DESTDIR)/share/ncf/
+ $(INSTALL) -m 755 ncf $(DESTDIR)/share/ncf/
+ mkdir -p $(DESTDIR)/bin
+ ln -s ../share/ncf/ncf $(DESTDIR)/bin/ncf
+ mkdir -p $(DESTDIR)/share/man/man1
+ $(INSTALL) -m 644 doc/ncf.1 $(DESTDIR)/share/man/man1/
test:
type fakeroot 2>/dev/null || { echo "fakeroot is required but not found." ; exit 1 ; }
@@ -7,9 +54,14 @@ test:
cd tests/acceptance/ && ./testall --no-network
cd tests/acceptance/ && ./testall
-doc:
+doc:
ls tree/30_generic_methods/*.cf | xargs egrep -h "^\s*bundle\s+agent\s+" | sed -r "s/\s*bundle\s+agent\s+//" | sort > doc/all_generic_methods.txt
tools/ncf_doc.py
+ rm -f tools/ncf_doc.pyc
+ rm -f tools/ncf.pyc
+
+doc/ncf.1:
+ cd doc && a2x --doctype manpage --format manpage ncf.asciidoc
html: doc
# To use this, run pip install pelican Markdown
@@ -44,8 +96,9 @@ clean:
rm -rf tests/acceptance/workdir/
rm -f doc/all_generic_methods.txt
rm -f doc/generic_methods.md
+ rm -f doc/ncf.1
find $(CURDIR) -iname "*.pyc" -delete
distclean: clean
-.PHONY: all test doc clean distclean
+.PHONY: all test doc clean distclean depend localdepend build install
diff --git a/api/run.py b/api/run.py
index 32c1dd6a6..91d69314d 100755
--- a/api/run.py
+++ b/api/run.py
@@ -1,4 +1,4 @@
-#!flask/bin/python
+#!/usr/bin/python
# This file is only present for development/ local test and should not be used in production
# To deploy ncf api you should use it with a virtual environment and a wsgi file
diff --git a/builder/README.md b/builder/README.md
old mode 100755
new mode 100644
diff --git a/builder/css/bootstrap.min.css b/builder/css/bootstrap.min.css
old mode 100755
new mode 100644
diff --git a/builder/css/custom.css b/builder/css/custom.css
old mode 100755
new mode 100644
diff --git a/builder/fonts/glyphicons-halflings-regular.eot b/builder/fonts/glyphicons-halflings-regular.eot
old mode 100755
new mode 100644
diff --git a/builder/fonts/glyphicons-halflings-regular.svg b/builder/fonts/glyphicons-halflings-regular.svg
old mode 100755
new mode 100644
diff --git a/builder/fonts/glyphicons-halflings-regular.ttf b/builder/fonts/glyphicons-halflings-regular.ttf
old mode 100755
new mode 100644
diff --git a/builder/fonts/glyphicons-halflings-regular.woff b/builder/fonts/glyphicons-halflings-regular.woff
old mode 100755
new mode 100644
diff --git a/builder/index.html b/builder/index.html
old mode 100755
new mode 100644
diff --git a/builder/js/bootstrap.min.js b/builder/js/bootstrap.min.js
old mode 100755
new mode 100644
diff --git a/builder/js/jquery-1.11.1.min.js b/builder/js/jquery-1.11.1.min.js
old mode 100755
new mode 100644
diff --git a/builder/js/ncf.js b/builder/js/ncf.js
old mode 100755
new mode 100644
index 371262cc8..b5d54ad23
--- a/builder/js/ncf.js
+++ b/builder/js/ncf.js
@@ -485,7 +485,7 @@ app.controller('ncf-builder', function ($scope, $modal, $http, $log, $location,
// Get the class value generated from a class prefix and a class kind (kept,repaired,error, ...)
$scope.getClassKind= function(method_call,kind) {
// do not canonify what is between ${ }
- var param = $scope.getClassParameter(method_call).replace(/[^\${}\w](?![^{}]+})|\$(?!{)/g,"_");
+ var param = $scope.getClassParameter(method_call).replace(/\\'/g, "'").replace(/\\"/g, '"').replace(/[^\${}\w](?![^{}]+})|\$(?!{)/g,"_");
return $scope.getClassPrefix(method_call)+"_"+param +"_"+kind
}
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 000000000..135c3a77b
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,11 @@
+ncf (0.201507210500) jessie; urgency=low
+
+ * First official version
+
+ -- Benoît PECCATTE Tue, 21 Jul 2015 11:55:00 +0100
+
+ncf (0.2013120500) squeeze; urgency=low
+
+ * Initial release
+
+ -- Matthieu CERDA Thu, 05 Dec 2013 15:50:24 +0100
diff --git a/debian/compat b/debian/compat
new file mode 100644
index 000000000..7f8f011eb
--- /dev/null
+++ b/debian/compat
@@ -0,0 +1 @@
+7
diff --git a/debian/control b/debian/control
new file mode 100644
index 000000000..8252173a3
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,16 @@
+Source: ncf
+Section: admin
+Priority: extra
+Maintainer: Rudder packaging team
+Build-Depends: debhelper (>= 7), python, asciidoc, libxml2-utils, xsltproc, docbook-xml, docbook-xsl
+Standards-Version: 3.8.0
+Homepage: http://www.ncf.io
+
+Package: ncf
+Architecture: all
+Depends: ${misc:Depends}
+Suggests: cfengine3 (>=3.5.0), cfengine-community (>=3.5.0), rudder-agent (>=2.8.0), python (>=2.6)
+Description: CFEngine framework
+ ncf is a CFEngine framework aimed at helping newcomers on CFEngine
+ to be more quickly operationnal and old timers to spend less time
+ focusing on low level details and have more time for fun things.
diff --git a/debian/copyright b/debian/copyright
new file mode 100644
index 000000000..badadea32
--- /dev/null
+++ b/debian/copyright
@@ -0,0 +1,23 @@
+This package was debianized by:
+
+ Matthieu CERDA on Thu, 05 Dec 2013 15:50:24 +0100
+
+It was downloaded from:
+
+ http://www.ncf.io/
+
+Copyright:
+
+ Copyright (C) 2013 Normation SAS
+
+License:
+
+ GNU General Public Licence version 3
+
+On Debian systems, the complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/GPL-3'.
+
+The Debian packaging is:
+
+ Copyright (C) 2013 Normation SAS
+
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 000000000..1e556f372
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,75 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+
+ # Add here commands to configure the package.
+
+build: build-arch build-indep
+build-arch: build-stamp
+build-indep: build-stamp
+
+build-stamp: configure-stamp
+ dh_testdir
+
+ touch $@
+
+clean:
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+
+ # Add here commands to clean up after the build process.
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_prep
+ dh_installdirs
+ make install DESTDIR=$(CURDIR)/debian/tmp/usr
+
+# Build architecture-dependent files here.
+binary-arch: install
+# We have nothing to do by default.
+
+# Build architecture-independent files here.
+binary-indep: install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_install debian/copyright /usr/share/doc/ncf/
+ dh_install usr /
+
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installmime
+# dh_python
+# dh_installcron
+# dh_installinfo
+ dh_installman
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+# dh_perl
+# dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/doc/.placeholder b/doc/.placeholder
deleted file mode 100644
index e69de29bb..000000000
diff --git a/doc/ncf.asciidoc b/doc/ncf.asciidoc
new file mode 100644
index 000000000..3f9a1eed8
--- /dev/null
+++ b/doc/ncf.asciidoc
@@ -0,0 +1,34 @@
+= ncf(1)
+:doctype: manpage
+
+== NAME
+
+ncf - CFEngine framework
+
+== SYNOPSIS
+
+*ncf* init [path]
+
+== DESCRIPTION
+
+Initialize a new ncf repository.
+This will copy the tree content in a new directory.
+This allows you to have a live content that can be used and modified on a CFEngine server.
+
+== OPTIONS
+
+Running ncf without arguments gives a basic help line.
+
+== AUTHOR
+
+Normation SAS (contact@normation.com)
+
+== RESOURCES
+
+Main web site: https://ncf.io/
+
+Sources: https://github.com/Normation/ncf/
+
+== COPYING
+
+Copyright \(C) 2014-2015 Normation SAS.
diff --git a/ncf.spec b/ncf.spec
new file mode 100644
index 000000000..06640d4ca
--- /dev/null
+++ b/ncf.spec
@@ -0,0 +1,111 @@
+#####################################################################################
+# Copyright 2012 Normation SAS
+#####################################################################################
+#
+# This program 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, Version 3.
+#
+# This program 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 this program. If not, see .
+#
+#####################################################################################
+
+#=================================================
+# Specification file for ncf
+#
+# Install the ncf framework
+#
+# Copyright (C) 2013 Normation
+#=================================================
+
+#=================================================
+# Variables
+#=================================================
+#%define installdir /usr
+
+#=================================================
+# Header
+#=================================================
+Summary: CFEngine framework
+Name: ncf
+Version: %{real_version}
+Release: 1%{?dist}
+Epoch: 0
+License: GPLv3
+URL: http://www.ncf.io
+Source: ncf-%{version}.tar.gz
+
+Group: Applications/System
+
+BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
+BuildArch: noarch
+
+# Add Requires here - order is important
+BuildRequires: python, asciidoc, libxml2, libxslt, docbook-dtds, docbook-style-xsl
+
+%description
+ncf is a CFEngine framework aimed at helping newcomers on CFEngine
+to be more quickly operationnal and old timers to spend less time
+focusing on low level details and have more time for fun things.
+
+#=================================================
+# Source preparation
+#=================================================
+%prep
+%setup
+
+#=================================================
+# Building
+#=================================================
+%build
+
+#=================================================
+# Installation
+#=================================================
+%install
+
+rm -rf %{buildroot}
+ls
+cat Makefile
+make install DESTDIR=%{buildroot}/usr
+
+%pre -n ncf
+#=================================================
+# Pre Installation
+#=================================================
+
+
+%post -n ncf
+#=================================================
+# Post Installation
+#=================================================
+
+
+#=================================================
+# Cleaning
+#=================================================
+%clean
+rm -rf %{buildroot}
+
+#=================================================
+# Files
+#=================================================
+%files
+%defattr(-, root, root, 0755)
+/usr/
+
+
+#=================================================
+# Changelog
+#=================================================
+%changelog
+* Tue Jul 21 2015 - Benoît PECCATTE 0.201507210500-1
+- First official version
+* Thu Dec 05 2013 - Matthieu CERDA 0.2013120500-1
+- Initial release
diff --git a/site/content/bugtracker.md b/site/content/bugtracker.md
new file mode 100644
index 000000000..124b2a020
--- /dev/null
+++ b/site/content/bugtracker.md
@@ -0,0 +1,6 @@
+Title: Bugtracker
+
+For a full-sized experience, please click here
+
+
+
diff --git a/tests/unit/test_expected_reports_with_quote.csv b/tests/unit/test_expected_reports_with_quote.csv
new file mode 100644
index 000000000..16296aecc
--- /dev/null
+++ b/tests/unit/test_expected_reports_with_quote.csv
@@ -0,0 +1,3 @@
+# This file contains one line per report expected by Rudder from this technique
+# Format: technique_name;;class_prefix_${key};;@@RUDDER_ID@@;;component name;;component key
+Technique_with_quote;;command_execution_/bin/echo 'Executing echo';;@@RUDDER_ID@@;;Command execution;;/bin/echo \'Executing echo\'
diff --git a/tests/unit/test_metadata_with_quote.xml b/tests/unit/test_metadata_with_quote.xml
new file mode 100644
index 000000000..851a27427
--- /dev/null
+++ b/tests/unit/test_metadata_with_quote.xml
@@ -0,0 +1,13 @@
+
+ A technique with quote
+
+ Technique_with_quote
+
+
+
+
+
diff --git a/tests/unit/test_ncf_rudder.py b/tests/unit/test_ncf_rudder.py
index b312bf98f..09bffc8ee 100644
--- a/tests/unit/test_ncf_rudder.py
+++ b/tests/unit/test_ncf_rudder.py
@@ -41,6 +41,20 @@ def setUp(self):
self.test_metadata_xml_file = os.path.realpath('test_metadata.xml')
self.test_metadata_xml_content = open(self.test_metadata_xml_file).read()
+
+ # Testing Techniques with quote
+ self.test_technique_with_quote_file = os.path.realpath('test_technique_with_quote.cf')
+ self.technique_with_quote_content = open(self.test_technique_with_quote_file).read()
+ self.technique_with_quote_metadata = ncf.parse_technique_metadata(self.technique_with_quote_content)
+ method_with_quote_calls = ncf.parse_technique_methods(self.test_technique_with_quote_file)
+ self.technique_with_quote_metadata['method_calls'] = method_with_quote_calls
+
+ self.test_expected_reports_with_quote_csv_file = os.path.realpath('test_expected_reports_with_quote.csv')
+ self.test_expected_reports_with_quote_csv_content = open(self.test_expected_reports_with_quote_csv_file).read()
+
+ self.test_metadata_with_quote_xml_file = os.path.realpath('test_metadata_with_quote.xml')
+ self.test_metadata_with_quote_xml_content = open(self.test_metadata_with_quote_xml_file).read()
+
def test_expected_reports_from_technique(self):
expected_reports_string = ncf_rudder.get_technique_expected_reports(self.technique_metadata)
self.assertEquals(expected_reports_string, self.test_expected_reports_csv_content)
@@ -68,6 +82,17 @@ def test_any_technique_reporting_file(self):
result = not os.path.exists(os.path.realpath(os.path.join(root_path, 'bla', '0.1', "rudder_reporting.st")))
self.assertTrue(result)
+
+ # Testing Techniques with quotes
+ def test_expected_reports_with_quote(self):
+ expected_reports_string = ncf_rudder.get_technique_expected_reports(self.technique_with_quote_metadata)
+ self.assertEquals(expected_reports_string, self.test_expected_reports_with_quote_csv_content)
+
+ def test_metadate_with_quote(self):
+ metadata_xml_string = ncf_rudder.get_technique_metadata_xml(self.technique_with_quote_metadata)
+ expected_metadata_pure_xml = self.test_metadata_with_quote_xml_content
+ self.assertEquals(expected_metadata_pure_xml, metadata_xml_string)
+
def test_rudder_reporting_content(self):
expected_result = []
diff --git a/tests/unit/test_technique_with_quote.cf b/tests/unit/test_technique_with_quote.cf
new file mode 100644
index 000000000..0263493c4
--- /dev/null
+++ b/tests/unit/test_technique_with_quote.cf
@@ -0,0 +1,9 @@
+# @name Technique with quote
+# @description A technique with quote
+# @version 1.0
+
+bundle agent Technique_with_quote
+{
+ methods:
+ "method_call" usebundle => command_execution("/bin/echo \'Executing echo\'");
+}
diff --git a/tools/ncf.py b/tools/ncf.py
index 0d7c10e8d..b6cf6585b 100644
--- a/tools/ncf.py
+++ b/tools/ncf.py
@@ -27,7 +27,7 @@
tags = {}
tags["common"] = ["bundle_name", "bundle_args"]
-tags["generic_method"] = ["name", "description", "parameter", "class_prefix", "class_parameter", "class_parameter_id"]
+tags["generic_method"] = ["name", "description", "parameter", "class_prefix", "class_parameter", "class_parameter_id", "deprecated"]
tags["technique"] = ["name", "description", "version"]
multiline_tags = [ "description" ]
@@ -330,9 +330,9 @@ def parse_technique_methods(technique_file):
promise_class_context = class_context_and(class_context, ifvarclass_context)
if args:
- res.append({'class_context': promise_class_context, 'method_name': method_name, 'args': args})
+ res.append({'class_context': promise_class_context, 'promiser': promiser, 'method_name': method_name, 'args': args})
else:
- res.append({'class_context': promise_class_context, 'method_name': method_name})
+ res.append({'class_context': promise_class_context, 'promiser': promiser, 'method_name': method_name})
return res
@@ -442,6 +442,9 @@ def generate_technique_content(technique_metadata):
content.append('')
content.append('bundle agent '+ technique['bundle_name'])
content.append('{')
+ content.append(' vars:')
+ content.append(' "class_prefix" string => canonify(join("_", "this.callers_promisers"));')
+ content.append('')
content.append(' methods:')
# Handle method calls
@@ -455,7 +458,11 @@ def generate_technique_content(technique_metadata):
arg_value = ""
class_context = canonify_class_context(method_call['class_context'])
- content.append(' "method_call" usebundle => '+method_call['method_name']+'('+arg_value+'),')
+ if 'promiser' in method_call:
+ promiser = method_call['promiser']
+ else:
+ promiser = "method_call"
+ content.append(' "'+promiser+'" usebundle => '+method_call['method_name']+'('+arg_value+'),')
content.append(' ifvarclass => concat("'+class_context+'");')
content.append('}')
diff --git a/tools/ncf_rudder.py b/tools/ncf_rudder.py
index 32430195f..ceca5eac0 100755
--- a/tools/ncf_rudder.py
+++ b/tools/ncf_rudder.py
@@ -262,7 +262,7 @@ def get_technique_expected_reports(technique_metadata):
component = generic_method['name']
key_value = method_call["args"][generic_method["class_parameter_id"]-1]
- class_prefix = generic_method["class_prefix"]+"_"+key_value
+ class_prefix = (generic_method["class_prefix"]+"_"+key_value).replace("\\'", "\'").replace('\\"', '\"')
line = technique_name+";;"+class_prefix+";;@@RUDDER_ID@@;;"+component+";;"+key_value
@@ -299,7 +299,7 @@ def generate_rudder_reporting(technique):
method_name = method_call['method_name']
generic_method = generic_methods[method_name]
- key_value = method_call["args"][generic_method["class_parameter_id"]-1]
+ key_value = method_call["args"][generic_method["class_parameter_id"]-1].replace("\\'", "\'")
regex = re.compile("[^\$\{\}\w](?![^{}]+})|\$(?!{)", flags=re.UNICODE)
key_value_canonified = regex.sub("_", key_value)
diff --git a/tree/10_ncf_internals/configuration.cf b/tree/10_ncf_internals/configuration.cf
index 446474efa..fc450d417 100644
--- a/tree/10_ncf_internals/configuration.cf
+++ b/tree/10_ncf_internals/configuration.cf
@@ -64,6 +64,10 @@ bundle agent configuration
classes:
"ncf_override_conf_file_defined" expression => fileexists("${ncf_configuration.ncf_configuration_file}");
+ # cfengine was patched to provide a variable to retrieve the promiser stack
+ "has_promiser_stack" expression => isvariable("this.callers_promisers"),
+ scope => "namespace";
+
"pass2" expression => "pass1";
"pass1" expression => "any";
diff --git a/tree/20_cfe_basics/ncf_lib.cf b/tree/20_cfe_basics/ncf_lib.cf
index 20635324d..ea367efe0 100644
--- a/tree/20_cfe_basics/ncf_lib.cf
+++ b/tree/20_cfe_basics/ncf_lib.cf
@@ -355,6 +355,40 @@ body classes classes_generic_return_codes(x, kept_return_code, repaired_return_c
promise_kept => { "promise_kept_$(x)", "$(x)_kept", "$(x)_ok", "$(x)_not_repaired", "$(x)_reached" };
}
+# WARNING !!!
+# For new class prefix migration only, this will be removed when migration is over
+# Define x and y prefixed/suffixed with promise outcome
+body classes classes_generic_two(x,y)
+{
+ !has_promiser_stack::
+ promise_repaired => { "promise_repaired_$(x)", "$(x)_repaired", "$(x)_ok", "$(x)_reached" };
+ repair_failed => { "repair_failed_$(x)", "$(x)_failed", "$(x)_not_ok", "$(x)_error", "$(x)_not_kept", "$(x)_not_repaired", "$(x)_reached" };
+ repair_denied => { "repair_denied_$(x)", "$(x)_denied", "$(x)_not_ok", "$(x)_error", "$(x)_not_kept", "$(x)_not_repaired", "$(x)_reached" };
+ repair_timeout => { "repair_timeout_$(x)", "$(x)_timeout", "$(x)_not_ok", "$(x)_error", "$(x)_not_kept", "$(x)_not_repaired", "$(x)_reached" };
+ promise_kept => { "promise_kept_$(x)", "$(x)_kept", "$(x)_ok", "$(x)_not_repaired", "$(x)_reached" };
+
+ has_promiser_stack::
+ promise_repaired => { "promise_repaired_$(x)", "$(x)_repaired", "$(x)_ok", "$(x)_reached",
+ "promise_repaired_$(y)", "$(y)_repaired", "$(y)_ok", "$(y)_reached" };
+ repair_failed => { "repair_failed_$(x)", "$(x)_failed", "$(x)_not_ok", "$(x)_error", "$(x)_not_kept", "$(x)_not_repaired", "$(x)_reached",
+ "repair_failed_$(y)", "$(y)_failed", "$(y)_not_ok", "$(y)_error", "$(y)_not_kept", "$(y)_not_repaired", "$(y)_reached" };
+ repair_denied => { "repair_denied_$(x)", "$(x)_denied", "$(x)_not_ok", "$(x)_error", "$(x)_not_kept", "$(x)_not_repaired", "$(x)_reached",
+ "repair_denied_$(y)", "$(y)_denied", "$(y)_not_ok", "$(y)_error", "$(y)_not_kept", "$(y)_not_repaired", "$(y)_reached" };
+ repair_timeout => { "repair_timeout_$(x)", "$(x)_timeout", "$(x)_not_ok", "$(x)_error", "$(x)_not_kept", "$(x)_not_repaired", "$(x)_reached",
+ "repair_timeout_$(y)", "$(y)_timeout", "$(y)_not_ok", "$(y)_error", "$(y)_not_kept", "$(y)_not_repaired", "$(y)_reached" };
+ promise_kept => { "promise_kept_$(x)", "$(x)_kept", "$(x)_ok", "$(x)_not_repaired", "$(x)_reached",
+ "promise_kept_$(y)", "$(y)_kept", "$(y)_ok", "$(y)_not_repaired", "$(y)_reached" };
+}
+
+# WARNING !!!
+# For new class prefix migration only, this will be removed when migration is over
+body process_count any_count_two(cl, cl2)
+{
+ match_range => "0,0";
+ out_of_range_define => { "$(cl)", "$(cl2)" };
+}
+
+
# Enforce or not content of a file
########################################################################
# Same as std_defs, allowing user to specify the file erase policy #
diff --git a/tree/30_generic_methods/_classes_copy.cf b/tree/30_generic_methods/_classes_copy.cf
index edb540e49..946055444 100644
--- a/tree/30_generic_methods/_classes_copy.cf
+++ b/tree/30_generic_methods/_classes_copy.cf
@@ -25,7 +25,7 @@
# @class_prefix
# @class_parameter
# This bundle will define a class ${destination_prefix}_{kept,repaired,not_ok,ok,reached}
-# based on ${source_prefix}_{kept,repaired,not_ok,ok,reached}
+# based on ${source_prefix}_{kept,repaired,not_ok,ok,reached}
bundle agent _classes_copy(source_prefix, destination_prefix)
{
@@ -33,6 +33,7 @@ bundle agent _classes_copy(source_prefix, destination_prefix)
"prefix" slist => { "promise_kept", "promise_repaired", "repair_failed", "repair_denied", "repair_timeout" };
"suffix" slist => { "repaired", "ok", "reached", "failed", "not_ok", "not_kept", "not_repaired", "denied", "timeout", "kept", "error" };
+ destination_should_exists.!destination_not_exists::
# Copy result classes prefixes
"${prefix}_local_destination_prefix"
string => "${prefix}_${destination_prefix}",
@@ -44,6 +45,12 @@ bundle agent _classes_copy(source_prefix, destination_prefix)
string => "${destination_prefix}_${suffix}",
ifvarclass => "${source_prefix}_${suffix}",
classes => always("${destination_prefix}_${suffix}");
-}
+ classes:
+ # this line will not ne evaluated by cfengine if destination_prefix contains a variable that do not exist
+ # and it will always be evaluated to true otherwise
+ "destination_not_exists" expression => strcmp("${destination_prefix}", "${destination_prefix}");
+ # previous line has been evaluated
+ "destination_should_exists" expression => "any";
+}
diff --git a/tree/30_generic_methods/_classes_copy_invert_kept_repaired.cf b/tree/30_generic_methods/_classes_copy_invert_kept_repaired.cf
index 2869dd0f4..a052c9db4 100644
--- a/tree/30_generic_methods/_classes_copy_invert_kept_repaired.cf
+++ b/tree/30_generic_methods/_classes_copy_invert_kept_repaired.cf
@@ -25,7 +25,7 @@
# @class_prefix
# @class_parameter
# This bundle will define a class ${destination_prefix}_{kept,repaired,not_ok,ok,reached}
-# based on an inverted ${source_prefix}_{kept,repaired,not_ok,ok,reached}
+# based on an inverted ${source_prefix}_{kept,repaired,not_ok,ok,reached}
#
# Conversion tables are:
#--------------------------------------------------
@@ -65,6 +65,7 @@ bundle agent _classes_copy_invert_kept_repaired(source_prefix, destination_prefi
"error_prefix" slist => { "repair_failed", "repair_denied", "repair_timeout" };
"error_suffix" slist => { "failed", "not_ok", "not_kept", "denied", "timeout", "error" };
+ destination_should_exists.!destination_not_exists::
# Copy not_repaired class, as it is a special case (only exists for error or kept, so kept classes are not exactly inverted repaired classes)
"local_destination_prefix_not_repaired"
string => "${destination_prefix}_not_repaired",
@@ -107,4 +108,11 @@ bundle agent _classes_copy_invert_kept_repaired(source_prefix, destination_prefi
ifvarclass => "${source_prefix}_${error_suffix}",
classes => always("${destination_prefix}_${error_suffix}");
+ classes:
+ # this line will not ne evaluated by cfengine if destination_prefix contains a variable that do not exist
+ # and it will always be evaluated to true otherwise
+ "destination_not_exists" expression => strcmp("${destination_prefix}", "${destination_prefix}");
+ # previous line has been evaluated
+ "destination_should_exists" expression => "any";
+
}
diff --git a/tree/30_generic_methods/command_execution.cf b/tree/30_generic_methods/command_execution.cf
index 8582d721d..eebf897ac 100644
--- a/tree/30_generic_methods/command_execution.cf
+++ b/tree/30_generic_methods/command_execution.cf
@@ -28,16 +28,17 @@
bundle agent command_execution(command_name)
{
vars:
- "class_prefix" string => canonify("command_execution_${command_name}");
+ "old_class_prefix" string => canonify("command_execution_${command_name}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
methods:
"report"
- usebundle => _logger("Execute the command ${command_name}", "${class_prefix}"),
- ifvarclass => "${class_prefix}_reached";
+ usebundle => _logger("Execute the command ${command_name}", "${old_class_prefix}"),
+ ifvarclass => "(!has_promiser_stack.${old_class_prefix}_reached)|(has_promiser_stack.${class_prefix}_reached)";
commands:
"${command_name}"
contain => in_shell,
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/directory_check_exists.cf b/tree/30_generic_methods/directory_check_exists.cf
index 800f2ed61..9c10f6920 100644
--- a/tree/30_generic_methods/directory_check_exists.cf
+++ b/tree/30_generic_methods/directory_check_exists.cf
@@ -30,21 +30,21 @@
bundle agent directory_check_exists(directory_name)
{
vars:
- "class_prefix" string => canonify("directory_check_exists_${directory_name}");
+ "old_class_prefix" string => canonify("directory_check_exists_${directory_name}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
classes:
"directory_exists" expression => isdir("${directory_name}");
methods:
directory_exists::
- "directory_exists"
- usebundle => _classes_success("${class_prefix}");
+ "directory_exists" usebundle => _classes_success("${old_class_prefix}");
+ "directory_exists" usebundle => _classes_success("${class_prefix}");
!directory_exists::
- "directory_dont_exists"
- usebundle => _classes_failure("${class_prefix}");
+ "directory_doesnt_exists" usebundle => _classes_failure("${old_class_prefix}");
+ "directory_doesnt_exists" usebundle => _classes_failure("${class_prefix}");
any::
- "report"
- usebundle => _logger("Check if directory ${directory_name} exists", "${class_prefix}");
+ "report" usebundle => _logger("Check if directory ${directory_name} exists", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/directory_create.cf b/tree/30_generic_methods/directory_create.cf
index d8e9b72e7..fde197b4c 100644
--- a/tree/30_generic_methods/directory_create.cf
+++ b/tree/30_generic_methods/directory_create.cf
@@ -28,14 +28,14 @@
bundle agent directory_create(target)
{
vars:
- "class_prefix" string => canonify("directory_create_${target}");
+ "old_class_prefix" string => canonify("directory_create_${target}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
files:
"${target}/."
create => "true",
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
- "report" usebundle => _logger("Create directory ${target}", "${class_prefix}");
-
+ "report" usebundle => _logger("Create directory ${target}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/file_check_exists.cf b/tree/30_generic_methods/file_check_exists.cf
index 6ff6bdb24..e1b597bfa 100644
--- a/tree/30_generic_methods/file_check_exists.cf
+++ b/tree/30_generic_methods/file_check_exists.cf
@@ -30,21 +30,21 @@
bundle agent file_check_exists(file_name)
{
vars:
- "class_prefix" string => canonify("file_check_exists_${file_name}");
+ "old_class_prefix" string => canonify("file_check_exists_${file_name}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
classes:
"file_exists" expression => fileexists("${file_name}");
methods:
file_exists::
- "file_exists"
- usebundle => _classes_success("${class_prefix}");
+ "file_exists" usebundle => _classes_success("${old_class_prefix}");
+ "file_exists" usebundle => _classes_success("${class_prefix}");
!file_exists::
- "file_dont_exists"
- usebundle => _classes_failure("${class_prefix}");
+ "file_dont_exists" usebundle => _classes_failure("${old_class_prefix}");
+ "file_dont_exists" usebundle => _classes_failure("${class_prefix}");
any::
- "report"
- usebundle => _logger("Check if ${file_name} exists", "${class_prefix}");
+ "report" usebundle => _logger("Check if ${file_name} exists", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/file_copy_from_local_source.cf b/tree/30_generic_methods/file_copy_from_local_source.cf
index 86df1448c..be419c379 100644
--- a/tree/30_generic_methods/file_copy_from_local_source.cf
+++ b/tree/30_generic_methods/file_copy_from_local_source.cf
@@ -20,7 +20,7 @@
# @description This is a bundle to ensure that a file or directory is copied from a local source
#
# @parameter source Source file
-# @parameter destination Destination file
+# @parameter destination Destination file
#
# @class_prefix file_copy_from_local_source
# @class_parameter destination
@@ -28,6 +28,10 @@
bundle agent file_copy_from_local_source(source, destination)
{
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+
methods:
- "placeholder" usebundle => file_copy_from_local_source_recursion("${source}", "${destination}", "0");
+ "copy without recursion" usebundle => file_copy_from_local_source_recursion("${source}", "${destination}", "0");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_copy_without_recursion", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/file_copy_from_local_source_recursion.cf b/tree/30_generic_methods/file_copy_from_local_source_recursion.cf
index 3f9b56390..65509437d 100644
--- a/tree/30_generic_methods/file_copy_from_local_source_recursion.cf
+++ b/tree/30_generic_methods/file_copy_from_local_source_recursion.cf
@@ -20,8 +20,8 @@
# @description This is a bundle to ensure that a file or directory is copied from a local source
#
# @parameter source Source file
-# @parameter destination Destination file
-# @parameter recursion Recursion depth to enforce for this path (0, 1, 2, ..., inf)
+# @parameter destination Destination file
+# @parameter recursion Recursion depth to enforce for this path (0, 1, 2, ..., inf)
#
# @class_prefix file_copy_from_local_source
# @class_parameter destination
@@ -30,7 +30,8 @@
bundle agent file_copy_from_local_source_recursion(source, destination, recursion)
{
vars:
- "class_prefix" string => canonify("file_copy_from_local_source_${destination}");
+ "old_class_prefix" string => canonify("file_copy_from_local_source_${destination}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
classes:
# depth_search prevents from copying file/symlink
@@ -47,22 +48,22 @@ bundle agent file_copy_from_local_source_recursion(source, destination, recursio
!is_dir_copy::
"${destination}"
copy_from => ncf_local_cp_method("${source}", "digest"),
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
is_dir_copy::
"${destination}"
copy_from => ncf_local_cp_method("${source}", "digest"),
depth_search => recurse("${recursion}"),
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
- # The reports should only be made after we know if this is a
- # directory (to apply recursion) or a file
- iteration_2.!is_dir_copy::
+ # The reports should only be made after we know if this is a
+ # directory (to apply recursion) or a file
+ iteration_2.!is_dir_copy::
"report"
- usebundle => _logger("Copying ${destination} from ${source}", "${class_prefix}");
+ usebundle => _logger("Copying ${destination} from ${source}", "${old_class_prefix}");
- iteration_2.is_dir_copy::
+ iteration_2.is_dir_copy::
"report"
- usebundle => _logger("Copying ${destination} from ${source}, recursion level ${recursion}", "${class_prefix}");
+ usebundle => _logger("Copying ${destination} from ${source}, recursion level ${recursion}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/file_copy_from_remote_source.cf b/tree/30_generic_methods/file_copy_from_remote_source.cf
index ed27545f4..126f02a5c 100644
--- a/tree/30_generic_methods/file_copy_from_remote_source.cf
+++ b/tree/30_generic_methods/file_copy_from_remote_source.cf
@@ -20,7 +20,7 @@
# @description This is a bundle to ensure that a file or directory is copied from a remote source
#
# @parameter source Source file
-# @parameter destination Destination file
+# @parameter destination Destination file
#
# @class_prefix file_copy_from_remote_source
# @class_parameter destination
@@ -28,6 +28,10 @@
bundle agent file_copy_from_remote_source(source, destination)
{
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+
methods:
- "placeholder" usebundle => file_copy_from_remote_source_recursion("${source}", "${destination}", "0");
+ "copy without recursion" usebundle => file_copy_from_remote_source_recursion("${source}", "${destination}", "0");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_copy_without_recursion", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/file_copy_from_remote_source_recursion.cf b/tree/30_generic_methods/file_copy_from_remote_source_recursion.cf
index 908562a9f..4a828fda8 100644
--- a/tree/30_generic_methods/file_copy_from_remote_source_recursion.cf
+++ b/tree/30_generic_methods/file_copy_from_remote_source_recursion.cf
@@ -20,8 +20,8 @@
# @description This is a bundle to ensure that a file or directory is copied from a remote source
#
# @parameter source Source file
-# @parameter destination Destination file
-# @parameter recursion Recursion depth to enforce for this path (0, 1, 2, ..., inf)
+# @parameter destination Destination file
+# @parameter recursion Recursion depth to enforce for this path (0, 1, 2, ..., inf)
#
# @class_prefix file_copy_from_remote_source
# @class_parameter destination
@@ -30,7 +30,8 @@
bundle agent file_copy_from_remote_source_recursion(source, destination, recursion)
{
vars:
- "class_prefix" string => canonify("file_copy_from_remote_source_${destination}");
+ "old_class_prefix" string => canonify("file_copy_from_remote_source_${destination}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
classes:
# depth_search prevents from copying file/symlink
@@ -48,22 +49,22 @@ bundle agent file_copy_from_remote_source_recursion(source, destination, recursi
!is_dir_copy::
"${destination}"
copy_from => ncf_remote_cp_method("${source}", "${sys.policy_hub}", "digest"),
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
is_dir_copy::
"${destination}"
copy_from => ncf_remote_cp_method("${source}", "${sys.policy_hub}", "digest"),
depth_search => recurse("${recursion}"),
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
- # The reports should only be made after we know if this is a
- # directory (to apply recursion) or a file
- iteration_2.!is_dir_copy::
+ # The reports should only be made after we know if this is a
+ # directory (to apply recursion) or a file
+ iteration_2.!is_dir_copy::
"report"
- usebundle => _logger("Copying ${destination} from ${source}", "${class_prefix}");
+ usebundle => _logger("Copying ${destination} from ${source}", "${old_class_prefix}");
- iteration_2.is_dir_copy::
+ iteration_2.is_dir_copy::
"report"
- usebundle => _logger("Copying ${destination} from ${source}, recursion level ${recursion}", "${class_prefix}");
+ usebundle => _logger("Copying ${destination} from ${source}, recursion level ${recursion}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/file_create.cf b/tree/30_generic_methods/file_create.cf
index c81871391..fe2e5c151 100644
--- a/tree/30_generic_methods/file_create.cf
+++ b/tree/30_generic_methods/file_create.cf
@@ -28,14 +28,14 @@
bundle agent file_create(target)
{
vars:
- "class_prefix" string => canonify("file_create_${target}");
+ "old_class_prefix" string => canonify("file_create_${target}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
files:
"${target}"
create => "true",
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
- "report" usebundle => _logger("Create file ${target}", "${class_prefix}");
-
+ "report" usebundle => _logger("Create file ${target}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/file_create_symlink.cf b/tree/30_generic_methods/file_create_symlink.cf
index 54625cb38..0332922d9 100644
--- a/tree/30_generic_methods/file_create_symlink.cf
+++ b/tree/30_generic_methods/file_create_symlink.cf
@@ -20,7 +20,7 @@
# @description This is a bundle to create a symlink at a destination path and pointing to a source target except if a file or directory already exists.
#
# @parameter source Source file
-# @parameter destination Destination file
+# @parameter destination Destination file
#
# @class_prefix file_create_symlink
# @class_parameter destination
@@ -28,8 +28,10 @@
bundle agent file_create_symlink(source, destination)
{
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
methods:
- "wrap" usebundle => file_create_symlink_enforce("${source}", "${destination}", "false");
-
+ "create without enforce" usebundle => file_create_symlink_enforce("${source}", "${destination}", "false");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_create_without_enforce", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/file_create_symlink_enforce.cf b/tree/30_generic_methods/file_create_symlink_enforce.cf
index 09de763a5..316ea442b 100644
--- a/tree/30_generic_methods/file_create_symlink_enforce.cf
+++ b/tree/30_generic_methods/file_create_symlink_enforce.cf
@@ -20,8 +20,8 @@
# @description This is a bundle to create a symlink at a destination path and pointing to a source target. This is also possible to enforce its creation
#
# @parameter source Source file
-# @parameter destination Destination file
-# @parameter enforce Force symlink if file already exist (true or false)
+# @parameter destination Destination file
+# @parameter enforce Force symlink if file already exist (true or false)
#
# @class_prefix file_create_symlink
# @class_parameter destination
@@ -30,17 +30,17 @@
bundle agent file_create_symlink_enforce(source, destination, enforce)
{
vars:
- "class_prefix" string => canonify("file_create_symlink_${destination}");
+ "old_class_prefix" string => canonify("file_create_symlink_${destination}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
files:
# Symlink
"${destination}"
link_from => ln_s("${source}"),
move_obstructions => "${enforce}",
- classes => classes_generic("${class_prefix}"),
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"),
comment => "Create the ${destination} symlink pointing to ${source}";
methods:
- "report"
- usebundle => _logger("Symlink ${destination} targeting ${source}", "${class_prefix}");
+ "report" usebundle => _logger("Symlink ${destination} targeting ${source}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/file_create_symlink_force.cf b/tree/30_generic_methods/file_create_symlink_force.cf
index f881ab408..0a95d0912 100644
--- a/tree/30_generic_methods/file_create_symlink_force.cf
+++ b/tree/30_generic_methods/file_create_symlink_force.cf
@@ -20,7 +20,7 @@
# @description This is a bundle to create a symlink at a destination path and pointing to a source target even if a file or directory already exists.
#
# @parameter source Source file
-# @parameter destination Destination file
+# @parameter destination Destination file
#
# @class_prefix file_create_symlink
# @class_parameter destination
@@ -28,8 +28,10 @@
bundle agent file_create_symlink_force(source, destination)
{
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
methods:
- "wrap" usebundle => file_create_symlink_enforce("${source}", "${destination}", "true");
-
+ "create with enforce" usebundle => file_create_symlink_enforce("${source}", "${destination}", "true");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_create_with_enforce", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/file_download.cf b/tree/30_generic_methods/file_download.cf
index 5b505b3bb..db0f64dcb 100644
--- a/tree/30_generic_methods/file_download.cf
+++ b/tree/30_generic_methods/file_download.cf
@@ -20,7 +20,7 @@
# @description Download a file if it does not exit, using curl with a fallback on wget
#
# @parameter source URL to download from
-# @parameter destination File destination
+# @parameter destination File destination
#
# @class_prefix file_download
# @class_parameter destination
@@ -44,7 +44,8 @@ bundle agent file_download(source, destination)
"canonified_destination" string => canonify("${destination}");
"canonified_action_command" string => canonify("${action_command}");
- "class_prefix" string => "file_download_${canonified_destination}";
+ "old_class_prefix" string => "file_download_${canonified_destination}";
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
classes:
@@ -56,22 +57,26 @@ bundle agent file_download(source, destination)
"action" usebundle => command_execution("${action_command}");
- "class copy" usebundle => _classes_copy("command_execution_${canonified_action_command}", "${class_prefix}");
+ "class copy" usebundle => _classes_copy("command_execution_${canonified_action_command}", "${old_class_prefix}");
- "report" usebundle => _logger("Download ${source} into ${destination}", "${class_prefix}"),
- ifvarclass => "${class_prefix}_reached";
+ "new result classes" usebundle => _classes_copy("${class_prefix}_action", "${class_prefix}");
+
+ "report" usebundle => _logger("Download ${source} into ${destination}", "${old_class_prefix}"),
+ ifvarclass => "(!has_promiser_stack.${old_class_prefix}_reached)|(has_promiser_stack.${class_prefix}_reached)";
!_stdlib_path_exists_curl.!_stdlib_path_exists_wget.!file_exists::
- "force_failure_class" usebundle => _classes_failure("${class_prefix}");
- "report" usebundle => _logger("Unable to download ${source}: neither wget or curl are installed", "${class_prefix}");
+ "force_failure_class" usebundle => _classes_failure("${old_class_prefix}");
+ "new result classes" usebundle => _classes_failure("${class_prefix}");
+ "report" usebundle => _logger("Unable to download ${source}: neither wget or curl are installed", "${old_class_prefix}");
file_exists::
- "force_success_class" usebundle => _classes_success("${class_prefix}"),
- ifvarclass => "!command_execution_${canonified_action_command}_repaired";
-
- "report" usebundle => _logger("File ${destination} already downloaded", "${class_prefix}"),
+ "force_success_class" usebundle => _classes_success("${old_class_prefix}"),
ifvarclass => "!command_execution_${canonified_action_command}_repaired";
+ "new result classes" usebundle => _classes_success("${class_prefix}"),
+ ifvarclass => "${class_prefix}_action_repaired";
+ "report" usebundle => _logger("File ${destination} already downloaded", "${old_class_prefix}"),
+ ifvarclass => "(!has_promiser_stack.!command_execution_${canonified_action_command}_repaired)|(has_promiser_stack.!${class_prefix}_action_repaired)";
}
diff --git a/tree/30_generic_methods/file_enforce_content.cf b/tree/30_generic_methods/file_enforce_content.cf
index 8bf764c5a..415df487c 100644
--- a/tree/30_generic_methods/file_enforce_content.cf
+++ b/tree/30_generic_methods/file_enforce_content.cf
@@ -20,7 +20,7 @@
# @description This is a bundle to enfore the content of a file
#
# @parameter file File name to edit
-# @parameter lines Line(s) to add in the file
+# @parameter lines Line(s) to add in the file
# @parameter enforce Enforce the file to contain only line(s) defined (true or false)
#
# @class_prefix file_ensure_lines_present
@@ -30,16 +30,16 @@
bundle agent file_enforce_content(file, lines, enforce)
{
vars:
- "class_prefix" string => canonify("file_ensure_lines_present_${file}");
+ "old_class_prefix" string => canonify("file_ensure_lines_present_${file}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
files:
"${file}"
create => "true",
edit_line => insert_lines("${lines}"),
edit_defaults => ncf_empty_select("${enforce}"),
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
- "report"
- usebundle => _logger("Insert content ${lines} into ${file}", "${class_prefix}");
+ "report" usebundle => _logger("Insert content ${lines} into ${file}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/file_ensure_block_in_section.cf b/tree/30_generic_methods/file_ensure_block_in_section.cf
index 6df4a7953..7c5f810a2 100644
--- a/tree/30_generic_methods/file_ensure_block_in_section.cf
+++ b/tree/30_generic_methods/file_ensure_block_in_section.cf
@@ -22,7 +22,7 @@
# @parameter file File name to edit
# @parameter section_start Start of the section
# @parameter section_end End of the section
-# @parameter block Block representing the content of the section
+# @parameter block Block representing the content of the section
#
# @class_prefix file_ensure_block_in_section
# @class_parameter file
@@ -31,16 +31,16 @@
bundle agent file_ensure_block_in_section(file, section_start, section_end, block)
{
vars:
- "class_prefix" string => canonify("file_ensure_block_in_section_${file}");
+ "old_class_prefix" string => canonify("file_ensure_block_in_section_${file}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
files:
"${file}"
create => "true",
edit_line => ncf_ensure_section_content("${section_start}", "${section_end}", "${block}"),
edit_defaults => no_backup,
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
- "report"
- usebundle => _logger("Insert text block ${block} into ${file}", "${class_prefix}");
+ "report" usebundle => _logger("Insert text block ${block} into ${file}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/file_ensure_block_present.cf b/tree/30_generic_methods/file_ensure_block_present.cf
index 993d41d0f..97e0a5a58 100644
--- a/tree/30_generic_methods/file_ensure_block_present.cf
+++ b/tree/30_generic_methods/file_ensure_block_present.cf
@@ -20,7 +20,7 @@
# @description This is a bundle to ensure that a text block is present in a specific location
#
# @parameter file File name to edit
-# @parameter block Block(s) to add in the file
+# @parameter block Block(s) to add in the file
#
# @class_prefix file_ensure_block_present
# @class_parameter file
@@ -29,16 +29,16 @@
bundle agent file_ensure_block_present(file, block)
{
vars:
- "class_prefix" string => canonify("file_ensure_block_present_${file}");
+ "old_class_prefix" string => canonify("file_ensure_block_present_${file}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
files:
"${file}"
create => "true",
edit_line => ncf_insert_block("${block}"),
edit_defaults => no_backup,
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
- "report"
- usebundle => _logger("Insert text block ${block} into ${file}", "${class_prefix}");
+ "report" usebundle => _logger("Insert text block ${block} into ${file}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/file_ensure_keys_values.cf b/tree/30_generic_methods/file_ensure_keys_values.cf
index 397a2b7f6..71a03ee3c 100644
--- a/tree/30_generic_methods/file_ensure_keys_values.cf
+++ b/tree/30_generic_methods/file_ensure_keys_values.cf
@@ -20,8 +20,8 @@
# @description Ensure that the file contains all pairs of "key separator value", with arbitrary separator between each key and its value
#
# @parameter file File name to edit
-# @parameter keys Array containing the keys (keys of the array), and values to define (values of the array)
-# @parameter separator Separator between key and value (for example "=" or " ")
+# @parameter keys Array containing the keys (keys of the array), and values to define (values of the array)
+# @parameter separator Separator between key and value (for example "=" or " ")
#
# @class_prefix file_ensure_keys_values
# @class_parameter file
@@ -31,16 +31,16 @@
bundle agent file_ensure_keys_values(file, keys, separator)
{
vars:
- "class_prefix" string => canonify("file_ensure_keys_values_${file}");
+ "old_class_prefix" string => canonify("file_ensure_keys_values_${file}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
files:
"${file}"
create => "true",
edit_line => maintain_key_values("${keys}", "${separator}"),
edit_defaults => no_backup,
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
- "report"
- usebundle => _logger("Ensure lines in format key${separator}values into ${file}", "${class_prefix}");
+ "report" usebundle => _logger("Ensure lines in format key${separator}values into ${file}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/file_ensure_line_present_in_ini_section.cf b/tree/30_generic_methods/file_ensure_line_present_in_ini_section.cf
index 052c7974a..d1bdd45cf 100644
--- a/tree/30_generic_methods/file_ensure_line_present_in_ini_section.cf
+++ b/tree/30_generic_methods/file_ensure_line_present_in_ini_section.cf
@@ -21,7 +21,7 @@
#
# @parameter file File name to edit
# @parameter section Name of the INI-style section under which lines should be added (not including the [] brackets)
-# @parameter line Line to ensure is present inside the section
+# @parameter line Line to ensure is present inside the section
#
# @class_prefix file_ensure_line_present_in_ini_section
# @class_parameter file
@@ -31,7 +31,8 @@
bundle agent file_ensure_line_present_in_ini_section(file, section, line)
{
vars:
- "class_prefix" string => canonify("file_ensure_line_present_in_ini_section_${file}");
+ "old_class_prefix" string => canonify("file_ensure_line_present_in_ini_section_${file}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
"section_and_blank_line" string => "[${section}]
";
@@ -54,9 +55,8 @@ bundle agent file_ensure_line_present_in_ini_section(file, section, line)
create => "true",
edit_line => ensure_line_in_ini_section("${section}", "${line}"),
edit_defaults => no_backup,
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
- "report"
- usebundle => _logger("Insert line(s) ${line} into ${file}", "${class_prefix}");
+ "report" usebundle => _logger("Insert line(s) ${line} into ${file}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/file_ensure_line_present_in_xml_tag.cf b/tree/30_generic_methods/file_ensure_line_present_in_xml_tag.cf
index 0578facd5..a93dbc699 100644
--- a/tree/30_generic_methods/file_ensure_line_present_in_xml_tag.cf
+++ b/tree/30_generic_methods/file_ensure_line_present_in_xml_tag.cf
@@ -21,7 +21,7 @@
#
# @parameter file File name to edit
# @parameter tag Name of the XML tag under which lines should be added (not including the <> brackets)
-# @parameter line Line to ensure is present inside the section
+# @parameter line Line to ensure is present inside the section
#
# @class_prefix file_ensure_line_present_in_xml_tag
# @class_parameter file
@@ -31,7 +31,8 @@
bundle agent file_ensure_line_present_in_xml_tag(file, tag, line)
{
vars:
- "class_prefix" string => canonify("file_ensure_line_present_in_xml_tag_${file}");
+ "old_class_prefix" string => canonify("file_ensure_line_present_in_xml_tag_${file}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
classes:
"opening_tag_exists" expression => regline("\s*<${tag}>\s*", "${file}");
@@ -43,13 +44,13 @@ bundle agent file_ensure_line_present_in_xml_tag(file, tag, line)
"${file}"
edit_line => ensure_line_in_xml_tag("${tag}", "${line}"),
edit_defaults => no_backup,
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
!tags_present::
+ "failure" usebundle => _classes_failure("${old_class_prefix}");
"failure" usebundle => _classes_failure("${class_prefix}");
any::
- "report"
- usebundle => _logger("Insert line(s) ${line} into ${file}", "${class_prefix}");
+ "report" usebundle => _logger("Insert line(s) ${line} into ${file}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/file_ensure_lines_absent.cf b/tree/30_generic_methods/file_ensure_lines_absent.cf
index edb8fb49a..404aecc43 100644
--- a/tree/30_generic_methods/file_ensure_lines_absent.cf
+++ b/tree/30_generic_methods/file_ensure_lines_absent.cf
@@ -20,7 +20,7 @@
# @description This is a bundle to ensure that a line is absent in a specific location
#
# @parameter file File name to edit
-# @parameter lines Line(s) to remove in the file
+# @parameter lines Line(s) to remove in the file
#
# @class_prefix file_ensure_lines_absent
# @class_parameter file
@@ -29,16 +29,16 @@
bundle agent file_ensure_lines_absent(file, lines)
{
vars:
- "class_prefix" string => canonify("file_ensure_lines_absent_${file}");
+ "old_class_prefix" string => canonify("file_ensure_lines_absent_${file}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
files:
"${file}"
create => "false",
edit_line => delete_lines_matching("${lines}"),
edit_defaults => no_backup,
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
- "report"
- usebundle => _logger("Ensure line(s) '${lines}' absent from ${file}", "${class_prefix}");
+ "report" usebundle => _logger("Ensure line(s) '${lines}' absent from ${file}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/file_ensure_lines_present.cf b/tree/30_generic_methods/file_ensure_lines_present.cf
index c0adcdbca..08c1825e6 100644
--- a/tree/30_generic_methods/file_ensure_lines_present.cf
+++ b/tree/30_generic_methods/file_ensure_lines_present.cf
@@ -20,7 +20,7 @@
# @description This is a bundle to ensure that one or more lines are present in a file
#
# @parameter file File name to edit
-# @parameter lines Line(s) to add in the file
+# @parameter lines Line(s) to add in the file
#
# @class_prefix file_ensure_lines_present
# @class_parameter file
@@ -28,6 +28,10 @@
bundle agent file_ensure_lines_present(file, lines)
{
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+
methods:
- "wrapper" usebundle => file_enforce_content("${file}", "${lines}", "false");
+ "enforce lines content" usebundle => file_enforce_content("${file}", "${lines}", "false");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_enforce_lines_content", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/file_from_template.cf b/tree/30_generic_methods/file_from_template.cf
index 98a2e0026..230001907 100644
--- a/tree/30_generic_methods/file_from_template.cf
+++ b/tree/30_generic_methods/file_from_template.cf
@@ -20,7 +20,7 @@
# @description This is a bundle to build a file from a template
#
# @parameter source_template Source file containing a template to be expanded
-# @parameter destination Destination file
+# @parameter destination Destination file
#
# @class_prefix file_from_template
# @class_parameter destination
@@ -29,7 +29,8 @@
bundle agent file_from_template(source_template, destination)
{
vars:
- "class_prefix" string => canonify("file_from_template_${destination}");
+ "old_class_prefix" string => canonify("file_from_template_${destination}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
classes:
@@ -40,16 +41,16 @@ bundle agent file_from_template(source_template, destination)
create => "true",
edit_template => "${source_template}",
ifvarclass => "template_exists",
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
!template_exists::
+ "template_absent" usebundle => _classes_failure("${old_class_prefix}");
"template_absent" usebundle => _classes_failure("${class_prefix}");
any::
-
- "report" usebundle => _logger("Build file ${destination} from template ${source_template}", "${class_prefix}");
+ "report" usebundle => _logger("Build file ${destination} from template ${source_template}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/file_from_template_mustache.cf b/tree/30_generic_methods/file_from_template_mustache.cf
index e8b4b1400..fe5b49888 100644
--- a/tree/30_generic_methods/file_from_template_mustache.cf
+++ b/tree/30_generic_methods/file_from_template_mustache.cf
@@ -21,7 +21,7 @@
# @agent_version >=3.6
#
# @parameter source_template Source file containing a template to be expanded
-# @parameter destination Destination file
+# @parameter destination Destination file
#
# @class_prefix file_from_template
# @class_parameter destination
@@ -29,6 +29,10 @@
bundle agent file_from_template_mustache(source_template, destination)
{
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+
methods:
- "placeholder" usebundle => file_from_template_type("${source_template}", "${destination}", "mustache");
+ "file template mustache type" usebundle => file_from_template_type("${source_template}", "${destination}", "mustache");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_file_template_mustache_type", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/file_from_template_type.cf b/tree/30_generic_methods/file_from_template_type.cf
index 0e18f7ff8..b4063cfee 100644
--- a/tree/30_generic_methods/file_from_template_type.cf
+++ b/tree/30_generic_methods/file_from_template_type.cf
@@ -21,8 +21,8 @@
# @agent_version >=3.6
#
# @parameter source_template Source file containing a template to be expanded
-# @parameter destination Destination file
-# @parameter template_type Template type (cfengine or mustache)
+# @parameter destination Destination file
+# @parameter template_type Template type (cfengine or mustache)
#
# @class_prefix file_from_template
# @class_parameter destination
@@ -30,9 +30,9 @@
bundle agent file_from_template_type(source_template, destination, template_type)
{
-
vars:
- "class_prefix" string => canonify("file_from_template_${destination}");
+ "old_class_prefix" string => canonify("file_from_template_${destination}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
classes:
"template_exists" expression => fileexists("${source_template}");
@@ -43,16 +43,16 @@ bundle agent file_from_template_type(source_template, destination, template_type
edit_template => "${source_template}",
template_method => "${template_type}",
ifvarclass => "template_exists",
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
!template_exists::
+ "template_absent" usebundle => _classes_failure("${old_class_prefix}");
"template_absent" usebundle => _classes_failure("${class_prefix}");
any::
-
- "report" usebundle => _logger("Build file ${destination} from ${template_type} template ${source_template}", "${class_prefix}");
+ "report" usebundle => _logger("Build file ${destination} from ${template_type} template ${source_template}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/file_remove.cf b/tree/30_generic_methods/file_remove.cf
index 313b1d76f..055077550 100644
--- a/tree/30_generic_methods/file_remove.cf
+++ b/tree/30_generic_methods/file_remove.cf
@@ -28,17 +28,21 @@
bundle agent file_remove(target)
{
vars:
- "class_prefix" string => canonify("file_remove_${target}");
+ "old_class_prefix" string => canonify("file_remove_${target}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
files:
"${target}"
delete => tidy,
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
+ "success_if_nothing" usebundle => _classes_success("${old_class_prefix}"),
+ ifvarclass => "!${old_class_prefix}_reached";
+
"success_if_nothing" usebundle => _classes_success("${class_prefix}"),
- ifvarclass => "!${class_prefix}_reached";
+ ifvarclass => "has_promiser_stack.!${class_prefix}_reached";
- "report" usebundle => _logger("Remove file ${target}", "${class_prefix}");
+ "report" usebundle => _logger("Remove file ${target}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/file_replace_lines.cf b/tree/30_generic_methods/file_replace_lines.cf
index 97881de4a..e1a92bd6d 100644
--- a/tree/30_generic_methods/file_replace_lines.cf
+++ b/tree/30_generic_methods/file_replace_lines.cf
@@ -20,8 +20,8 @@
# @description This is a bundle to ensure that a line in a file is replaced by another one
#
# @parameter file File name to edit
-# @parameter line Line to match in the file
-# @parameter replacement Line to add in the file as a replacement
+# @parameter line Line to match in the file
+# @parameter replacement Line to add in the file as a replacement
#
# @class_prefix file_replace_lines
# @class_parameter file
@@ -31,16 +31,16 @@
bundle agent file_replace_lines(file, line, replacement)
{
vars:
- "class_prefix" string => canonify("file_replace_lines_${file}");
+ "old_class_prefix" string => canonify("file_replace_lines_${file}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
files:
"${file}"
create => "false",
edit_line => regex_replace("${line}", "${replacement}"),
edit_defaults => no_backup,
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
- "report"
- usebundle => _logger("Replace line ${lines} with ${replacement} into ${file}", "${class_prefix}");
+ "report" usebundle => _logger("Replace line ${lines} with ${replacement} into ${file}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/file_template_expand.cf b/tree/30_generic_methods/file_template_expand.cf
index af4fb1f29..cfa341b9a 100644
--- a/tree/30_generic_methods/file_template_expand.cf
+++ b/tree/30_generic_methods/file_template_expand.cf
@@ -20,20 +20,22 @@
# @description This is a bundle to expand a template in a specific location
#
# @parameter tml_file File name (with full path within the framework) of the template file
-# @parameter target_file File name (with full path) where to expand the template
+# @parameter target_file File name (with full path) where to expand the template
# @parameter mode Mode of destination file
# @parameter owner Owner of destination file
# @parameter group Froup of destination file
#
# @class_prefix file_template_expand
# @class_parameter target_file
+# @deprecated Use file from template instead
#
# This bundle will define a class file_template_expand_${target_file}_{kept,repaired,not_ok,ok,reached}
bundle agent file_template_expand(tml_file, target_file, mode, owner, group)
{
vars:
- "class_prefix" string => canonify("file_template_expand_${target_file}");
+ "old_class_prefix" string => canonify("file_template_expand_${target_file}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
files:
"${target_file}"
@@ -41,9 +43,8 @@ bundle agent file_template_expand(tml_file, target_file, mode, owner, group)
edit_template => "${me.framework_path}/${tml_file}",
edit_defaults => no_backup,
perms => mog("${mode}","${owner}","${group}"),
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
- "report"
- usebundle => _logger("Expand template ${tml_file} into ${target_file} with perms ${mode}, ${owner}, ${group}", "${class_prefix}");
+ "report" usebundle => _logger("Expand template ${tml_file} into ${target_file} with perms ${mode}, ${owner}, ${group}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/http_request_check_status_headers.cf b/tree/30_generic_methods/http_request_check_status_headers.cf
index 95bfd172e..815239605 100644
--- a/tree/30_generic_methods/http_request_check_status_headers.cf
+++ b/tree/30_generic_methods/http_request_check_status_headers.cf
@@ -31,7 +31,8 @@
bundle agent http_request_check_status_headers(method, url, expected_status, headers)
{
vars:
- "class_prefix" string => canonify("http_request_check_status_headers_${url}");
+ "old_class_prefix" string => canonify("http_request_check_status_headers_${url}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
classes:
any::
@@ -40,15 +41,14 @@ bundle agent http_request_check_status_headers(method, url, expected_status, hea
methods:
pass2::
- "report"
- usebundle => _logger("Performing a HTTP ${method} request on ${url}, expecting status ${expected_status}", "${class_prefix}");
+ "report" usebundle => _logger("Performing a HTTP ${method} request on ${url}, expecting status ${expected_status}", "${old_class_prefix}");
commands:
"${paths.path[curl]}"
args => "-I -s -o /dev/null -w \"%{http_code}\" ${url} -X ${method} -H '${headers}' | /bin/grep -q ${expected_status}",
contain => in_shell,
# We don't define repaired class, as we only query and expect, so using 999 to avoid using this feature
- classes => classes_generic_return_codes("${class_prefix}", "0", "999", "1");
+ classes => classes_generic_return_codes("${old_class_prefix}", "0", "999", "1");
}
diff --git a/tree/30_generic_methods/http_request_content_headers.cf b/tree/30_generic_methods/http_request_content_headers.cf
index 32cbbbc65..e14c7a82e 100644
--- a/tree/30_generic_methods/http_request_content_headers.cf
+++ b/tree/30_generic_methods/http_request_content_headers.cf
@@ -31,7 +31,8 @@
bundle agent http_request_content_headers(method, url, content, headers)
{
vars:
- "class_prefix" string => canonify("http_request_content_headers_${url}");
+ "old_class_prefix" string => canonify("http_request_content_headers_${url}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
classes:
any::
@@ -40,14 +41,13 @@ bundle agent http_request_content_headers(method, url, content, headers)
methods:
pass2::
- "report"
- usebundle => _logger("Performing a HTTP ${method} request on ${url} with specific content", "${class_prefix}");
+ "report" usebundle => _logger("Performing a HTTP ${method} request on ${url} with specific content", "${old_class_prefix}");
commands:
"/bin/echo \"${content}\" | ${paths.path[curl]}"
args => "${url} -X ${method} -H '${headers}' -o /dev/null -s -f -d @-",
contain => in_shell,
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/logger_rudder.cf b/tree/30_generic_methods/logger_rudder.cf
index 062e17d50..de92e66f4 100644
--- a/tree/30_generic_methods/logger_rudder.cf
+++ b/tree/30_generic_methods/logger_rudder.cf
@@ -43,7 +43,7 @@ bundle agent logger_rudder(message, class_prefix)
"reports[${keys}][canon]" string => canonify("${reports[${keys}][1]}");
(logger_rudder_final_resfile_repaired|logger_rudder_temp_resfile_kept)::
- "c_class_prefix" string => canonify("${class_prefix}");
+ "c_class_prefix" string => canonify("${old_class_prefix}");
# 4/ Once the final expected reports file has been expanded, read in our array
"number_lines"
@@ -147,19 +147,19 @@ bundle agent _rudder_common_reports_generic(technique_name, class_prefix, identi
methods:
"na"
usebundle => _rudder_common_report("${technique_name}", "result_na", "${identifier}", "${component_name}", "${component_key}", "${message_prefix} was not applicable"),
- ifvarclass => "${class_prefix}_noop.!${class_prefix}_kept.!${class_prefix}_repaired.!${class_prefix}_error";
+ ifvarclass => "${old_class_prefix}_noop.!${old_class_prefix}_kept.!${old_class_prefix}_repaired.!${old_class_prefix}_error";
"success"
usebundle => _rudder_common_report("${technique_name}", "result_success", "${identifier}", "${component_name}", "${component_key}", "${message_prefix} was correct"),
- ifvarclass => "${class_prefix}_kept.!${class_prefix}_repaired.!${class_prefix}_error";
+ ifvarclass => "${old_class_prefix}_kept.!${old_class_prefix}_repaired.!${old_class_prefix}_error";
"repaired"
usebundle => _rudder_common_report("${technique_name}", "result_repaired", "${identifier}", "${component_name}", "${component_key}", "${message_prefix} was repaired"),
- ifvarclass => "${class_prefix}_repaired.!${class_prefix}_error";
+ ifvarclass => "${old_class_prefix}_repaired.!${old_class_prefix}_error";
"error"
usebundle => _rudder_common_report("${technique_name}", "result_error", "${identifier}", "${component_name}", "${component_key}", "${message_prefix} could not be repaired"),
- ifvarclass => "${class_prefix}_error";
+ ifvarclass => "${old_class_prefix}_error";
}
bundle agent _startExecution(identifier)
diff --git a/tree/30_generic_methods/package_check_installed.cf b/tree/30_generic_methods/package_check_installed.cf
index 7f362a28d..e5afaf2e0 100644
--- a/tree/30_generic_methods/package_check_installed.cf
+++ b/tree/30_generic_methods/package_check_installed.cf
@@ -31,19 +31,30 @@
bundle agent package_check_installed(package_name)
{
vars:
- "class_prefix" string => canonify("package_check_installed_${package_name}");
+ "old_class_prefix" string => canonify("package_check_installed_${package_name}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
"called_class_prefix" string => canonify("package_install_${package_name}");
methods:
- "placeholder" usebundle => package_install_version_cmp_update("${package_name}", "==", "latest", "verify", "false");
+ "check install with latest version"
+ usebundle => package_install_version_cmp_update("${package_name}", "==", "latest", "verify", "false");
"success"
- usebundle => _classes_success("${class_prefix}"),
+ usebundle => _classes_success("${old_class_prefix}"),
ifvarclass => "${called_class_prefix}_kept";
+ "success"
+ usebundle => _classes_success("${class_prefix}"),
+ ifvarclass => "${class_prefix}_check_install_with_latest_version_kept";
+
"failed"
- usebundle => _classes_failure("${class_prefix}"),
+ usebundle => _classes_failure("${old_class_prefix}"),
ifvarclass => "${called_class_prefix}_repaired";
- "report" usebundle => _logger("Check that package ${package_name} is installed", "${class_prefix}");
+ "failed"
+ usebundle => _classes_failure("${class_prefix}"),
+ ifvarclass => "${class_prefix}_check_install_with_latest_version_repaired";
+
+ "report"
+ usebundle => _logger("Check that package ${package_name} is installed", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/package_install.cf b/tree/30_generic_methods/package_install.cf
index 76ef8b6d0..3b2c81535 100644
--- a/tree/30_generic_methods/package_install.cf
+++ b/tree/30_generic_methods/package_install.cf
@@ -27,6 +27,10 @@
bundle agent package_install(package_name)
{
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+
methods:
- "placeholder" usebundle => package_install_version("${package_name}", "latest");
+ "install latest" usebundle => package_install_version("${package_name}", "latest");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_install_latest", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/package_install_version.cf b/tree/30_generic_methods/package_install_version.cf
index f28a9d280..849628769 100644
--- a/tree/30_generic_methods/package_install_version.cf
+++ b/tree/30_generic_methods/package_install_version.cf
@@ -28,7 +28,11 @@
bundle agent package_install_version(package_name, package_version)
{
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+
methods:
- "placeholder" usebundle => package_install_version_cmp("${package_name}", "==", "${package_version}", "add");
+ "install vith version" usebundle => package_install_version_cmp("${package_name}", "==", "${package_version}", "add");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_install_vith_version", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/package_install_version_cmp.cf b/tree/30_generic_methods/package_install_version_cmp.cf
index 6c22bd5d1..425866e90 100644
--- a/tree/30_generic_methods/package_install_version_cmp.cf
+++ b/tree/30_generic_methods/package_install_version_cmp.cf
@@ -34,6 +34,10 @@
bundle agent package_install_version_cmp(package_name, version_comparator, package_version, action)
{
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+
methods:
- "wrapper" usebundle => package_install_version_cmp_update("${package_name}", "${version_comparator}", "${package_version}", "${action}", "true");
+ "install or update" usebundle => package_install_version_cmp_update("${package_name}", "${version_comparator}", "${package_version}", "${action}", "true");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_install_or_update", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/package_install_version_cmp_update.cf b/tree/30_generic_methods/package_install_version_cmp_update.cf
index f44ff658b..133b4830c 100644
--- a/tree/30_generic_methods/package_install_version_cmp_update.cf
+++ b/tree/30_generic_methods/package_install_version_cmp_update.cf
@@ -37,7 +37,8 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator
{
vars:
"canonified_package_name" string => canonify("${package_name}");
- "class_prefix" string => "package_install_${canonified_package_name}";
+ "old_class_prefix" string => "package_install_${canonified_package_name}";
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
defaults:
"action" string => "immediate", if_match_regex => "add";
@@ -62,7 +63,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator
package_version => "${package_version}",
package_select => "${version_comparator}",
package_method => debian_local_install,
- classes => classes_generic("${class_prefix}"),
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"),
action => do_if_immediate;
@@ -72,7 +73,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator
package_version => "${package_version}",
package_select => "${version_comparator}",
package_method => apt_get,
- classes => classes_generic("${class_prefix}"),
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"),
action => do_if_immediate;
@@ -80,14 +81,14 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator
"${package_name}"
package_policy => "${update_policy}",
package_method => debian_local_install,
- classes => classes_generic("${class_prefix}"),
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"),
action => do_if_immediate;
version_not_specified.!local_package.debian::
"${package_name}"
package_policy => "${update_policy}",
package_method => apt_get,
- classes => classes_generic("${class_prefix}"),
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"),
action => do_if_immediate;
## RedHat support ##
@@ -97,7 +98,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator
package_version => "${package_version}",
package_select => "${version_comparator}",
package_method => redhat_local_install,
- classes => classes_generic("${class_prefix}"),
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"),
action => do_if_immediate;
!version_not_specified.!local_package.redhat::
@@ -106,7 +107,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator
package_version => "${package_version}",
package_select => "${version_comparator}",
package_method => yum_rpm,
- classes => classes_generic("${class_prefix}"),
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"),
action => do_if_immediate;
@@ -114,7 +115,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator
"${package_name}"
package_policy => "${update_policy}",
package_method => redhat_local_install,
- classes => classes_generic("${class_prefix}"),
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"),
action => do_if_immediate;
@@ -122,7 +123,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator
"${package_name}"
package_policy => "${update_policy}",
package_method => yum_rpm,
- classes => classes_generic("${class_prefix}"),
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"),
action => do_if_immediate;
## SUSE support ##
@@ -132,7 +133,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator
package_version => "${package_version}",
package_select => "${version_comparator}",
package_method => ncf_generic,
- classes => classes_generic("${class_prefix}"),
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"),
action => do_if_immediate;
!version_not_specified.!local_package.SuSE::
@@ -141,7 +142,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator
package_version => "${package_version}",
package_select => "${version_comparator}",
package_method => ncf_generic,
- classes => classes_generic("${class_prefix}"),
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"),
action => do_if_immediate;
@@ -149,7 +150,7 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator
"${package_name}"
package_policy => "${update_policy}",
package_method => ncf_generic,
- classes => classes_generic("${class_prefix}"),
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"),
action => do_if_immediate;
@@ -157,18 +158,18 @@ bundle agent package_install_version_cmp_update(package_name, version_comparator
"${package_name}"
package_policy => "${update_policy}",
package_method => ncf_generic,
- classes => classes_generic("${class_prefix}"),
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"),
action => do_if_immediate;
methods:
immediate.!update::
- "Reports" usebundle => _logger("Install package ${package_name}", "${class_prefix}");
+ "Reports" usebundle => _logger("Install package ${package_name}", "${old_class_prefix}");
immediate.update::
- "Reports" usebundle => _logger("Install or update package ${package_name} in version ${package_version}", "${class_prefix}");
+ "Reports" usebundle => _logger("Install or update package ${package_name} in version ${package_version}", "${old_class_prefix}");
!immediate.!version_not_specified::
- "Reports" usebundle => _logger("Verify that package ${package_name} is installed in version ${package_version}", "${class_prefix}");
+ "Reports" usebundle => _logger("Verify that package ${package_name} is installed in version ${package_version}", "${old_class_prefix}");
!immediate.version_not_specified.update::
- "Reports" usebundle => _logger("Verify that package ${package_name} is installed and up-to-date", "${class_prefix}");
+ "Reports" usebundle => _logger("Verify that package ${package_name} is installed and up-to-date", "${old_class_prefix}");
!immediate.version_not_specified.!update::
- "Reports" usebundle => _logger("Verify that package ${package_name} is installed", "${class_prefix}");
+ "Reports" usebundle => _logger("Verify that package ${package_name} is installed", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/package_remove.cf b/tree/30_generic_methods/package_remove.cf
index faf33dc65..b8144b1d2 100644
--- a/tree/30_generic_methods/package_remove.cf
+++ b/tree/30_generic_methods/package_remove.cf
@@ -34,14 +34,15 @@ bundle agent package_remove(package_name)
vars:
"canonified_package_name" string => canonify("${package_name}");
- "class_prefix" string => "package_remove_${canonified_package_name}";
+ "old_class_prefix" string => "package_remove_${canonified_package_name}";
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
packages:
"${package_name}"
package_policy => "delete",
package_method => generic,
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
- "placeholder" usebundle => _logger("Remove package ${package_name}", "${class_prefix}");
+ "placeholder" usebundle => _logger("Remove package ${package_name}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/package_verify.cf b/tree/30_generic_methods/package_verify.cf
index 37dec7a00..bef9273b5 100644
--- a/tree/30_generic_methods/package_verify.cf
+++ b/tree/30_generic_methods/package_verify.cf
@@ -27,7 +27,11 @@
bundle agent package_verify(package_name)
{
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+
methods:
- "placeholder" usebundle => package_verify_version("${package_name}", "latest");
+ "verify latest" usebundle => package_verify_version("${package_name}", "latest");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_verify_latest", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/package_verify_version.cf b/tree/30_generic_methods/package_verify_version.cf
index 867cd793c..60c83b6d8 100644
--- a/tree/30_generic_methods/package_verify_version.cf
+++ b/tree/30_generic_methods/package_verify_version.cf
@@ -28,8 +28,12 @@
bundle agent package_verify_version(package_name, package_version)
{
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+
methods:
- "placeholder" usebundle => package_install_version_cmp("${package_name}", "==", "${package_version}", "verify");
+ "package verify" usebundle => package_install_version_cmp("${package_name}", "==", "${package_version}", "verify");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_package_verify", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/permissions.cf b/tree/30_generic_methods/permissions.cf
index 936cc2db4..d6d1159fa 100644
--- a/tree/30_generic_methods/permissions.cf
+++ b/tree/30_generic_methods/permissions.cf
@@ -30,7 +30,11 @@
bundle agent permissions(path, mode, owner, group)
{
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+
methods:
- "placeholder" usebundle => permissions_type_recursion("${path}", "${mode}", "${owner}", "${group}", "all", "0");
+ "permission without recursion" usebundle => permissions_type_recursion("${path}", "${mode}", "${owner}", "${group}", "all", "0");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_permission_without_recursion", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/permissions_dirs.cf b/tree/30_generic_methods/permissions_dirs.cf
index f688af97e..0e6dbde75 100644
--- a/tree/30_generic_methods/permissions_dirs.cf
+++ b/tree/30_generic_methods/permissions_dirs.cf
@@ -20,9 +20,9 @@
# @description Verify if a directory has the right permissions non recursively
#
# @parameter path Path of the directory
-# @parameter mode Mode to enfore
-# @parameter owner Owner to enforce
-# @parameter group Group to enforce
+# @parameter mode Mode to enfore
+# @parameter owner Owner to enforce
+# @parameter group Group to enforce
#
# @class_prefix permissions
# @class_parameter path
@@ -30,6 +30,10 @@
bundle agent permissions_dirs(path, mode, owner, group)
{
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+
methods:
- "placeholder" usebundle => permissions_type_recursion("${path}", "${mode}", "${owner}", "${group}", "directories", "0");
+ "permission without recursion" usebundle => permissions_type_recursion("${path}", "${mode}", "${owner}", "${group}", "directories", "0");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_permission_without_recursion", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/permissions_dirs_recurse.cf b/tree/30_generic_methods/permissions_dirs_recurse.cf
index 00a418f38..2170ccc71 100644
--- a/tree/30_generic_methods/permissions_dirs_recurse.cf
+++ b/tree/30_generic_methods/permissions_dirs_recurse.cf
@@ -30,6 +30,10 @@
bundle agent permissions_dirs_recurse(path, mode, owner, group)
{
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+
methods:
- "placeholder" usebundle => permissions_type_recursion("${path}", "${mode}", "${owner}", "${group}", "directories", "inf");
+ "permission with recursion" usebundle => permissions_type_recursion("${path}", "${mode}", "${owner}", "${group}", "directories", "inf");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_permission_with_recursion", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/permissions_recurse.cf b/tree/30_generic_methods/permissions_recurse.cf
index 61a781434..02f150128 100644
--- a/tree/30_generic_methods/permissions_recurse.cf
+++ b/tree/30_generic_methods/permissions_recurse.cf
@@ -30,6 +30,10 @@
bundle agent permissions_recurse(path, mode, owner, group)
{
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+
methods:
- "placeholder" usebundle => permissions_type_recursion("${path}", "${mode}", "${owner}", "${group}", "all", "inf");
+ "permission with recursion" usebundle => permissions_type_recursion("${path}", "${mode}", "${owner}", "${group}", "all", "inf");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_permission_with_recursion", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/permissions_type_recursion.cf b/tree/30_generic_methods/permissions_type_recursion.cf
index 6e772c554..4584ef5dc 100644
--- a/tree/30_generic_methods/permissions_type_recursion.cf
+++ b/tree/30_generic_methods/permissions_type_recursion.cf
@@ -20,11 +20,11 @@
# @description This is a bundle to ensure that a file or directory is present and has the right mode/owner/group
#
# @parameter path Path to edit
-# @parameter mode Mode of the path to edit
-# @parameter owner Owner of the path to edit
-# @parameter group Group of the path to edit
-# @parameter type Type of the path to edit (all/files/directories)
-# @parameter recursion Recursion depth to enforce for this path (0, 1, 2, ..., inf)
+# @parameter mode Mode of the path to edit
+# @parameter owner Owner of the path to edit
+# @parameter group Group of the path to edit
+# @parameter type Type of the path to edit (all/files/directories)
+# @parameter recursion Recursion depth to enforce for this path (0, 1, 2, ..., inf)
#
# @class_prefix permissions
# @class_parameter path
@@ -33,7 +33,8 @@
bundle agent permissions_type_recursion(path, mode, owner, group, type, recursion)
{
vars:
- "class_prefix" string => canonify("permissions_${path}");
+ "old_class_prefix" string => canonify("permissions_${path}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
classes:
"is_type_all" expression => strcmp("${type}", "all");
@@ -53,14 +54,14 @@ bundle agent permissions_type_recursion(path, mode, owner, group, type, recursio
create => "false",
perms => mog("${mode}", "${owner}", "${group}"),
depth_search => recurse_with_base("${recursion}"),
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
is_type_all.((is_target_directory.is_depth_zero)|!is_target_directory)::
"${path}"
create => "false",
perms => mog("${mode}", "${owner}", "${group}"),
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
is_type_files.is_target_directory.!is_depth_zero::
@@ -69,7 +70,7 @@ bundle agent permissions_type_recursion(path, mode, owner, group, type, recursio
perms => mog("${mode}", "${owner}", "${group}"),
depth_search => recurse("${recursion}"),
file_select => plain,
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
is_type_files.((is_target_directory.is_depth_zero)|!is_target_directory)::
@@ -77,7 +78,7 @@ bundle agent permissions_type_recursion(path, mode, owner, group, type, recursio
create => "false",
perms => mog("${mode}", "${owner}", "${group}"),
file_select => plain,
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
is_type_directories.is_target_directory.!is_depth_zero::
@@ -86,7 +87,7 @@ bundle agent permissions_type_recursion(path, mode, owner, group, type, recursio
perms => mog("${mode}", "${owner}", "${group}"),
depth_search => recurse_with_base("${recursion}"),
file_select => dirs,
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
is_type_directories.((is_target_directory.is_depth_zero)|!is_target_directory)::
@@ -94,9 +95,8 @@ bundle agent permissions_type_recursion(path, mode, owner, group, type, recursio
create => "false",
perms => mog("${mode}", "${owner}", "${group}"),
file_select => dirs,
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
methods:
- "report"
- usebundle => _logger("Ensure permissions mode ${mode}, owner ${owner} and group ${group} on ${path}", "${class_prefix}");
+ "report" usebundle => _logger("Ensure permissions mode ${mode}, owner ${owner} and group ${group} on ${path}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/schedule_simple.cf b/tree/30_generic_methods/schedule_simple.cf
index c76e45798..20f6e1d70 100644
--- a/tree/30_generic_methods/schedule_simple.cf
+++ b/tree/30_generic_methods/schedule_simple.cf
@@ -46,21 +46,27 @@ bundle agent schedule_simple(job_id, agent_periodicity,
{
vars:
any::
- "class_prefix" string => canonify("schedule_simple_${job_id}");
-
+ "old_class_prefix" string => "schedule_simple_${job_id}";
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
methods:
any::
- "any" usebundle => schedule_simple_generic("${job_id}", "${agent_periodicity}", "${max_execution_delay_minutes}", "${max_execution_delay_hours}",
- "${start_on_minutes}", "${start_on_hours}", "${start_on_day_of_week}",
- "${periodicity_minutes}", "${periodicity_hours}", "${periodicity_days}", "${mode}");
+ "simple scheduler" usebundle => schedule_simple_generic("${job_id}", "${agent_periodicity}", "${max_execution_delay_minutes}", "${max_execution_delay_hours}",
+ "${start_on_minutes}", "${start_on_hours}", "${start_on_day_of_week}",
+ "${periodicity_minutes}", "${periodicity_hours}", "${periodicity_days}", "${mode}");
+ "kept" usebundle => _classes_success("${old_class_prefix}"),
+ ifvarclass => "!job_${job_id}_run.!job_${job_id}_error";
"kept" usebundle => _classes_success("${class_prefix}"),
ifvarclass => "!job_${job_id}_run.!job_${job_id}_error";
+ "repaired" usebundle => _classes_repaired("${old_class_prefix}"),
+ ifvarclass => "job_${job_id}_run";
"repaired" usebundle => _classes_repaired("${class_prefix}"),
ifvarclass => "job_${job_id}_run";
+ "error" usebundle => _classes_failure("${old_class_prefix}"),
+ ifvarclass => "job_${job_id}_error";
"error" usebundle => _classes_failure("${class_prefix}"),
ifvarclass => "job_${job_id}_error";
- "report" usebundle => _logger("Scheduling ${job_id}", "${class_prefix}");
+ "report" usebundle => _logger("Scheduling ${job_id}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/schedule_simple_catchup.cf b/tree/30_generic_methods/schedule_simple_catchup.cf
index 97343ff70..8244af89e 100644
--- a/tree/30_generic_methods/schedule_simple_catchup.cf
+++ b/tree/30_generic_methods/schedule_simple_catchup.cf
@@ -44,10 +44,16 @@ bundle agent schedule_simple_catchup(job_id, agent_periodicity,
periodicity_minutes, periodicity_hours, periodicity_days)
{
+ vars:
+ any::
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+
methods:
any::
- "any" usebundle => schedule_simple("${job_id}", "${agent_periodicity}", "${max_execution_delay_minutes}", "${max_execution_delay_hours}",
+ "simple scheduler" usebundle => schedule_simple("${job_id}", "${agent_periodicity}", "${max_execution_delay_minutes}", "${max_execution_delay_hours}",
"${start_on_minutes}", "${start_on_hours}", "${start_on_day_of_week}",
"${periodicity_minutes}", "${periodicity_hours}", "${periodicity_days}", "catchup");
+
+ "new result classes" usebundle => _classes_copy("${class_prefix}_simple_scheduler", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/schedule_simple_nodups.cf b/tree/30_generic_methods/schedule_simple_nodups.cf
index b3b4b4d7e..0dc75b898 100644
--- a/tree/30_generic_methods/schedule_simple_nodups.cf
+++ b/tree/30_generic_methods/schedule_simple_nodups.cf
@@ -44,10 +44,16 @@ bundle agent schedule_simple_nodups(job_id, agent_periodicity,
periodicity_minutes, periodicity_hours, periodicity_days)
{
+ vars:
+ any::
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+
methods:
any::
- "any" usebundle => schedule_simple("${job_id}", "${agent_periodicity}", "${max_execution_delay_minutes}", "${max_execution_delay_hours}",
- "${start_on_minutes}", "${start_on_hours}", "${start_on_day_of_week}",
- "${periodicity_minutes}", "${periodicity_hours}", "${periodicity_days}", "nodups");
+ "simple scheduler" usebundle => schedule_simple("${job_id}", "${agent_periodicity}", "${max_execution_delay_minutes}", "${max_execution_delay_hours}",
+ "${start_on_minutes}", "${start_on_hours}", "${start_on_day_of_week}",
+ "${periodicity_minutes}", "${periodicity_hours}", "${periodicity_days}", "nodups");
+
+ "new result classes" usebundle => _classes_copy("${class_prefix}_simple_scheduler", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/schedule_simple_stateless.cf b/tree/30_generic_methods/schedule_simple_stateless.cf
index 1a69984a4..859f78ee7 100644
--- a/tree/30_generic_methods/schedule_simple_stateless.cf
+++ b/tree/30_generic_methods/schedule_simple_stateless.cf
@@ -44,10 +44,16 @@ bundle agent schedule_simple_stateless(job_id, agent_periodicity,
periodicity_minutes, periodicity_hours, periodicity_days)
{
+ vars:
+ any::
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+
methods:
any::
- "any" usebundle => schedule_simple("${job_id}", "${agent_periodicity}", "${max_execution_delay_minutes}", "${max_execution_delay_hours}",
- "${start_on_minutes}", "${start_on_hours}", "${start_on_day_of_week}",
- "${periodicity_minutes}", "${periodicity_hours}", "${periodicity_days}", "stateless");
+ "simple scheduler" usebundle => schedule_simple("${job_id}", "${agent_periodicity}", "${max_execution_delay_minutes}", "${max_execution_delay_hours}",
+ "${start_on_minutes}", "${start_on_hours}", "${start_on_day_of_week}",
+ "${periodicity_minutes}", "${periodicity_hours}", "${periodicity_days}", "stateless");
+
+ "new result classes" usebundle => _classes_copy("${class_prefix}_simple_scheduler", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/service_action.cf b/tree/30_generic_methods/service_action.cf
index 193435abb..b13b6a694 100644
--- a/tree/30_generic_methods/service_action.cf
+++ b/tree/30_generic_methods/service_action.cf
@@ -28,7 +28,6 @@
bundle agent service_action(service_name, action)
{
-
vars:
systemctl_utility_present::
@@ -48,7 +47,8 @@ bundle agent service_action(service_name, action)
"canonified_service_name" string => canonify("${service_name}");
"canonified_action_command" string => canonify("${action_command}");
- "class_prefix" string => "service_action_${canonified_service_name}";
+ "old_class_prefix" string => "service_action_${canonified_service_name}";
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
classes:
windows::
@@ -63,35 +63,37 @@ bundle agent service_action(service_name, action)
systemctl_utility_present|service_utility_present|init_d_directory_present::
- "action" usebundle => command_execution("${action_command}");
+ "action using command" usebundle => command_execution("${action_command}");
- "class copy" usebundle => _classes_copy("command_execution_${canonified_action_command}", "${class_prefix}");
+ "class copy" usebundle => _classes_copy("command_execution_${canonified_action_command}", "${old_class_prefix}");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_action_using_command", "${class_prefix}");
systemctl_utility_present|service_utility_present|init_d_directory_present|(windows.is_valid_action)::
- "report" usebundle => _logger("Run action ${action} on service ${service_name}", "${class_prefix}"),
- ifvarclass => "${class_prefix}_reached";
+ "report" usebundle => _logger("Run action ${action} on service ${service_name}", "${old_class_prefix}"),
+ ifvarclass => "(!has_promiser_stack.${old_class_prefix}_reached)|(has_promiser_stack.${class_prefix}_reached)";
(!systemctl_utility_present.!service_utility_present.!init_d_directory_present.!windows)|(windows.!is_valid_action)::
+ "force_failure_class" usebundle => _classes_failure("${old_class_prefix}");
"force_failure_class" usebundle => _classes_failure("${class_prefix}");
- "report" usebundle => _logger("Running ${action} on service ${service_name} is not possible yet on this system", "${class_prefix}");
+ "report" usebundle => _logger("Running ${action} on service ${service_name} is not possible yet on this system", "${old_class_prefix}");
services:
# Restart causes the agent to fail, so we must replace it by stop and start
windows.is_valid_action.!is_restart_action::
"${service_name}"
service_policy => "${action}",
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
windows.is_restart_action::
"${service_name}"
service_policy => "stop",
- classes => classes_generic("${class_prefix}_stop_service");
+ classes => classes_generic_two("${old_class_prefix}_stop_service", "${class_prefix}_stop_service");
"${service_name}"
service_policy => "start",
- classes => classes_generic("${class_prefix}"),
- ifvarclass => "${class_prefix}_stop_service_ok";
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}"),
+ ifvarclass => "(!has_promiser_stack.${old_class_prefix}_stop_service_ok)|(has_promiser_stack.${class_prefix}_stop_service_ok)";
}
diff --git a/tree/30_generic_methods/service_check_running.cf b/tree/30_generic_methods/service_check_running.cf
index ceecb90de..fc000d38f 100644
--- a/tree/30_generic_methods/service_check_running.cf
+++ b/tree/30_generic_methods/service_check_running.cf
@@ -27,9 +27,11 @@
bundle agent service_check_running(service_name)
{
- methods:
-
- # Will be replaced later with less naive conditions (using either service, upstart, ...
- "placeholder" usebundle => service_check_running_ps("${service_name}");
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+ methods:
+ # Will be replaced later with less naive conditions (using either service, upstart, ...
+ "check running with ps" usebundle => service_check_running_ps("${service_name}");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_check_running_with_ps", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/service_check_running_ps.cf b/tree/30_generic_methods/service_check_running_ps.cf
index 15921228f..a1ec43767 100644
--- a/tree/30_generic_methods/service_check_running_ps.cf
+++ b/tree/30_generic_methods/service_check_running_ps.cf
@@ -28,8 +28,8 @@
bundle agent service_check_running_ps(service_regex)
{
vars:
-
- "class_prefix" string => canonify("service_check_running_${service_regex}");
+ "old_class_prefix" string => canonify("service_check_running_${service_regex}");
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
classes:
any::
@@ -38,23 +38,32 @@ bundle agent service_check_running_ps(service_regex)
methods:
pass2::
+ "success_classes"
+ usebundle => _classes_success("${old_class_prefix}"),
+ ifvarclass => "${old_class_prefix}_checked_ok";
+
"success_classes"
usebundle => _classes_success("${class_prefix}"),
- ifvarclass => canonify("${class_prefix}_checked_ok");
+ ifvarclass => "has_promiser_stack.${class_prefix}_checked_ok";
+
+ "error_classes"
+ usebundle => _classes_failure("${old_class_prefix}"),
+ ifvarclass => "${old_class_prefix}_checked_not_ok";
"error_classes"
usebundle => _classes_failure("${class_prefix}"),
- ifvarclass => canonify("${class_prefix}_checked_not_ok");
+ ifvarclass => "has_promiser_stack.${class_prefix}_checked_not_ok";
"report"
- usebundle => _logger("Check if the service ${service_regex} is started using ps", "${class_prefix}");
+ usebundle => _logger("Check if the service ${service_regex} is started using ps", "${old_class_prefix}");
processes:
"${service_regex}"
- process_count => any_count("${class_prefix}_checked_ok");
+ process_count => any_count_two("${old_class_prefix}_checked_ok", "${class_prefix}_checked_ok");
"${service_regex}"
- restart_class => "${class_prefix}_checked_not_ok";
+ # missing new_class_prefix : we cannot put 2 classes here, so we put the only one that we are sure to work
+ restart_class => "${old_class_prefix}_checked_not_ok";
}
diff --git a/tree/30_generic_methods/service_check_started_at_boot.cf b/tree/30_generic_methods/service_check_started_at_boot.cf
index 2ca9a16b2..f2b01c837 100644
--- a/tree/30_generic_methods/service_check_started_at_boot.cf
+++ b/tree/30_generic_methods/service_check_started_at_boot.cf
@@ -43,7 +43,8 @@ bundle agent service_check_started_at_boot(service_name)
"canonified_service_name" string => canonify("${service_name}");
"canonified_command" string => canonify("${command_to_check}");
- "class_prefix" string => "service_check_started_at_boot_${canonified_service_name}";
+ "old_class_prefix" string => "service_check_started_at_boot_${canonified_service_name}";
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
classes:
@@ -63,12 +64,17 @@ bundle agent service_check_started_at_boot(service_name)
"check_run"
usebundle => command_execution("${command_to_check}");
- "success" usebundle => _classes_success("${class_prefix}"),
+ "success" usebundle => _classes_success("${old_class_prefix}"),
ifvarclass => "command_execution_${canonified_command}_repaired.!command_execution_${canonified_command}_failed";
- "failure" usebundle => _classes_failure("${class_prefix}"),
+ "success" usebundle => _classes_success("${class_prefix}"),
+ ifvarclass => "has_promiser_stack.(${class_prefix}_check_run_repaired.!${class_prefix}_check_run_failed)";
+
+ "failure" usebundle => _classes_failure("${old_class_prefix}"),
ifvarclass => "command_execution_${canonified_command}_failed";
- "reports" usebundle => _logger("Ensure that service ${service_name} is defined at boot", "${class_prefix}");
+ "failure" usebundle => _classes_failure("${class_prefix}"),
+ ifvarclass => "${class_prefix}_check_run_failed";
+ "reports" usebundle => _logger("Ensure that service ${service_name} is defined at boot", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/service_ensure_running.cf b/tree/30_generic_methods/service_ensure_running.cf
index 362d92808..47f1a4459 100644
--- a/tree/30_generic_methods/service_ensure_running.cf
+++ b/tree/30_generic_methods/service_ensure_running.cf
@@ -27,9 +27,10 @@
bundle agent service_ensure_running(service_name)
{
- methods:
-
- "check running"
- usebundle => service_ensure_running_path("${service_name}", "${service_name}");
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+ methods:
+ "check running" usebundle => service_ensure_running_path("${service_name}", "${service_name}");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_check-running", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/service_ensure_running_path.cf b/tree/30_generic_methods/service_ensure_running_path.cf
index 536aca00e..42ec6d586 100644
--- a/tree/30_generic_methods/service_ensure_running_path.cf
+++ b/tree/30_generic_methods/service_ensure_running_path.cf
@@ -34,7 +34,8 @@ bundle agent service_ensure_running_path(service_name, service_path)
"canonified_service_name" string => canonify("${service_name}");
"canonified_service_path" string => canonify("${service_path}");
- "class_prefix" string => "service_ensure_running_${canonified_service_name}";
+ "old_class_prefix" string => "service_ensure_running_${canonified_service_name}";
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
methods:
!windows::
@@ -43,28 +44,32 @@ bundle agent service_ensure_running_path(service_name, service_path)
"start if not running"
usebundle => service_start("${service_name}"),
- ifvarclass => "!service_check_running_${canonified_service_path}_kept";
+ ifvarclass => "(!has_promiser_stack.!service_check_running_${canonified_service_path}_kept)|(has_promiser_stack.${class_prefix}_check_running_kept)";
"class copy check"
- usebundle => _classes_success("${class_prefix}"),
+ usebundle => _classes_success("${old_class_prefix}"),
ifvarclass => "service_check_running_${canonified_service_path}_kept";
+
+ "class copy check"
+ usebundle => _classes_success("${class_prefix}"),
+ ifvarclass => "${class_prefix}_check_running_kept";
"class copy if not running"
- usebundle => _classes_copy("service_start_${canonified_service_path}", "${class_prefix}"),
+ usebundle => _classes_copy("service_start_${canonified_service_path}", "${old_class_prefix}"),
ifvarclass => "!service_check_running_${canonified_service_path}_kept";
+ "class copy if not running"
+ usebundle => _classes_copy("${class_prefix}_start_if_not_running", "${class_prefix}"),
+ ifvarclass => "has_promiser_stack.!${class_prefix}_check_running_kept";
+
any::
"report"
- usebundle => _logger("Ensure that service ${service_name} is running", "${class_prefix}"),
- ifvarclass => "${class_prefix}_reached";
+ usebundle => _logger("Ensure that service ${service_name} is running", "${old_class_prefix}"),
+ ifvarclass => "(!has_promiser_stack.${old_class_prefix}_reached)|(has_promiser_stack.${class_prefix}_reached)";
services:
windows::
"${service_name}"
service_policy => "start",
- classes => classes_generic("${class_prefix}");
-
-
-
-
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/service_ensure_started_at_boot.cf b/tree/30_generic_methods/service_ensure_started_at_boot.cf
index 7da0a1c9d..fe1501330 100644
--- a/tree/30_generic_methods/service_ensure_started_at_boot.cf
+++ b/tree/30_generic_methods/service_ensure_started_at_boot.cf
@@ -42,7 +42,8 @@ bundle agent service_ensure_started_at_boot(service_name)
"canonified_service_name" string => canonify("${service_name}");
"canonified_command_name" string => canonify("${command_to_register}");
- "class_prefix" string => "service_ensure_started_at_boot_${canonified_service_name}";
+ "old_class_prefix" string => "service_ensure_started_at_boot_${canonified_service_name}";
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
methods:
!windows::
@@ -51,25 +52,33 @@ bundle agent service_ensure_started_at_boot(service_name)
"define_at_boot"
usebundle => command_execution("${service_ensure_started_at_boot.command_to_register}"),
- ifvarclass => "service_check_started_at_boot_${canonified_service_name}_not_ok";
+ ifvarclass => "(!has_promiser_stack.service_check_started_at_boot_${canonified_service_name}_not_ok)|(has_promiser_stack.${class_prefix}_check_at_boot_not_ok)";
"already defined"
- usebundle => _classes_success("${class_prefix}"),
+ usebundle => _classes_success("${old_class_prefix}"),
ifvarclass => "service_check_started_at_boot_${canonified_service_name}_ok";
+ "already defined"
+ usebundle => _classes_success("${class_prefix}"),
+ ifvarclass => "${class_prefix}_check_at_boot_ok";
+
"copy classes"
- usebundle => _classes_copy("command_execution_${canonified_command_name}", "${class_prefix}"),
+ usebundle => _classes_copy("command_execution_${canonified_command_name}", "${old_class_prefix}"),
ifvarclass => "service_check_started_at_boot_${canonified_service_name}_not_ok";
+ "copy classes"
+ usebundle => _classes_copy("${class_prefix}_define_at_boot", "${class_prefix}"),
+ ifvarclass => "${class_prefix}_check_at_boot_not_ok";
+
any::
"report"
- usebundle => _logger("Ensure service ${service_name} is set at boot", "${class_prefix}"),
- ifvarclass => "${class_prefix}_reached";
+ usebundle => _logger("Ensure service ${service_name} is set at boot", "${old_class_prefix}"),
+ ifvarclass => "(!has_promiser_stack.${old_class_prefix}_reached)|(has_promiser_stack.${class_prefix}_reached)";
services:
windows::
"${service_name}"
service_policy => "start",
service_method => bootstart,
- classes => classes_generic("${class_prefix}");
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/service_ensure_stopped.cf b/tree/30_generic_methods/service_ensure_stopped.cf
index 791fa545a..ede06818f 100644
--- a/tree/30_generic_methods/service_ensure_stopped.cf
+++ b/tree/30_generic_methods/service_ensure_stopped.cf
@@ -31,7 +31,8 @@ bundle agent service_ensure_stopped(service_name)
"canonified_service_name" string => canonify("${service_name}");
- "class_prefix" string => "service_ensure_stopped_${canonified_service_name}";
+ "old_class_prefix" string => "service_ensure_stopped_${canonified_service_name}";
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
methods:
!windows::
@@ -42,31 +43,32 @@ bundle agent service_ensure_stopped(service_name)
# a success, so we have to stop the process
"stop if running"
usebundle => service_stop("${service_name}"),
- ifvarclass => "service_check_running_${canonified_service_name}_kept";
+ ifvarclass => "(!has_promiser_stack.service_check_running_${canonified_service_name}_kept)|(has_promiser_stack.${class_prefix}_check_running_kept)";
# If service_check_running has no detected any process, it will not result
# in a success so the result class of this promise should be the a success.
"create success class"
- usebundle => _classes_success("${class_prefix}"),
- ifvarclass => "!service_check_running_${canonified_service_name}_kept";
+ usebundle => _classes_success("${old_class_prefix}"),
+ ifvarclass => "(!has_promiser_stack.!service_check_running_${canonified_service_name}_kept)|(has_promiser_stack.!${class_prefix}_check_running_kept)";
# If service_check_running has detected a process, the process will be
# stopped and the result class should be the same as this promise.
"class copy if running"
- usebundle => _classes_copy("service_stop_${canonified_service_name}", "${class_prefix}"),
+ usebundle => _classes_copy("service_stop_${canonified_service_name}", "${old_class_prefix}"),
ifvarclass => "service_check_running_${canonified_service_name}_kept";
+ "class copy if running"
+ usebundle => _classes_copy("${class_prefix}_stop_if_running", "${class_prefix}"),
+ ifvarclass => "has_promiser_stack.${class_prefix}_check_running_kept";
+
any::
"report"
- usebundle => _logger("Ensure that service ${service_name} is stopped", "${class_prefix}"),
- ifvarclass =>"${class_prefix}_reached";
+ usebundle => _logger("Ensure that service ${service_name} is stopped", "${old_class_prefix}"),
+ ifvarclass =>"(!has_promiser_stack.${old_class_prefix}_reached)|(has_promiser_stack.!${class_prefix}_reached)";
services:
windows::
"${service_name}"
service_policy => "stop",
- classes => classes_generic("${class_prefix}");
-
-
-
+ classes => classes_generic_two("${old_class_prefix}", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/service_reload.cf b/tree/30_generic_methods/service_reload.cf
index d1fdc4cce..b7b8623f7 100644
--- a/tree/30_generic_methods/service_reload.cf
+++ b/tree/30_generic_methods/service_reload.cf
@@ -31,14 +31,16 @@ bundle agent service_reload(service_name)
"canonified_service_name" string => canonify("${service_name}");
- "class_prefix" string => "service_reload_${canonified_service_name}";
+ "old_class_prefix" string => "service_reload_${canonified_service_name}";
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
methods:
"reload" usebundle => service_action("${service_name}", "reload");
- "class copy" usebundle => _classes_copy("service_action_${canonified_service_name}", "${class_prefix}");
+ "class copy" usebundle => _classes_copy("service_action_${canonified_service_name}", "${old_class_prefix}");
- "report" usebundle => _logger("Reload service ${service_name}", "${class_prefix}");
+ "class copy" usebundle => _classes_copy("${class_prefix}_reload", "${class_prefix}");
+ "report" usebundle => _logger("Reload service ${service_name}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/service_restart.cf b/tree/30_generic_methods/service_restart.cf
index 19e516f79..93cee3386 100644
--- a/tree/30_generic_methods/service_restart.cf
+++ b/tree/30_generic_methods/service_restart.cf
@@ -27,8 +27,12 @@
bundle agent service_restart(service_name)
{
+ vars:
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
+
methods:
- "wrap" usebundle => service_restart_if("${service_name}","any");
+ "restart always" usebundle => service_restart_if("${service_name}","any");
+ "new result classes" usebundle => _classes_copy("${class_prefix}_restart_always", "${class_prefix}");
}
diff --git a/tree/30_generic_methods/service_restart_if.cf b/tree/30_generic_methods/service_restart_if.cf
index 9c54dd5b9..f5ff7ec93 100644
--- a/tree/30_generic_methods/service_restart_if.cf
+++ b/tree/30_generic_methods/service_restart_if.cf
@@ -24,6 +24,7 @@
#
# @class_prefix service_restart
# @class_parameter service_name
+# @deprecated Use a condition with service_restart instead
# This bundle will define a class service_restart_${canonified_service_name}_{kept,repaired,not_ok,ok,reached}
bundle agent service_restart_if(service_name, trigger_class)
@@ -32,19 +33,27 @@ bundle agent service_restart_if(service_name, trigger_class)
"canonified_service_name" string => canonify("${service_name}");
- "class_prefix" string => "service_restart_${canonified_service_name}";
+ "old_class_prefix" string => "service_restart_${canonified_service_name}";
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
methods:
# Create kept class
+ "success_class" usebundle => _classes_success("${old_class_prefix}"),
+ # parenthesis used to negate all the classes
+ ifvarclass => "!(${trigger_class})";
+
"success_class" usebundle => _classes_success("${class_prefix}"),
- # parenthesis used to negate all the class
+ # parenthesis used to negate all the classes
ifvarclass => "!(${trigger_class})";
- "restart" usebundle => service_action("${service_name}", "restart"),
+ "restart" usebundle => service_action("${service_name}", "restart"),
+ ifvarclass => "${trigger_class}";
+
+ "class copy" usebundle => _classes_copy("service_action_${canonified_service_name}", "${old_class_prefix}"),
ifvarclass => "${trigger_class}";
- "class copy" usebundle => _classes_copy("service_action_${canonified_service_name}", "${class_prefix}"),
+ "class copy" usebundle => _classes_copy("${class_prefix}_restart", "${class_prefix}"),
ifvarclass => "${trigger_class}";
"report" usebundle => _logger("Restart service ${canonified_service_name}", "service_restart_${canonified_service_name}");
diff --git a/tree/30_generic_methods/service_start.cf b/tree/30_generic_methods/service_start.cf
index c9bdd3a77..0865c0485 100644
--- a/tree/30_generic_methods/service_start.cf
+++ b/tree/30_generic_methods/service_start.cf
@@ -31,14 +31,17 @@ bundle agent service_start(service_name)
"canonified_service_name" string => canonify("${service_name}");
- "class_prefix" string => "service_start_${canonified_service_name}";
+ "old_class_prefix" string => "service_start_${canonified_service_name}";
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
methods:
"start" usebundle => service_action("${service_name}", "start");
- "class copy" usebundle => _classes_copy("service_action_${canonified_service_name}", "${class_prefix}");
+ "class copy" usebundle => _classes_copy("service_action_${canonified_service_name}", "${old_class_prefix}");
- "report" usebundle => _logger("Start service ${service_name}", "${class_prefix}");
+ "class copy" usebundle => _classes_copy("${class_prefix}_start", "${class_prefix}");
+
+ "report" usebundle => _logger("Start service ${service_name}", "${old_class_prefix}");
}
diff --git a/tree/30_generic_methods/service_stop.cf b/tree/30_generic_methods/service_stop.cf
index 2540a12cb..7f5ee04a7 100644
--- a/tree/30_generic_methods/service_stop.cf
+++ b/tree/30_generic_methods/service_stop.cf
@@ -31,14 +31,17 @@ bundle agent service_stop(service_name)
"canonified_service_name" string => canonify("${service_name}");
- "class_prefix" string => "service_stop_${canonified_service_name}";
+ "old_class_prefix" string => "service_stop_${canonified_service_name}";
+ "class_prefix" string => canonify(join("_", "this.callers_promisers"));
methods:
"stop" usebundle => service_action("${service_name}", "stop");
- "class copy" usebundle => _classes_copy("service_action_${canonified_service_name}", "${class_prefix}");
+ "class copy" usebundle => _classes_copy("service_action_${canonified_service_name}", "${old_class_prefix}");
- "report" usebundle => _logger("Stop service ${service_name}", "${class_prefix}");
+ "class copy" usebundle => _classes_copy("${class_prefix}_stop", "${class_prefix}");
+
+ "report" usebundle => _logger("Stop service ${service_name}", "${old_class_prefix}");
}