Add files conf subdirectory for static files.
This commit is contained in:
		
					parent
					
						
							
								e3636e6ffc
							
						
					
				
			
			
				commit
				
					
						0049b62cca
					
				
			
		
					 9 changed files with 26 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -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):
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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" })
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,4 +6,5 @@ __target_host: $__target_host
 | 
			
		|||
__global: $__global
 | 
			
		||||
__cdist_type_base_path: $__cdist_type_base_path
 | 
			
		||||
__manifest: $__manifest
 | 
			
		||||
__files: $__files
 | 
			
		||||
DONE
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -10,4 +10,5 @@ __self: $__self
 | 
			
		|||
__object: $__object
 | 
			
		||||
__object_id: $__object_id
 | 
			
		||||
__object_name: $__object_name
 | 
			
		||||
__files: $__files
 | 
			
		||||
DONE
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue