out_path -> base_path

Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
Nico Schottelius 2013-08-19 12:03:25 +02:00
parent ffeaa3d06b
commit 2f5de23ae9
6 changed files with 39 additions and 35 deletions

View file

@ -94,7 +94,7 @@ class Manifest(object):
self.env = {
'PATH': "%s:%s" % (self.local.bin_path, os.environ['PATH']),
'__cdist_type_base_path': self.local.type_path, # for use in type emulator
'__global': self.local.out_path,
'__global': self.local.base_path,
'__target_host': self.target_host,
}
if self.log.getEffectiveLevel() == logging.DEBUG:

View file

@ -28,6 +28,8 @@ import sys
import cdist
from cdist import core
class MissingEnvironmentVariable(cdist.Error):
class Emulator(object):
def __init__(self, argv, stdin=sys.stdin.buffer, env=os.environ):
self.argv = argv
@ -36,6 +38,7 @@ class Emulator(object):
self.object_id = ''
try:
self.global_path = self.env['__global']
self.target_host = self.env['__target_host']
@ -43,6 +46,8 @@ class Emulator(object):
self.object_source = self.env['__cdist_manifest']
self.type_base_path = self.env['__cdist_type_base_path']
except KeyError:
self.object_base_path = os.path.join(self.global_path, "object")
self.type_name = os.path.basename(argv[0])

View file

@ -41,11 +41,11 @@ class CodeTestCase(test.CdistTestCase):
def setUp(self):
self.target_host = 'localhost'
self.out_path = self.mkdtemp()
self.base_path = self.mkdtemp()
self.local = local.Local(
target_host=self.target_host,
out_path = self.out_path,
base_path = self.base_path,
exec_path = cdist.test.cdist_exec_path,
add_conf_dirs=[conf_dir])
self.local.create_files_dirs()
@ -63,7 +63,7 @@ class CodeTestCase(test.CdistTestCase):
self.cdist_object.create()
def tearDown(self):
shutil.rmtree(self.out_path)
shutil.rmtree(self.base_path)
shutil.rmtree(self.remote_base_path)
def test_run_gencode_local_environment(self):
@ -75,7 +75,7 @@ class CodeTestCase(test.CdistTestCase):
key = junk.split(' ')[1]
output_dict[key] = value
self.assertEqual(output_dict['__target_host'], self.local.target_host)
self.assertEqual(output_dict['__global'], self.local.out_path)
self.assertEqual(output_dict['__global'], self.local.base_path)
self.assertEqual(output_dict['__type'], self.cdist_type.absolute_path)
self.assertEqual(output_dict['__object'], self.cdist_object.absolute_path)
self.assertEqual(output_dict['__object_id'], self.cdist_object.object_id)
@ -90,7 +90,7 @@ class CodeTestCase(test.CdistTestCase):
key = junk.split(' ')[1]
output_dict[key] = value
self.assertEqual(output_dict['__target_host'], self.local.target_host)
self.assertEqual(output_dict['__global'], self.local.out_path)
self.assertEqual(output_dict['__global'], self.local.base_path)
self.assertEqual(output_dict['__type'], self.cdist_type.absolute_path)
self.assertEqual(output_dict['__object'], self.cdist_object.absolute_path)
self.assertEqual(output_dict['__object_id'], self.cdist_object.object_id)

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
# 2012 Nico Schottelius (nico-cdist at schottelius.org)
# 2012-2013 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@ -33,7 +33,6 @@ from cdist.exec import local
from cdist import emulator
from cdist import core
from cdist import config
import cdist.context
import os.path as op
my_dir = op.abspath(op.dirname(__file__))
@ -46,11 +45,11 @@ class EmulatorTestCase(test.CdistTestCase):
self.temp_dir = self.mkdtemp()
handle, self.script = self.mkstemp(dir=self.temp_dir)
os.close(handle)
out_path = self.temp_dir
base_path = self.temp_dir
self.local = local.Local(
target_host=self.target_host,
out_path=out_path,
base_path=base_path,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir])
self.local.create_files_dirs()
@ -108,11 +107,11 @@ class AutoRequireEmulatorTestCase(test.CdistTestCase):
def setUp(self):
self.temp_dir = self.mkdtemp()
out_path = os.path.join(self.temp_dir, "out")
base_path = os.path.join(self.temp_dir, "out")
self.local = local.Local(
target_host=self.target_host,
out_path=out_path,
base_path=base_path,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir])
self.local.create_files_dirs()
@ -135,13 +134,13 @@ class ArgumentsTestCase(test.CdistTestCase):
def setUp(self):
self.temp_dir = self.mkdtemp()
out_path = self.temp_dir
base_path = self.temp_dir
handle, self.script = self.mkstemp(dir=self.temp_dir)
os.close(handle)
self.local = local.Local(
target_host=self.target_host,
out_path=out_path,
base_path=base_path,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir])
self.local.create_files_dirs()
@ -183,6 +182,7 @@ class ArgumentsTestCase(test.CdistTestCase):
object_id = 'some-id'
value = 'some value'
argv = [type_name, object_id, '--required1', value, '--required2', value]
print(self.env)
os.environ.update(self.env)
emu = emulator.Emulator(argv)
emu.run()
@ -227,11 +227,11 @@ class StdinTestCase(test.CdistTestCase):
os.environ = os.environ.copy()
self.temp_dir = self.mkdtemp()
out_path = os.path.join(self.temp_dir, "out")
base_path = os.path.join(self.temp_dir, "out")
self.local = local.Local(
target_host=self.target_host,
out_path=out_path,
base_path=base_path,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir])

