mirror of
https://github.com/kevingruesser/bootstrap-vz.git
synced 2025-08-24 15:36:27 +00:00
Abstracted some of the copy_tree stuff out
This commit is contained in:
parent
b56bf53573
commit
c8b916b5a2
3 changed files with 22 additions and 35 deletions
|
@ -1,5 +1,3 @@
|
||||||
|
|
||||||
|
|
||||||
def log_check_call(command, stdin=None, env=None, shell=False):
|
def log_check_call(command, stdin=None, env=None, shell=False):
|
||||||
status, stdout, stderr = log_call(command, stdin, env, shell)
|
status, stdout, stderr = log_call(command, stdin, env, shell)
|
||||||
if status != 0:
|
if status != 0:
|
||||||
|
@ -71,3 +69,21 @@ def config_get(path, config_path):
|
||||||
for key in config_path:
|
for key in config_path:
|
||||||
config = config.get(key)
|
config = config.get(key)
|
||||||
return config
|
return config
|
||||||
|
|
||||||
|
def copy_tree(from_path,to_path):
|
||||||
|
from shutil import copy
|
||||||
|
import os
|
||||||
|
for abs_prefix, dirs, files in os.walk(from_path):
|
||||||
|
prefix = os.path.normpath(os.path.relpath(abs_prefix, from_path))
|
||||||
|
for path in dirs:
|
||||||
|
full_path = os.path.join(to_path, prefix, path)
|
||||||
|
if os.path.exists(full_path):
|
||||||
|
if os.path.isdir(full_path):
|
||||||
|
continue
|
||||||
|
else:
|
||||||
|
os.remove(full_path)
|
||||||
|
os.mkdir(full_path)
|
||||||
|
for path in files:
|
||||||
|
copy(os.path.join(abs_prefix, path),
|
||||||
|
os.path.join(to_path, prefix, path))
|
||||||
|
|
||||||
|
|
|
@ -36,20 +36,5 @@ class CopyChefAssets(Task):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
from shutil import copy
|
from common.tools import copy_tree
|
||||||
chef_path = os.path.join(info.root, 'etc/chef')
|
copy_tree(info.manifest.plugins['chef']['assets'], os.path.join(info.root, 'etc/chef'))
|
||||||
chef_assets = info.manifest.plugins['chef']['assets']
|
|
||||||
for abs_prefix, dirs, files in os.walk(chef_assets):
|
|
||||||
prefix = os.path.normpath(os.path.relpath(abs_prefix, chef_assets))
|
|
||||||
for path in dirs:
|
|
||||||
full_path = os.path.join(chef_path, prefix, path)
|
|
||||||
if os.path.exists(full_path):
|
|
||||||
if os.path.isdir(full_path):
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
os.remove(full_path)
|
|
||||||
os.mkdir(full_path)
|
|
||||||
for path in files:
|
|
||||||
copy(os.path.join(abs_prefix, path),
|
|
||||||
os.path.join(chef_path, prefix, path))
|
|
||||||
|
|
||||||
|
|
|
@ -53,22 +53,8 @@ class CopyPuppetAssets(Task):
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def run(cls, info):
|
def run(cls, info):
|
||||||
from shutil import copy
|
from common.tools import copy_tree
|
||||||
puppet_path = os.path.join(info.root, 'etc/puppet')
|
copy_tree(info.manifest.plugins['puppet']['assets'], os.path.join(info.root, 'etc/puppet'))
|
||||||
puppet_assets = info.manifest.plugins['puppet']['assets']
|
|
||||||
for abs_prefix, dirs, files in os.walk(puppet_assets):
|
|
||||||
prefix = os.path.normpath(os.path.relpath(abs_prefix, puppet_assets))
|
|
||||||
for path in dirs:
|
|
||||||
full_path = os.path.join(puppet_path, prefix, path)
|
|
||||||
if os.path.exists(full_path):
|
|
||||||
if os.path.isdir(full_path):
|
|
||||||
continue
|
|
||||||
else:
|
|
||||||
os.remove(full_path)
|
|
||||||
os.mkdir(full_path)
|
|
||||||
for path in files:
|
|
||||||
copy(os.path.join(abs_prefix, path),
|
|
||||||
os.path.join(puppet_path, prefix, path))
|
|
||||||
|
|
||||||
|
|
||||||
class ApplyPuppetManifest(Task):
|
class ApplyPuppetManifest(Task):
|
||||||
|
|
Loading…
Add table
Reference in a new issue