当前位置: 首页>>代码示例>>Python>>正文


Python lib.debug函数代码示例

本文整理汇总了Python中snfdeploy.lib.debug函数的典型用法代码示例。如果您正苦于以下问题:Python debug函数的具体用法?Python debug怎么用?Python debug使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了debug函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: install_package

def install_package(package):
    debug(env.host, " * Installing package %s..." % package)
    apt_get = "export DEBIAN_FRONTEND=noninteractive ;" + \
              "apt-get install -y --force-yes "

    host_info = env.env.ips_info[env.host]
    env.env.update_packages(host_info.os)
    if ast.literal_eval(env.env.use_local_packages):
        with settings(warn_only=True):
            deb = local("ls %s/%s*%s_*.deb"
                        % (env.env.packages, package, host_info.os),
                        capture=True)
            if deb:
                debug(env.host,
                      " * Package %s found in %s..."
                      % (package, env.env.packages))
                try_put(deb, "/tmp/")
                try_run("dpkg -i /tmp/%s || "
                        % os.path.basename(deb) + apt_get + "-f")
                try_run("rm /tmp/%s" % os.path.basename(deb))
                return

    info = getattr(env.env, package)
    if info in \
            ["squeeze-backports", "squeeze", "stable",
             "testing", "unstable", "wheezy"]:
        apt_get += " -t %s %s " % (info, package)
    elif info:
        apt_get += " %s=%s " % (package, info)
    else:
        apt_get += package

    try_run(apt_get)

    return
开发者ID:antonis-m,项目名称:synnefo,代码行数:35,代码来源:fabfile.py

示例2: create_bridges

def create_bridges():
    debug(env.host, " * Creating bridges...")
    install_package("bridge-utils")
    cmd = """
    brctl addbr {0} ; ip link set {0} up
    """.format(env.env.common_bridge)
    try_run(cmd)
开发者ID:antonis-m,项目名称:synnefo,代码行数:7,代码来源:fabfile.py

示例3: setup_cms

def setup_cms():
    debug(env.host, "Setting up cms...")
    if env.cms_pass:
        debug(env.host, "Aborting. Prerequisites not met.")
        return
    with settings(hide("everything")):
        try_run("ping -c1 accounts." + env.env.domain)
    setup_gunicorn()
    setup_apache()
    setup_webproject()
    install_package("snf-cloudcms")

    tmpl = "/etc/synnefo/cms.conf"
    replace = {
        "ACCOUNTS": env.env.accounts.fqdn,
        }
    custom = customize_settings_from_tmpl(tmpl, replace)
    try_put(custom, tmpl, mode=0644)
    try_run("/etc/init.d/gunicorn restart")

    cmd = """
    snf-manage syncdb
    snf-manage migrate --delete-ghost-migrations
    """.format(env.env.domain)
    try_run(cmd)
开发者ID:antonis-m,项目名称:synnefo,代码行数:25,代码来源:fabfile.py

示例4: check_dns

def check_dns():
    debug(env.host, "Checking fqdns for synnefo..")
    for n, info in env.env.nodes_info.iteritems():
        try_run("ping -c 1 " + info.fqdn)

    for n, info in env.env.roles.iteritems():
        try_run("ping -c 1 " + info.fqdn)
开发者ID:antonis-m,项目名称:synnefo,代码行数:7,代码来源:fabfile.py

示例5: setup_resolv_conf

def setup_resolv_conf():
    debug(env.host, "Tweak /etc/resolv.conf...")
    try_run("/etc/init.d/network-manager stop", abort=False)
    tmpl = "/etc/dhcp/dhclient-enter-hooks.d/nodnsupdate"
    replace = {}
    custom = customize_settings_from_tmpl(tmpl, replace)
    try_put(custom, tmpl, mode=0644)
    try_run("cp /etc/resolv.conf /etc/resolv.conf.bak")
    tmpl = "/etc/resolv.conf"
    replace = {
        "domain": env.env.domain,
        "ns_node_ip": env.env.ns.ip,
    }
    custom = customize_settings_from_tmpl(tmpl, replace)
    try:
        try_put(custom, tmpl)
        cmd = """
        echo "\
# This has been generated automatically by snf-deploy, at
# $(date).
# The immutable bit (+i attribute) has been used to avoid it being
# overwritten by software such as NetworkManager or resolvconf.
# Use lsattr/chattr to view or modify its file attributes.


$(cat {0})" > {0}
""".format(tmpl)
        try_run(cmd)
    except:
        pass
    try_run("chattr +i /etc/resolv.conf")
