_id stringlengths 2 7 | title stringlengths 1 88 | partition stringclasses 3
values | text stringlengths 75 19.8k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q258500 | FileSatchel.copy | validation | def copy(self, source, destination, recursive=False, use_sudo=False):
"""
Copy a file or directory
"""
func = use_sudo and run_as_root or self.run
options = '-r ' if recursive else ''
func('/bin/cp {0}{1} {2}'.format(options, quote(source), quote(destination))) | python | {
"resource": ""
} |
q258501 | FileSatchel.move | validation | def move(self, source, destination, use_sudo=False):
"""
Move a file or directory
"""
func = use_sudo and run_as_root or self.run
func('/bin/mv {0} {1}'.format(quote(source), quote(destination))) | python | {
"resource": ""
} |
q258502 | FileSatchel.remove | validation | def remove(self, path, recursive=False, use_sudo=False):
"""
Remove a file or directory
"""
func = use_sudo and run_as_root or self.run
options = '-r ' if recursive else ''
func('/bin/rm {0}{1}'.format(options, quote(path))) | python | {
"resource": ""
} |
q258503 | FileSatchel.require | validation | def require(self, path=None, contents=None, source=None, url=None, md5=None,
use_sudo=False, owner=None, group='', mode=None, verify_remote=True,
temp_dir='/tmp'):
"""
Require a file to exist and have specific contents and properties.
You can provide either:
- *conten... | python | {
"resource": ""
} |
q258504 | SeleniumSatchel.check_for_change | validation | def check_for_change(self):
"""
Determines if a new release has been made.
"""
r = self.local_renderer
lm = self.last_manifest
last_fingerprint = lm.fingerprint
current_fingerprint = self.get_target_geckodriver_version_number()
self.vprint('last_fingerprin... | python | {
"resource": ""
} |
q258505 | update | validation | def update(kernel=False):
"""
Upgrade all packages, skip obsoletes if ``obsoletes=0`` in ``yum.conf``.
Exclude *kernel* upgrades by default.
"""
manager = MANAGER
cmds = {'yum -y --color=never': {False: '--exclude=kernel* update', True: 'update'}}
cmd = cmds[manager][kernel]
run_as_root... | python | {
"resource": ""
} |
q258506 | is_installed | validation | def is_installed(pkg_name):
"""
Check if an RPM package is installed.
"""
manager = MANAGER
with settings(hide('running', 'stdout', 'stderr', 'warnings'), warn_only=True):
res = run("rpm --query %(pkg_name)s" % locals())
if res.succeeded:
return True
return False | python | {
"resource": ""
} |
q258507 | install | validation | def install(packages, repos=None, yes=None, options=None):
"""
Install one or more RPM packages.
Extra *repos* may be passed to ``yum`` to enable extra repositories at install time.
Extra *yes* may be passed to ``yum`` to validate license if necessary.
Extra *options* may be passed to ``yum`` if ... | python | {
"resource": ""
} |
q258508 | groupinstall | validation | def groupinstall(group, options=None):
"""
Install a group of packages.
You can use ``yum grouplist`` to get the list of groups.
Extra *options* may be passed to ``yum`` if necessary like
(e.g. ``['--nogpgcheck', '--exclude=package']``).
::
import burlap
# Install developmen... | python | {
"resource": ""
} |
q258509 | groupuninstall | validation | def groupuninstall(group, options=None):
"""
Remove an existing software group.
Extra *options* may be passed to ``yum`` if necessary.
"""
manager = MANAGER
if options is None:
options = []
elif isinstance(options, str):
options = [options]
options = " ".join(options)
... | python | {
"resource": ""
} |
q258510 | repolist | validation | def repolist(status='', media=None):
"""
Get the list of ``yum`` repositories.
Returns enabled repositories by default. Extra *status* may be passed
to list disabled repositories if necessary.
Media and debug repositories are kept disabled, except if you pass *media*.
::
import burla... | python | {
"resource": ""
} |
q258511 | S3Satchel.sync | validation | def sync(self, sync_set, force=0, site=None, role=None):
"""
Uploads media to an Amazon S3 bucket using s3sync.
Requires s3cmd. Install with:
pip install s3cmd
"""
from burlap.dj import dj
force = int(force)
r = self.local_renderer
r.env.s... | python | {
"resource": ""
} |
q258512 | S3Satchel.invalidate | validation | def invalidate(self, *paths):
"""
Issues invalidation requests to a Cloudfront distribution
for the current static media bucket, triggering it to reload the specified
paths from the origin.
Note, only 1000 paths can be issued in a request at any one time.
"""
dj ... | python | {
"resource": ""
} |
q258513 | S3Satchel.get_or_create_bucket | validation | def get_or_create_bucket(self, name):
"""
Gets an S3 bucket of the given name, creating one if it doesn't already exist.
Should be called with a role, if AWS credentials are stored in role settings. e.g.
fab local s3.get_or_create_bucket:mybucket
"""
from boto.s3 im... | python | {
"resource": ""
} |
q258514 | IPSatchel.static | validation | def static(self):
"""
Configures the server to use a static IP.
"""
fn = self.render_to_file('ip/ip_interfaces_static.template')
r = self.local_renderer
r.put(local_path=fn, remote_path=r.env.interfaces_fn, use_sudo=True) | python | {
"resource": ""
} |
q258515 | upgrade | validation | def upgrade(safe=True):
"""
Upgrade all packages.
"""
manager = MANAGER
if safe:
cmd = 'upgrade'
else:
cmd = 'dist-upgrade'
run_as_root("%(manager)s --assume-yes %(cmd)s" % locals(), pty=False) | python | {
"resource": ""
} |
q258516 | is_installed | validation | def is_installed(pkg_name):
"""
Check if a package is installed.
"""
with settings(hide('running', 'stdout', 'stderr', 'warnings'), warn_only=True):
res = run("dpkg -s %(pkg_name)s" % locals())
for line in res.splitlines():
if line.startswith("Status: "):
stat... | python | {
"resource": ""
} |
q258517 | install | validation | def install(packages, update=False, options=None, version=None):
"""
Install one or more packages.
If *update* is ``True``, the package definitions will be updated
first, using :py:func:`~burlap.deb.update_index`.
Extra *options* may be passed to ``apt-get`` if necessary.
Example::
i... | python | {
"resource": ""
} |
q258518 | preseed_package | validation | def preseed_package(pkg_name, preseed):
"""
Enable unattended package installation by preseeding ``debconf``
parameters.
Example::
import burlap
# Unattended install of Postfix mail server
burlap.deb.preseed_package('postfix', {
'postfix/main_mailer_type': ('select... | python | {
"resource": ""
} |
q258519 | get_selections | validation | def get_selections():
"""
Get the state of ``dkpg`` selections.
Returns a dict with state => [packages].
"""
with settings(hide('stdout')):
res = run_as_root('dpkg --get-selections')
selections = dict()
for line in res.splitlines():
package, status = line.split()
sel... | python | {
"resource": ""
} |
q258520 | apt_key_exists | validation | def apt_key_exists(keyid):
"""
Check if the given key id exists in apt keyring.
"""
# Command extracted from apt-key source
gpg_cmd = 'gpg --ignore-time-conflict --no-options --no-default-keyring --keyring /etc/apt/trusted.gpg'
with settings(hide('everything'), warn_only=True):
res = r... | python | {
"resource": ""
} |
q258521 | add_apt_key | validation | def add_apt_key(filename=None, url=None, keyid=None, keyserver='subkeys.pgp.net', update=False):
"""
Trust packages signed with this public key.
Example::
import burlap
# Varnish signing key from URL and verify fingerprint)
burlap.deb.add_apt_key(keyid='C4DEFFEB', url='http://repo... | python | {
"resource": ""
} |
q258522 | GroupSatchel.exists | validation | def exists(self, name):
"""
Check if a group exists.
"""
with self.settings(hide('running', 'stdout', 'warnings'), warn_only=True):
return self.run('getent group %(name)s' % locals()).succeeded | python | {
"resource": ""
} |
q258523 | UserSatchel.enter_password_change | validation | def enter_password_change(self, username=None, old_password=None):
"""
Responds to a forced password change via `passwd` prompts due to password expiration.
"""
from fabric.state import connections
from fabric.network import disconnect_all
r = self.local_renderer
# ... | python | {
"resource": ""
} |
q258524 | UserSatchel.togroups | validation | def togroups(self, user, groups):
"""
Adds the user to the given list of groups.
"""
r = self.local_renderer
if isinstance(groups, six.string_types):
groups = [_.strip() for _ in groups.split(',') if _.strip()]
for group in groups:
r.env.username... | python | {
"resource": ""
} |
q258525 | UserSatchel.create | validation | def create(self, username, groups=None, uid=None, create_home=None, system=False, password=None, home_dir=None):
"""
Creates a user with the given username.
"""
r = self.local_renderer
r.env.username = username
args = []
if uid:
args.append('-u %s' %... | python | {
"resource": ""
} |
q258526 | UserSatchel.expire_password | validation | def expire_password(self, username):
"""
Forces the user to change their password the next time they login.
"""
r = self.local_renderer
r.env.username = username
r.sudo('chage -d 0 {username}') | python | {
"resource": ""
} |
q258527 | run_as_root | validation | def run_as_root(command, *args, **kwargs):
"""
Run a remote command as the root user.
When connecting as root to the remote system, this will use Fabric's
``run`` function. In other cases, it will use ``sudo``.
"""
from burlap.common import run_or_dryrun, sudo_or_dryrun
if env.user == 'root... | python | {
"resource": ""
} |
q258528 | get_file_hash | validation | def get_file_hash(fin, block_size=2**20):
"""
Iteratively builds a file hash without loading the entire file into memory.
Designed to process an arbitrary binary file.
"""
if isinstance(fin, six.string_types):
fin = open(fin)
h = hashlib.sha512()
while True:
data = fin.read(b... | python | {
"resource": ""
} |
q258529 | InadynSatchel.check | validation | def check(self):
"""
Run inadyn from the commandline to test the configuration.
To be run like:
fab role inadyn.check
"""
self._validate_settings()
r = self.local_renderer
r.env.alias = r.env.aliases[0]
r.sudo(r.env.check_command_template) | python | {
"resource": ""
} |
q258530 | DebugSatchel.shell | validation | def shell(self, gui=0, command='', dryrun=None, shell_interactive_cmd_str=None):
"""
Opens an SSH connection.
"""
from burlap.common import get_hosts_for_site
if dryrun is not None:
self.dryrun = dryrun
r = self.local_renderer
if r.genv.SITE != r.ge... | python | {
"resource": ""
} |
q258531 | DebugSatchel.disk | validation | def disk(self):
"""
Display percent of disk usage.
"""
r = self.local_renderer
r.run(r.env.disk_usage_command) | python | {
"resource": ""
} |
q258532 | DebugSatchel.tunnel | validation | def tunnel(self, local_port, remote_port):
"""
Creates an SSH tunnel.
"""
r = self.local_renderer
r.env.tunnel_local_port = local_port
r.env.tunnel_remote_port = remote_port
r.local(' ssh -i {key_filename} -L {tunnel_local_port}:localhost:{tunnel_remote_port} {use... | python | {
"resource": ""
} |
q258533 | install_setuptools | validation | def install_setuptools(python_cmd='python', use_sudo=True):
"""
Install the latest version of `setuptools`_.
::
import burlap
burlap.python_setuptools.install_setuptools()
"""
setuptools_version = package_version('setuptools', python_cmd)
distribute_version = package_version... | python | {
"resource": ""
} |
q258534 | _install_from_scratch | validation | def _install_from_scratch(python_cmd, use_sudo):
"""
Install setuptools from scratch using installer
"""
with cd("/tmp"):
download(EZ_SETUP_URL)
command = '%(python_cmd)s ez_setup.py' % locals()
if use_sudo:
run_as_root(command)
else:
run(command... | python | {
"resource": ""
} |
q258535 | install | validation | def install(packages, upgrade=False, use_sudo=False, python_cmd='python'):
"""
Install Python packages with ``easy_install``.
Examples::
import burlap
# Install a single package
burlap.python_setuptools.install('package', use_sudo=True)
# Install a list of packages
... | python | {
"resource": ""
} |
q258536 | PIPSatchel.bootstrap | validation | def bootstrap(self, force=0):
"""
Installs all the necessary packages necessary for managing virtual
environments with pip.
"""
force = int(force)
if self.has_pip() and not force:
return
r = self.local_renderer
if r.env.bootstrap_method == GE... | python | {
"resource": ""
} |
q258537 | PIPSatchel.has_virtualenv | validation | def has_virtualenv(self):
"""
Returns true if the virtualenv tool is installed.
"""
with self.settings(warn_only=True):
ret = self.run_or_local('which virtualenv').strip()
return bool(ret) | python | {
"resource": ""
} |
q258538 | PIPSatchel.virtualenv_exists | validation | def virtualenv_exists(self, virtualenv_dir=None):
"""
Returns true if the virtual environment has been created.
"""
r = self.local_renderer
ret = True
with self.settings(warn_only=True):
ret = r.run_or_local('ls {virtualenv_dir}') or ''
ret = 'cann... | python | {
"resource": ""
} |
q258539 | PIPSatchel.what_requires | validation | def what_requires(self, name):
"""
Lists the packages that require the given package.
"""
r = self.local_renderer
r.env.name = name
r.local('pipdeptree -p {name} --reverse') | python | {
"resource": ""
} |
q258540 | PIPSatchel.init | validation | def init(self):
"""
Creates the virtual environment.
"""
r = self.local_renderer
# if self.virtualenv_exists():
# print('virtualenv exists')
# return
print('Creating new virtual environment...')
with self.settings(warn_only=True):
... | python | {
"resource": ""
} |
q258541 | PIPSatchel.get_combined_requirements | validation | def get_combined_requirements(self, requirements=None):
"""
Returns all requirements files combined into one string.
"""
requirements = requirements or self.env.requirements
def iter_lines(fn):
with open(fn, 'r') as fin:
for line in fin.readlines():
... | python | {
"resource": ""
} |
q258542 | list_instances | validation | def list_instances(show=1, name=None, group=None, release=None, except_release=None):
"""
Retrieves all virtual machines instances in the current environment.
"""
from burlap.common import shelf, OrderedDict, get_verbose
verbose = get_verbose()
require('vm_type', 'vm_group')
assert env.vm_t... | python | {
"resource": ""
} |
q258543 | get_or_create_ec2_key_pair | validation | def get_or_create_ec2_key_pair(name=None, verbose=1):
"""
Creates and saves an EC2 key pair to a local PEM file.
"""
verbose = int(verbose)
name = name or env.vm_ec2_keypair_name
pem_path = 'roles/%s/%s.pem' % (env.ROLE, name)
conn = get_ec2_connection()
kp = conn.get_key_pair(name)
... | python | {
"resource": ""
} |
q258544 | exists | validation | def exists(name=None, group=None, release=None, except_release=None, verbose=1):
"""
Determines if a virtual machine instance exists.
"""
verbose = int(verbose)
instances = list_instances(
name=name,
group=group,
release=release,
except_release=except_release,
... | python | {
"resource": ""
} |
q258545 | get_or_create | validation | def get_or_create(name=None, group=None, config=None, extra=0, verbose=0, backend_opts=None):
"""
Creates a virtual machine instance.
"""
require('vm_type', 'vm_group')
backend_opts = backend_opts or {}
verbose = int(verbose)
extra = int(extra)
if config:
config_fn = common.fi... | python | {
"resource": ""
} |
q258546 | delete | validation | def delete(name=None, group=None, release=None, except_release=None,
dryrun=1, verbose=1):
"""
Permanently erase one or more VM instances from existence.
"""
verbose = int(verbose)
if env.vm_type == EC2:
conn = get_ec2_connection()
instances = list_instances(
name=... | python | {
"resource": ""
} |
q258547 | get_name | validation | def get_name():
"""
Retrieves the instance name associated with the current host string.
"""
if env.vm_type == EC2:
for instance in get_all_running_ec2_instances():
if env.host_string == instance.public_dns_name:
name = instance.tags.get(env.vm_name_tag)
... | python | {
"resource": ""
} |
q258548 | respawn | validation | def respawn(name=None, group=None):
"""
Deletes and recreates one or more VM instances.
"""
if name is None:
name = get_name()
delete(name=name, group=group)
instance = get_or_create(name=name, group=group)
env.host_string = instance.public_dns_name | python | {
"resource": ""
} |
q258549 | RsyncSatchel.deploy_code | validation | def deploy_code(self):
"""
Generates a rsync of all deployable code.
"""
assert self.genv.SITE, 'Site unspecified.'
assert self.genv.ROLE, 'Role unspecified.'
r = self.local_renderer
if self.env.exclusions:
r.env.exclusions_str = ' '.join(
... | python | {
"resource": ""
} |
q258550 | init_env | validation | def init_env():
"""
Populates the global env variables with custom default settings.
"""
env.ROLES_DIR = ROLE_DIR
env.services = []
env.confirm_deployment = False
env.is_local = None
env.base_config_dir = '.'
env.src_dir = 'src' # The path relative to fab where the code resides.
... | python | {
"resource": ""
} |
q258551 | create_module | validation | def create_module(name, code=None):
"""
Dynamically creates a module with the given name.
"""
if name not in sys.modules:
sys.modules[name] = imp.new_module(name)
module = sys.modules[name]
if code:
print('executing code for %s: %s' % (name, code))
exec(code in module.... | python | {
"resource": ""
} |
q258552 | add_class_methods_as_module_level_functions_for_fabric | validation | def add_class_methods_as_module_level_functions_for_fabric(instance, module_name, method_name, module_alias=None):
'''
Utility to take the methods of the instance of a class, instance,
and add them as functions to a module, module_name, so that Fabric
can find and call them. Call this at the bottom of a... | python | {
"resource": ""
} |
q258553 | str_to_list | validation | def str_to_list(s):
"""
Converts a string of comma delimited values and returns a list.
"""
if s is None:
return []
elif isinstance(s, (tuple, list)):
return s
elif not isinstance(s, six.string_types):
raise NotImplementedError('Unknown type: %s' % type(s))
return [_.... | python | {
"resource": ""
} |
q258554 | get_hosts_retriever | validation | def get_hosts_retriever(s=None):
"""
Given the function name, looks up the method for dynamically retrieving host data.
"""
s = s or env.hosts_retriever
# #assert s, 'No hosts retriever specified.'
if not s:
return env_hosts_retriever
# module_name = '.'.join(s.split('.')[:-1])
# ... | python | {
"resource": ""
} |
q258555 | write_temp_file_or_dryrun | validation | def write_temp_file_or_dryrun(content, *args, **kwargs):
"""
Writes the given content to a local temporary file.
"""
dryrun = get_dryrun(kwargs.get('dryrun'))
if dryrun:
fd, tmp_fn = tempfile.mkstemp()
os.remove(tmp_fn)
cmd_run = 'local'
cmd = 'cat <<EOT >> %s\n%s\nEO... | python | {
"resource": ""
} |
q258556 | reboot_or_dryrun | validation | def reboot_or_dryrun(*args, **kwargs):
"""
An improved version of fabric.operations.reboot with better error handling.
"""
from fabric.state import connections
verbose = get_verbose()
dryrun = get_dryrun(kwargs.get('dryrun'))
# Use 'wait' as max total wait time
kwargs.setdefault('wait... | python | {
"resource": ""
} |
q258557 | get_component_settings | validation | def get_component_settings(prefixes=None):
"""
Returns a subset of the env dictionary containing
only those keys with the name prefix.
"""
prefixes = prefixes or []
assert isinstance(prefixes, (tuple, list)), 'Prefixes must be a sequence type, not %s.' % type(prefixes)
data = {}
for name... | python | {
"resource": ""
} |
q258558 | get_last_modified_timestamp | validation | def get_last_modified_timestamp(path, ignore=None):
"""
Recursively finds the most recent timestamp in the given directory.
"""
ignore = ignore or []
if not isinstance(path, six.string_types):
return
ignore_str = ''
if ignore:
assert isinstance(ignore, (tuple, list))
... | python | {
"resource": ""
} |
q258559 | check_settings_for_differences | validation | def check_settings_for_differences(old, new, as_bool=False, as_tri=False):
"""
Returns a subset of the env dictionary keys that differ,
either being added, deleted or changed between old and new.
"""
assert not as_bool or not as_tri
old = old or {}
new = new or {}
changes = set(k for ... | python | {
"resource": ""
} |
q258560 | get_packager | validation | def get_packager():
"""
Returns the packager detected on the remote system.
"""
# TODO: remove once fabric stops using contextlib.nested.
# https://github.com/fabric/fabric/issues/1364
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
common_packager = get_... | python | {
"resource": ""
} |
q258561 | get_os_version | validation | def get_os_version():
"""
Returns a named tuple describing the operating system on the remote host.
"""
# TODO: remove once fabric stops using contextlib.nested.
# https://github.com/fabric/fabric/issues/1364
import warnings
warnings.filterwarnings("ignore", category=DeprecationWarning)
... | python | {
"resource": ""
} |
q258562 | render_to_string | validation | def render_to_string(template, extra=None):
"""
Renders the given template to a string.
"""
from jinja2 import Template
extra = extra or {}
final_fqfn = find_template(template)
assert final_fqfn, 'Template not found: %s' % template
template_content = open(final_fqfn, 'r').read()
t = ... | python | {
"resource": ""
} |
q258563 | render_to_file | validation | def render_to_file(template, fn=None, extra=None, **kwargs):
"""
Returns a template to a local file.
If no filename given, a temporary filename will be generated and returned.
"""
import tempfile
dryrun = get_dryrun(kwargs.get('dryrun'))
append_newline = kwargs.pop('append_newline', True)
... | python | {
"resource": ""
} |
q258564 | install_config | validation | def install_config(local_path=None, remote_path=None, render=True, extra=None, formatter=None):
"""
Returns a template to a remote file.
If no filename given, a temporary filename will be generated and returned.
"""
local_path = find_template(local_path)
if render:
extra = extra or {}
... | python | {
"resource": ""
} |
q258565 | iter_sites | validation | def iter_sites(sites=None, site=None, renderer=None, setter=None, no_secure=False, verbose=None):
"""
Iterates over sites, safely setting environment variables for each site.
"""
if verbose is None:
verbose = get_verbose()
hostname = get_current_hostname()
target_sites = env.available_... | python | {
"resource": ""
} |
q258566 | topological_sort | validation | def topological_sort(source):
"""perform topo sort on elements.
:arg source: list of ``(name, [list of dependancies])`` pairs
:returns: list of names, with dependancies listed first
"""
if isinstance(source, dict):
source = source.items()
pending = sorted([(name, set(deps)) for name, de... | python | {
"resource": ""
} |
q258567 | get_hosts_for_site | validation | def get_hosts_for_site(site=None):
"""
Returns a list of hosts that have been configured to support the given site.
"""
site = site or env.SITE
hosts = set()
for hostname, _sites in six.iteritems(env.available_sites_by_host):
# print('checking hostname:',hostname, _sites)
for _si... | python | {
"resource": ""
} |
q258568 | Renderer.collect_genv | validation | def collect_genv(self, include_local=True, include_global=True):
"""
Returns a copy of the global environment with all the local variables copied back into it.
"""
e = type(self.genv)()
if include_global:
e.update(self.genv)
if include_local:
for k... | python | {
"resource": ""
} |
q258569 | Satchel.capture_bash | validation | def capture_bash(self):
"""
Context manager that hides the command prefix and activates dryrun to capture all following task commands to their equivalent Bash outputs.
"""
class Capture(object):
def __init__(self, satchel):
self.satchel = satchel
... | python | {
"resource": ""
} |
q258570 | Satchel.register | validation | def register(self):
"""
Adds this satchel to the global registeries for fast lookup from other satchels.
"""
self._set_defaults()
all_satchels[self.name.upper()] = self
manifest_recorder[self.name] = self.record_manifest
# Register service commands.
if... | python | {
"resource": ""
} |
q258571 | Satchel.unregister | validation | def unregister(self):
"""
Removes this satchel from global registeries.
"""
for k in list(env.keys()):
if k.startswith(self.env_prefix):
del env[k]
try:
del all_satchels[self.name.upper()]
except KeyError:
pass
... | python | {
"resource": ""
} |
q258572 | Satchel.get_tasks | validation | def get_tasks(self):
"""
Returns an ordered list of all task names.
"""
tasks = set(self.tasks)#DEPRECATED
for _name in dir(self):
# Skip properties so we don't accidentally execute any methods.
if isinstance(getattr(type(self), _name, None), property):
... | python | {
"resource": ""
} |
q258573 | Satchel.local_renderer | validation | def local_renderer(self):
"""
Retrieves the cached local renderer.
"""
if not self._local_renderer:
r = self.create_local_renderer()
self._local_renderer = r
return self._local_renderer | python | {
"resource": ""
} |
q258574 | Satchel.all_other_enabled_satchels | validation | def all_other_enabled_satchels(self):
"""
Returns a dictionary of satchels used in the current configuration, excluding ourselves.
"""
return dict(
(name, satchel)
for name, satchel in self.all_satchels.items()
if name != self.name.upper() and name.low... | python | {
"resource": ""
} |
q258575 | Satchel.lenv | validation | def lenv(self):
"""
Returns a version of env filtered to only include the variables in our namespace.
"""
_env = type(env)()
for _k, _v in six.iteritems(env):
if _k.startswith(self.name+'_'):
_env[_k[len(self.name)+1:]] = _v
return _env | python | {
"resource": ""
} |
q258576 | Satchel.param_changed_to | validation | def param_changed_to(self, key, to_value, from_value=None):
"""
Returns true if the given parameter, with name key, has transitioned to the given value.
"""
last_value = getattr(self.last_manifest, key)
current_value = self.current_manifest.get(key)
if from_value is not N... | python | {
"resource": ""
} |
q258577 | Satchel.reboot_or_dryrun | validation | def reboot_or_dryrun(self, *args, **kwargs):
"""
Reboots the server and waits for it to come back.
"""
warnings.warn('Use self.run() instead.', DeprecationWarning, stacklevel=2)
self.reboot(*args, **kwargs) | python | {
"resource": ""
} |
q258578 | Satchel.set_site_specifics | validation | def set_site_specifics(self, site):
"""
Loads settings for the target site.
"""
r = self.local_renderer
site_data = self.genv.sites[site].copy()
r.env.site = site
if self.verbose:
print('set_site_specifics.data:')
pprint(site_data, indent=4... | python | {
"resource": ""
} |
q258579 | Satchel.get_package_list | validation | def get_package_list(self):
"""
Returns a list of all required packages.
"""
os_version = self.os_version # OS(type=LINUX, distro=UBUNTU, release='14.04')
self.vprint('os_version:', os_version)
# Lookup legacy package list.
# OS: [package1, package2, ...],
... | python | {
"resource": ""
} |
q258580 | Satchel.has_changes | validation | def has_changes(self):
"""
Returns true if at least one tracker detects a change.
"""
lm = self.last_manifest
for tracker in self.get_trackers():
last_thumbprint = lm['_tracker_%s' % tracker.get_natural_key_hash()]
if tracker.is_changed(last_thumbprint):
... | python | {
"resource": ""
} |
q258581 | Satchel.configure | validation | def configure(self):
"""
The standard method called to apply functionality when the manifest changes.
"""
lm = self.last_manifest
for tracker in self.get_trackers():
self.vprint('Checking tracker:', tracker)
last_thumbprint = lm['_tracker_%s' % tracker.get... | python | {
"resource": ""
} |
q258582 | PostgreSQLSatchel.write_pgpass | validation | def write_pgpass(self, name=None, site=None, use_sudo=0, root=0):
"""
Write the file used to store login credentials for PostgreSQL.
"""
r = self.database_renderer(name=name, site=site)
root = int(root)
use_sudo = int(use_sudo)
r.run('touch {pgpass_path}')
... | python | {
"resource": ""
} |
q258583 | PostgreSQLSatchel.dumpload | validation | def dumpload(self, site=None, role=None):
"""
Dumps and loads a database snapshot simultaneously.
Requires that the destination server has direct database access
to the source server.
This is better than a serial dump+load when:
1. The network connection is reliable.
... | python | {
"resource": ""
} |
q258584 | PostgreSQLSatchel.drop_database | validation | def drop_database(self, name):
"""
Delete a PostgreSQL database.
Example::
import burlap
# Remove DB if it exists
if burlap.postgres.database_exists('myapp'):
burlap.postgres.drop_database('myapp')
"""
with settings(warn_onl... | python | {
"resource": ""
} |
q258585 | PostgreSQLSatchel.load_table | validation | def load_table(self, table_name, src, dst='localhost', name=None, site=None):
"""
Directly transfers a table between two databases.
"""
#TODO: incomplete
r = self.database_renderer(name=name, site=site)
r.env.table_name = table_name
r.run('psql --user={dst_db_user... | python | {
"resource": ""
} |
q258586 | interfaces | validation | def interfaces():
"""
Get the list of network interfaces. Will return all datalinks on SmartOS.
"""
with settings(hide('running', 'stdout')):
if is_file('/usr/sbin/dladm'):
res = run('/usr/sbin/dladm show-link')
else:
res = sudo('/sbin/ifconfig -s')
return [li... | python | {
"resource": ""
} |
q258587 | address | validation | def address(interface):
"""
Get the IPv4 address assigned to an interface.
Example::
import burlap
# Print all configured IP addresses
for interface in burlap.network.interfaces():
print(burlap.network.address(interface))
"""
with settings(hide('running', 'std... | python | {
"resource": ""
} |
q258588 | PackagerSatchel.update | validation | def update(self):
"""
Preparse the packaging system for installations.
"""
packager = self.packager
if packager == APT:
self.sudo('DEBIAN_FRONTEND=noninteractive apt-get -yq update')
elif packager == YUM:
self.sudo('yum update')
else:
... | python | {
"resource": ""
} |
q258589 | PackagerSatchel.install_apt | validation | def install_apt(self, fn=None, package_name=None, update=0, list_only=0):
"""
Installs system packages listed in apt-requirements.txt.
"""
r = self.local_renderer
assert self.genv[ROLE]
apt_req_fqfn = fn or (self.env.apt_requirments_fn and self.find_template(self.env.apt_... | python | {
"resource": ""
} |
q258590 | PackagerSatchel.install_yum | validation | def install_yum(self, fn=None, package_name=None, update=0, list_only=0):
"""
Installs system packages listed in yum-requirements.txt.
"""
assert self.genv[ROLE]
yum_req_fn = fn or self.find_template(self.genv.yum_requirments_fn)
if not yum_req_fn:
return []
... | python | {
"resource": ""
} |
q258591 | PackagerSatchel.list_required | validation | def list_required(self, type=None, service=None): # pylint: disable=redefined-builtin
"""
Displays all packages required by the current role
based on the documented services provided.
"""
from burlap.common import (
required_system_packages,
required_pytho... | python | {
"resource": ""
} |
q258592 | PackagerSatchel.install_required | validation | def install_required(self, type=None, service=None, list_only=0, **kwargs): # pylint: disable=redefined-builtin
"""
Installs system packages listed as required by services this host uses.
"""
r = self.local_renderer
list_only = int(list_only)
type = (type or '').lower().s... | python | {
"resource": ""
} |
q258593 | PackagerSatchel.uninstall_blacklisted | validation | def uninstall_blacklisted(self):
"""
Uninstalls all blacklisted packages.
"""
from burlap.system import distrib_family
blacklisted_packages = self.env.blacklisted_packages
if not blacklisted_packages:
print('No blacklisted packages.')
return
... | python | {
"resource": ""
} |
q258594 | CronSatchel.deploy | validation | def deploy(self, site=None):
"""
Writes entire crontab to the host.
"""
r = self.local_renderer
self.deploy_logrotate()
cron_crontabs = []
# if self.verbose:
# print('hostname: "%s"' % (hostname,), file=sys.stderr)
for _site, site_data in sel... | python | {
"resource": ""
} |
q258595 | RabbitMQSatchel.force_stop_and_purge | validation | def force_stop_and_purge(self):
"""
Forcibly kills Rabbit and purges all its queues.
For emergency use when the server becomes unresponsive, even to service stop calls.
If this also fails to correct the performance issues, the server may have to be completely
reinstalled.
... | python | {
"resource": ""
} |
q258596 | RabbitMQSatchel._configure_users | validation | def _configure_users(self, site=None, full=0, only_data=0):
"""
Installs and configures RabbitMQ.
"""
site = site or ALL
full = int(full)
if full and not only_data:
packager = self.get_satchel('packager')
packager.install_required(type=SYSTEM, s... | python | {
"resource": ""
} |
q258597 | iter_dict_differences | validation | def iter_dict_differences(a, b):
"""
Returns a generator yielding all the keys that have values that differ between each dictionary.
"""
common_keys = set(a).union(b)
for k in common_keys:
a_value = a.get(k)
b_value = b.get(k)
if a_value != b_value:
yield k, (a_va... | python | {
"resource": ""
} |
q258598 | get_component_order | validation | def get_component_order(component_names):
"""
Given a list of components, re-orders them according to inter-component dependencies so the most depended upon are first.
"""
assert isinstance(component_names, (tuple, list))
component_dependences = {}
for _name in component_names:
deps = se... | python | {
"resource": ""
} |
q258599 | get_deploy_funcs | validation | def get_deploy_funcs(components, current_thumbprint, previous_thumbprint, preview=False):
"""
Returns a generator yielding the named functions needed for a deployment.
"""
for component in components:
funcs = manifest_deployers.get(component, [])
for func_name in funcs:
#TOD... | python | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.