Did I find the right examples for you? yes no

All Samples(4)  |  Call(2)  |  Derive(0)  |  Import(2)
Common code to upload puppet and chef config files
to remote server.

Heavily based on upload procedure from fabric-provision:
https://github.com/caffeinehit/fabric-provision/blob/master/provision/__init__.py

        def upload_config(config, config_folder_names=[], config_files={}):
    """ Common code to upload puppet and chef config files
    to remote server.

    Heavily based on upload procedure from fabric-provision:
    https://github.com/caffeinehit/fabric-provision/blob/master/provision/__init__.py
    """
    names = config_folder_names + config_files.keys()
    ctx = dict(map(lambda name: (name, '%s/%s' % (config.path, name)), names))

    tmpfolder = mkdtemp()

    listify = lambda what: what if isinstance(what, list) else [what]

    for folder_name in config_folder_names:
        setattr(config, folder_name, listify(getattr(config, folder_name)))

    for folder_name in config_folder_names:
        local('mkdir %s/%s' % (tmpfolder, folder_name))

    def copyfolder(folder, what):
        if not os.path.exists(folder):
            os.makedirs(folder)

        with settings(warn_only=True):
            local('cp -r %(folder)s/* %(tmpfolder)s/%(what)s' % dict(
                    folder=folder,
                    tmpfolder=tmpfolder,
                    what=what))

    for what in config_folder_names:
        map(lambda f: copyfolder(f, what), getattr(config, what))

    folder_paths = " ".join(map(lambda folder_name: "./%s" % folder_name, config_folder_names))
    local('cd %s && tar -f config_dir.tgz -cz %s' % (tmpfolder, folder_paths))

    # Get rid of old files
    with settings(warn_only=True):
        map(lambda what: sudo("rm -rf '%s'" % ctx[what]), ctx.keys())

    # Upload
    put('%s/config_dir.tgz' % tmpfolder, config.path, use_sudo=True)

    with cd(config.path):
        sudo('tar -xf config_dir.tgz')

    for file, contents in config_files.iteritems():
        files.append(ctx[file], contents, use_sudo=True)
        


src/c/l/cloudbiolinux-HEAD/cloudbio/config_management/puppet.py   cloudbiolinux(Download)
from fabric.state import _AttributeDict
from fabric.api import cd
 
from utils import upload_config, config_dir, build_properties
from cloudbio.package.deb import _apt_packages
def _puppet_provision(env, classes):
    env.safe_sudo('mkdir -p %(path)s' % puppet)
    manifest_body = "node default {\n%s\n}\n" % _build_node_def_body(env, classes)
    config_files = {"manifest.pp": manifest_body}
    upload_config(puppet, config_folder_names=["modules"], config_files=config_files)

src/c/l/cloudbiolinux-HEAD/cloudbio/config_management/chef.py   cloudbiolinux(Download)
 
from cloudbio.flavor.config import get_config_file
from utils import build_properties, upload_config, config_dir
 
 
    config_files = {'node.json': json.dumps(chef.json),
                    'solo.rb': SOLO_RB % chef}
    upload_config(chef, config_folder_names=['cookbooks', 'data_bags', 'roles'], config_files=config_files)
 
    with cd(chef.path):