From c818442ef2d3363175f8ba960eaf43b121264165 Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Sat, 12 Apr 2014 19:40:41 +0200 Subject: [PATCH 1/4] also linke "files" subdir Signed-off-by: Nico Schottelius --- cdist/exec/local.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cdist/exec/local.py b/cdist/exec/local.py index 2f75ffd4..6b0ad9b5 100644 --- a/cdist/exec/local.py +++ b/cdist/exec/local.py @@ -33,6 +33,8 @@ import cdist import cdist.message from cdist import core +CONF_SUBDIRS_LINKED = [ "explorer", "files", "manifest", "type" ]: + class Local(object): """Execute commands locally. @@ -216,14 +218,14 @@ class Local(object): pass def _create_conf_path_and_link_conf_dirs(self): - # Link destination directories - for sub_dir in [ "explorer", "manifest", "type" ]: + # Create destination directories + for sub_dir in CONF_SUBDIRS_LINKED: self.mkdir(os.path.join(self.conf_path, sub_dir)) # Iterate over all directories and link the to the output dir for conf_dir in self.conf_dirs: self.log.debug("Checking conf_dir %s ..." % (conf_dir)) - for sub_dir in [ "explorer", "manifest", "type" ]: + for sub_dir in CONF_SUBDIRS_LINKED: current_dir = os.path.join(conf_dir, sub_dir) # Allow conf dirs to contain only partial content From aa8c5555b78591a48bccdd696389105bdac03e9a Mon Sep 17 00:00:00 2001 From: Nico Schottelius Date: Mon, 14 Apr 2014 09:46:52 +0200 Subject: [PATCH 2/4] document __files Signed-off-by: Nico Schottelius --- docs/man/cdist-reference.text.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/docs/man/cdist-reference.text.sh b/docs/man/cdist-reference.text.sh index 7081e762..c6e5053f 100755 --- a/docs/man/cdist-reference.text.sh +++ b/docs/man/cdist-reference.text.sh @@ -75,6 +75,10 @@ confdir:: By default it consists of everything in \$HOME/.cdist and cdist/conf/. For more details see cdist(1) +confdir/files/:: + Cdist does not care about this directory besides providing access to it. + It is thought to be a general file storage area. + confdir/manifest/init:: This is the central entry point. It is an executable (+x bit set) shell script that can use @@ -196,6 +200,10 @@ The following environment variables are exported by cdist: __explorer:: Directory that contains all global explorers. Available for: initial manifest, explorer, type explorer, shell +__files:: + Directory that contains content from the "files" subdirectories + from the configuration directories. + Available for: initial manifest, type manifest, type gencode, shell __manifest:: Directory that contains the initial manifest. Available for: initial manifest, type manifest, shell From 0049b62cca56929ab2ab2feca3b22b24fa9cbdb1 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 11 Jun 2016 12:02:13 +0200 Subject: [PATCH 3/4] Add files conf subdirectory for static files. --- cdist/core/code.py | 3 +++ cdist/core/manifest.py | 2 ++ cdist/exec/local.py | 3 ++- cdist/test/code/__init__.py | 6 ++++++ .../fixtures/conf/type/__dump_environment/gencode-local | 1 + cdist/test/manifest/__init__.py | 7 +++++++ .../test/manifest/fixtures/conf/manifest/dump_environment | 1 + .../fixtures/conf/type/__dump_environment/manifest | 1 + docs/changelog | 3 +++ 9 files changed, 26 insertions(+), 1 deletion(-) diff --git a/cdist/core/code.py b/cdist/core/code.py index 5374bcdf..64517532 100644 --- a/cdist/core/code.py +++ b/cdist/core/code.py @@ -50,6 +50,7 @@ gencode-local __object_id: the objects id __object_fq: full qualified object id, iow: $type.name + / + object_id __type: full qualified path to the type's dir + __files: full qualified path to the files dir returns: string containing the generated code or None @@ -63,6 +64,7 @@ gencode-remote __object_id: the objects id __object_fq: full qualified object id, iow: $type.name + / + object_id __type: full qualified path to the type's dir + __files: full qualified path to the files dir returns: string containing the generated code or None @@ -91,6 +93,7 @@ class Code(object): self.env = { '__target_host': self.target_host, '__global': self.local.base_path, + '__files': self.local.files_path, } def _run_gencode(self, cdist_object, which): diff --git a/cdist/core/manifest.py b/cdist/core/manifest.py index 240e57a1..3b71a215 100644 --- a/cdist/core/manifest.py +++ b/cdist/core/manifest.py @@ -36,6 +36,7 @@ common: __cdist_manifest: full qualified path of the manifest == script __cdist_type_base_path: full qualified path to the directory where types are defined for use in type emulator == local.type_path + __files: full qualified path to the files dir initial manifest is: script: full qualified path to the initial manifest @@ -96,6 +97,7 @@ class Manifest(object): '__cdist_type_base_path': self.local.type_path, # for use in type emulator '__global': self.local.base_path, '__target_host': self.target_host, + '__files': self.local.files_path, } if self.log.getEffectiveLevel() == logging.DEBUG: self.env.update({'__cdist_debug': "yes" }) diff --git a/cdist/exec/local.py b/cdist/exec/local.py index fa003cb0..6f4bd239 100644 --- a/cdist/exec/local.py +++ b/cdist/exec/local.py @@ -34,7 +34,7 @@ import cdist import cdist.message from cdist import core -CONF_SUBDIRS_LINKED = [ "explorer", "files", "manifest", "type" ]: +CONF_SUBDIRS_LINKED = [ "explorer", "files", "manifest", "type" ] class Local(object): """Execute commands locally. @@ -111,6 +111,7 @@ class Local(object): self.global_explorer_out_path = os.path.join(self.base_path, "explorer") self.object_path = os.path.join(self.base_path, "object") self.messages_path = os.path.join(self.base_path, "messages") + self.files_path = os.path.join(self.conf_path, "files") # Depending on conf_path self.global_explorer_path = os.path.join(self.conf_path, "explorer") diff --git a/cdist/test/code/__init__.py b/cdist/test/code/__init__.py index 689fcff6..811d3a33 100644 --- a/cdist/test/code/__init__.py +++ b/cdist/test/code/__init__.py @@ -82,6 +82,7 @@ class CodeTestCase(test.CdistTestCase): self.assertEqual(output_dict['__object'], self.cdist_object.absolute_path) self.assertEqual(output_dict['__object_id'], self.cdist_object.object_id) self.assertEqual(output_dict['__object_name'], self.cdist_object.name) + self.assertEqual(output_dict['__files'], self.local.files_path) def test_run_gencode_remote_environment(self): output_string = self.code.run_gencode_remote(self.cdist_object) @@ -97,6 +98,7 @@ class CodeTestCase(test.CdistTestCase): self.assertEqual(output_dict['__object'], self.cdist_object.absolute_path) self.assertEqual(output_dict['__object_id'], self.cdist_object.object_id) self.assertEqual(output_dict['__object_name'], self.cdist_object.name) + self.assertEqual(output_dict['__files'], self.local.files_path) def test_transfer_code_remote(self): self.cdist_object.code_remote = self.code.run_gencode_remote(self.cdist_object) @@ -112,3 +114,7 @@ class CodeTestCase(test.CdistTestCase): self.cdist_object.code_remote = self.code.run_gencode_remote(self.cdist_object) self.code.transfer_code_remote(self.cdist_object) self.code.run_code_remote(self.cdist_object) + +if __name__ == '__main__': + import unittest + unittest.main() diff --git a/cdist/test/code/fixtures/conf/type/__dump_environment/gencode-local b/cdist/test/code/fixtures/conf/type/__dump_environment/gencode-local index 771894fb..5883c268 100755 --- a/cdist/test/code/fixtures/conf/type/__dump_environment/gencode-local +++ b/cdist/test/code/fixtures/conf/type/__dump_environment/gencode-local @@ -6,3 +6,4 @@ echo "echo __type: $__type" echo "echo __object: $__object" echo "echo __object_id: $__object_id" echo "echo __object_name: $__object_name" +echo "echo __files: $__files" diff --git a/cdist/test/manifest/__init__.py b/cdist/test/manifest/__init__.py index cc60c844..f9eb8b8a 100644 --- a/cdist/test/manifest/__init__.py +++ b/cdist/test/manifest/__init__.py @@ -81,6 +81,7 @@ class ManifestTestCase(test.CdistTestCase): self.assertEqual(output_dict['__global'], self.local.base_path) self.assertEqual(output_dict['__cdist_type_base_path'], self.local.type_path) self.assertEqual(output_dict['__manifest'], self.local.manifest_path) + self.assertEqual(output_dict['__files'], self.local.files_path) def test_type_manifest_environment(self): cdist_type = core.CdistType(self.local.type_path, '__dump_environment') @@ -105,6 +106,7 @@ class ManifestTestCase(test.CdistTestCase): self.assertEqual(output_dict['__object'], cdist_object.absolute_path) self.assertEqual(output_dict['__object_id'], cdist_object.object_id) self.assertEqual(output_dict['__object_name'], cdist_object.name) + self.assertEqual(output_dict['__files'], self.local.files_path) def test_debug_env_setup(self): current_level = self.log.getEffectiveLevel() @@ -112,3 +114,8 @@ class ManifestTestCase(test.CdistTestCase): manifest = cdist.core.manifest.Manifest(self.target_host, self.local) self.assertTrue("__cdist_debug" in manifest.env) self.log.setLevel(current_level) + + +if __name__ == '__main__': + import unittest + unittest.main() diff --git a/cdist/test/manifest/fixtures/conf/manifest/dump_environment b/cdist/test/manifest/fixtures/conf/manifest/dump_environment index 7ce983ab..df901910 100755 --- a/cdist/test/manifest/fixtures/conf/manifest/dump_environment +++ b/cdist/test/manifest/fixtures/conf/manifest/dump_environment @@ -6,4 +6,5 @@ __target_host: $__target_host __global: $__global __cdist_type_base_path: $__cdist_type_base_path __manifest: $__manifest +__files: $__files DONE diff --git a/cdist/test/manifest/fixtures/conf/type/__dump_environment/manifest b/cdist/test/manifest/fixtures/conf/type/__dump_environment/manifest index e135de35..13efe038 100755 --- a/cdist/test/manifest/fixtures/conf/type/__dump_environment/manifest +++ b/cdist/test/manifest/fixtures/conf/type/__dump_environment/manifest @@ -10,4 +10,5 @@ __self: $__self __object: $__object __object_id: $__object_id __object_name: $__object_name +__files: $__files DONE diff --git a/docs/changelog b/docs/changelog index dada1d90..ca567627 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,6 +1,9 @@ Changelog --------- +next: + * Core: Add files directory for static files (Darko Poljak) + 4.1.0: 2016-05-27 * Documentation: Migrate to reStructuredText format and sphinx (Darko Poljak) * Core: Add -f option to read additional hosts from file/stdin (Darko Poljak) From d7583e7a1a33763df579e5ef0294b4f42616e52e Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sun, 12 Jun 2016 17:55:29 +0200 Subject: [PATCH 4/4] Add __files to shell env. --- cdist/shell.py | 1 + 1 file changed, 1 insertion(+) diff --git a/cdist/shell.py b/cdist/shell.py index d0921bc9..83b2acf7 100644 --- a/cdist/shell.py +++ b/cdist/shell.py @@ -60,6 +60,7 @@ class Shell(object): '__target_host': self.target_host, '__manifest': self.local.manifest_path, '__explorer': self.local.global_explorer_path, + '__files': self.local.files_path, } self.env.update(additional_env)