repository_name stringclasses 316
values | func_path_in_repository stringlengths 6 223 | func_name stringlengths 1 134 | language stringclasses 1
value | func_code_string stringlengths 57 65.5k | func_documentation_string stringlengths 1 46.3k | split_name stringclasses 1
value | func_code_url stringlengths 91 315 | called_functions listlengths 1 156 ⌀ | enclosing_scope stringlengths 2 1.48M |
|---|---|---|---|---|---|---|---|---|---|
saltstack/salt | salt/modules/panos.py | get_uncommitted_changes | python | def get_uncommitted_changes():
'''
Retrieve a list of all uncommitted changes on the device.
Requires PANOS version 8.0.0 or greater.
CLI Example:
.. code-block:: bash
salt '*' panos.get_uncommitted_changes
'''
_required_version = '8.0.0'
if not __proxy__['panos.is_required_v... | Retrieve a list of all uncommitted changes on the device.
Requires PANOS version 8.0.0 or greater.
CLI Example:
.. code-block:: bash
salt '*' panos.get_uncommitted_changes | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L1260-L1279 | null | # -*- coding: utf-8 -*-
'''
Module to provide Palo Alto compatibility to Salt
:codeauthor: ``Spencer Ervin <spencer_ervin@hotmail.com>``
:maturity: new
:depends: none
:platform: unix
.. versionadded:: 2018.3.0
Configuration
=============
This module accepts connection configuration details either as
paramete... |
saltstack/salt | salt/modules/panos.py | install_antivirus | python | def install_antivirus(version=None, latest=False, synch=False, skip_commit=False,):
'''
Install anti-virus packages.
Args:
version(str): The version of the PANOS file to install.
latest(bool): If true, the latest anti-virus file will be installed.
The specified versio... | Install anti-virus packages.
Args:
version(str): The version of the PANOS file to install.
latest(bool): If true, the latest anti-virus file will be installed.
The specified version option will be ignored.
synch(bool): If true, the anti-virus will synch to the peer u... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L1382-L1427 | [
"def _get_job_results(query=None):\n '''\n Executes a query that requires a job for completion. This function will wait for the job to complete\n and return the results.\n '''\n if not query:\n raise CommandExecutionError(\"Query parameters cannot be empty.\")\n\n response = __proxy__['pano... | # -*- coding: utf-8 -*-
'''
Module to provide Palo Alto compatibility to Salt
:codeauthor: ``Spencer Ervin <spencer_ervin@hotmail.com>``
:maturity: new
:depends: none
:platform: unix
.. versionadded:: 2018.3.0
Configuration
=============
This module accepts connection configuration details either as
paramete... |
saltstack/salt | salt/modules/panos.py | refresh_fqdn_cache | python | def refresh_fqdn_cache(force=False):
'''
Force refreshes all FQDNs used in rules.
force
Forces all fqdn refresh
CLI Example:
.. code-block:: bash
salt '*' panos.refresh_fqdn_cache
salt '*' panos.refresh_fqdn_cache force=True
'''
if not isinstance(force, bool):
... | Force refreshes all FQDNs used in rules.
force
Forces all fqdn refresh
CLI Example:
.. code-block:: bash
salt '*' panos.refresh_fqdn_cache
salt '*' panos.refresh_fqdn_cache force=True | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L1486-L1510 | null | # -*- coding: utf-8 -*-
'''
Module to provide Palo Alto compatibility to Salt
:codeauthor: ``Spencer Ervin <spencer_ervin@hotmail.com>``
:maturity: new
:depends: none
:platform: unix
.. versionadded:: 2018.3.0
Configuration
=============
This module accepts connection configuration details either as
paramete... |
saltstack/salt | salt/modules/panos.py | resolve_address | python | def resolve_address(address=None, vsys=None):
'''
Resolve address to ip address.
Required version 7.0.0 or greater.
address
Address name you want to resolve.
vsys
The vsys name.
CLI Example:
.. code-block:: bash
salt '*' panos.resolve_address foo.bar.com
... | Resolve address to ip address.
Required version 7.0.0 or greater.
address
Address name you want to resolve.
vsys
The vsys name.
CLI Example:
.. code-block:: bash
salt '*' panos.resolve_address foo.bar.com
salt '*' panos.resolve_address foo.bar.com vsys=2 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L1529-L1563 | null | # -*- coding: utf-8 -*-
'''
Module to provide Palo Alto compatibility to Salt
:codeauthor: ``Spencer Ervin <spencer_ervin@hotmail.com>``
:maturity: new
:depends: none
:platform: unix
.. versionadded:: 2018.3.0
Configuration
=============
This module accepts connection configuration details either as
paramete... |
saltstack/salt | salt/modules/panos.py | set_authentication_profile | python | def set_authentication_profile(profile=None, deploy=False):
'''
Set the authentication profile of the Palo Alto proxy minion. A commit will be required before this is processed.
CLI Example:
Args:
profile (str): The name of the authentication profile to set.
deploy (bool): If true the... | Set the authentication profile of the Palo Alto proxy minion. A commit will be required before this is processed.
CLI Example:
Args:
profile (str): The name of the authentication profile to set.
deploy (bool): If true then commit the full candidate configuration, if false only set pending cha... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L1604-L1638 | [
"def commit():\n '''\n Commits the candidate configuration to the running configuration.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' panos.commit\n\n '''\n query = {'type': 'commit', 'cmd': '<commit></commit>'}\n\n return _get_job_results(query)\n"
] | # -*- coding: utf-8 -*-
'''
Module to provide Palo Alto compatibility to Salt
:codeauthor: ``Spencer Ervin <spencer_ervin@hotmail.com>``
:maturity: new
:depends: none
:platform: unix
.. versionadded:: 2018.3.0
Configuration
=============
This module accepts connection configuration details either as
paramete... |
saltstack/salt | salt/modules/panos.py | set_hostname | python | def set_hostname(hostname=None, deploy=False):
'''
Set the hostname of the Palo Alto proxy minion. A commit will be required before this is processed.
CLI Example:
Args:
hostname (str): The hostname to set
deploy (bool): If true then commit the full candidate configuration, if false o... | Set the hostname of the Palo Alto proxy minion. A commit will be required before this is processed.
CLI Example:
Args:
hostname (str): The hostname to set
deploy (bool): If true then commit the full candidate configuration, if false only set pending change.
.. code-block:: bash
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L1641-L1674 | [
"def commit():\n '''\n Commits the candidate configuration to the running configuration.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' panos.commit\n\n '''\n query = {'type': 'commit', 'cmd': '<commit></commit>'}\n\n return _get_job_results(query)\n"
] | # -*- coding: utf-8 -*-
'''
Module to provide Palo Alto compatibility to Salt
:codeauthor: ``Spencer Ervin <spencer_ervin@hotmail.com>``
:maturity: new
:depends: none
:platform: unix
.. versionadded:: 2018.3.0
Configuration
=============
This module accepts connection configuration details either as
paramete... |
saltstack/salt | salt/modules/panos.py | set_management_icmp | python | def set_management_icmp(enabled=True, deploy=False):
'''
Enables or disables the ICMP management service on the device.
CLI Example:
Args:
enabled (bool): If true the service will be enabled. If false the service will be disabled.
deploy (bool): If true then commit the full candidate ... | Enables or disables the ICMP management service on the device.
CLI Example:
Args:
enabled (bool): If true the service will be enabled. If false the service will be disabled.
deploy (bool): If true then commit the full candidate configuration, if false only set pending change.
.. code-blo... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L1677-L1714 | [
"def commit():\n '''\n Commits the candidate configuration to the running configuration.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' panos.commit\n\n '''\n query = {'type': 'commit', 'cmd': '<commit></commit>'}\n\n return _get_job_results(query)\n"
] | # -*- coding: utf-8 -*-
'''
Module to provide Palo Alto compatibility to Salt
:codeauthor: ``Spencer Ervin <spencer_ervin@hotmail.com>``
:maturity: new
:depends: none
:platform: unix
.. versionadded:: 2018.3.0
Configuration
=============
This module accepts connection configuration details either as
paramete... |
saltstack/salt | salt/modules/panos.py | set_ntp_authentication | python | def set_ntp_authentication(target=None,
authentication_type=None,
key_id=None,
authentication_key=None,
algorithm=None,
deploy=False):
'''
Set the NTP authentication of the Palo... | Set the NTP authentication of the Palo Alto proxy minion. A commit will be required before this is processed.
CLI Example:
Args:
target(str): Determines the target of the authentication. Valid options are primary, secondary, or both.
authentication_type(str): The authentication type to be use... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L1957-L2066 | [
"def commit():\n '''\n Commits the candidate configuration to the running configuration.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' panos.commit\n\n '''\n query = {'type': 'commit', 'cmd': '<commit></commit>'}\n\n return _get_job_results(query)\n"
] | # -*- coding: utf-8 -*-
'''
Module to provide Palo Alto compatibility to Salt
:codeauthor: ``Spencer Ervin <spencer_ervin@hotmail.com>``
:maturity: new
:depends: none
:platform: unix
.. versionadded:: 2018.3.0
Configuration
=============
This module accepts connection configuration details either as
paramete... |
saltstack/salt | salt/modules/panos.py | set_ntp_servers | python | def set_ntp_servers(primary_server=None, secondary_server=None, deploy=False):
'''
Set the NTP servers of the Palo Alto proxy minion. A commit will be required before this is processed.
CLI Example:
Args:
primary_server(str): The primary NTP server IP address or FQDN.
secondary_server... | Set the NTP servers of the Palo Alto proxy minion. A commit will be required before this is processed.
CLI Example:
Args:
primary_server(str): The primary NTP server IP address or FQDN.
secondary_server(str): The secondary NTP server IP address or FQDN.
deploy (bool): If true then co... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L2069-L2110 | [
"def commit():\n '''\n Commits the candidate configuration to the running configuration.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' panos.commit\n\n '''\n query = {'type': 'commit', 'cmd': '<commit></commit>'}\n\n return _get_job_results(query)\n"
] | # -*- coding: utf-8 -*-
'''
Module to provide Palo Alto compatibility to Salt
:codeauthor: ``Spencer Ervin <spencer_ervin@hotmail.com>``
:maturity: new
:depends: none
:platform: unix
.. versionadded:: 2018.3.0
Configuration
=============
This module accepts connection configuration details either as
paramete... |
saltstack/salt | salt/modules/panos.py | set_permitted_ip | python | def set_permitted_ip(address=None, deploy=False):
'''
Add an IPv4 address or network to the permitted IP list.
CLI Example:
Args:
address (str): The IPv4 address or network to allow access to add to the Palo Alto device.
deploy (bool): If true then commit the full candidate configurat... | Add an IPv4 address or network to the permitted IP list.
CLI Example:
Args:
address (str): The IPv4 address or network to allow access to add to the Palo Alto device.
deploy (bool): If true then commit the full candidate configuration, if false only set pending change.
.. code-block:: ba... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L2113-L2147 | [
"def commit():\n '''\n Commits the candidate configuration to the running configuration.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' panos.commit\n\n '''\n query = {'type': 'commit', 'cmd': '<commit></commit>'}\n\n return _get_job_results(query)\n"
] | # -*- coding: utf-8 -*-
'''
Module to provide Palo Alto compatibility to Salt
:codeauthor: ``Spencer Ervin <spencer_ervin@hotmail.com>``
:maturity: new
:depends: none
:platform: unix
.. versionadded:: 2018.3.0
Configuration
=============
This module accepts connection configuration details either as
paramete... |
saltstack/salt | salt/modules/panos.py | set_timezone | python | def set_timezone(tz=None, deploy=False):
'''
Set the timezone of the Palo Alto proxy minion. A commit will be required before this is processed.
CLI Example:
Args:
tz (str): The name of the timezone to set.
deploy (bool): If true then commit the full candidate configuration, if false ... | Set the timezone of the Palo Alto proxy minion. A commit will be required before this is processed.
CLI Example:
Args:
tz (str): The name of the timezone to set.
deploy (bool): If true then commit the full candidate configuration, if false only set pending change.
.. code-block:: bash
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/panos.py#L2150-L2183 | [
"def commit():\n '''\n Commits the candidate configuration to the running configuration.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' panos.commit\n\n '''\n query = {'type': 'commit', 'cmd': '<commit></commit>'}\n\n return _get_job_results(query)\n"
] | # -*- coding: utf-8 -*-
'''
Module to provide Palo Alto compatibility to Salt
:codeauthor: ``Spencer Ervin <spencer_ervin@hotmail.com>``
:maturity: new
:depends: none
:platform: unix
.. versionadded:: 2018.3.0
Configuration
=============
This module accepts connection configuration details either as
paramete... |
saltstack/salt | salt/states/vault.py | policy_present | python | def policy_present(name, rules):
'''
Ensure a Vault policy with the given name and rules is present.
name
The name of the policy
rules
Rules formatted as in-line HCL
.. code-block:: yaml
demo-policy:
vault.policy_present:
- name: foo/bar
... | Ensure a Vault policy with the given name and rules is present.
name
The name of the policy
rules
Rules formatted as in-line HCL
.. code-block:: yaml
demo-policy:
vault.policy_present:
- name: foo/bar
- rules: |
path "secret/top-... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/vault.py#L21-L61 | [
"def _handle_existing_policy(name, new_rules, existing_rules):\n ret = {'name': name}\n if new_rules == existing_rules:\n ret['result'] = True\n ret['changes'] = {}\n ret['comment'] = 'Policy exists, and has the correct content'\n return ret\n\n change = ''.join(difflib.unified_... | # -*- coding: utf-8 -*-
'''
States for managing Hashicorp Vault.
Currently handles policies. Configuration instructions are documented in the execution module docs.
:maintainer: SaltStack
:maturity: new
:platform: all
.. versionadded:: 2017.7.0
'''
# Import Python libs
from __future__ import absolute_im... |
saltstack/salt | salt/returners/rawfile_json.py | returner | python | def returner(ret):
'''
Write the return data to a file on the minion.
'''
opts = _get_options(ret)
try:
with salt.utils.files.flopen(opts['filename'], 'a') as logfile:
salt.utils.json.dump(ret, logfile)
logfile.write(str('\n')) # future lint: disable=blacklisted-func... | Write the return data to a file on the minion. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/rawfile_json.py#L54-L65 | [
"def dump(obj, fp, **kwargs):\n '''\n .. versionadded:: 2018.3.0\n\n Wraps json.dump, and assumes that ensure_ascii is False (unless explicitly\n passed as True) for unicode compatibility. Note that setting it to True\n will mess up any unicode characters, as they will be dumped as the string\n li... | # -*- coding: utf-8 -*-
'''
Take data from salt and "return" it into a raw file containing the json, with
one line per event.
Add the following to the minion or master configuration file.
.. code-block:: yaml
rawfile_json.filename: <path_to_output_file>
Default is ``/var/log/salt/events``.
Common use is to log... |
saltstack/salt | salt/returners/rawfile_json.py | event_return | python | def event_return(events):
'''
Write event data (return data and non-return data) to file on the master.
'''
if not events:
# events is an empty list.
# Don't open the logfile in vain.
return
opts = _get_options({}) # Pass in empty ret, since this is a list of events
try:... | Write event data (return data and non-return data) to file on the master. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/rawfile_json.py#L68-L84 | [
"def dump(obj, fp, **kwargs):\n '''\n .. versionadded:: 2018.3.0\n\n Wraps json.dump, and assumes that ensure_ascii is False (unless explicitly\n passed as True) for unicode compatibility. Note that setting it to True\n will mess up any unicode characters, as they will be dumped as the string\n li... | # -*- coding: utf-8 -*-
'''
Take data from salt and "return" it into a raw file containing the json, with
one line per event.
Add the following to the minion or master configuration file.
.. code-block:: yaml
rawfile_json.filename: <path_to_output_file>
Default is ``/var/log/salt/events``.
Common use is to log... |
saltstack/salt | salt/states/zpool.py | _layout_to_vdev | python | def _layout_to_vdev(layout, device_dir=None):
'''
Turn the layout data into usable vdevs spedcification
We need to support 2 ways of passing the layout:
.. code::
layout_new:
- mirror:
- disk0
- disk1
- mirror:
- disk2
- disk3... | Turn the layout data into usable vdevs spedcification
We need to support 2 ways of passing the layout:
.. code::
layout_new:
- mirror:
- disk0
- disk1
- mirror:
- disk2
- disk3
.. code:
layout_legacy:
mirror-0:
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zpool.py#L97-L167 | null | # -*- coding: utf-8 -*-
'''
States for managing zpools
:maintainer: Jorge Schrauwen <sjorge@blackdot.be>
:maturity: new
:depends: salt.utils.zfs, salt.modules.zpool
:platform: smartos, illumos, solaris, freebsd, linux
.. versionadded:: 2016.3.0
.. versionchanged:: 2018.3.1
Big refactor to remove ... |
saltstack/salt | salt/states/zpool.py | present | python | def present(name, properties=None, filesystem_properties=None, layout=None, config=None):
'''
ensure storage pool is present on the system
name : string
name of storage pool
properties : dict
optional set of properties to set for the storage pool
filesystem_properties : dict
... | ensure storage pool is present on the system
name : string
name of storage pool
properties : dict
optional set of properties to set for the storage pool
filesystem_properties : dict
optional set of filesystem properties to set for the storage pool (creation only)
layout: dict
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zpool.py#L170-L381 | [
"def _layout_to_vdev(layout, device_dir=None):\n '''\n Turn the layout data into usable vdevs spedcification\n\n We need to support 2 ways of passing the layout:\n\n .. code::\n layout_new:\n - mirror:\n - disk0\n - disk1\n - mirror:\n - disk2\n ... | # -*- coding: utf-8 -*-
'''
States for managing zpools
:maintainer: Jorge Schrauwen <sjorge@blackdot.be>
:maturity: new
:depends: salt.utils.zfs, salt.modules.zpool
:platform: smartos, illumos, solaris, freebsd, linux
.. versionadded:: 2016.3.0
.. versionchanged:: 2018.3.1
Big refactor to remove ... |
saltstack/salt | salt/states/zpool.py | absent | python | def absent(name, export=False, force=False):
'''
ensure storage pool is absent on the system
name : string
name of storage pool
export : boolean
export instread of destroy the zpool if present
force : boolean
force destroy or export
'''
ret = {'name': name,
... | ensure storage pool is absent on the system
name : string
name of storage pool
export : boolean
export instread of destroy the zpool if present
force : boolean
force destroy or export | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zpool.py#L384-L434 | null | # -*- coding: utf-8 -*-
'''
States for managing zpools
:maintainer: Jorge Schrauwen <sjorge@blackdot.be>
:maturity: new
:depends: salt.utils.zfs, salt.modules.zpool
:platform: smartos, illumos, solaris, freebsd, linux
.. versionadded:: 2016.3.0
.. versionchanged:: 2018.3.1
Big refactor to remove ... |
saltstack/salt | salt/utils/systemd.py | booted | python | def booted(context=None):
'''
Return True if the system was booted with systemd, False otherwise. If the
loader context dict ``__context__`` is passed, this function will set the
``salt.utils.systemd.booted`` key to represent if systemd is running and
keep the logic below from needing to be run aga... | Return True if the system was booted with systemd, False otherwise. If the
loader context dict ``__context__`` is passed, this function will set the
``salt.utils.systemd.booted`` key to represent if systemd is running and
keep the logic below from needing to be run again during the same salt run. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/systemd.py#L19-L47 | null | # -*- coding: utf-8 -*-
'''
Contains systemd related help files
'''
# import python libs
from __future__ import absolute_import, print_function, unicode_literals
import logging
import os
import re
import subprocess
# Import Salt libs
from salt.exceptions import SaltInvocationError
import salt.utils.stringutils
log = ... |
saltstack/salt | salt/utils/systemd.py | version | python | def version(context=None):
'''
Attempts to run systemctl --version. Returns None if unable to determine
version.
'''
contextkey = 'salt.utils.systemd.version'
if isinstance(context, dict):
# Can't put this if block on the same line as the above if block,
# because it will break t... | Attempts to run systemctl --version. Returns None if unable to determine
version. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/systemd.py#L50-L81 | [
"def to_str(s, encoding=None, errors='strict', normalize=False):\n '''\n Given str, bytes, bytearray, or unicode (py2), return str\n '''\n def _normalize(s):\n try:\n return unicodedata.normalize('NFC', s) if normalize else s\n except TypeError:\n return s\n\n if e... | # -*- coding: utf-8 -*-
'''
Contains systemd related help files
'''
# import python libs
from __future__ import absolute_import, print_function, unicode_literals
import logging
import os
import re
import subprocess
# Import Salt libs
from salt.exceptions import SaltInvocationError
import salt.utils.stringutils
log = ... |
saltstack/salt | salt/utils/systemd.py | has_scope | python | def has_scope(context=None):
'''
Scopes were introduced in systemd 205, this function returns a boolean
which is true when the minion is systemd-booted and running systemd>=205.
'''
if not booted(context):
return False
_sd_version = version(context)
if _sd_version is None:
re... | Scopes were introduced in systemd 205, this function returns a boolean
which is true when the minion is systemd-booted and running systemd>=205. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/systemd.py#L84-L94 | [
"def version(context=None):\n '''\n Attempts to run systemctl --version. Returns None if unable to determine\n version.\n '''\n contextkey = 'salt.utils.systemd.version'\n if isinstance(context, dict):\n # Can't put this if block on the same line as the above if block,\n # because it... | # -*- coding: utf-8 -*-
'''
Contains systemd related help files
'''
# import python libs
from __future__ import absolute_import, print_function, unicode_literals
import logging
import os
import re
import subprocess
# Import Salt libs
from salt.exceptions import SaltInvocationError
import salt.utils.stringutils
log = ... |
saltstack/salt | salt/returners/postgres_local_cache.py | _get_conn | python | def _get_conn():
'''
Return a postgres connection.
'''
try:
conn = psycopg2.connect(
host=__opts__['master_job_cache.postgres.host'],
user=__opts__['master_job_cache.postgres.user'],
password=__opts__['master_job_cache.postgres.passwd'],
... | Return a postgres connection. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L139-L153 | null | # -*- coding: utf-8 -*-
'''
Use a postgresql server for the master job cache. This helps the job cache to
cope with scale.
.. note::
There are three PostgreSQL returners. Any can function as an external
:ref:`master job cache <external-job-cache>`. but each has different
features. SaltStack recommends
... |
saltstack/salt | salt/returners/postgres_local_cache.py | _format_job_instance | python | def _format_job_instance(job):
'''
Format the job instance correctly
'''
ret = {'Function': job.get('fun', 'unknown-function'),
'Arguments': salt.utils.json.loads(job.get('arg', '[]')),
# unlikely but safeguard from invalid returns
'Target': job.get('tgt', 'unknown-targe... | Format the job instance correctly | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L164-L175 | null | # -*- coding: utf-8 -*-
'''
Use a postgresql server for the master job cache. This helps the job cache to
cope with scale.
.. note::
There are three PostgreSQL returners. Any can function as an external
:ref:`master job cache <external-job-cache>`. but each has different
features. SaltStack recommends
... |
saltstack/salt | salt/returners/postgres_local_cache.py | _gen_jid | python | def _gen_jid(cur):
'''
Generate an unique job id
'''
jid = salt.utils.jid.gen_jid(__opts__)
sql = '''SELECT jid FROM jids WHERE jid = %s'''
cur.execute(sql, (jid,))
data = cur.fetchall()
if not data:
return jid
return None | Generate an unique job id | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L187-L197 | [
"def gen_jid(opts=None):\n '''\n Generate a jid\n '''\n if opts is None:\n salt.utils.versions.warn_until(\n 'Sodium',\n 'The `opts` argument was not passed into salt.utils.jid.gen_jid(). '\n 'This will be required starting in {version}.'\n )\n opts ... | # -*- coding: utf-8 -*-
'''
Use a postgresql server for the master job cache. This helps the job cache to
cope with scale.
.. note::
There are three PostgreSQL returners. Any can function as an external
:ref:`master job cache <external-job-cache>`. but each has different
features. SaltStack recommends
... |
saltstack/salt | salt/returners/postgres_local_cache.py | prep_jid | python | def prep_jid(nocache=False, passed_jid=None):
'''
Return a job id and prepare the job id directory
This is the function responsible for making sure jids don't collide
(unless its passed a jid). So do what you have to do to make sure that
stays the case
'''
conn = _get_conn()
if conn is N... | Return a job id and prepare the job id directory
This is the function responsible for making sure jids don't collide
(unless its passed a jid). So do what you have to do to make sure that
stays the case | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L200-L221 | [
"def _get_conn():\n '''\n Return a postgres connection.\n '''\n try:\n conn = psycopg2.connect(\n host=__opts__['master_job_cache.postgres.host'],\n user=__opts__['master_job_cache.postgres.user'],\n password=__opts__['master_job_cache.postgres.passwd'],\... | # -*- coding: utf-8 -*-
'''
Use a postgresql server for the master job cache. This helps the job cache to
cope with scale.
.. note::
There are three PostgreSQL returners. Any can function as an external
:ref:`master job cache <external-job-cache>`. but each has different
features. SaltStack recommends
... |
saltstack/salt | salt/returners/postgres_local_cache.py | returner | python | def returner(load):
'''
Return data to a postgres server
'''
conn = _get_conn()
if conn is None:
return None
cur = conn.cursor()
sql = '''INSERT INTO salt_returns
(fun, jid, return, id, success)
VALUES (%s, %s, %s, %s, %s)'''
try:
ret = six.text_ty... | Return data to a postgres server | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L224-L253 | [
"def dumps(obj, **kwargs):\n '''\n .. versionadded:: 2018.3.0\n\n Wraps json.dumps, and assumes that ensure_ascii is False (unless explicitly\n passed as True) for unicode compatibility. Note that setting it to True\n will mess up any unicode characters, as they will be dumped as the string\n lite... | # -*- coding: utf-8 -*-
'''
Use a postgresql server for the master job cache. This helps the job cache to
cope with scale.
.. note::
There are three PostgreSQL returners. Any can function as an external
:ref:`master job cache <external-job-cache>`. but each has different
features. SaltStack recommends
... |
saltstack/salt | salt/returners/postgres_local_cache.py | event_return | python | def event_return(events):
'''
Return event to a postgres server
Require that configuration be enabled via 'event_return'
option in master config.
'''
conn = _get_conn()
if conn is None:
return None
cur = conn.cursor()
for event in events:
tag = event.get('tag', '')
... | Return event to a postgres server
Require that configuration be enabled via 'event_return'
option in master config. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L256-L274 | [
"def dumps(obj, **kwargs):\n '''\n .. versionadded:: 2018.3.0\n\n Wraps json.dumps, and assumes that ensure_ascii is False (unless explicitly\n passed as True) for unicode compatibility. Note that setting it to True\n will mess up any unicode characters, as they will be dumped as the string\n lite... | # -*- coding: utf-8 -*-
'''
Use a postgresql server for the master job cache. This helps the job cache to
cope with scale.
.. note::
There are three PostgreSQL returners. Any can function as an external
:ref:`master job cache <external-job-cache>`. but each has different
features. SaltStack recommends
... |
saltstack/salt | salt/returners/postgres_local_cache.py | save_load | python | def save_load(jid, clear_load, minions=None):
'''
Save the load to the specified jid id
'''
jid = _escape_jid(jid)
conn = _get_conn()
if conn is None:
return None
cur = conn.cursor()
sql = '''INSERT INTO jids ''' \
'''(jid, started, tgt_type, cmd, tgt, kwargs, ret, user... | Save the load to the specified jid id | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L277-L306 | [
"def dumps(obj, **kwargs):\n '''\n .. versionadded:: 2018.3.0\n\n Wraps json.dumps, and assumes that ensure_ascii is False (unless explicitly\n passed as True) for unicode compatibility. Note that setting it to True\n will mess up any unicode characters, as they will be dumped as the string\n lite... | # -*- coding: utf-8 -*-
'''
Use a postgresql server for the master job cache. This helps the job cache to
cope with scale.
.. note::
There are three PostgreSQL returners. Any can function as an external
:ref:`master job cache <external-job-cache>`. but each has different
features. SaltStack recommends
... |
saltstack/salt | salt/returners/postgres_local_cache.py | _escape_jid | python | def _escape_jid(jid):
'''
Do proper formatting of the jid
'''
jid = six.text_type(jid)
jid = re.sub(r"'*", "", jid)
return jid | Do proper formatting of the jid | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L316-L322 | null | # -*- coding: utf-8 -*-
'''
Use a postgresql server for the master job cache. This helps the job cache to
cope with scale.
.. note::
There are three PostgreSQL returners. Any can function as an external
:ref:`master job cache <external-job-cache>`. but each has different
features. SaltStack recommends
... |
saltstack/salt | salt/returners/postgres_local_cache.py | _build_dict | python | def _build_dict(data):
'''
Rebuild dict
'''
result = {}
# TODO: Add Metadata support when it is merged from develop
result["jid"] = data[0]
result["tgt_type"] = data[1]
result["cmd"] = data[2]
result["tgt"] = data[3]
result["kwargs"] = data[4]
result["ret"] = data[5]
resu... | Rebuild dict | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L325-L340 | null | # -*- coding: utf-8 -*-
'''
Use a postgresql server for the master job cache. This helps the job cache to
cope with scale.
.. note::
There are three PostgreSQL returners. Any can function as an external
:ref:`master job cache <external-job-cache>`. but each has different
features. SaltStack recommends
... |
saltstack/salt | salt/returners/postgres_local_cache.py | get_load | python | def get_load(jid):
'''
Return the load data that marks a specified jid
'''
jid = _escape_jid(jid)
conn = _get_conn()
if conn is None:
return None
cur = conn.cursor()
sql = '''SELECT jid, tgt_type, cmd, tgt, kwargs, ret, username, arg,''' \
''' fun FROM jids WHERE jid = ... | Return the load data that marks a specified jid | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L343-L359 | [
"def _get_conn():\n '''\n Return a postgres connection.\n '''\n try:\n conn = psycopg2.connect(\n host=__opts__['master_job_cache.postgres.host'],\n user=__opts__['master_job_cache.postgres.user'],\n password=__opts__['master_job_cache.postgres.passwd'],\... | # -*- coding: utf-8 -*-
'''
Use a postgresql server for the master job cache. This helps the job cache to
cope with scale.
.. note::
There are three PostgreSQL returners. Any can function as an external
:ref:`master job cache <external-job-cache>`. but each has different
features. SaltStack recommends
... |
saltstack/salt | salt/returners/postgres_local_cache.py | get_jid | python | def get_jid(jid):
'''
Return the information returned when the specified job id was executed
'''
jid = _escape_jid(jid)
conn = _get_conn()
if conn is None:
return None
cur = conn.cursor()
sql = '''SELECT id, return FROM salt_returns WHERE jid = %s'''
cur.execute(sql, (jid,))... | Return the information returned when the specified job id was executed | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L362-L385 | [
"def loads(s, **kwargs):\n '''\n .. versionadded:: 2018.3.0\n\n Wraps json.loads and prevents a traceback in the event that a bytestring is\n passed to the function. (Python < 3.6 cannot load bytestrings)\n\n You can pass an alternate json module (loaded via import_json() above)\n using the _json_... | # -*- coding: utf-8 -*-
'''
Use a postgresql server for the master job cache. This helps the job cache to
cope with scale.
.. note::
There are three PostgreSQL returners. Any can function as an external
:ref:`master job cache <external-job-cache>`. but each has different
features. SaltStack recommends
... |
saltstack/salt | salt/returners/postgres_local_cache.py | get_jids | python | def get_jids():
'''
Return a list of all job ids
For master job cache this also formats the output and returns a string
'''
conn = _get_conn()
cur = conn.cursor()
sql = '''SELECT ''' \
'''jid, tgt_type, cmd, tgt, kwargs, ret, username, arg, fun ''' \
'''FROM jids'''
i... | Return a list of all job ids
For master job cache this also formats the output and returns a string | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/postgres_local_cache.py#L388-L412 | [
"def _get_conn():\n '''\n Return a postgres connection.\n '''\n try:\n conn = psycopg2.connect(\n host=__opts__['master_job_cache.postgres.host'],\n user=__opts__['master_job_cache.postgres.user'],\n password=__opts__['master_job_cache.postgres.passwd'],\... | # -*- coding: utf-8 -*-
'''
Use a postgresql server for the master job cache. This helps the job cache to
cope with scale.
.. note::
There are three PostgreSQL returners. Any can function as an external
:ref:`master job cache <external-job-cache>`. but each has different
features. SaltStack recommends
... |
saltstack/salt | salt/modules/aix_shadow.py | login_failures | python | def login_failures(user):
'''
Query for all accounts which have 3 or more login failures.
CLI Example:
.. code-block:: bash
salt <minion_id> shadow.login_failures ALL
'''
cmd = 'lsuser -a unsuccessful_login_count {0}'.format(user)
cmd += " | grep -E 'unsuccessful_login_count=([3... | Query for all accounts which have 3 or more login failures.
CLI Example:
.. code-block:: bash
salt <minion_id> shadow.login_failures ALL | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/aix_shadow.py#L32-L54 | null | # -*- coding: utf-8 -*-
'''
Manage account locks on AIX systems
.. versionadded:: 2018.3.0
:depends: none
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python librarie
import logging
log = logging.getLogger(__name__)
# Define the module's virtual name
__virtualname__ = 'sh... |
saltstack/salt | salt/modules/aix_shadow.py | unlock | python | def unlock(user):
'''
Unlock user for locked account
CLI Example:
.. code-block:: bash
salt <minion_id> shadow.unlock user
'''
cmd = 'chuser account_locked=false {0} | ' \
'chsec -f /etc/security/lastlog -a "unsuccessful_login_count=0" -s {0}'.format(user)
ret = __salt_... | Unlock user for locked account
CLI Example:
.. code-block:: bash
salt <minion_id> shadow.unlock user | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/aix_shadow.py#L81-L96 | null | # -*- coding: utf-8 -*-
'''
Manage account locks on AIX systems
.. versionadded:: 2018.3.0
:depends: none
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python librarie
import logging
log = logging.getLogger(__name__)
# Define the module's virtual name
__virtualname__ = 'sh... |
saltstack/salt | salt/states/opsgenie.py | create_alert | python | def create_alert(name=None, api_key=None, reason=None, action_type="Create"):
'''
Create an alert in OpsGenie. Example usage with Salt's requisites and other
global state arguments could be found above.
Required Parameters:
api_key
It's the API Key you've copied while adding integration in... | Create an alert in OpsGenie. Example usage with Salt's requisites and other
global state arguments could be found above.
Required Parameters:
api_key
It's the API Key you've copied while adding integration in OpsGenie.
reason
It will be used as alert's default message in OpsGenie.
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/opsgenie.py#L46-L119 | null | # -*- coding: utf-8 -*-
'''
Create/Close an alert in OpsGenie
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. versionadded:: 2018.3.0
This state is useful for creating or closing alerts in OpsGenie
during state runs.
.. code-block:: yaml
used_space:
disk.status:
- name: /
- maximum: 79%
- min... |
saltstack/salt | salt/states/opsgenie.py | close_alert | python | def close_alert(name=None, api_key=None, reason="Conditions are met.",
action_type="Close"):
'''
Close an alert in OpsGenie. It's a wrapper function for create_alert.
Example usage with Salt's requisites and other global state arguments
could be found above.
Required Parameters:
... | Close an alert in OpsGenie. It's a wrapper function for create_alert.
Example usage with Salt's requisites and other global state arguments
could be found above.
Required Parameters:
name
It will be used as alert's alias. If you want to use the close
functionality you must provide name... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/opsgenie.py#L122-L153 | [
"def create_alert(name=None, api_key=None, reason=None, action_type=\"Create\"):\n '''\n Create an alert in OpsGenie. Example usage with Salt's requisites and other\n global state arguments could be found above.\n\n Required Parameters:\n\n api_key\n It's the API Key you've copied while adding... | # -*- coding: utf-8 -*-
'''
Create/Close an alert in OpsGenie
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. versionadded:: 2018.3.0
This state is useful for creating or closing alerts in OpsGenie
during state runs.
.. code-block:: yaml
used_space:
disk.status:
- name: /
- maximum: 79%
- min... |
saltstack/salt | salt/states/probes.py | _expand_probes | python | def _expand_probes(probes, defaults):
'''
Updates the probes dictionary with different levels of default values.
'''
expected_probes = {}
for probe_name, probe_test in six.iteritems(probes):
if probe_name not in expected_probes.keys():
expected_probes[probe_name] = {}
... | Updates the probes dictionary with different levels of default values. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/probes.py#L84-L105 | null | # -*- coding: utf-8 -*-
'''
Network Probes
===============
Configure RPM (JunOS)/SLA (Cisco) probes on the device via NAPALM proxy.
:codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com>
:maturity: new
:depends: napalm
:platform: unix
Dependencies
------------
- :mod:`napalm p... |
saltstack/salt | salt/states/probes.py | _clean_probes | python | def _clean_probes(probes):
'''
Will remove empty and useless values from the probes dictionary.
'''
probes = _ordered_dict_to_dict(probes) # make sure we are working only with dict-type
probes_copy = deepcopy(probes)
for probe_name, probe_tests in six.iteritems(probes_copy):
if not pr... | Will remove empty and useless values from the probes dictionary. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/probes.py#L108-L126 | null | # -*- coding: utf-8 -*-
'''
Network Probes
===============
Configure RPM (JunOS)/SLA (Cisco) probes on the device via NAPALM proxy.
:codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com>
:maturity: new
:depends: napalm
:platform: unix
Dependencies
------------
- :mod:`napalm p... |
saltstack/salt | salt/states/probes.py | _compare_probes | python | def _compare_probes(configured_probes, expected_probes):
'''
Compares configured probes on the device with the expected configuration and returns the differences.
'''
new_probes = {}
update_probes = {}
remove_probes = {}
# noth configured => configure with expected probes
if not confi... | Compares configured probes on the device with the expected configuration and returns the differences. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/probes.py#L129-L201 | null | # -*- coding: utf-8 -*-
'''
Network Probes
===============
Configure RPM (JunOS)/SLA (Cisco) probes on the device via NAPALM proxy.
:codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com>
:maturity: new
:depends: napalm
:platform: unix
Dependencies
------------
- :mod:`napalm p... |
saltstack/salt | salt/states/probes.py | managed | python | def managed(name, probes, defaults=None):
'''
Ensure the networks device is configured as specified in the state SLS file.
Probes not specified will be removed, while probes not confiured as expected will trigger config updates.
:param probes: Defines the probes as expected to be configured on the
... | Ensure the networks device is configured as specified in the state SLS file.
Probes not specified will be removed, while probes not confiured as expected will trigger config updates.
:param probes: Defines the probes as expected to be configured on the
device. In order to ease the configuration and av... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/probes.py#L252-L454 | [
"def _default_ret(name):\n\n '''\n Returns a default structure of the dictionary to be returned as output of the state functions.\n '''\n\n return {\n 'name': name,\n 'result': False,\n 'changes': {},\n 'comment': ''\n }\n",
"def _ordered_dict_to_dict(probes):\n\n '''... | # -*- coding: utf-8 -*-
'''
Network Probes
===============
Configure RPM (JunOS)/SLA (Cisco) probes on the device via NAPALM proxy.
:codeauthor: Mircea Ulinic <mircea@cloudflare.com> & Jerome Fleury <jf@cloudflare.com>
:maturity: new
:depends: napalm
:platform: unix
Dependencies
------------
- :mod:`napalm p... |
saltstack/salt | salt/returners/smtp_return.py | returner | python | def returner(ret):
'''
Send an email with the data
'''
_options = _get_options(ret)
from_addr = _options.get('from')
to_addrs = _options.get('to').split(',')
host = _options.get('host')
port = _options.get('port')
user = _options.get('username')
passwd = _options.get('password')... | Send an email with the data | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/smtp_return.py#L163-L260 | [
"def compile_template(template,\n renderers,\n default,\n blacklist,\n whitelist,\n saltenv='base',\n sls='',\n input_data='',\n **kwargs):\n '''\n Ta... | # -*- coding: utf-8 -*-
'''
Return salt data via email
The following fields can be set in the minion conf file. Fields are optional
unless noted otherwise.
* ``from`` (required) The name/address of the email sender.
* ``to`` (required) The names/addresses of the email recipients;
comma-delimited. For example: ``y... |
saltstack/salt | salt/returners/smtp_return.py | event_return | python | def event_return(events):
'''
Return event data via SMTP
'''
for event in events:
ret = event.get('data', False)
if ret:
returner(ret) | Return event data via SMTP | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/smtp_return.py#L270-L279 | [
"def returner(ret):\n '''\n Send an email with the data\n '''\n\n _options = _get_options(ret)\n from_addr = _options.get('from')\n to_addrs = _options.get('to').split(',')\n host = _options.get('host')\n port = _options.get('port')\n user = _options.get('username')\n passwd = _options... | # -*- coding: utf-8 -*-
'''
Return salt data via email
The following fields can be set in the minion conf file. Fields are optional
unless noted otherwise.
* ``from`` (required) The name/address of the email sender.
* ``to`` (required) The names/addresses of the email recipients;
comma-delimited. For example: ``y... |
saltstack/salt | salt/modules/incron.py | _render_tab | python | def _render_tab(lst):
'''
Takes a tab list structure and renders it to a list for applying it to
a file
'''
ret = []
for pre in lst['pre']:
ret.append('{0}\n'.format(pre))
for cron in lst['crons']:
ret.append('{0} {1} {2} {3}\n'.format(cron['path'],
... | Takes a tab list structure and renders it to a list for applying it to
a file | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L47-L62 | null | # -*- coding: utf-8 -*-
'''
Work with incron
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
import os
# Import salt libs
from salt.ext import six
from salt.ext.six.moves import range
import salt.utils.data
import salt.utils.files
import salt.utils.func... |
saltstack/salt | salt/modules/incron.py | write_incron_file | python | def write_incron_file(user, path):
'''
Writes the contents of a file to a user's incrontab
CLI Example:
.. code-block:: bash
salt '*' incron.write_incron_file root /tmp/new_incron
'''
return __salt__['cmd.retcode'](_get_incron_cmdstr(path), runas=user, python_shell=False) == 0 | Writes the contents of a file to a user's incrontab
CLI Example:
.. code-block:: bash
salt '*' incron.write_incron_file root /tmp/new_incron | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L72-L82 | [
"def _get_incron_cmdstr(path):\n '''\n Returns a format string, to be used to build an incrontab command.\n '''\n return 'incrontab {0}'.format(path)\n"
] | # -*- coding: utf-8 -*-
'''
Work with incron
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
import os
# Import salt libs
from salt.ext import six
from salt.ext.six.moves import range
import salt.utils.data
import salt.utils.files
import salt.utils.func... |
saltstack/salt | salt/modules/incron.py | write_incron_file_verbose | python | def write_incron_file_verbose(user, path):
'''
Writes the contents of a file to a user's incrontab and return error message on error
CLI Example:
.. code-block:: bash
salt '*' incron.write_incron_file_verbose root /tmp/new_incron
'''
return __salt__['cmd.run_all'](_get_incron_cmdstr(p... | Writes the contents of a file to a user's incrontab and return error message on error
CLI Example:
.. code-block:: bash
salt '*' incron.write_incron_file_verbose root /tmp/new_incron | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L85-L95 | [
"def _get_incron_cmdstr(path):\n '''\n Returns a format string, to be used to build an incrontab command.\n '''\n return 'incrontab {0}'.format(path)\n"
] | # -*- coding: utf-8 -*-
'''
Work with incron
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
import os
# Import salt libs
from salt.ext import six
from salt.ext.six.moves import range
import salt.utils.data
import salt.utils.files
import salt.utils.func... |
saltstack/salt | salt/modules/incron.py | _write_incron_lines | python | def _write_incron_lines(user, lines):
'''
Takes a list of lines to be committed to a user's incrontab and writes it
'''
if user == 'system':
ret = {}
ret['retcode'] = _write_file(_INCRON_SYSTEM_TAB, 'salt', ''.join(lines))
return ret
else:
path = salt.utils.files.mkst... | Takes a list of lines to be committed to a user's incrontab and writes it | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L98-L114 | [
"def encode(data, encoding=None, errors='strict', keep=False,\n preserve_dict_class=False, preserve_tuples=False):\n '''\n Generic function which will encode whichever type is passed, if necessary\n\n If `strict` is True, and `keep` is False, and we fail to encode, a\n UnicodeEncodeError will ... | # -*- coding: utf-8 -*-
'''
Work with incron
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
import os
# Import salt libs
from salt.ext import six
from salt.ext.six.moves import range
import salt.utils.data
import salt.utils.files
import salt.utils.func... |
saltstack/salt | salt/modules/incron.py | _write_file | python | def _write_file(folder, filename, data):
'''
Writes a file to disk
'''
path = os.path.join(folder, filename)
if not os.path.exists(folder):
msg = '{0} cannot be written. {1} does not exist'.format(filename, folder)
log.error(msg)
raise AttributeError(six.text_type(msg))
w... | Writes a file to disk | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L117-L129 | null | # -*- coding: utf-8 -*-
'''
Work with incron
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
import os
# Import salt libs
from salt.ext import six
from salt.ext.six.moves import range
import salt.utils.data
import salt.utils.files
import salt.utils.func... |
saltstack/salt | salt/modules/incron.py | _read_file | python | def _read_file(folder, filename):
'''
Reads and returns the contents of a file
'''
path = os.path.join(folder, filename)
try:
with salt.utils.files.fopen(path, 'rb') as contents:
return salt.utils.data.decode(contents.readlines())
except (OSError, IOError):
return '' | Reads and returns the contents of a file | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L132-L141 | [
"def decode(data, encoding=None, errors='strict', keep=False,\n normalize=False, preserve_dict_class=False, preserve_tuples=False,\n to_str=False):\n '''\n Generic function which will decode whichever type is passed, if necessary.\n Optionally use to_str=True to ensure strings are str t... | # -*- coding: utf-8 -*-
'''
Work with incron
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
import os
# Import salt libs
from salt.ext import six
from salt.ext.six.moves import range
import salt.utils.data
import salt.utils.files
import salt.utils.func... |
saltstack/salt | salt/modules/incron.py | raw_incron | python | def raw_incron(user):
'''
Return the contents of the user's incrontab
CLI Example:
.. code-block:: bash
salt '*' incron.raw_incron root
'''
if __grains__['os_family'] == 'Solaris':
cmd = 'incrontab -l {0}'.format(user)
else:
cmd = 'incrontab -l -u {0}'.format(user)... | Return the contents of the user's incrontab
CLI Example:
.. code-block:: bash
salt '*' incron.raw_incron root | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L159-L173 | null | # -*- coding: utf-8 -*-
'''
Work with incron
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
import os
# Import salt libs
from salt.ext import six
from salt.ext.six.moves import range
import salt.utils.data
import salt.utils.files
import salt.utils.func... |
saltstack/salt | salt/modules/incron.py | list_tab | python | def list_tab(user):
'''
Return the contents of the specified user's incrontab
CLI Example:
.. code-block:: bash
salt '*' incron.list_tab root
'''
if user == 'system':
data = raw_system_incron()
else:
data = raw_incron(user)
log.debug('incron user data %s', ... | Return the contents of the specified user's incrontab
CLI Example:
.. code-block:: bash
salt '*' incron.list_tab root | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L176-L214 | [
"def raw_system_incron():\n '''\n Return the contents of the system wide incrontab\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' incron.raw_system_incron\n '''\n _contents = _read_file(_INCRON_SYSTEM_TAB, 'salt')\n log.debug('incron read_file contents: %s', _contents)\n retur... | # -*- coding: utf-8 -*-
'''
Work with incron
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
import os
# Import salt libs
from salt.ext import six
from salt.ext.six.moves import range
import salt.utils.data
import salt.utils.files
import salt.utils.func... |
saltstack/salt | salt/modules/incron.py | set_job | python | def set_job(user, path, mask, cmd):
'''
Sets an incron job up for a specified user.
CLI Example:
.. code-block:: bash
salt '*' incron.set_job root '/root' 'IN_MODIFY' 'echo "$$ $@ $# $% $&"'
'''
# Scrub the types
mask = six.text_type(mask).upper()
# Check for valid mask types... | Sets an incron job up for a specified user.
CLI Example:
.. code-block:: bash
salt '*' incron.set_job root '/root' 'IN_MODIFY' 'echo "$$ $@ $# $% $&"' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L221-L276 | [
"def _render_tab(lst):\n '''\n Takes a tab list structure and renders it to a list for applying it to\n a file\n '''\n ret = []\n for pre in lst['pre']:\n ret.append('{0}\\n'.format(pre))\n for cron in lst['crons']:\n ret.append('{0} {1} {2} {3}\\n'.format(cron['path'],\n ... | # -*- coding: utf-8 -*-
'''
Work with incron
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
import os
# Import salt libs
from salt.ext import six
from salt.ext.six.moves import range
import salt.utils.data
import salt.utils.files
import salt.utils.func... |
saltstack/salt | salt/modules/incron.py | rm_job | python | def rm_job(user,
path,
mask,
cmd):
'''
Remove a incron job for a specified user. If any of the day/time params are
specified, the job will only be removed if the specified params match.
CLI Example:
.. code-block:: bash
salt '*' incron.rm_job root /path
... | Remove a incron job for a specified user. If any of the day/time params are
specified, the job will only be removed if the specified params match.
CLI Example:
.. code-block:: bash
salt '*' incron.rm_job root /path | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/incron.py#L279-L320 | [
"def _render_tab(lst):\n '''\n Takes a tab list structure and renders it to a list for applying it to\n a file\n '''\n ret = []\n for pre in lst['pre']:\n ret.append('{0}\\n'.format(pre))\n for cron in lst['crons']:\n ret.append('{0} {1} {2} {3}\\n'.format(cron['path'],\n ... | # -*- coding: utf-8 -*-
'''
Work with incron
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import logging
import os
# Import salt libs
from salt.ext import six
from salt.ext.six.moves import range
import salt.utils.data
import salt.utils.files
import salt.utils.func... |
saltstack/salt | salt/engines/ircbot.py | start | python | def start(nick, host, port=6667, username=None, password=None, channels=None, use_ssl=False, use_sasl=False,
char='!', allow_hosts=False, allow_nicks=False, disable_query=True):
'''
IRC Bot for interacting with salt.
nick
Nickname of the connected Bot.
host
irc server (exampl... | IRC Bot for interacting with salt.
nick
Nickname of the connected Bot.
host
irc server (example - chat.freenode.net).
port
irc port. Default: 6667
password
password for authenticating. If not provided, user will not authenticate on the irc server.
channels
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/ircbot.py#L225-L285 | null | # -*- coding: utf-8 -*-
'''
IRC Bot engine
.. versionadded:: 2017.7.0
Example Configuration
.. code-block:: yaml
engines:
- ircbot:
nick: <nick>
username: <username>
password: <password>
host: chat.freenode.net
port: 7000
channels:
- ... |
saltstack/salt | salt/modules/suse_apache.py | check_mod_enabled | python | def check_mod_enabled(mod):
'''
Checks to see if the specific apache mod is enabled.
This will only be functional on operating systems that support
`a2enmod -l` to list the enabled mods.
CLI Example:
.. code-block:: bash
salt '*' apache.check_mod_enabled status
'''
if mod.end... | Checks to see if the specific apache mod is enabled.
This will only be functional on operating systems that support
`a2enmod -l` to list the enabled mods.
CLI Example:
.. code-block:: bash
salt '*' apache.check_mod_enabled status | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/suse_apache.py#L31-L55 | null | # -*- coding: utf-8 -*-
'''
Support for Apache
Please note: The functions in here are SUSE-specific. Placing them in this
separate file will allow them to load only on SUSE systems, while still
loading under the ``apache`` namespace.
'''
from __future__ import absolute_import, unicode_literals, print_function
# Impor... |
saltstack/salt | salt/modules/boto_kms.py | create_alias | python | def create_alias(alias_name, target_key_id, region=None, key=None, keyid=None,
profile=None):
'''
Create a display name for a key.
CLI example::
salt myminion boto_kms.create_alias 'alias/mykey' key_id
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profi... | Create a display name for a key.
CLI example::
salt myminion boto_kms.create_alias 'alias/mykey' key_id | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L80-L98 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon KMS
.. versionadded:: 2015.8.0
:configuration: This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no furthe... |
saltstack/salt | salt/modules/boto_kms.py | create_grant | python | def create_grant(key_id, grantee_principal, retiring_principal=None,
operations=None, constraints=None, grant_tokens=None,
region=None, key=None, keyid=None, profile=None):
'''
Adds a grant to a key to specify who can access the key and under what
conditions.
CLI examp... | Adds a grant to a key to specify who can access the key and under what
conditions.
CLI example::
salt myminion boto_kms.create_grant 'alias/mykey' 'arn:aws:iam::1111111:/role/myrole' operations='["Encrypt","Decrypt"]' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L101-L128 | [
"def _get_key_id(alias, region=None, key=None, keyid=None, profile=None):\n '''\n From an alias, get a key_id.\n '''\n key_metadata = describe_key(\n alias, region, key, keyid, profile\n )['key_metadata']\n return key_metadata['KeyId']\n"
] | # -*- coding: utf-8 -*-
'''
Connection module for Amazon KMS
.. versionadded:: 2015.8.0
:configuration: This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no furthe... |
saltstack/salt | salt/modules/boto_kms.py | create_key | python | def create_key(policy=None, description=None, key_usage=None, region=None,
key=None, keyid=None, profile=None):
'''
Creates a master key.
CLI example::
salt myminion boto_kms.create_key '{"Statement":...}' "My master key"
'''
conn = _get_conn(region=region, key=key, keyid=ke... | Creates a master key.
CLI example::
salt myminion boto_kms.create_key '{"Statement":...}' "My master key" | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L131-L153 | [
"def serialize(obj, **options):\n '''\n Serialize Python data to JSON.\n\n :param obj: the data structure to serialize\n :param options: options given to lower json/simplejson module.\n '''\n\n try:\n if 'fp' in options:\n return salt.utils.json.dump(obj, _json_module=_json, **op... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon KMS
.. versionadded:: 2015.8.0
:configuration: This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no furthe... |
saltstack/salt | salt/modules/boto_kms.py | decrypt | python | def decrypt(ciphertext_blob, encryption_context=None, grant_tokens=None,
region=None, key=None, keyid=None, profile=None):
'''
Decrypt ciphertext.
CLI example::
salt myminion boto_kms.decrypt encrypted_ciphertext
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile... | Decrypt ciphertext.
CLI example::
salt myminion boto_kms.decrypt encrypted_ciphertext | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L156-L177 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon KMS
.. versionadded:: 2015.8.0
:configuration: This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no furthe... |
saltstack/salt | salt/modules/boto_kms.py | key_exists | python | def key_exists(key_id, region=None, key=None, keyid=None, profile=None):
'''
Check for the existence of a key.
CLI example::
salt myminion boto_kms.key_exists 'alias/mykey'
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
r = {}
try:
key = conn.de... | Check for the existence of a key.
CLI example::
salt myminion boto_kms.key_exists 'alias/mykey' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L180-L200 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon KMS
.. versionadded:: 2015.8.0
:configuration: This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no furthe... |
saltstack/salt | salt/modules/boto_kms.py | _get_key_id | python | def _get_key_id(alias, region=None, key=None, keyid=None, profile=None):
'''
From an alias, get a key_id.
'''
key_metadata = describe_key(
alias, region, key, keyid, profile
)['key_metadata']
return key_metadata['KeyId'] | From an alias, get a key_id. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L203-L210 | [
"def describe_key(key_id, region=None, key=None, keyid=None, profile=None):\n '''\n Get detailed information about a key.\n\n CLI example::\n\n salt myminion boto_kms.describe_key 'alias/mykey'\n '''\n conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)\n\n r = {}\n tr... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon KMS
.. versionadded:: 2015.8.0
:configuration: This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no furthe... |
saltstack/salt | salt/modules/boto_kms.py | disable_key | python | def disable_key(key_id, region=None, key=None, keyid=None, profile=None):
'''
Mark key as disabled.
CLI example::
salt myminion boto_kms.disable_key 'alias/mykey'
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
r = {}
try:
key = conn.disable_key(... | Mark key as disabled.
CLI example::
salt myminion boto_kms.disable_key 'alias/mykey' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L233-L250 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon KMS
.. versionadded:: 2015.8.0
:configuration: This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no furthe... |
saltstack/salt | salt/modules/boto_kms.py | encrypt | python | def encrypt(key_id, plaintext, encryption_context=None, grant_tokens=None,
region=None, key=None, keyid=None, profile=None):
'''
Encrypt plaintext into cipher text using specified key.
CLI example::
salt myminion boto_kms.encrypt 'alias/mykey' 'myplaindata' '{"aws:username":"myuser"}'
... | Encrypt plaintext into cipher text using specified key.
CLI example::
salt myminion boto_kms.encrypt 'alias/mykey' 'myplaindata' '{"aws:username":"myuser"}' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L315-L337 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon KMS
.. versionadded:: 2015.8.0
:configuration: This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no furthe... |
saltstack/salt | salt/modules/boto_kms.py | generate_data_key | python | def generate_data_key(key_id, encryption_context=None, number_of_bytes=None,
key_spec=None, grant_tokens=None, region=None, key=None,
keyid=None, profile=None):
'''
Generate a secure data key.
CLI example::
salt myminion boto_kms.generate_data_key 'alias... | Generate a secure data key.
CLI example::
salt myminion boto_kms.generate_data_key 'alias/mykey' number_of_bytes=1024 key_spec=AES_128 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L340-L364 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon KMS
.. versionadded:: 2015.8.0
:configuration: This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no furthe... |
saltstack/salt | salt/modules/boto_kms.py | generate_random | python | def generate_random(number_of_bytes=None, region=None, key=None, keyid=None,
profile=None):
'''
Generate a random string.
CLI example::
salt myminion boto_kms.generate_random number_of_bytes=1024
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)... | Generate a random string.
CLI example::
salt myminion boto_kms.generate_random number_of_bytes=1024 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L395-L412 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon KMS
.. versionadded:: 2015.8.0
:configuration: This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no furthe... |
saltstack/salt | salt/modules/boto_kms.py | get_key_policy | python | def get_key_policy(key_id, policy_name, region=None, key=None, keyid=None,
profile=None):
'''
Get the policy for the specified key.
CLI example::
salt myminion boto_kms.get_key_policy 'alias/mykey' mypolicy
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profil... | Get the policy for the specified key.
CLI example::
salt myminion boto_kms.get_key_policy 'alias/mykey' mypolicy | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L415-L435 | [
"def deserialize(stream_or_string, **options):\n '''\n Deserialize any string or stream like object into a Python data structure.\n\n :param stream_or_string: stream or string to deserialize.\n :param options: options given to lower json/simplejson module.\n '''\n\n try:\n if not isinstance... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon KMS
.. versionadded:: 2015.8.0
:configuration: This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no furthe... |
saltstack/salt | salt/modules/boto_kms.py | get_key_rotation_status | python | def get_key_rotation_status(key_id, region=None, key=None, keyid=None,
profile=None):
'''
Get status of whether or not key rotation is enabled for a key.
CLI example::
salt myminion boto_kms.get_key_rotation_status 'alias/mykey'
'''
conn = _get_conn(region=regio... | Get status of whether or not key rotation is enabled for a key.
CLI example::
salt myminion boto_kms.get_key_rotation_status 'alias/mykey' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L438-L455 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon KMS
.. versionadded:: 2015.8.0
:configuration: This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no furthe... |
saltstack/salt | salt/modules/boto_kms.py | list_grants | python | def list_grants(key_id, limit=None, marker=None, region=None, key=None,
keyid=None, profile=None):
'''
List grants for the specified key.
CLI example::
salt myminion boto_kms.list_grants 'alias/mykey'
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile... | List grants for the specified key.
CLI example::
salt myminion boto_kms.list_grants 'alias/mykey' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L458-L490 | [
"def _get_key_id(alias, region=None, key=None, keyid=None, profile=None):\n '''\n From an alias, get a key_id.\n '''\n key_metadata = describe_key(\n alias, region, key, keyid, profile\n )['key_metadata']\n return key_metadata['KeyId']\n"
] | # -*- coding: utf-8 -*-
'''
Connection module for Amazon KMS
.. versionadded:: 2015.8.0
:configuration: This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no furthe... |
saltstack/salt | salt/modules/boto_kms.py | list_key_policies | python | def list_key_policies(key_id, limit=None, marker=None, region=None, key=None,
keyid=None, profile=None):
'''
List key_policies for the specified key.
CLI example::
salt myminion boto_kms.list_key_policies 'alias/mykey'
'''
conn = _get_conn(region=region, key=key, keyi... | List key_policies for the specified key.
CLI example::
salt myminion boto_kms.list_key_policies 'alias/mykey' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L493-L517 | [
"def _get_key_id(alias, region=None, key=None, keyid=None, profile=None):\n '''\n From an alias, get a key_id.\n '''\n key_metadata = describe_key(\n alias, region, key, keyid, profile\n )['key_metadata']\n return key_metadata['KeyId']\n"
] | # -*- coding: utf-8 -*-
'''
Connection module for Amazon KMS
.. versionadded:: 2015.8.0
:configuration: This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no furthe... |
saltstack/salt | salt/modules/boto_kms.py | put_key_policy | python | def put_key_policy(key_id, policy_name, policy, region=None, key=None,
keyid=None, profile=None):
'''
Attach a key policy to the specified key.
CLI example::
salt myminion boto_kms.put_key_policy 'alias/mykey' default '{"Statement":...}'
'''
conn = _get_conn(region=regio... | Attach a key policy to the specified key.
CLI example::
salt myminion boto_kms.put_key_policy 'alias/mykey' default '{"Statement":...}' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L520-L538 | [
"def serialize(obj, **options):\n '''\n Serialize Python data to JSON.\n\n :param obj: the data structure to serialize\n :param options: options given to lower json/simplejson module.\n '''\n\n try:\n if 'fp' in options:\n return salt.utils.json.dump(obj, _json_module=_json, **op... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon KMS
.. versionadded:: 2015.8.0
:configuration: This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no furthe... |
saltstack/salt | salt/modules/boto_kms.py | re_encrypt | python | def re_encrypt(ciphertext_blob, destination_key_id,
source_encryption_context=None,
destination_encryption_context=None, grant_tokens=None,
region=None, key=None, keyid=None, profile=None):
'''
Reencrypt encrypted data with a new master key.
CLI example::
... | Reencrypt encrypted data with a new master key.
CLI example::
salt myminion boto_kms.re_encrypt 'encrypted_data' 'alias/mynewkey' default '{"Statement":...}' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L541-L568 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon KMS
.. versionadded:: 2015.8.0
:configuration: This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no furthe... |
saltstack/salt | salt/modules/boto_kms.py | revoke_grant | python | def revoke_grant(key_id, grant_id, region=None, key=None, keyid=None,
profile=None):
'''
Revoke a grant from a key.
CLI example::
salt myminion boto_kms.revoke_grant 'alias/mykey' 8u89hf-j09j...
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
... | Revoke a grant from a key.
CLI example::
salt myminion boto_kms.revoke_grant 'alias/mykey' 8u89hf-j09j... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_kms.py#L571-L591 | [
"def _get_key_id(alias, region=None, key=None, keyid=None, profile=None):\n '''\n From an alias, get a key_id.\n '''\n key_metadata = describe_key(\n alias, region, key, keyid, profile\n )['key_metadata']\n return key_metadata['KeyId']\n"
] | # -*- coding: utf-8 -*-
'''
Connection module for Amazon KMS
.. versionadded:: 2015.8.0
:configuration: This module accepts explicit kms credentials but can also utilize
IAM roles assigned to the instance through Instance Profiles. Dynamic
credentials are then automatically obtained from AWS API and no furthe... |
saltstack/salt | salt/utils/debug.py | _makepretty | python | def _makepretty(printout, stack):
'''
Pretty print the stack trace and environment information
for debugging those hard to reproduce user problems. :)
'''
printout.write('======== Salt Debug Stack Trace =========\n')
traceback.print_stack(stack, file=printout)
printout.write('==============... | Pretty print the stack trace and environment information
for debugging those hard to reproduce user problems. :) | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/debug.py#L21-L28 | null | # -*- coding: utf-8 -*-
'''
Print a stacktrace when sent a SIGUSR1 for debugging
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import os
import sys
import time
import signal
import tempfile
import traceback
import inspect
# Import salt libs
import salt.utils.files
i... |
saltstack/salt | salt/utils/debug.py | _handle_sigusr1 | python | def _handle_sigusr1(sig, stack):
'''
Signal handler for SIGUSR1, only available on Unix-like systems
'''
# When running in the foreground, do the right thing
# and spit out the debug info straight to the console
if sys.stderr.isatty():
output = sys.stderr
_makepretty(output, sta... | Signal handler for SIGUSR1, only available on Unix-like systems | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/debug.py#L31-L44 | null | # -*- coding: utf-8 -*-
'''
Print a stacktrace when sent a SIGUSR1 for debugging
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import os
import sys
import time
import signal
import tempfile
import traceback
import inspect
# Import salt libs
import salt.utils.files
i... |
saltstack/salt | salt/utils/debug.py | _handle_sigusr2 | python | def _handle_sigusr2(sig, stack):
'''
Signal handler for SIGUSR2, only available on Unix-like systems
'''
try:
import yappi
except ImportError:
return
if yappi.is_running():
yappi.stop()
filename = 'callgrind.salt-{0}-{1}'.format(int(time.time()), os.getpid())
... | Signal handler for SIGUSR2, only available on Unix-like systems | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/debug.py#L47-L66 | null | # -*- coding: utf-8 -*-
'''
Print a stacktrace when sent a SIGUSR1 for debugging
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import os
import sys
import time
import signal
import tempfile
import traceback
import inspect
# Import salt libs
import salt.utils.files
i... |
saltstack/salt | salt/utils/debug.py | enable_sig_handler | python | def enable_sig_handler(signal_name, handler):
'''
Add signal handler for signal name if it exists on given platform
'''
if hasattr(signal, signal_name):
signal.signal(getattr(signal, signal_name), handler) | Add signal handler for signal name if it exists on given platform | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/debug.py#L69-L74 | null | # -*- coding: utf-8 -*-
'''
Print a stacktrace when sent a SIGUSR1 for debugging
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import os
import sys
import time
import signal
import tempfile
import traceback
import inspect
# Import salt libs
import salt.utils.files
i... |
saltstack/salt | salt/utils/debug.py | caller_name | python | def caller_name(skip=2, include_lineno=False):
'''
Get a name of a caller in the format module.class.method
`skip` specifies how many levels of stack to skip while getting caller
name. skip=1 means "who calls me", skip=2 "who calls my caller" etc.
An empty string is returned if skipped levels exce... | Get a name of a caller in the format module.class.method
`skip` specifies how many levels of stack to skip while getting caller
name. skip=1 means "who calls me", skip=2 "who calls my caller" etc.
An empty string is returned if skipped levels exceed stack height
Source: https://gist.github.com/techto... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/debug.py#L102-L143 | null | # -*- coding: utf-8 -*-
'''
Print a stacktrace when sent a SIGUSR1 for debugging
'''
from __future__ import absolute_import, print_function, unicode_literals
# Import python libs
import os
import sys
import time
import signal
import tempfile
import traceback
import inspect
# Import salt libs
import salt.utils.files
i... |
saltstack/salt | salt/states/nxos_upgrade.py | image_running | python | def image_running(name, system_image, kickstart_image=None, issu=True, **kwargs):
'''
Ensure the NX-OS system image is running on the device.
name
Name of the salt state task
system_image
Name of the system image file on bootflash:
kickstart_image
Name of the kickstart ima... | Ensure the NX-OS system image is running on the device.
name
Name of the salt state task
system_image
Name of the system image file on bootflash:
kickstart_image
Name of the kickstart image file on bootflash:
This is not needed if the system_image is a combined system and
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/nxos_upgrade.py#L41-L107 | [
"def _version_info():\n '''\n Helper method to return running image version\n '''\n if 'NXOS' in __grains__['nxos']['software']:\n return __grains__['nxos']['software']['NXOS']\n elif 'kickstart' in __grains__['nxos']['software']:\n return __grains__['nxos']['software']['kickstart']\n ... | # -*- coding: utf-8 -*-
# Copyright (c) 2018 Cisco and/or its affiliates.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless require... |
saltstack/salt | salt/ext/vsan/vsanapiutils.py | WaitForTasks | python | def WaitForTasks(tasks, si):
pc = si.content.propertyCollector
taskList = [str(task) for task in tasks]
# Create filter
objSpecs = [vmodl.query.PropertyCollector.ObjectSpec(obj=task)
for task in tasks]
propSpec = vmodl.query.PropertyCollector... | Given the service instance si and tasks, it returns after all the
tasks are complete | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/ext/vsan/vsanapiutils.py#L116-L165 | null | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Copyright 2016 VMware, Inc. All rights reserved.
This module defines basic helper functions used in the sampe codes
"""
# pylint: skip-file
__author__ = 'VMware, Inc'
from pyVmomi import vim, vmodl, SoapStubAdapter
#import the VSAN API python bindings
import vsanmg... |
saltstack/salt | salt/modules/ddns.py | _config | python | def _config(name, key=None, **kwargs):
'''
Return a value for 'name' from command line args then config file options.
Specify 'key' if the config file option is not the same as 'name'.
'''
if key is None:
key = name
if name in kwargs:
value = kwargs[name]
else:
value ... | Return a value for 'name' from command line args then config file options.
Specify 'key' if the config file option is not the same as 'name'. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ddns.py#L55-L68 | null | # -*- coding: utf-8 -*-
'''
Support for RFC 2136 dynamic DNS updates.
:depends: - dnspython Python module
:configuration: If you want to use TSIG authentication for the server, there
are a couple of optional configuration parameters made available to
support this (the keyname is only needed if the keyring co... |
saltstack/salt | salt/modules/ddns.py | add_host | python | def add_host(zone, name, ttl, ip, nameserver='127.0.0.1', replace=True,
timeout=5, port=53, **kwargs):
'''
Add, replace, or update the A and PTR (reverse) records for a host.
CLI Example:
.. code-block:: bash
salt ns1 ddns.add_host example.com host1 60 10.1.1.1
'''
res = ... | Add, replace, or update the A and PTR (reverse) records for a host.
CLI Example:
.. code-block:: bash
salt ns1 ddns.add_host example.com host1 60 10.1.1.1 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ddns.py#L79-L109 | [
"def update(zone, name, ttl, rdtype, data, nameserver='127.0.0.1', timeout=5,\n replace=False, port=53, **kwargs):\n '''\n Add, replace, or update a DNS record.\n nameserver must be an IP address and the minion running this module\n must have update privileges on that server.\n If replace i... | # -*- coding: utf-8 -*-
'''
Support for RFC 2136 dynamic DNS updates.
:depends: - dnspython Python module
:configuration: If you want to use TSIG authentication for the server, there
are a couple of optional configuration parameters made available to
support this (the keyname is only needed if the keyring co... |
saltstack/salt | salt/modules/ddns.py | delete_host | python | def delete_host(zone, name, nameserver='127.0.0.1', timeout=5, port=53,
**kwargs):
'''
Delete the forward and reverse records for a host.
Returns true if any records are deleted.
CLI Example:
.. code-block:: bash
salt ns1 ddns.delete_host example.com host1
'''
fqd... | Delete the forward and reverse records for a host.
Returns true if any records are deleted.
CLI Example:
.. code-block:: bash
salt ns1 ddns.delete_host example.com host1 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ddns.py#L112-L151 | [
"def delete(zone, name, rdtype=None, data=None, nameserver='127.0.0.1',\n timeout=5, port=53, **kwargs):\n '''\n Delete a DNS record.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt ns1 ddns.delete example.com host1 A\n '''\n name = six.text_type(name)\n\n if name[-1:] == '.... | # -*- coding: utf-8 -*-
'''
Support for RFC 2136 dynamic DNS updates.
:depends: - dnspython Python module
:configuration: If you want to use TSIG authentication for the server, there
are a couple of optional configuration parameters made available to
support this (the keyname is only needed if the keyring co... |
saltstack/salt | salt/modules/ddns.py | update | python | def update(zone, name, ttl, rdtype, data, nameserver='127.0.0.1', timeout=5,
replace=False, port=53, **kwargs):
'''
Add, replace, or update a DNS record.
nameserver must be an IP address and the minion running this module
must have update privileges on that server.
If replace is true, fir... | Add, replace, or update a DNS record.
nameserver must be an IP address and the minion running this module
must have update privileges on that server.
If replace is true, first deletes all records for this name and type.
CLI Example:
.. code-block:: bash
salt ns1 ddns.update example.com ho... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ddns.py#L154-L205 | [
"def _config(name, key=None, **kwargs):\n '''\n Return a value for 'name' from command line args then config file options.\n Specify 'key' if the config file option is not the same as 'name'.\n '''\n if key is None:\n key = name\n if name in kwargs:\n value = kwargs[name]\n else:\... | # -*- coding: utf-8 -*-
'''
Support for RFC 2136 dynamic DNS updates.
:depends: - dnspython Python module
:configuration: If you want to use TSIG authentication for the server, there
are a couple of optional configuration parameters made available to
support this (the keyname is only needed if the keyring co... |
saltstack/salt | salt/modules/ansiblegate.py | _set_callables | python | def _set_callables(modules):
'''
Set all Ansible modules callables
:return:
'''
def _set_function(cmd_name, doc):
'''
Create a Salt function for the Ansible module.
'''
def _cmd(*args, **kw):
'''
Call an Ansible module as a function from the Sa... | Set all Ansible modules callables
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ansiblegate.py#L190-L215 | null | # -*- coding: utf-8 -*-
#
# Author: Bo Maryniuk <bo@suse.de>
#
# Copyright 2017 SUSE LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unles... |
saltstack/salt | salt/modules/ansiblegate.py | help | python | def help(module=None, *args):
'''
Display help on Ansible standard module.
:param module:
:return:
'''
if not module:
raise CommandExecutionError('Please tell me what module you want to have helped with. '
'Or call "ansible.list" to know what is avail... | Display help on Ansible standard module.
:param module:
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ansiblegate.py#L237-L273 | [
"def safe_load(stream, Loader=SaltYamlSafeLoader):\n '''\n .. versionadded:: 2018.3.0\n\n Helper function which automagically uses our custom loader.\n '''\n return yaml.load(stream, Loader=Loader)\n"
] | # -*- coding: utf-8 -*-
#
# Author: Bo Maryniuk <bo@suse.de>
#
# Copyright 2017 SUSE LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unles... |
saltstack/salt | salt/modules/ansiblegate.py | playbooks | python | def playbooks(playbook, rundir=None, check=False, diff=False, extra_vars=None,
flush_cache=False, forks=5, inventory=None, limit=None,
list_hosts=False, list_tags=False, list_tasks=False,
module_path=None, skip_tags=None, start_at_task=None,
syntax_check=False, ta... | Run Ansible Playbooks
:param playbook: Which playbook to run.
:param rundir: Directory to run `ansible-playbook` in. (Default: None)
:param check: don't make any changes; instead, try to predict some
of the changes that may occur (Default: False)
:param diff: when changing (small) fil... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ansiblegate.py#L286-L381 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n"
] | # -*- coding: utf-8 -*-
#
# Author: Bo Maryniuk <bo@suse.de>
#
# Copyright 2017 SUSE LLC
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unles... |
saltstack/salt | salt/modules/ansiblegate.py | AnsibleModuleResolver._get_modules_map | python | def _get_modules_map(self, path=None):
'''
Get installed Ansible modules
:return:
'''
paths = {}
root = ansible.modules.__path__[0]
if not path:
path = root
for p_el in os.listdir(path):
p_el_path = os.path.join(path, p_el)
... | Get installed Ansible modules
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ansiblegate.py#L68-L92 | null | class AnsibleModuleResolver(object):
'''
This class is to resolve all available modules in Ansible.
'''
def __init__(self, opts):
self.opts = opts
self._modules_map = {}
def load_module(self, module):
'''
Introspect Ansible module.
:param module:
:r... |
saltstack/salt | salt/modules/ansiblegate.py | AnsibleModuleResolver.load_module | python | def load_module(self, module):
'''
Introspect Ansible module.
:param module:
:return:
'''
m_ref = self._modules_map.get(module)
if m_ref is None:
raise LoaderError('Module "{0}" was not found'.format(module))
mod = importlib.import_module('ans... | Introspect Ansible module.
:param module:
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ansiblegate.py#L94-L107 | null | class AnsibleModuleResolver(object):
'''
This class is to resolve all available modules in Ansible.
'''
def __init__(self, opts):
self.opts = opts
self._modules_map = {}
def _get_modules_map(self, path=None):
'''
Get installed Ansible modules
:return:
... |
saltstack/salt | salt/modules/ansiblegate.py | AnsibleModuleResolver.get_modules_list | python | def get_modules_list(self, pattern=None):
'''
Return module map references.
:return:
'''
if pattern and '*' not in pattern:
pattern = '*{0}*'.format(pattern)
modules = []
for m_name, m_path in self._modules_map.items():
m_path = m_path.spli... | Return module map references.
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ansiblegate.py#L109-L122 | null | class AnsibleModuleResolver(object):
'''
This class is to resolve all available modules in Ansible.
'''
def __init__(self, opts):
self.opts = opts
self._modules_map = {}
def _get_modules_map(self, path=None):
'''
Get installed Ansible modules
:return:
... |
saltstack/salt | salt/modules/ansiblegate.py | AnsibleModuleCaller.call | python | def call(self, module, *args, **kwargs):
'''
Call an Ansible module by invoking it.
:param module: the name of the module.
:param args: Arguments to the module
:param kwargs: keywords to the module
:return:
'''
module = self._resolver.load_module(module)
... | Call an Ansible module by invoking it.
:param module: the name of the module.
:param args: Arguments to the module
:param kwargs: keywords to the module
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/ansiblegate.py#L142-L183 | [
"def loads(s, **kwargs):\n '''\n .. versionadded:: 2018.3.0\n\n Wraps json.loads and prevents a traceback in the event that a bytestring is\n passed to the function. (Python < 3.6 cannot load bytestrings)\n\n You can pass an alternate json module (loaded via import_json() above)\n using the _json_... | class AnsibleModuleCaller(object):
DEFAULT_TIMEOUT = 1200 # seconds (20 minutes)
OPT_TIMEOUT_KEY = 'ansible_timeout'
def __init__(self, resolver):
self._resolver = resolver
self.timeout = self._resolver.opts.get(self.OPT_TIMEOUT_KEY, self.DEFAULT_TIMEOUT)
|
saltstack/salt | salt/modules/file.py | __clean_tmp | python | def __clean_tmp(sfn):
'''
Clean out a template temp file
'''
if sfn.startswith(os.path.join(tempfile.gettempdir(),
salt.utils.files.TEMPFILE_PREFIX)):
# Don't remove if it exists in file_roots (any saltenv)
all_roots = itertools.chain.from_iterable(
... | Clean out a template temp file | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/file.py#L88-L100 | [
"def itervalues(d, **kw):\n return d.itervalues(**kw)\n"
] | # -*- coding: utf-8 -*-
'''
Manage information about regular files, directories,
and special files on the minion, set/read user,
group, mode, and data
'''
# TODO: We should add the capability to do u+r type operations here
# some time in the future
from __future__ import absolute_import, print_function, unicode_liter... |
saltstack/salt | salt/modules/file.py | _binary_replace | python | def _binary_replace(old, new):
'''
This function does NOT do any diffing, it just checks the old and new files
to see if either is binary, and provides an appropriate string noting the
difference between the two files. If neither file is binary, an empty
string is returned.
This function should... | This function does NOT do any diffing, it just checks the old and new files
to see if either is binary, and provides an appropriate string noting the
difference between the two files. If neither file is binary, an empty
string is returned.
This function should only be run AFTER it has been determined t... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/file.py#L112-L131 | null | # -*- coding: utf-8 -*-
'''
Manage information about regular files, directories,
and special files on the minion, set/read user,
group, mode, and data
'''
# TODO: We should add the capability to do u+r type operations here
# some time in the future
from __future__ import absolute_import, print_function, unicode_liter... |
saltstack/salt | salt/modules/file.py | _splitlines_preserving_trailing_newline | python | def _splitlines_preserving_trailing_newline(str):
'''
Returns a list of the lines in the string, breaking at line boundaries and
preserving a trailing newline (if present).
Essentially, this works like ``str.striplines(False)`` but preserves an
empty line at the end. This is equivalent to the follo... | Returns a list of the lines in the string, breaking at line boundaries and
preserving a trailing newline (if present).
Essentially, this works like ``str.striplines(False)`` but preserves an
empty line at the end. This is equivalent to the following code:
.. code-block:: python
lines = str.sp... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/file.py#L142-L159 | null | # -*- coding: utf-8 -*-
'''
Manage information about regular files, directories,
and special files on the minion, set/read user,
group, mode, and data
'''
# TODO: We should add the capability to do u+r type operations here
# some time in the future
from __future__ import absolute_import, print_function, unicode_liter... |
saltstack/salt | salt/modules/file.py | gid_to_group | python | def gid_to_group(gid):
'''
Convert the group id to the group name on this system
gid
gid to convert to a group name
CLI Example:
.. code-block:: bash
salt '*' file.gid_to_group 0
'''
try:
gid = int(gid)
except ValueError:
# This is not an integer, mayb... | Convert the group id to the group name on this system
gid
gid to convert to a group name
CLI Example:
.. code-block:: bash
salt '*' file.gid_to_group 0 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/file.py#L162-L189 | [
"def group_to_gid(group):\n '''\n Convert the group to the gid on this system\n\n group\n group to convert to its gid\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' file.group_to_gid root\n '''\n if group is None:\n return ''\n try:\n if isinstance(group, ... | # -*- coding: utf-8 -*-
'''
Manage information about regular files, directories,
and special files on the minion, set/read user,
group, mode, and data
'''
# TODO: We should add the capability to do u+r type operations here
# some time in the future
from __future__ import absolute_import, print_function, unicode_liter... |
saltstack/salt | salt/modules/file.py | group_to_gid | python | def group_to_gid(group):
'''
Convert the group to the gid on this system
group
group to convert to its gid
CLI Example:
.. code-block:: bash
salt '*' file.group_to_gid root
'''
if group is None:
return ''
try:
if isinstance(group, int):
ret... | Convert the group to the gid on this system
group
group to convert to its gid
CLI Example:
.. code-block:: bash
salt '*' file.group_to_gid root | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/file.py#L192-L212 | null | # -*- coding: utf-8 -*-
'''
Manage information about regular files, directories,
and special files on the minion, set/read user,
group, mode, and data
'''
# TODO: We should add the capability to do u+r type operations here
# some time in the future
from __future__ import absolute_import, print_function, unicode_liter... |
saltstack/salt | salt/modules/file.py | get_gid | python | def get_gid(path, follow_symlinks=True):
'''
Return the id of the group that owns a given file
path
file or directory of which to get the gid
follow_symlinks
indicated if symlinks should be followed
CLI Example:
.. code-block:: bash
salt '*' file.get_gid /etc/passwd... | Return the id of the group that owns a given file
path
file or directory of which to get the gid
follow_symlinks
indicated if symlinks should be followed
CLI Example:
.. code-block:: bash
salt '*' file.get_gid /etc/passwd
.. versionchanged:: 0.16.4
``follow_sym... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/file.py#L215-L235 | [
"def stats(path, hash_type=None, follow_symlinks=True):\n '''\n Return a dict containing the stats for a given file\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' file.stats /etc/passwd\n '''\n path = os.path.expanduser(path)\n\n ret = {}\n if not os.path.exists(path):\n ... | # -*- coding: utf-8 -*-
'''
Manage information about regular files, directories,
and special files on the minion, set/read user,
group, mode, and data
'''
# TODO: We should add the capability to do u+r type operations here
# some time in the future
from __future__ import absolute_import, print_function, unicode_liter... |
saltstack/salt | salt/modules/file.py | get_group | python | def get_group(path, follow_symlinks=True):
'''
Return the group that owns a given file
path
file or directory of which to get the group
follow_symlinks
indicated if symlinks should be followed
CLI Example:
.. code-block:: bash
salt '*' file.get_group /etc/passwd
... | Return the group that owns a given file
path
file or directory of which to get the group
follow_symlinks
indicated if symlinks should be followed
CLI Example:
.. code-block:: bash
salt '*' file.get_group /etc/passwd
.. versionchanged:: 0.16.4
``follow_symlinks``... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/file.py#L238-L257 | [
"def stats(path, hash_type=None, follow_symlinks=True):\n '''\n Return a dict containing the stats for a given file\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' file.stats /etc/passwd\n '''\n path = os.path.expanduser(path)\n\n ret = {}\n if not os.path.exists(path):\n ... | # -*- coding: utf-8 -*-
'''
Manage information about regular files, directories,
and special files on the minion, set/read user,
group, mode, and data
'''
# TODO: We should add the capability to do u+r type operations here
# some time in the future
from __future__ import absolute_import, print_function, unicode_liter... |
saltstack/salt | salt/modules/file.py | user_to_uid | python | def user_to_uid(user):
'''
Convert user name to a uid
user
user name to convert to its uid
CLI Example:
.. code-block:: bash
salt '*' file.user_to_uid root
'''
if user is None:
user = salt.utils.user.get_user()
try:
if isinstance(user, int):
... | Convert user name to a uid
user
user name to convert to its uid
CLI Example:
.. code-block:: bash
salt '*' file.user_to_uid root | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/file.py#L280-L300 | [
"def get_user():\n '''\n Get the current user\n '''\n if HAS_PWD:\n ret = pwd.getpwuid(os.geteuid()).pw_name\n elif HAS_WIN_FUNCTIONS and salt.utils.win_functions.HAS_WIN32:\n ret = salt.utils.win_functions.get_current_user()\n else:\n raise CommandExecutionError(\n ... | # -*- coding: utf-8 -*-
'''
Manage information about regular files, directories,
and special files on the minion, set/read user,
group, mode, and data
'''
# TODO: We should add the capability to do u+r type operations here
# some time in the future
from __future__ import absolute_import, print_function, unicode_liter... |
saltstack/salt | salt/modules/file.py | get_uid | python | def get_uid(path, follow_symlinks=True):
'''
Return the id of the user that owns a given file
path
file or directory of which to get the uid
follow_symlinks
indicated if symlinks should be followed
CLI Example:
.. code-block:: bash
salt '*' file.get_uid /etc/passwd
... | Return the id of the user that owns a given file
path
file or directory of which to get the uid
follow_symlinks
indicated if symlinks should be followed
CLI Example:
.. code-block:: bash
salt '*' file.get_uid /etc/passwd
.. versionchanged:: 0.16.4
``follow_symli... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/file.py#L303-L322 | [
"def stats(path, hash_type=None, follow_symlinks=True):\n '''\n Return a dict containing the stats for a given file\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' file.stats /etc/passwd\n '''\n path = os.path.expanduser(path)\n\n ret = {}\n if not os.path.exists(path):\n ... | # -*- coding: utf-8 -*-
'''
Manage information about regular files, directories,
and special files on the minion, set/read user,
group, mode, and data
'''
# TODO: We should add the capability to do u+r type operations here
# some time in the future
from __future__ import absolute_import, print_function, unicode_liter... |
saltstack/salt | salt/modules/file.py | get_mode | python | def get_mode(path, follow_symlinks=True):
'''
Return the mode of a file
path
file or directory of which to get the mode
follow_symlinks
indicated if symlinks should be followed
CLI Example:
.. code-block:: bash
salt '*' file.get_mode /etc/passwd
.. versionchange... | Return the mode of a file
path
file or directory of which to get the mode
follow_symlinks
indicated if symlinks should be followed
CLI Example:
.. code-block:: bash
salt '*' file.get_mode /etc/passwd
.. versionchanged:: 2014.1.0
``follow_symlinks`` option added | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/file.py#L347-L366 | [
"def stats(path, hash_type=None, follow_symlinks=True):\n '''\n Return a dict containing the stats for a given file\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' file.stats /etc/passwd\n '''\n path = os.path.expanduser(path)\n\n ret = {}\n if not os.path.exists(path):\n ... | # -*- coding: utf-8 -*-
'''
Manage information about regular files, directories,
and special files on the minion, set/read user,
group, mode, and data
'''
# TODO: We should add the capability to do u+r type operations here
# some time in the future
from __future__ import absolute_import, print_function, unicode_liter... |
saltstack/salt | salt/modules/file.py | set_mode | python | def set_mode(path, mode):
'''
Set the mode of a file
path
file or directory of which to set the mode
mode
mode to set the path to
CLI Example:
.. code-block:: bash
salt '*' file.set_mode /etc/passwd 0644
'''
path = os.path.expanduser(path)
mode = six.tex... | Set the mode of a file
path
file or directory of which to set the mode
mode
mode to set the path to
CLI Example:
.. code-block:: bash
salt '*' file.set_mode /etc/passwd 0644 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/file.py#L369-L396 | [
"def get_mode(path, follow_symlinks=True):\n '''\n Return the mode of a file\n\n path\n file or directory of which to get the mode\n\n follow_symlinks\n indicated if symlinks should be followed\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' file.get_mode /etc/passwd\n\... | # -*- coding: utf-8 -*-
'''
Manage information about regular files, directories,
and special files on the minion, set/read user,
group, mode, and data
'''
# TODO: We should add the capability to do u+r type operations here
# some time in the future
from __future__ import absolute_import, print_function, unicode_liter... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.