From 0049b62cca56929ab2ab2feca3b22b24fa9cbdb1 Mon Sep 17 00:00:00 2001 From: Darko Poljak Date: Sat, 11 Jun 2016 12:02:13 +0200 Subject: [PATCH] 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)