开发者ID:antonis-m,项目名称:synnefo,代码行数:31,代码来源:fabfile.py

示例6: setup_ganeti

def setup_ganeti():
    debug(env.host, "Setting up snf-ganeti...")
    node_info = env.env.ips_info[env.host]
    with settings(hide("everything")):
        #if env.enable_lvm:
        #    try_run("vgs " + env.env.vg)
        try_run("getent hosts " + env.env.cluster.fqdn)
        try_run("getent hosts %s | grep -v ^127" % env.host)
        try_run("hostname -f | grep " + node_info.fqdn)
        #try_run("ip link show " + env.env.common_bridge)
        #try_run("ip link show " + env.env.common_bridge)
        #try_run("apt-get update")
    install_package("qemu-kvm")
    install_package("python-bitarray")
    install_package("ganeti-haskell")
    install_package("ganeti-htools")
    install_package("snf-ganeti")
    try_run("mkdir -p /srv/ganeti/file-storage/")
    cmd = """
cat <<EOF > /etc/ganeti/file-storage-paths
/srv/ganeti/file-storage
/srv/ganeti/shared-file-storage
EOF
"""
    try_run(cmd)
开发者ID:antonis-m,项目名称:synnefo,代码行数:25,代码来源:fabfile.py

示例7: setup_apache

def setup_apache():
    debug(env.host, " * Setting up apache2...")
    host_info = env.env.ips_info[env.host]
    install_package("apache2")
    tmpl = "/etc/apache2/sites-available/synnefo"
    replace = {
        "HOST": host_info.fqdn,
    }
    custom = customize_settings_from_tmpl(tmpl, replace)
    try_put(custom, tmpl)
    tmpl = "/etc/apache2/sites-available/synnefo-ssl"
    custom = customize_settings_from_tmpl(tmpl, replace)
    try_put(custom, tmpl)
    cmd = """
    a2enmod ssl
    a2enmod rewrite
    a2dissite default
    a2ensite synnefo
    a2ensite synnefo-ssl
    a2enmod headers
    a2enmod proxy_http
    a2dismod autoindex
    """
    try_run(cmd)
    try_run("/etc/init.d/apache2 restart")
开发者ID:antonis-m,项目名称:synnefo,代码行数:25,代码来源:fabfile.py

示例8: update_ns_for_ganeti

def update_ns_for_ganeti():
    debug(env.host,
          "Updating name server entries for backend %s..."
          % env.env.cluster.fqdn)
    update_arecord(env.env.cluster)
    update_ptrrecord(env.env.cluster)
    try_run("/etc/init.d/bind9 restart")
开发者ID:antonis-m,项目名称:synnefo,代码行数:7,代码来源:fabfile.py

示例9: add_pools

def add_pools():
    debug(env.host,
          " * Creating pools of resources (brigdes, mac prefixes) " +
          "in cyclades...")
    try_run("snf-manage pool-create --type=mac-prefix " +
            "--base=aa:00:0 --size=65536")
    try_run("snf-manage pool-create --type=bridge --base=prv --size=20")
开发者ID:antonis-m,项目名称:synnefo,代码行数:7,代码来源:fabfile.py

示例10: enable_drbd

def enable_drbd():
    if env.enable_drbd:
        debug(env.host, " * Enabling DRBD...")
        install_package("drbd8-utils")
        try_run("modprobe drbd minor_count=255 usermode_helper=/bin/true")
        try_run("echo drbd minor_count=255 usermode_helper=/bin/true " +
                ">> /etc/modules")
