Merge branch 'enhance_cache'
Signed-off-by: Nico Schottelius <nico@bento.schottelius.org> Conflicts: cdist/test/code/__init__.py cdist/test/config_install/__init__.py cdist/test/explorer/__init__.py
This commit is contained in:
commit
e6feee14fb
12 changed files with 87 additions and 67 deletions
|
|
@ -1,7 +1,7 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
|
|
@ -41,18 +41,18 @@ class Local(object):
|
|||
"""
|
||||
def __init__(self,
|
||||
target_host,
|
||||
exec_path,
|
||||
exec_path=sys.argv[0],
|
||||
initial_manifest=None,
|
||||
out_path=None,
|
||||
base_path=None,
|
||||
add_conf_dirs=None):
|
||||
|
||||
self.target_host = target_host
|
||||
|
||||
# FIXME: stopped: create base that does not require moving later
|
||||
if out_path:
|
||||
self.out_path = out_path
|
||||
if base_path:
|
||||
self.base_path = base_path
|
||||
else:
|
||||
self.out_path = tempfile.mkdtemp()
|
||||
self.base_path = tempfile.mkdtemp()
|
||||
|
||||
# FIXME: as well
|
||||
self._init_cache_dir(None)
|
||||
|
|
@ -88,10 +88,10 @@ class Local(object):
|
|||
|
||||
def _init_paths(self):
|
||||
# Depending on out_path
|
||||
self.bin_path = os.path.join(self.out_path, "bin")
|
||||
self.conf_path = os.path.join(self.out_path, "conf")
|
||||
self.global_explorer_out_path = os.path.join(self.out_path, "explorer")
|
||||
self.object_path = os.path.join(self.out_path, "object")
|
||||
self.bin_path = os.path.join(self.base_path, "bin")
|
||||
self.conf_path = os.path.join(self.base_path, "conf")
|
||||
self.global_explorer_out_path = os.path.join(self.base_path, "explorer")
|
||||
self.object_path = os.path.join(self.base_path, "object")
|
||||
|
||||
# Depending on conf_path
|
||||
self.global_explorer_path = os.path.join(self.conf_path, "explorer")
|
||||
|
|
@ -185,10 +185,10 @@ class Local(object):
|
|||
|
||||
def save_cache(self):
|
||||
destination = os.path.join(self.cache_path, self.target_host)
|
||||
self.log.debug("Saving " + self.out_path + " to " + destination)
|
||||
self.log.debug("Saving " + self.base_path + " to " + destination)
|
||||
if os.path.exists(destination):
|
||||
shutil.rmtree(destination)
|
||||
shutil.move(self.out_path, destination)
|
||||
shutil.move(self.base_path, destination)
|
||||
|
||||
def _create_conf_path_and_link_conf_dirs(self):
|
||||
# Link destination directories
|
||||
|
|
|
|||
|
|
@ -43,12 +43,20 @@ class Remote(object):
|
|||
Directly accessing the remote side from python code is a bug.
|
||||
|
||||
"""
|
||||
def __init__(self, target_host, remote_exec, remote_copy):
|
||||
def __init__(self,
|
||||
target_host,
|
||||
remote_exec,
|
||||
remote_copy,
|
||||
base_path=None):
|
||||
self.target_host = target_host
|
||||
self.base_path = os.environ.get('__cdist_remote_out_dir', "/var/lib/cdist")
|
||||
self._exec = remote_exec
|
||||
self._copy = remote_copy
|
||||
|
||||
if base_path:
|
||||
self.base_path = base_path
|
||||
else:
|
||||
self.base_path = "/var/lib/cdist"
|
||||
|
||||
self.conf_path = os.path.join(self.base_path, "conf")
|
||||
self.object_path = os.path.join(self.base_path, "object")
|
||||
|
||||
|
|
@ -141,6 +149,6 @@ class Remote(object):
|
|||
except subprocess.CalledProcessError:
|
||||
raise cdist.Error("Command failed: " + " ".join(command))
|
||||
except OSError as error:
|
||||
raise cdist.Error(" ".join(*args) + ": " + error.args[1])
|
||||
raise cdist.Error(" ".join(command) + ": " + error.args[1])
|
||||
except UnicodeDecodeError:
|
||||
raise DecodeError(command)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue