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


Python api.info函数代码示例

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


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

示例1: install

def install():
    with sudo():
        info("Installing Ruby v1.9.3")
        debian.apt_get("install", "ruby1.9.3")

    info("Installing Bundler")
    gem("install", "bundler")
开发者ID:zalphi,项目名称:blues,代码行数:7,代码来源:ruby.py

示例2: generate_nginx_conf

def generate_nginx_conf(role='www'):
    """
    Generate nginx config for reverse proxying Kibana application
    """
    info('Generating kibana config to [email protected]{}...'.format(role))
    context = {
        'domain': blueprint.get('domain', '_'),
        'elasticsearch_host': blueprint.get('elasticsearch_host', '127.0.0.1')
    }
    template = 'nginx/kibana.conf'
    conf = blueprint.render_template(template, context)
    pwd = os.path.dirname(env['real_fabfile'])

    for _dir, _conf in [('sites-available', 'kibana.conf'), ('includes', 'kibana-locations.conf')]:
        conf_dir = os.path.join(pwd, 'templates', role, 'nginx', _dir)
        conf_path = os.path.join(conf_dir, _conf)

        if not os.path.exists(conf_dir):
            os.makedirs(conf_dir)

        with open(conf_path, 'w+') as f:
            f.write(conf)

    info('Select username and password...')
    passwd_dir = os.path.join(pwd, 'templates', role, 'nginx', 'conf.d')
    passwd_path = os.path.join(passwd_dir, 'kibana.htpasswd')
    if not os.path.exists(passwd_dir):
        os.makedirs(passwd_dir)
    username = prompt('Username:', default='kibana')
    local('htpasswd -c {filename} {username}'.format(filename=passwd_path,
                                                     username=username))
开发者ID:5monkeys,项目名称:blues,代码行数:31,代码来源:kibana.py

示例3: flush

def flush():
    """
    Clear varnish cache
    """
    info('Flushing Varnish...')
    varnishadm('ban.url .*')
    info('Down the drain!')
开发者ID:Sportamore,项目名称:blues,代码行数:7,代码来源:varnish.py

示例4: setup

def setup():
    """
    Setup Logstash server
    """
    from .elasticsearch import add_elastic_repo

    with sudo():
        branch = blueprint.get('branch', '6.x')
        add_elastic_repo(branch)

        version = blueprint.get('version', 'latest')
        info('Installing {} version {}', 'logstash', version)
        package = 'logstash' + ('={}'.format(version) if version != 'latest' else '')
        debian.apt_get('install', package)

        # Enable on boot
        debian.add_rc_service('logstash')

        # prep custom folders
        debian.mkdir(conf_available_path)
        debian.mkdir(conf_enabled_path)

        # Install plugins
        plugins = blueprint.get('plugins', [])
        for plugin in plugins:
            info('Installing logstash "{}" plugin...', plugin)
            install_plugin(plugin)

    configure()
开发者ID:Sportamore,项目名称:blues,代码行数:29,代码来源:logstash.py

示例5: configure_infra

def configure_infra():
    with sudo():
        info('Adding license key to config')
        context = {"newrelic_key": blueprint.get('newrelic_key', None)}
        blueprint.upload('newrelic-infra.yml',
                         '/etc/newrelic-infra.yml',
                         context=context)
开发者ID:Sportamore,项目名称:blues,代码行数:7,代码来源:newrelic.py

示例6: install_forwarder

def install_forwarder():
    """
    TODO: Build from github

    - wget https://storage.googleapis.com/golang/go1.4.1.linux-amd64.tar.gz
    - gunzip <go>
    - mv go /usr/local/
    - apt-get install unzip make ruby ruby-dev
    - wget https://github.com/elasticsearch/logstash-forwarder/archive/master.zip
    - unzip <forwarder>
    - cd <forwarder>
    - go build
    - gem install fpm
    - make deb
    - dpkg -i <forwarder>
    """
    with sudo():
        info("Adding apt repository for {}", "logstash forwarder")
        debian.add_apt_repository("http://packages.elasticsearch.org/logstashforwarder/debian stable main")

        info("Installing {}", "logstash forwarder")
        debian.apt_get("update")
        debian.apt_get("install", "logstash-forwarder")

        # Upload init script
        blueprint.upload("forwarder/init.d/logstash-forwarder", "/etc/init.d/")
        debian.chmod("/etc/init.d/logstash-forwarder", mode=755)

        # Enable on boot
        debian.add_rc_service("logstash-forwarder")
