Add -l/--log-level option. Honor __cdist_loglevel env var. (#572)

Add -l/--log-level option, __cdist_loglevel -> __cdist_log_level; honor __cdist_log_level env var
This commit is contained in:
Darko Poljak 2017-09-09 21:17:29 +02:00 • committed by GitHub
commit 3454da076f
23 changed files with 152 additions and 69 deletions

View file

@ -210,6 +210,31 @@ class ExplorerClassTestCase(test.CdistTestCase):
self.assertEqual(names, output)
shutil.rmtree(out_path)
def test_explorer_environment(self):
cdist_type = core.CdistType(self.local.type_path, '__dump_env')
cdist_object = core.CdistObject(cdist_type, self.local.object_path,
self.local.object_marker_name,
'whatever')
self.explorer.transfer_type_explorers(cdist_type)
output = self.explorer.run_type_explorer('dump', cdist_object)
output_dict = {}
for line in output.split('\n'):
if line:
key, value = line.split(': ')
output_dict[key] = value
self.assertEqual(output_dict['__target_host'],
self.local.target_host[0])
self.assertEqual(output_dict['__target_hostname'],
self.local.target_host[1])
self.assertEqual(output_dict['__target_fqdn'],
self.local.target_host[2])
self.assertEqual(output_dict['__explorer'],
self.remote.global_explorer_path)
self.assertEqual(output_dict['__target_host_tags'],
self.local.target_host_tags)
self.assertEqual(output_dict['__cdist_log_level'], 'WARNING')
if __name__ == '__main__':
import unittest

View file

@ -0,0 +1,8 @@
#!/bin/sh
echo "__target_host: $__target_host"
echo "__target_hostname: $__target_hostname"
echo "__target_fqdn: $__target_fqdn"
echo "__explorer: $__explorer"
echo "__target_host_tags: $__target_host_tags"
echo "__cdist_log_level: $__cdist_log_level"