forked from ungleich-public/cdist
out_path -> base_path
Signed-off-by: Nico Schottelius <nico@bento.schottelius.org>
This commit is contained in:
parent
ffeaa3d06b
commit
2f5de23ae9
6 changed files with 39 additions and 35 deletions
|
@ -94,7 +94,7 @@ class Manifest(object):
|
||||||
self.env = {
|
self.env = {
|
||||||
'PATH': "%s:%s" % (self.local.bin_path, os.environ['PATH']),
|
'PATH': "%s:%s" % (self.local.bin_path, os.environ['PATH']),
|
||||||
'__cdist_type_base_path': self.local.type_path, # for use in type emulator
|
'__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,
|
'__target_host': self.target_host,
|
||||||
}
|
}
|
||||||
if self.log.getEffectiveLevel() == logging.DEBUG:
|
if self.log.getEffectiveLevel() == logging.DEBUG:
|
||||||
|
|
|
@ -28,6 +28,8 @@ import sys
|
||||||
import cdist
|
import cdist
|
||||||
from cdist import core
|
from cdist import core
|
||||||
|
|
||||||
|
class MissingEnvironmentVariable(cdist.Error):
|
||||||
|
|
||||||
class Emulator(object):
|
class Emulator(object):
|
||||||
def __init__(self, argv, stdin=sys.stdin.buffer, env=os.environ):
|
def __init__(self, argv, stdin=sys.stdin.buffer, env=os.environ):
|
||||||
self.argv = argv
|
self.argv = argv
|
||||||
|
@ -36,12 +38,15 @@ class Emulator(object):
|
||||||
|
|
||||||
self.object_id = ''
|
self.object_id = ''
|
||||||
|
|
||||||
self.global_path = self.env['__global']
|
try:
|
||||||
self.target_host = self.env['__target_host']
|
self.global_path = self.env['__global']
|
||||||
|
self.target_host = self.env['__target_host']
|
||||||
|
|
||||||
# Internally only
|
# Internally only
|
||||||
self.object_source = self.env['__cdist_manifest']
|
self.object_source = self.env['__cdist_manifest']
|
||||||
self.type_base_path = self.env['__cdist_type_base_path']
|
self.type_base_path = self.env['__cdist_type_base_path']
|
||||||
|
|
||||||
|
except KeyError:
|
||||||
|
|
||||||
self.object_base_path = os.path.join(self.global_path, "object")
|
self.object_base_path = os.path.join(self.global_path, "object")
|
||||||
|
|
||||||
|
|
|
@ -41,11 +41,11 @@ class CodeTestCase(test.CdistTestCase):
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.target_host = 'localhost'
|
self.target_host = 'localhost'
|
||||||
|
|
||||||
self.out_path = self.mkdtemp()
|
self.base_path = self.mkdtemp()
|
||||||
|
|
||||||
self.local = local.Local(
|
self.local = local.Local(
|
||||||
target_host=self.target_host,
|
target_host=self.target_host,
|
||||||
out_path = self.out_path,
|
base_path = self.base_path,
|
||||||
exec_path = cdist.test.cdist_exec_path,
|
exec_path = cdist.test.cdist_exec_path,
|
||||||
add_conf_dirs=[conf_dir])
|
add_conf_dirs=[conf_dir])
|
||||||
self.local.create_files_dirs()
|
self.local.create_files_dirs()
|
||||||
|
@ -63,7 +63,7 @@ class CodeTestCase(test.CdistTestCase):
|
||||||
self.cdist_object.create()
|
self.cdist_object.create()
|
||||||
|
|
||||||
def tearDown(self):
|
def tearDown(self):
|
||||||
shutil.rmtree(self.out_path)
|
shutil.rmtree(self.base_path)
|
||||||
shutil.rmtree(self.remote_base_path)
|
shutil.rmtree(self.remote_base_path)
|
||||||
|
|
||||||
def test_run_gencode_local_environment(self):
|
def test_run_gencode_local_environment(self):
|
||||||
|
@ -75,7 +75,7 @@ class CodeTestCase(test.CdistTestCase):
|
||||||
key = junk.split(' ')[1]
|
key = junk.split(' ')[1]
|
||||||
output_dict[key] = value
|
output_dict[key] = value
|
||||||
self.assertEqual(output_dict['__target_host'], self.local.target_host)
|
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['__type'], self.cdist_type.absolute_path)
|
||||||
self.assertEqual(output_dict['__object'], self.cdist_object.absolute_path)
|
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_id'], self.cdist_object.object_id)
|
||||||
|
@ -90,7 +90,7 @@ class CodeTestCase(test.CdistTestCase):
|
||||||
key = junk.split(' ')[1]
|
key = junk.split(' ')[1]
|
||||||
output_dict[key] = value
|
output_dict[key] = value
|
||||||
self.assertEqual(output_dict['__target_host'], self.local.target_host)
|
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['__type'], self.cdist_type.absolute_path)
|
||||||
self.assertEqual(output_dict['__object'], self.cdist_object.absolute_path)
|
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_id'], self.cdist_object.object_id)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 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.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -33,7 +33,6 @@ from cdist.exec import local
|
||||||
from cdist import emulator
|
from cdist import emulator
|
||||||
from cdist import core
|
from cdist import core
|
||||||
from cdist import config
|
from cdist import config
|
||||||
import cdist.context
|
|
||||||
|
|
||||||
import os.path as op
|
import os.path as op
|
||||||
my_dir = op.abspath(op.dirname(__file__))
|
my_dir = op.abspath(op.dirname(__file__))
|
||||||
|
@ -46,11 +45,11 @@ class EmulatorTestCase(test.CdistTestCase):
|
||||||
self.temp_dir = self.mkdtemp()
|
self.temp_dir = self.mkdtemp()
|
||||||
handle, self.script = self.mkstemp(dir=self.temp_dir)
|
handle, self.script = self.mkstemp(dir=self.temp_dir)
|
||||||
os.close(handle)
|
os.close(handle)
|
||||||
out_path = self.temp_dir
|
base_path = self.temp_dir
|
||||||
|
|
||||||
self.local = local.Local(
|
self.local = local.Local(
|
||||||
target_host=self.target_host,
|
target_host=self.target_host,
|
||||||
out_path=out_path,
|
base_path=base_path,
|
||||||
exec_path=test.cdist_exec_path,
|
exec_path=test.cdist_exec_path,
|
||||||
add_conf_dirs=[conf_dir])
|
add_conf_dirs=[conf_dir])
|
||||||
self.local.create_files_dirs()
|
self.local.create_files_dirs()
|
||||||
|
@ -108,11 +107,11 @@ class AutoRequireEmulatorTestCase(test.CdistTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.temp_dir = self.mkdtemp()
|
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(
|
self.local = local.Local(
|
||||||
target_host=self.target_host,
|
target_host=self.target_host,
|
||||||
out_path=out_path,
|
base_path=base_path,
|
||||||
exec_path=test.cdist_exec_path,
|
exec_path=test.cdist_exec_path,
|
||||||
add_conf_dirs=[conf_dir])
|
add_conf_dirs=[conf_dir])
|
||||||
self.local.create_files_dirs()
|
self.local.create_files_dirs()
|
||||||
|
@ -135,13 +134,13 @@ class ArgumentsTestCase(test.CdistTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.temp_dir = self.mkdtemp()
|
self.temp_dir = self.mkdtemp()
|
||||||
out_path = self.temp_dir
|
base_path = self.temp_dir
|
||||||
handle, self.script = self.mkstemp(dir=self.temp_dir)
|
handle, self.script = self.mkstemp(dir=self.temp_dir)
|
||||||
os.close(handle)
|
os.close(handle)
|
||||||
|
|
||||||
self.local = local.Local(
|
self.local = local.Local(
|
||||||
target_host=self.target_host,
|
target_host=self.target_host,
|
||||||
out_path=out_path,
|
base_path=base_path,
|
||||||
exec_path=test.cdist_exec_path,
|
exec_path=test.cdist_exec_path,
|
||||||
add_conf_dirs=[conf_dir])
|
add_conf_dirs=[conf_dir])
|
||||||
self.local.create_files_dirs()
|
self.local.create_files_dirs()
|
||||||
|
@ -183,6 +182,7 @@ class ArgumentsTestCase(test.CdistTestCase):
|
||||||
object_id = 'some-id'
|
object_id = 'some-id'
|
||||||
value = 'some value'
|
value = 'some value'
|
||||||
argv = [type_name, object_id, '--required1', value, '--required2', value]
|
argv = [type_name, object_id, '--required1', value, '--required2', value]
|
||||||
|
print(self.env)
|
||||||
os.environ.update(self.env)
|
os.environ.update(self.env)
|
||||||
emu = emulator.Emulator(argv)
|
emu = emulator.Emulator(argv)
|
||||||
emu.run()
|
emu.run()
|
||||||
|
@ -227,11 +227,11 @@ class StdinTestCase(test.CdistTestCase):
|
||||||
os.environ = os.environ.copy()
|
os.environ = os.environ.copy()
|
||||||
|
|
||||||
self.temp_dir = self.mkdtemp()
|
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(
|
self.local = local.Local(
|
||||||
target_host=self.target_host,
|
target_host=self.target_host,
|
||||||
out_path=out_path,
|
base_path=base_path,
|
||||||
exec_path=test.cdist_exec_path,
|
exec_path=test.cdist_exec_path,
|
||||||
add_conf_dirs=[conf_dir])
|
add_conf_dirs=[conf_dir])
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# 2010-2011 Steven Armstrong (steven-cdist at armstrong.cc)
|
# 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.
|
# This file is part of cdist.
|
||||||
#
|
#
|
||||||
|
@ -39,26 +39,25 @@ conf_dir = op.join(fixtures, "conf")
|
||||||
class ExplorerClassTestCase(test.CdistTestCase):
|
class ExplorerClassTestCase(test.CdistTestCase):
|
||||||
|
|
||||||
def setUp(self):
|
def setUp(self):
|
||||||
self.target_host = 'localhost'
|
|
||||||
|
|
||||||
self.temp_dir = self.mkdtemp()
|
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")
|
self.remote_base_path = os.path.join(self.temp_dir, "remote")
|
||||||
os.makedirs(self.remote_base_path)
|
os.makedirs(self.remote_base_path)
|
||||||
|
|
||||||
self.local = local.Local(
|
self.local = local.Local(
|
||||||
target_host=self.target_host,
|
target_host=self.target_host,
|
||||||
out_path=self.out_path,
|
base_path=self.local_path,
|
||||||
exec_path=test.cdist_exec_path,
|
exec_path=test.cdist_exec_path,
|
||||||
add_conf_dirs=[conf_dir])
|
add_conf_dirs=[conf_dir],
|
||||||
|
)
|
||||||
|
|
||||||
self.local.create_files_dirs()
|
self.local.create_files_dirs()
|
||||||
|
|
||||||
self.remote = remote.Remote(
|
self.remote = remote.Remote(
|
||||||
self.target_host,
|
target_host=self.target_host,
|
||||||
self.remote_base_path,
|
remote_exec=self.remote_exec,
|
||||||
self.remote_exec,
|
remote_copy=self.remote_copy,
|
||||||
self.remote_copy)
|
base_path=self.remote_base_path)
|
||||||
self.remote.create_files_dirs()
|
self.remote.create_files_dirs()
|
||||||
|
|
||||||
self.explorer = explorer.Explorer(
|
self.explorer = explorer.Explorer(
|
||||||
|
|
|
@ -46,11 +46,11 @@ class ManifestTestCase(test.CdistTestCase):
|
||||||
self.orig_environ = os.environ
|
self.orig_environ = os.environ
|
||||||
os.environ = os.environ.copy()
|
os.environ = os.environ.copy()
|
||||||
self.temp_dir = self.mkdtemp()
|
self.temp_dir = self.mkdtemp()
|
||||||
self.target_host = 'localhost'
|
|
||||||
out_path = self.temp_dir
|
out_path = self.temp_dir
|
||||||
self.local = local.Local(
|
self.local = local.Local(
|
||||||
target_host=self.target_host,
|
target_host=self.target_host,
|
||||||
out_path=out_path,
|
base_path=out_path,
|
||||||
exec_path = cdist.test.cdist_exec_path,
|
exec_path = cdist.test.cdist_exec_path,
|
||||||
add_conf_dirs=[conf_dir])
|
add_conf_dirs=[conf_dir])
|
||||||
self.local.create_files_dirs()
|
self.local.create_files_dirs()
|
||||||
|
@ -78,7 +78,7 @@ class ManifestTestCase(test.CdistTestCase):
|
||||||
output_dict[key] = value
|
output_dict[key] = value
|
||||||
self.assertTrue(output_dict['PATH'].startswith(self.local.bin_path))
|
self.assertTrue(output_dict['PATH'].startswith(self.local.bin_path))
|
||||||
self.assertEqual(output_dict['__target_host'], self.local.target_host)
|
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['__cdist_type_base_path'], self.local.type_path)
|
||||||
self.assertEqual(output_dict['__manifest'], self.local.manifest_path)
|
self.assertEqual(output_dict['__manifest'], self.local.manifest_path)
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ class ManifestTestCase(test.CdistTestCase):
|
||||||
output_dict[key] = value
|
output_dict[key] = value
|
||||||
self.assertTrue(output_dict['PATH'].startswith(self.local.bin_path))
|
self.assertTrue(output_dict['PATH'].startswith(self.local.bin_path))
|
||||||
self.assertEqual(output_dict['__target_host'], self.local.target_host)
|
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['__cdist_type_base_path'], self.local.type_path)
|
||||||
self.assertEqual(output_dict['__type'], cdist_type.absolute_path)
|
self.assertEqual(output_dict['__type'], cdist_type.absolute_path)
|
||||||
self.assertEqual(output_dict['__object'], cdist_object.absolute_path)
|
self.assertEqual(output_dict['__object'], cdist_object.absolute_path)
|
||||||
|
|
Loading…
Reference in a new issue