开发者ID:zalphi,项目名称:blues,代码行数:30,代码来源:logstash.py

示例7: install_postgis

def install_postgis(v=None):
    if not v:
        v = version()

    info('Installing postgis...')
    debian.apt_get('install', 'postgis',
                   'postgresql-{}-postgis-scripts'.format(v))
开发者ID:Sportamore,项目名称:blues,代码行数:7,代码来源:postgres.py

示例8: enable

def enable(site, do_reload=True):
    """
    Enable site

    :param site: Site to enable
    :param do_reload: Reload nginx service
    :return: Got enabled?
    """
    enabled = False
    site = site if site.endswith('.conf') or site == 'default' else '{}.conf'.format(site)

    with sudo():
        available_site = os.path.join(sites_available_path, site)
        if not files.exists(available_site):
            warn('Invalid site: {}'.format(site))
        else:
            with cd(sites_enabled_path):
                if not files.exists(site):
                    info('Enabling site: {}', site)
                    with silent():
                        debian.ln(available_site, site)
                        enabled = True
                    if do_reload:
                        reload()

    return enabled
开发者ID:5monkeys,项目名称:blues,代码行数:26,代码来源:nginx.py

示例9: enable

def enable(program, do_reload=True):
    """
    Enable program.

    :param program: Program to enable
    :param do_reload: Reload supervisor
    :return: Got enabled?
    """
    enabled = False
    program = program if program.endswith(".conf") or program == "default" else "{}.conf".format(program)

    with sudo():
        available_program = os.path.join(programs_available_path, program)
        if not files.exists(available_program):
            warn("Invalid program: {}".format(program))
        else:
            with cd(programs_enabled_path):
                if not files.exists(program):
                    info("Enabling program: {}", program)
                    with silent():
                        debian.ln(available_program, program)
                        enabled = True
                    if do_reload:
                        reload()

    return enabled
开发者ID:gelbander,项目名称:blues,代码行数:26,代码来源:supervisor.py

示例10: enable

def enable(conf, weight, do_restart=True):
    """
    Enable logstash input/output provider

    :param conf: Input or output provider config file
    :param weight: Weight of provider
    :param do_restart: Restart service
    :return: Got enabled?
    """
    enabled = False
    conf = conf if conf.endswith(".conf") else "{}.conf".format(conf)

    with sudo():
        available_conf = os.path.join(conf_available_path, conf)
        if not files.exists(available_conf):
            warn("Invalid conf: {}".format(conf))
        else:
            with cd(conf_enabled_path):
                weight = str(weight).zfill(2)
                conf = "{}-{}".format(weight, conf)
                if not files.exists(conf):
                    info("Enabling conf: {}", conf)
                    with silent():
                        debian.ln(available_conf, conf)
                        enabled = True
                    if do_restart:
                        restart("server")

    return enabled
开发者ID:zalphi,项目名称:blues,代码行数:29,代码来源:logstash.py

示例11: update_modules

def update_modules(beat):
    changes = []

    # Get desired state
    desired_modules = set(blueprint.get('{}.modules'.format(beat), []))

    # Get current state
    with silent():
        module_files = run('find /etc/{}/modules.d -iname "*.yml"'.format(beat)).split()
        enabled_modules = {os.path.basename(module).split('.')[0] for module in module_files}

    # Disable extra services
    for extra in enabled_modules - desired_modules:
        info('Disabling {} module: {}', beat, extra)
        changes.append(extra)

        with silent(), sudo():
            run('{} modules disable {}'.format(beat, extra))

    # Enable services
    for missing in desired_modules - enabled_modules:
        info('Enabling {} module: {}', beat, missing)
        changes.append(missing)

        with silent(), sudo():
            run('{} modules enable {}'.format(beat, missing))

    return changes
