INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Helper that can be used inside a state SLS in order to get the filter configuration given its name. | def get_filter_pillar(filter_name,
pillar_key='acl',
pillarenv=None,
saltenv=None):
'''
Helper that can be used inside a state SLS,
in order to get the filter configuration given its name.
filter_name
The name of the filter.
... |
Helper that can be used inside a state SLS in order to get the term configuration given its name under a certain filter uniquely identified by its name. | def get_term_pillar(filter_name,
term_name,
pillar_key='acl',
pillarenv=None,
saltenv=None):
'''
Helper that can be used inside a state SLS,
in order to get the term configuration given its name,
under a certain filter uniqu... |
Execute the salt call! | def run(self):
'''
Execute the salt call!
'''
self.parse_args()
if self.options.file_root:
# check if the argument is pointing to a file on disk
file_root = os.path.abspath(self.options.file_root)
self.config['file_roots'] = {'base': _expand_g... |
Add content to a document generated using highstate_doc. render. | def note(name, source=None, contents=None, **kwargs):
'''
Add content to a document generated using `highstate_doc.render`.
This state does not preform any tasks on the host. It only is used in highstate_doc lowstate proccessers
to include extra documents.
.. code-block:: yaml
{{sls}} exa... |
.. versionadded:: 2017. 7. 0 | def available(software=True,
drivers=True,
summary=False,
skip_installed=True,
skip_hidden=True,
skip_mandatory=False,
skip_reboot=False,
categories=None,
severities=None,):
'''
.. versionadded:: 2017... |
.. versionadded:: 2017. 7. 0 | def get(name, download=False, install=False):
'''
.. versionadded:: 2017.7.0
Returns details for the named update
Args:
name (str):
The name of the update you're searching for. This can be the GUID, a
KB number, or any part of the name of the update. GUIDs and KBs are
... |
.. versionadded:: 2017. 7. 0 | def list(software=True,
drivers=False,
summary=False,
skip_installed=True,
categories=None,
severities=None,
download=False,
install=False):
'''
.. versionadded:: 2017.7.0
Returns a detailed list of available updates or a summary. If download o... |
.. versionadded:: 2017. 7. 0 | def download(names):
'''
.. versionadded:: 2017.7.0
Downloads updates that match the list of passed identifiers. It's easier to
use this function by using list_updates and setting install=True.
Args:
names (str, list):
A single update or a list of updates to download. This can... |
.. versionadded:: 2017. 7. 0 | def uninstall(names):
'''
.. versionadded:: 2017.7.0
Uninstall updates.
Args:
names (str, list):
A single update or a list of updates to uninstall. This can be any
combination of GUIDs, KB numbers, or names. GUIDs or KBs are
preferred.
Returns:
... |
Change Windows Update settings. If no parameters are passed the current value will be returned. | def set_wu_settings(level=None,
recommended=None,
featured=None,
elevated=None,
msupdate=None,
day=None,
time=None):
'''
Change Windows Update settings. If no parameters are passed, the curren... |
Get current Windows Update settings. | def get_wu_settings():
'''
Get current Windows Update settings.
Returns:
dict: A dictionary of Windows Update settings:
Featured Updates:
Boolean value that indicates whether to display notifications for
featured updates.
Group Policy Required (Read-only):
... |
Check to see if Microsoft Update is Enabled Return Boolean | def _get_msupdate_status():
'''
Check to see if Microsoft Update is Enabled
Return Boolean
'''
# To get the status of Microsoft Update we actually have to check the
# Microsoft Update Service Manager
# Initialize the PyCom system
with salt.utils.winapi.Com():
# Create a ServiceMa... |
Get metadata about an S3 object. Returns None if the object does not exist. | def get_object_metadata(
name,
extra_args=None,
region=None,
key=None,
keyid=None,
profile=None,
):
'''
Get metadata about an S3 object.
Returns None if the object does not exist.
You can pass AWS SSE-C related args and/or RequestPayer in extra_args.
CLI Example:
.. co... |
Upload a local file as an S3 object. | def upload_file(
source,
name,
extra_args=None,
region=None,
key=None,
keyid=None,
profile=None,
):
'''
Upload a local file as an S3 object.
CLI Example:
.. code-block:: bash
salt myminion boto_s3.upload_file \\
/path/to/local/file \\
... |
Decorator for adding profiling to a nested function in Salt | def profile_func(filename=None):
'''
Decorator for adding profiling to a nested function in Salt
'''
def proffunc(fun):
def profiled_func(*args, **kwargs):
logging.info('Profiling function %s', fun.__name__)
try:
profiler = cProfile.Profile()
... |
Return the django admin | def _get_django_admin(bin_env):
'''
Return the django admin
'''
if not bin_env:
if salt.utils.path.which('django-admin.py'):
return 'django-admin.py'
elif salt.utils.path.which('django-admin'):
return 'django-admin'
else:
raise salt.exceptions.... |
Run arbitrary django management command | def command(settings_module,
command,
bin_env=None,
pythonpath=None,
env=None,
runas=None,
*args, **kwargs):
'''
Run arbitrary django management command
CLI Example:
.. code-block:: bash
salt '*' django.command <settings_... |
Run syncdb | def syncdb(settings_module,
bin_env=None,
migrate=False,
database=None,
pythonpath=None,
env=None,
noinput=True,
runas=None):
'''
Run syncdb
Execute the Django-Admin syncdb command, if South is available on the
minion the ``mi... |
Run migrate | def migrate(settings_module,
app_label=None,
migration_name=None,
bin_env=None,
database=None,
pythonpath=None,
env=None,
noinput=True,
runas=None):
'''
Run migrate
Execute the Django-Admin migrate command (requires Dja... |
Create a super user for the database. This function defaults to use the -- noinput flag which prevents the creation of a password for the superuser. | def createsuperuser(settings_module,
username,
email,
bin_env=None,
database=None,
pythonpath=None,
env=None,
runas=None):
'''
Create a super user for the database.
Thi... |
Load fixture data | def loaddata(settings_module,
fixtures,
bin_env=None,
database=None,
pythonpath=None,
env=None):
'''
Load fixture data
Fixtures:
comma separated list of fixtures to load
CLI Example:
.. code-block:: bash
salt '*' dj... |
Collect static files from each of your applications into a single location that can easily be served in production. | def collectstatic(settings_module,
bin_env=None,
no_post_process=False,
ignore=None,
dry_run=False,
clear=False,
link=False,
no_default_ignore=False,
pythonpath=None,
... |
Grant the requested privilege ( s ) on the specified object to a role | def present(name,
object_name,
object_type,
defprivileges=None,
grant_option=None,
prepend='public',
maintenance_db=None,
user=None,
db_password=None,
db_host=None,
db_port=None,
db_user=N... |
List configured exports | def list_exports(exports='/etc/exports'):
'''
List configured exports
CLI Example:
.. code-block:: bash
salt '*' nfs.list_exports
'''
ret = {}
with salt.utils.files.fopen(exports, 'r') as efl:
for line in salt.utils.stringutils.to_unicode(efl.read()).splitlines():
... |
Remove an export | def del_export(exports='/etc/exports', path=None):
'''
Remove an export
CLI Example:
.. code-block:: bash
salt '*' nfs.del_export /media/storage
'''
edict = list_exports(exports)
del edict[path]
_write_exports(exports, edict)
return edict |
Add an export | def add_export(exports='/etc/exports', path=None, hosts=None, options=None):
'''
Add an export
CLI Example:
.. code-block:: bash
salt '*' nfs3.add_export path='/srv/test' hosts='127.0.0.1' options=['rw']
'''
if options is None:
options = []
if not isinstance(hosts, six.str... |
Write an exports file to disk | def _write_exports(exports, edict):
'''
Write an exports file to disk
If multiple shares were initially configured per line, like:
/media/storage /media/data *(ro,sync,no_subtree_check)
...then they will be saved to disk with only one share per line:
/media/storage *(ro,sync,no_subtr... |
Trigger a reload of the exports file to apply changes | def reload_exports():
'''
Trigger a reload of the exports file to apply changes
CLI Example:
.. code-block:: bash
salt '*' nfs3.reload_exports
'''
ret = {}
command = 'exportfs -r'
output = __salt__['cmd.run_all'](command)
ret['stdout'] = output['stdout']
ret['stderr'... |
.. versionchanged:: 2018. 3. 0 The tag argument has been added. It is now required unless pulling from a registry. | def present(name,
tag=None,
build=None,
load=None,
force=False,
insecure_registry=False,
client_timeout=salt.utils.docker.CLIENT_TIMEOUT,
dockerfile=None,
sls=None,
base='opensuse/python',
saltenv='ba... |
Ensure that an image is absent from the Minion. Image names can be specified either using repo: tag notation or just the repo name ( in which case a tag of latest is assumed ). | def absent(name=None, images=None, force=False):
'''
Ensure that an image is absent from the Minion. Image names can be
specified either using ``repo:tag`` notation, or just the repo name (in
which case a tag of ``latest`` is assumed).
images
Run this state on more than one image at a time.... |
The docker_image watcher called to invoke the watch command. | def mod_watch(name, sfun=None, **kwargs):
'''
The docker_image watcher, called to invoke the watch command.
.. note::
This state exists to support special handling of the ``watch``
:ref:`requisite <requisites>`. It should not be called directly.
Parameters for this function should... |
Render a Genshi template. A method should be passed in as part of the kwargs. If no method is passed in xml is assumed. Valid methods are: | def render(genshi_data, saltenv='base', sls='', method='xml', **kws):
'''
Render a Genshi template. A method should be passed in as part of the
kwargs. If no method is passed in, xml is assumed. Valid methods are:
.. code-block:
- xml
- xhtml
- html
- text
- new... |
Display ret data | def output(ret, **kwargs):
'''
Display ret data
'''
# Prefer kwargs before opts
retcode = kwargs.get('_retcode', 0)
base_indent = kwargs.get('nested_indent', 0) \
or __opts__.get('nested_indent', 0)
nest = NestDisplay(retcode=retcode)
lines = nest.display(ret, base_indent, '', []... |
Recursively iterate down through data structures to determine output | def display(self, ret, indent, prefix, out):
'''
Recursively iterate down through data structures to determine output
'''
if isinstance(ret, bytes):
try:
ret = salt.utils.stringutils.to_unicode(ret)
except UnicodeDecodeError:
# ret ... |
Reads and returns the contents of a text file | def _read_file(path):
'''
Reads and returns the contents of a text file
'''
try:
with salt.utils.files.fopen(path, 'rb') as contents:
return salt.utils.yaml.safe_load(contents)
except (OSError, IOError):
return {} |
Write the mount cache file. | def write_cache(cache, opts):
'''
Write the mount cache file.
'''
cache_file = get_cache(opts)
try:
_cache = salt.utils.stringutils.to_bytes(
salt.utils.yaml.safe_dump(cache)
)
with salt.utils.files.fopen(cache_file, 'wb+') as fp_:
fp_.write(_cache)
... |
Returns the diff of two text blobs. | def _get_diff_text(old, new):
'''
Returns the diff of two text blobs.
'''
diff = difflib.unified_diff(old.splitlines(1),
new.splitlines(1))
return ''.join([x.replace('\r', '') for x in diff]) |
Return the config as text from a config tree. | def _print_config_text(tree, indentation=0):
'''
Return the config as text from a config tree.
'''
config = ''
for key, value in six.iteritems(tree):
config += '{indent}{line}\n'.format(indent=' '*indentation, line=key)
if value:
config += _print_config_text(value, indent... |
Transform Cisco IOS style configuration to structured Python dictionary. Depending on the value of the with_tags argument this function may provide different views valuable in different situations. | def tree(config=None,
path=None,
with_tags=False,
saltenv='base'):
'''
Transform Cisco IOS style configuration to structured Python dictionary.
Depending on the value of the ``with_tags`` argument, this function may
provide different views, valuable in different situations.
... |
Return a clean version of the config without any special signs ( such as ! as an individual line ) or empty lines but just lines with significant value in the configuration of the network device. | def clean(config=None, path=None, saltenv='base'):
'''
Return a clean version of the config, without any special signs (such as
``!`` as an individual line) or empty lines, but just lines with significant
value in the configuration of the network device.
config
The configuration sent as tex... |
Return the merge tree of the initial_config with the merge_config as a Python dictionary. | def merge_tree(initial_config=None,
initial_path=None,
merge_config=None,
merge_path=None,
saltenv='base'):
'''
Return the merge tree of the ``initial_config`` with the ``merge_config``,
as a Python dictionary.
initial_config
The initi... |
Return the merge result of the initial_config with the merge_config as plain text. | def merge_text(initial_config=None,
initial_path=None,
merge_config=None,
merge_path=None,
saltenv='base'):
'''
Return the merge result of the ``initial_config`` with the ``merge_config``,
as plain text.
initial_config
The initial conf... |
Return the merge diff as text after merging the merge config into the initial config. | def merge_diff(initial_config=None,
initial_path=None,
merge_config=None,
merge_path=None,
saltenv='base'):
'''
Return the merge diff, as text, after merging the merge config into the
initial config.
initial_config
The initial configur... |
Return the diff as Python dictionary between the candidate and the running configuration. | def diff_tree(candidate_config=None,
candidate_path=None,
running_config=None,
running_path=None,
saltenv='base'):
'''
Return the diff, as Python dictionary, between the candidate and the running
configuration.
candidate_config
The candida... |
Return the diff as text between the candidate and the running config. | def diff_text(candidate_config=None,
candidate_path=None,
running_config=None,
running_path=None,
saltenv='base'):
'''
Return the diff, as text, between the candidate and the running config.
candidate_config
The candidate configuration sent as... |
Show an item via pcs command ( mainly for use with the pcs state module ) | def item_show(item, item_id=None, item_type=None, show='show', extra_args=None, cibfile=None):
'''
Show an item via pcs command
(mainly for use with the pcs state module)
item
config, property, resource, constraint etc.
item_id
id of the item
item_type
item type
show... |
Create an item via pcs command ( mainly for use with the pcs state module ) | def item_create(item, item_id, item_type, create='create', extra_args=None, cibfile=None):
'''
Create an item via pcs command
(mainly for use with the pcs state module)
item
config, property, resource, constraint etc.
item_id
id of the item
item_type
item type
create... |
Authorize nodes to the cluster | def auth(nodes, pcsuser='hacluster', pcspasswd='hacluster', extra_args=None):
'''
Authorize nodes to the cluster
nodes
a list of nodes which should be authorized to the cluster
pcsuser
user for communitcation with PCS (default: hacluster)
pcspasswd
password for pcsuser (defa... |
Check if nodes are already authorized | def is_auth(nodes):
'''
Check if nodes are already authorized
nodes
a list of nodes to be checked for authorization to the cluster
CLI Example:
.. code-block:: bash
salt '*' pcs.is_auth nodes='[node1.example.org node2.example.org]'
'''
cmd = ['pcs', 'cluster', 'auth']
... |
Setup pacemaker cluster via pcs command | def cluster_setup(nodes, pcsclustername='pcscluster', extra_args=None):
'''
Setup pacemaker cluster via pcs command
nodes
a list of nodes which should be set up
pcsclustername
Name of the Pacemaker cluster (default: pcscluster)
extra_args
list of extra option for the \'pcs c... |
Add a node to the pacemaker cluster via pcs command | def cluster_node_add(node, extra_args=None):
'''
Add a node to the pacemaker cluster via pcs command
node
node that should be added
extra_args
list of extra option for the \'pcs cluster node add\' command
CLI Example:
.. code-block:: bash
salt '*' pcs.cluster_node_add... |
Create a CIB - file from the current CIB of the cluster | def cib_create(cibfile, scope='configuration', extra_args=None):
'''
Create a CIB-file from the current CIB of the cluster
cibfile
name/path of the file containing the CIB
scope
specific section of the CIB (default: configuration)
extra_args
additional options for creating t... |
Show the value of a cluster property | def prop_show(prop, extra_args=None, cibfile=None):
'''
Show the value of a cluster property
prop
name of the property
extra_args
additional options for the pcs property command
cibfile
use cibfile instead of the live CIB
CLI Example:
.. code-block:: bash
... |
Set the value of a cluster property | def prop_set(prop, value, extra_args=None, cibfile=None):
'''
Set the value of a cluster property
prop
name of the property
value
value of the property prop
extra_args
additional options for the pcs property command
cibfile
use cibfile instead of the live CIB
... |
Show the value of a cluster stonith | def stonith_show(stonith_id, extra_args=None, cibfile=None):
'''
Show the value of a cluster stonith
stonith_id
name for the stonith resource
extra_args
additional options for the pcs stonith command
cibfile
use cibfile instead of the live CIB
CLI Example:
.. code-... |
Create a stonith resource via pcs command | def stonith_create(stonith_id, stonith_device_type, stonith_device_options=None, cibfile=None):
'''
Create a stonith resource via pcs command
stonith_id
name for the stonith resource
stonith_device_type
name of the stonith agent fence_eps, fence_xvm f.e.
stonith_device_options
... |
Show a resource via pcs command | def resource_show(resource_id, extra_args=None, cibfile=None):
'''
Show a resource via pcs command
resource_id
name of the resource
extra_args
additional options for the pcs command
cibfile
use cibfile instead of the live CIB
CLI Example:
.. code-block:: bash
... |
Create a resource via pcs command | def resource_create(resource_id, resource_type, resource_options=None, cibfile=None):
'''
Create a resource via pcs command
resource_id
name for the resource
resource_type
resource type (f.e. ocf:heartbeat:IPaddr2 or VirtualIP)
resource_options
additional options for creatin... |
Wrap text to the required dimensions and clean it up prepare for display. | def wrap(txt, width=80, ident=0):
'''
Wrap text to the required dimensions and clean it up, prepare for display.
:param txt:
:param width:
:return:
'''
ident = ' ' * ident
txt = (txt or '').replace(os.linesep, ' ').strip()
wrapper = textwrap.TextWrapper()
wrapper.fix_sentence_e... |
Print message with an indent. | def put(self, message, indent=0):
'''
Print message with an indent.
:param message:
:param indent:
:return:
'''
color = self._colors_conf.get(indent + indent % 2, self._colors_conf.get(0, self._default_color))
for chunk in [' ' * indent, self._colors[col... |
Hint message. | def msg(self, message, title=None, title_color=None, color='BLUE', ident=0):
'''
Hint message.
:param message:
:param title:
:param title_color:
:param color:
:param ident:
:return:
'''
if title and not title_color:
title_color... |
Highlighter works the way that message parameter is a template the values is a list of arguments going one after another as values there. And so the colors should designate either highlight color or alternate for each. | def highlight(self, message, *values, **colors):
'''
Highlighter works the way that message parameter is a template,
the "values" is a list of arguments going one after another as values there.
And so the "colors" should designate either highlight color or alternate for each.
Ex... |
Decorator to ensure that the named container exists. | def _ensure_exists(wrapped):
'''
Decorator to ensure that the named container exists.
'''
@functools.wraps(wrapped)
def check_exists(name, *args, **kwargs):
if not exists(name):
raise CommandExecutionError(
'Container \'{0}\' does not exist'.format(name)
... |
Return the container root directory. Starting with systemd 219 new images go into/ var/ lib/ machines. | def _root(name='', all_roots=False):
'''
Return the container root directory. Starting with systemd 219, new
images go into /var/lib/machines.
'''
if _sd_version() >= 219:
if all_roots:
return [os.path.join(x, name)
for x in ('/var/lib/machines', '/var/lib/con... |
Make the container root directory | def _make_container_root(name):
'''
Make the container root directory
'''
path = _root(name)
if os.path.exists(path):
__context__['retcode'] = salt.defaults.exitcodes.SALT_BUILD_FAIL
raise CommandExecutionError(
'Container {0} already exists'.format(name)
)
el... |
Bootstrap an Arch Linux container | def _bootstrap_arch(name, **kwargs):
'''
Bootstrap an Arch Linux container
'''
if not salt.utils.path.which('pacstrap'):
raise CommandExecutionError(
'pacstrap not found, is the arch-install-scripts package '
'installed?'
)
dst = _make_container_root(name)
... |
Bootstrap a Debian Linux container | def _bootstrap_debian(name, **kwargs):
'''
Bootstrap a Debian Linux container
'''
version = kwargs.get('version', False)
if not version:
if __grains__['os'].lower() == 'debian':
version = __grains__['osrelease']
else:
version = 'stable'
release_blacklist ... |
Bootstrap a Fedora container | def _bootstrap_fedora(name, **kwargs):
'''
Bootstrap a Fedora container
'''
dst = _make_container_root(name)
if not kwargs.get('version', False):
if __grains__['os'].lower() == 'fedora':
version = __grains__['osrelease']
else:
version = '21'
else:
... |
Raises an exception if the systemd version is not greater than the passed version. | def _ensure_systemd(version):
'''
Raises an exception if the systemd version is not greater than the
passed version.
'''
try:
version = int(version)
except ValueError:
raise CommandExecutionError('Invalid version \'{0}\''.format(version))
try:
installed = _sd_version... |
Helper function to run machinectl | def _machinectl(cmd,
output_loglevel='debug',
ignore_retcode=False,
use_vt=False):
'''
Helper function to run machinectl
'''
prefix = 'machinectl --no-legend --no-pager'
return __salt__['cmd.run_all']('{0} {1}'.format(prefix, cmd),
... |
Common logic for nspawn. run functions | def _run(name,
cmd,
output=None,
no_start=False,
stdin=None,
python_shell=True,
preserve_state=False,
output_loglevel='debug',
ignore_retcode=False,
use_vt=False,
keep_env=None):
'''
Common logic for nspawn.run functions
... |
Returns the PID of a container | def pid(name):
'''
Returns the PID of a container
name
Container name
CLI Example:
.. code-block:: bash
salt myminion nspawn.pid arch1
'''
try:
return int(info(name).get('PID'))
except (TypeError, ValueError) as exc:
raise CommandExecutionError(
... |
Bootstrap a container from package servers if dist is None the os the minion is running as will be created otherwise the needed bootstrapping tools will need to be available on the host. | def bootstrap_container(name, dist=None, version=None):
'''
Bootstrap a container from package servers, if dist is None the os the
minion is running as will be created, otherwise the needed bootstrapping
tools will need to be available on the host.
CLI Example:
.. code-block:: bash
sa... |
Bootstrap a container from package servers if dist is None the os the minion is running as will be created otherwise the needed bootstrapping tools will need to be available on the host. | def bootstrap_salt(name,
config=None,
approve_key=True,
install=True,
pub_key=None,
priv_key=None,
bootstrap_url=None,
force_install=False,
unconditional_install=False,... |
Lists all nspawn containers | def list_all():
'''
Lists all nspawn containers
CLI Example:
.. code-block:: bash
salt myminion nspawn.list_all
'''
ret = []
if _sd_version() >= 219:
for line in _machinectl('list-images')['stdout'].splitlines():
try:
ret.append(line.split()[0])... |
Lists running nspawn containers | def list_running():
'''
Lists running nspawn containers
.. note::
``nspawn.list`` also works to list running containers
CLI Example:
.. code-block:: bash
salt myminion nspawn.list_running
salt myminion nspawn.list
'''
ret = []
for line in _machinectl('list')[... |
Returns true if the named container exists | def exists(name):
'''
Returns true if the named container exists
CLI Example:
.. code-block:: bash
salt myminion nspawn.exists <name>
'''
contextkey = 'nspawn.exists.{0}'.format(name)
if contextkey in __context__:
return __context__[contextkey]
__context__[contextkey] ... |
Return state of container ( running or stopped ) | def state(name):
'''
Return state of container (running or stopped)
CLI Example:
.. code-block:: bash
salt myminion nspawn.state <name>
'''
try:
cmd = 'show {0} --property=State'.format(name)
return _machinectl(cmd, ignore_retcode=True)['stdout'].split('=')[-1]
exc... |
Return info about a container | def info(name, **kwargs):
'''
Return info about a container
.. note::
The container must be running for ``machinectl`` to gather information
about it. If the container is stopped, then this function will start
it.
start : False
If ``True``, then the container will be s... |
Set the named container to be launched at boot | def enable(name):
'''
Set the named container to be launched at boot
CLI Example:
.. code-block:: bash
salt myminion nspawn.enable <name>
'''
cmd = 'systemctl enable systemd-nspawn@{0}'.format(name)
if __salt__['cmd.retcode'](cmd, python_shell=False) != 0:
__context__['ret... |
Start the named container | def start(name):
'''
Start the named container
CLI Example:
.. code-block:: bash
salt myminion nspawn.start <name>
'''
if _sd_version() >= 219:
ret = _machinectl('start {0}'.format(name))
else:
cmd = 'systemctl start systemd-nspawn@{0}'.format(name)
ret = _... |
This is a compatibility function which provides the logic for nspawn. poweroff and nspawn. terminate. | def stop(name, kill=False):
'''
This is a compatibility function which provides the logic for
nspawn.poweroff and nspawn.terminate.
'''
if _sd_version() >= 219:
if kill:
action = 'terminate'
else:
action = 'poweroff'
ret = _machinectl('{0} {1}'.format(... |
Reboot the container by sending a SIGINT to its init process. Equivalent to running machinectl reboot on the named container. | def reboot(name, kill=False):
'''
Reboot the container by sending a SIGINT to its init process. Equivalent
to running ``machinectl reboot`` on the named container.
For convenience, running ``nspawn.restart`` (as shown in the CLI examples
below) is equivalent to running ``nspawn.reboot``.
.. no... |
Remove the named container | def remove(name, stop=False):
'''
Remove the named container
.. warning::
This function will remove all data associated with the container. It
will not, however, remove the btrfs subvolumes created by pulling
container images (:mod:`nspawn.pull_raw
<salt.modules.nspawn.pull... |
Copy a file from the host into a container | def copy_to(name, source, dest, overwrite=False, makedirs=False):
'''
Copy a file from the host into a container
name
Container name
source
File to be copied to the container
dest
Destination on the container. Must be an absolute path.
overwrite : False
Unless... |
Common logic for machinectl pull - * commands | def _pull_image(pull_type, image, name, **kwargs):
'''
Common logic for machinectl pull-* commands
'''
_ensure_systemd(219)
if exists(name):
raise SaltInvocationError(
'Container \'{0}\' already exists'.format(name)
)
if pull_type in ('raw', 'tar'):
valid_kwar... |
Execute a machinectl pull - raw to download a. qcow2 or raw disk image and add it to/ var/ lib/ machines as a new container. | def pull_raw(url, name, verify=False):
'''
Execute a ``machinectl pull-raw`` to download a .qcow2 or raw disk image,
and add it to /var/lib/machines as a new container.
.. note::
**Requires systemd >= 219**
url
URL from which to download the container
name
Name for th... |
Execute a machinectl pull - raw to download a. tar container image and add it to/ var/ lib/ machines as a new container. | def pull_tar(url, name, verify=False):
'''
Execute a ``machinectl pull-raw`` to download a .tar container image,
and add it to /var/lib/machines as a new container.
.. note::
**Requires systemd >= 219**
url
URL from which to download the container
name
Name for the ne... |
Prepares the ACL returned from the AWS API for comparison with a given one. | def _prep_acl_for_compare(ACL):
'''
Prepares the ACL returned from the AWS API for comparison with a given one.
'''
ret = copy.deepcopy(ACL)
ret['Owner'] = _normalize_user(ret['Owner'])
for item in ret.get('Grants', ()):
item['Grantee'] = _normalize_user(item.get('Grantee'))
return r... |
ACLs can be specified using macro - style names that get expanded to something more complex. There s no predictable way to reverse it. So expand all syntactic sugar in our input and compare against that rather than the input itself. | def _compare_acl(current, desired, region, key, keyid, profile):
'''
ACLs can be specified using macro-style names that get expanded to
something more complex. There's no predictable way to reverse it.
So expand all syntactic sugar in our input, and compare against that
rather than the input itself.... |
Replication accepts a non - ARN role name but always returns an ARN | def _compare_replication(current, desired, region, key, keyid, profile):
'''
Replication accepts a non-ARN role name, but always returns an ARN
'''
if desired is not None and desired.get('Role'):
desired = copy.deepcopy(desired)
desired['Role'] = _get_role_arn(desired['Role'],
... |
Ensure bucket exists. | def present(name, Bucket,
LocationConstraint=None,
ACL=None,
CORSRules=None,
LifecycleConfiguration=None,
Logging=None,
NotificationConfiguration=None,
Policy=None,
Replication=None,
RequestPayment=None,
... |
Looks to see if pkgin is present on the system return full path | def _check_pkgin():
'''
Looks to see if pkgin is present on the system, return full path
'''
ppath = salt.utils.path.which('pkgin')
if ppath is None:
# pkgin was not found in $PATH, try to find it via LOCALBASE
try:
localbase = __salt__['cmd.run'](
'pkg_inf... |
Get the pkgin version | def _get_version():
'''
Get the pkgin version
'''
version_string = __salt__['cmd.run'](
[_check_pkgin(), '-v'],
output_loglevel='trace')
if version_string is None:
# Dunno why it would, but...
return False
version_match = VERSION_MATCH.search(version_string)
... |
Searches for an exact match using pkgin ^package$ | def search(pkg_name, **kwargs):
'''
Searches for an exact match using pkgin ^package$
CLI Example:
.. code-block:: bash
salt '*' pkg.search 'mysql-server'
'''
pkglist = {}
pkgin = _check_pkgin()
if not pkgin:
return pkglist
if _supports_regex():
pkg_name ... |
Use pkg update to get latest pkg_summary | def refresh_db(force=False, **kwargs):
'''
Use pkg update to get latest pkg_summary
force
Pass -f so that the cache is always refreshed.
.. versionadded:: 2018.3.0
CLI Example:
.. code-block:: bash
salt '*' pkg.refresh_db
'''
# Remove rtag file to keep multiple ... |
.. versionchanged: 2016. 3. 0 | def list_pkgs(versions_as_list=False, **kwargs):
'''
.. versionchanged: 2016.3.0
List the packages currently installed as a dict::
{'<package_name>': '<version>'}
CLI Example:
.. code-block:: bash
salt '*' pkg.list_pkgs
'''
versions_as_list = salt.utils.data.is_true(vers... |
List all available package upgrades. | def list_upgrades(refresh=True, **kwargs):
'''
List all available package upgrades.
.. versionadded:: 2018.3.0
refresh
Whether or not to refresh the package database before installing.
CLI Example:
.. code-block:: bash
salt '*' pkg.list_upgrades
'''
pkgs = {}
for... |
Install the passed package | def install(name=None, refresh=False, fromrepo=None,
pkgs=None, sources=None, **kwargs):
'''
Install the passed package
name
The name of the package to be installed.
refresh
Whether or not to refresh the package database before installing.
fromrepo
Specify a pa... |
Run pkg upgrade if pkgin used. Otherwise do nothing | def upgrade(refresh=True, pkgs=None, **kwargs):
'''
Run pkg upgrade, if pkgin used. Otherwise do nothing
refresh
Whether or not to refresh the package database before installing.
Multiple Package Upgrade Options:
pkgs
A list of packages to upgrade from a software repository. Must ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.