View file

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
# 2011-2012 Nico Schottelius (nico-cdist at schottelius.org)
# 2011-2013 Nico Schottelius (nico-cdist at schottelius.org)
#
# This file is part of cdist.
#
@ -39,26 +39,25 @@ conf_dir = op.join(fixtures, "conf")
class ExplorerClassTestCase(test.CdistTestCase):
def setUp(self):
self.target_host = 'localhost'
self.temp_dir = self.mkdtemp()
self.out_path = os.path.join(self.temp_dir, "out")
self.local_path = os.path.join(self.temp_dir, "local")
self.remote_base_path = os.path.join(self.temp_dir, "remote")
os.makedirs(self.remote_base_path)
self.local = local.Local(
target_host=self.target_host,
out_path=self.out_path,
base_path=self.local_path,
exec_path=test.cdist_exec_path,
add_conf_dirs=[conf_dir])
add_conf_dirs=[conf_dir],
)
self.local.create_files_dirs()
self.remote = remote.Remote(
self.target_host,
self.remote_base_path,
self.remote_exec,
self.remote_copy)
target_host=self.target_host,
remote_exec=self.remote_exec,
remote_copy=self.remote_copy,
base_path=self.remote_base_path)
self.remote.create_files_dirs()
self.explorer = explorer.Explorer(

View file

@ -46,11 +46,11 @@ class ManifestTestCase(test.CdistTestCase):
self.orig_environ = os.environ
os.environ = os.environ.copy()
self.temp_dir = self.mkdtemp()
self.target_host = 'localhost'
out_path = self.temp_dir
self.local = local.Local(
target_host=self.target_host,
out_path=out_path,
base_path=out_path,
exec_path = cdist.test.cdist_exec_path,
add_conf_dirs=[conf_dir])
self.local.create_files_dirs()
@ -78,7 +78,7 @@ class ManifestTestCase(test.CdistTestCase):
output_dict[key] = value
self.assertTrue(output_dict['PATH'].startswith(self.local.bin_path))
self.assertEqual(output_dict['__target_host'], self.local.target_host)
self.assertEqual(output_dict['__global'], self.local.out_path)
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)
@ -99,7 +99,7 @@ class ManifestTestCase(test.CdistTestCase):
output_dict[key] = value
self.assertTrue(output_dict['PATH'].startswith(self.local.bin_path))
self.assertEqual(output_dict['__target_host'], self.local.target_host)
self.assertEqual(output_dict['__global'], self.local.out_path)
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['__type'], cdist_type.absolute_path)
self.assertEqual(output_dict['__object'], cdist_object.absolute_path)