开发者ID:Sportamore,项目名称:blues,代码行数:28,代码来源:beats.py

示例12: setup_schemas

def setup_schemas(drop=False):
    """
    Create database schemas and grant user privileges

    :param drop: Drop existing schemas before creation
    """
    schemas = blueprint.get('schemas', {})
    with sudo('postgres'):
        for schema, config in schemas.iteritems():
            user, password = config['user'], config.get('password')
            info('Creating user {}', user)
            if password:
                _client_exec("CREATE ROLE %(user)s WITH PASSWORD '%(password)s' LOGIN",
                             user=user, password=password)
            else:
                _client_exec("CREATE ROLE %(user)s LOGIN", user=user)
            if drop:
                info('Droping schema {}', schema)
                _client_exec('DROP DATABASE %(name)s', name=schema)
            info('Creating schema {}', schema)
            _client_exec('CREATE DATABASE %(name)s', name=schema)
            info('Granting user {} to schema {}'.format(user, schema))
            _client_exec("GRANT ALL PRIVILEGES ON DATABASE %(schema)s to %(user)s",
                         schema=schema, user=user)

            for ext in blueprint.get('extensions', []):
                info('Creating extension {}'.format(ext))
                _client_exec("CREATE EXTENSION IF NOT EXISTS %(ext)s", ext=ext, schema=schema)
开发者ID:5monkeys,项目名称:blues,代码行数:28,代码来源:postgres.py

示例13: info

def info(scope=''):
    """
    Get runtime information from redis itself
    """
    with silent(), hide_prefix():
        output = api.run('redis-cli info ' + scope)
        api.info(output)
开发者ID:Sportamore,项目名称:blues,代码行数:7,代码来源:redis.py

示例14: send_deploy_event

def send_deploy_event():

    newrelic_key = blueprint.get('newrelic_key', None)
    app_name = blueprint.get('app_name', None)

    if newrelic_key and app_name:
        url = 'https://api.newrelic.com/deployments.xml'
        headers = {'x-api-key': newrelic_key}
        with cd(python_path()):
            tag = run('git describe --tags')
            commit_hash = run('git rev-parse HEAD')

        deployer = git.get_local_commiter()

        payload = {
                'deployment[app_name]': app_name,
                # 'application_id': '1234567',
                'deployment[description]': tag,
                'deployment[revision]': commit_hash,
                # 'deployment[changelog]': changes,
                'deployment[user]': deployer,
            }

        response = requests.post(url, data=payload, headers=headers)
        info(response.text)
    else:
        info('No key found')

#http://gc-taylor.com/blog/2013/02/11/fabric-task-for-notifying-new-relic-code-deploy/#sthash.5AnhN3An.sfju
开发者ID:zalphi,项目名称:blues,代码行数:29,代码来源:newrelic.py

示例15: update_filters

def update_filters():
    changes = []

    # Generate desired state as enabled_name => source_name
    config = blueprint.get('config', {})
    filters = {
        '{}-{}.conf'.format(str(weight).zfill(2), conf): "{}.conf".format(conf)
        for weight, conf in config.iteritems()
    }

    # Get current state
    with silent():
        enabled_filters = run('ls {}'.format(conf_enabled_path)).split()

    # Disable extra services
    if blueprint.get('auto_disable_conf', True):
        for link in set(enabled_filters) - set(filters.keys()):
            info('Disabling conf: {}', link)
            changes.append(link)

            with silent(), sudo(), cd(conf_enabled_path):
                debian.rm(link)

    # Enable services
    for target in set(filters.keys()) - set(enabled_filters):
        source = os.path.join(conf_available_path, filters[target])
        info('Enabling conf: {}', target)
        changes.append(source)

        with silent(), sudo(), cd(conf_enabled_path):
            debian.ln(source, target)

    return changes
开发者ID:Sportamore,项目名称:blues,代码行数:33,代码来源:logstash.py


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