本文整理汇总了Python中refabric.api.info函数的典型用法代码示例。如果您正苦于以下问题:Python info函数的具体用法?Python info怎么用?Python info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了info函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: add_repository
def add_repository():
name = debian.lsb_codename()
info('Adding postgres {} apt repository...', name)
repo = 'deb https://apt.postgresql.org/pub/repos/apt/ {}-pgdg main'.format(name)
debian.add_apt_key('https://www.postgresql.org/media/keys/ACCC4CF8.asc')
debian.add_apt_repository(repository=repo, src=True)
debian.apt_get_update()
开发者ID:Sportamore,项目名称:blues,代码行数:7,代码来源:postgres.py
示例17: configure_web
def configure_web(self):
"""
Render and upload web.ini vassal to <project>.ini.
:return: Updated vassals
"""
destination = self.get_config_path()
context = self.get_context()
ini = self.get_web_vassal()
template = os.path.join('uwsgi', ini)
default_templates = uwsgi.blueprint.get_default_template_root()
with settings(template_dirs=[default_templates]):
# Check if a specific web vassal have been created or use the default
if template not in blueprint.get_template_loader().list_templates():
# Upload default web vassal
info(indent('...using default web vassal'))
template = os.path.join('uwsgi', 'default', 'web.ini')
uploads = blueprint.upload(template, os.path.join(destination, ini), context=context)
if uploads:
self.updates.extend(uploads)
# Upload remaining (local) vassals
user_vassals = blueprint.upload('uwsgi/', destination, context=context) # TODO: skip subdirs
if user_vassals:
self.updates.extend(user_vassals)
return self.updates
开发者ID:lericson,项目名称:blues,代码行数:29,代码来源:uwsgi.py
示例18: get_context
def get_context(self):
"""
Build jinja context for web.ini vassal.
:return: context
"""
context = super(UWSGIProvider, self).get_context()
# Memory optimized options
cpu_count = blueprint.get('web.max_cores', debian.nproc())
total_memory = int(round(debian.total_memory() / 1024.0 / 1024.0 / 1024.0))
total_memory = blueprint.get('web.max_memory', default=total_memory)
workers = blueprint.get('web.workers', default=uwsgi.get_worker_count(cpu_count))
gevent = blueprint.get('web.gevent', default=0)
info('Generating uWSGI conf based on {} core(s), {} GB memory and {} worker(s)',
cpu_count, total_memory, workers)
# TODO: Handle different loop engines (gevent)
context.update({
'cpu_affinity': uwsgi.get_cpu_affinity(cpu_count, workers),
'workers': workers,
'max_requests': int(uwsgi.get_max_requests(total_memory)),
'reload_on_as': int(uwsgi.get_reload_on_as(total_memory)),
'reload_on_rss': int(uwsgi.get_reload_on_rss(total_memory)),
'limit_as': int(uwsgi.get_limit_as(total_memory)),
'gevent': gevent,
})
# Override context defaults with blueprint settings
context.update(blueprint.get('web'))
return context
开发者ID:lericson,项目名称:blues,代码行数:32,代码来源:uwsgi.py
示例19: reset
def reset(branch, repository_path=None, **kwargs):
"""
Fetch, reset, clean and checkout repository branch.
:return: commit
"""
commit = None
if not repository_path:
repository_path = debian.pwd()
with cd(repository_path):
name = os.path.basename(repository_path)
info('Resetting git repository: {}@{}', name, branch)
with silent('warnings'):
commands = [
'git fetch origin', # Fetch branches and tags
'git reset --hard HEAD', # Make hard reset to HEAD
'git clean -fdx', # Remove untracked files pyc, xxx~ etc
'git checkout HEAD', # Checkout HEAD
'git reset refs/remotes/origin/{} --hard'.format(branch) # Reset to branch
]
output = run(' && '.join(commands))
if output.return_code != 0:
warn('Failed to reset repository "{}", probably permission denied!'.format(name))
else:
output = output.split(os.linesep)[-1][len('HEAD is now at '):]
commit = output.split()[0]
info('HEAD is now at: {}', output)
return commit
开发者ID:5monkeys,项目名称:blues,代码行数:33,代码来源:git.py
示例20: clone
def clone(url, branch=None, repository_path=None, **kwargs):
"""
Clone repository and branch.
:param url: Git url to clone
:param branch: Branch to checkout
:param repository_path: Destination
:param kwargs: Not used but here for easier kwarg passing
:return: (destination, got_cloned bool)
"""
repository = parse_url(url, branch=branch)
name = repository['name']
branch = repository['branch']
cloned = False
if not repository_path:
repository_path = os.path.join('.', name)
if not files.exists(os.path.join(repository_path, '.git')):
info('Cloning {}@{} into {}', url, branch, repository_path)
with silent('warnings'):
cmd = 'git clone -b {branch} {remote} {name}'.format(branch=branch, remote=url, name=name)
output = run(cmd)
if output.return_code != 0:
warn('Failed to clone repository "{}", probably permission denied!'.format(name))
cloned = None
else:
cloned = True
else:
info('Git repository already cloned: {}', name)
return repository_path, cloned
开发者ID:5monkeys,项目名称:blues,代码行数:32,代码来源:git.py
注:本文中的refabric.api.info函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论