Add derived env vars for target hostname and fqdn.

This commit is contained in:
Darko Poljak 2016-08-10 23:56:56 +02:00
commit dbcc94ab65
23 changed files with 181 additions and 59 deletions

View file

@ -41,7 +41,7 @@ class CodeTestCase(test.CdistTestCase):
def setUp(self):
self.local_dir = self.mkdtemp()
self.hostdir = cdist.str_hash(self.target_host)
self.hostdir = cdist.str_hash(self.target_host[0])
self.host_base_path = os.path.join(self.local_dir, self.hostdir)
self.local = local.Local(
@ -83,7 +83,12 @@ class CodeTestCase(test.CdistTestCase):
junk, value = line.split(': ')
key = junk.split(' ')[1]
output_dict[key] = value
self.assertEqual(output_dict['__target_host'], self.local.target_host)
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['__global'], self.local.base_path)
self.assertEqual(output_dict['__type'], self.cdist_type.absolute_path)
self.assertEqual(output_dict['__object'],
@ -101,7 +106,12 @@ class CodeTestCase(test.CdistTestCase):
junk, value = line.split(': ')
key = junk.split(' ')[1]
output_dict[key] = value
self.assertEqual(output_dict['__target_host'], self.local.target_host)
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['__global'], self.local.base_path)
self.assertEqual(output_dict['__type'], self.cdist_type.absolute_path)
self.assertEqual(output_dict['__object'],

View file

@ -1,6 +1,8 @@
#!/bin/sh
echo "echo __target_host: $__target_host"
echo "echo __target_hostname: $__target_hostname"
echo "echo __target_fqdn: $__target_fqdn"
echo "echo __global: $__global"
echo "echo __type: $__type"
echo "echo __object: $__object"