开发者ID:antonis-m,项目名称:synnefo,代码行数:7,代码来源:fabfile.py

示例11: init_cluster

def init_cluster():
    debug(env.host, " * Initializing Ganeti backend...")
    # extra = ""
    # if env.enable_lvm:
    #     extra += " --vg-name={0} ".format(env.env.vg)
    # else:
    #     extra += " --no-lvm-storage "
    # if not env.enable_drbd:
    #     extra += " --no-drbd-storage "
    extra = " --no-lvm-storage --no-drbd-storage "
    cmd = """
    gnt-cluster init --enabled-hypervisors=kvm \
        {0} \
        --nic-parameters link={1},mode=bridged \
        --master-netdev {2} \
        --default-iallocator hail \
        --specs-nic-count min=0,max=8 \
        --hypervisor-parameters kvm:kernel_path=,vnc_bind_address=0.0.0.0 \
        --no-ssh-init --no-etc-hosts \
        {3}
    """.format(extra, env.env.common_bridge,
               env.env.cluster_netdev, env.env.cluster.fqdn)
    try_run(cmd)
    cmd = """gnt-cluster modify --enabled-disk-templates file,plain,ext"""
    try_run(cmd)
开发者ID:antonis-m,项目名称:synnefo,代码行数:25,代码来源:fabfile.py

示例12: get_service_details

def get_service_details(service="pithos"):
    debug(env.host, " * Getting registered details for %s service..." % service)
    result = try_run("snf-manage component-list")
    r = re.compile(r".*%s.*" % service, re.M)
    service_id, _, _, service_token = r.search(result).group().split()
    # print("%s: %s %s" % (service, service_id, service_token))
    return (service_id, service_token)
开发者ID:vkoukis,项目名称:synnefo,代码行数:7,代码来源:fabfile.py

示例13: setup_db

def setup_db():
    debug(env.host, "Setting up DataBase server...")
    install_package("postgresql")

    tmpl = "/tmp/db-init.psql"
    replace = {
        "synnefo_user": env.env.synnefo_user,
        "synnefo_db_passwd": env.env.synnefo_db_passwd,
        }
    custom = customize_settings_from_tmpl(tmpl, replace)
    try_put(custom, tmpl)
    cmd = 'su - postgres -c "psql -w -f %s" ' % tmpl
    try_run(cmd)
    cmd = """
    conf=$(ls /etc/postgresql/*/main/postgresql.conf)
    echo "listen_addresses = '*'" >> $conf
    """
    try_run(cmd)

    if env.env.testing_vm:
        cmd = """
        conf=$(ls /etc/postgresql/*/main/postgresql.conf)
        echo "fsync=off\nsynchronous_commit=off\nfull_page_writes=off" >> $conf
        """
        try_run(cmd)

    allow_access_in_db(env.host, "all", "trust")
    try_run("/etc/init.d/postgresql restart")
开发者ID:antonis-m,项目名称:synnefo,代码行数:28,代码来源:fabfile.py

示例14: try_get

def try_get(remote_path, local_path=None, abort=True, **kwargs):
    try:
        get(remote_path, local_path=local_path, **kwargs)
    except BaseException as e:
        if abort:
            fabric.utils.abort(e)
        else:
            debug(env.host, "WARNING: command failed. Continuing anyway...")
开发者ID:antonis-m,项目名称:synnefo,代码行数:8,代码来源:fabfile.py

示例15: setup_gunicorn

def setup_gunicorn():
    debug(env.host, " * Setting up gunicorn...")
    install_package("gunicorn")
    tmpl = "/etc/gunicorn.d/synnefo"
    replace = {}
    custom = customize_settings_from_tmpl(tmpl, replace)
    try_put(custom, tmpl, mode=0644)
    try_run("/etc/init.d/gunicorn restart")
开发者ID:vkoukis,项目名称:synnefo,代码行数:8,代码来源:fabfile.py


注:本文中的snfdeploy.lib.debug函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。