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/status.py
netdev
python
def netdev(): ''' .. versionchanged:: 2016.3.2 Return the network device stats for this minion .. versionchanged:: 2016.11.4 Added support for AIX CLI Example: .. code-block:: bash salt '*' status.netdev ''' def linux_netdev(): ''' linux specific i...
.. versionchanged:: 2016.3.2 Return the network device stats for this minion .. versionchanged:: 2016.11.4 Added support for AIX CLI Example: .. code-block:: bash salt '*' status.netdev
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/status.py#L1254-L1431
null
# -*- coding: utf-8 -*- ''' Module for returning various status data about a minion. These data can be useful for compiling into stats later. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import datetime import os import re import logging import fnmatch import collec...
saltstack/salt
salt/modules/status.py
w
python
def w(): # pylint: disable=C0103 ''' Return a list of logged in users for this minion, using the w command CLI Example: .. code-block:: bash salt '*' status.w ''' def linux_w(): ''' Linux specific implementation for w ''' user_list = [] users =...
Return a list of logged in users for this minion, using the w command CLI Example: .. code-block:: bash salt '*' status.w
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/status.py#L1434-L1492
null
# -*- coding: utf-8 -*- ''' Module for returning various status data about a minion. These data can be useful for compiling into stats later. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import datetime import os import re import logging import fnmatch import collec...
saltstack/salt
salt/modules/status.py
all_status
python
def all_status(): ''' Return a composite of all status data and info for this minion. Warning: There is a LOT here! CLI Example: .. code-block:: bash salt '*' status.all_status ''' return {'cpuinfo': cpuinfo(), 'cpustats': cpustats(), 'diskstats': diskstats...
Return a composite of all status data and info for this minion. Warning: There is a LOT here! CLI Example: .. code-block:: bash salt '*' status.all_status
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/status.py#L1495-L1516
[ "def w(): # pylint: disable=C0103\n '''\n Return a list of logged in users for this minion, using the w command\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' status.w\n '''\n def linux_w():\n '''\n Linux specific implementation for w\n '''\n user_list =...
# -*- coding: utf-8 -*- ''' Module for returning various status data about a minion. These data can be useful for compiling into stats later. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import datetime import os import re import logging import fnmatch import collec...
saltstack/salt
salt/modules/status.py
pid
python
def pid(sig): ''' Return the PID or an empty string if the process is running or not. Pass a signature to use to find the process via ps. Note you can pass a Python-compatible regular expression to return all pids of processes matching the regexp. .. versionchanged:: 2016.11.4 Added su...
Return the PID or an empty string if the process is running or not. Pass a signature to use to find the process via ps. Note you can pass a Python-compatible regular expression to return all pids of processes matching the regexp. .. versionchanged:: 2016.11.4 Added support for AIX CLI Exa...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/status.py#L1519-L1548
null
# -*- coding: utf-8 -*- ''' Module for returning various status data about a minion. These data can be useful for compiling into stats later. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import datetime import os import re import logging import fnmatch import collec...
saltstack/salt
salt/modules/status.py
version
python
def version(): ''' Return the system version for this minion .. versionchanged:: 2016.11.4 Added support for AIX .. versionchanged:: 2018.3.0 Added support for OpenBSD CLI Example: .. code-block:: bash salt '*' status.version ''' def linux_version(): ...
Return the system version for this minion .. versionchanged:: 2016.11.4 Added support for AIX .. versionchanged:: 2018.3.0 Added support for OpenBSD CLI Example: .. code-block:: bash salt '*' status.version
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/status.py#L1551-L1592
null
# -*- coding: utf-8 -*- ''' Module for returning various status data about a minion. These data can be useful for compiling into stats later. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import datetime import os import re import logging import fnmatch import collec...
saltstack/salt
salt/modules/status.py
master
python
def master(master=None, connected=True): ''' .. versionadded:: 2014.7.0 Return the connection status with master. Fire an event if the connection to master is not as expected. This function is meant to be run via a scheduled job from the minion. If master_ip is an FQDN/Hostname, it must be reso...
.. versionadded:: 2014.7.0 Return the connection status with master. Fire an event if the connection to master is not as expected. This function is meant to be run via a scheduled job from the minion. If master_ip is an FQDN/Hostname, it must be resolvable to a valid IPv4 address. .. versionchange...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/status.py#L1595-L1639
[ "def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ...
# -*- coding: utf-8 -*- ''' Module for returning various status data about a minion. These data can be useful for compiling into stats later. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import datetime import os import re import logging import fnmatch import collec...
saltstack/salt
salt/modules/status.py
ping_master
python
def ping_master(master): ''' .. versionadded:: 2016.3.0 Sends ping request to the given master. Fires '__master_failback' event on success. Returns bool result. CLI Example: .. code-block:: bash salt '*' status.ping_master localhost ''' if master is None or master == '': ...
.. versionadded:: 2016.3.0 Sends ping request to the given master. Fires '__master_failback' event on success. Returns bool result. CLI Example: .. code-block:: bash salt '*' status.ping_master localhost
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/status.py#L1642-L1683
[ "def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ...
# -*- coding: utf-8 -*- ''' Module for returning various status data about a minion. These data can be useful for compiling into stats later. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import datetime import os import re import logging import fnmatch import collec...
saltstack/salt
salt/modules/status.py
proxy_reconnect
python
def proxy_reconnect(proxy_name, opts=None): ''' Forces proxy minion reconnection when not alive. proxy_name The virtual name of the proxy module. opts: None Opts dictionary. Not intended for CLI usage. CLI Example: salt '*' status.proxy_reconnect rest_sample ''' ...
Forces proxy minion reconnection when not alive. proxy_name The virtual name of the proxy module. opts: None Opts dictionary. Not intended for CLI usage. CLI Example: salt '*' status.proxy_reconnect rest_sample
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/status.py#L1686-L1719
null
# -*- coding: utf-8 -*- ''' Module for returning various status data about a minion. These data can be useful for compiling into stats later. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import datetime import os import re import logging import fnmatch import collec...
saltstack/salt
salt/states/x509.py
_revoked_to_list
python
def _revoked_to_list(revs): ''' Turn the mess of OrderedDicts and Lists into a list of dicts for use in the CRL module. ''' list_ = [] for rev in revs: for rev_name, props in six.iteritems( rev): # pylint: disable=unused-variable dict_ = {} ...
Turn the mess of OrderedDicts and Lists into a list of dicts for use in the CRL module.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/x509.py#L187-L205
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n" ]
# -*- coding: utf-8 -*- ''' Manage X509 Certificates .. versionadded:: 2015.8.0 :depends: M2Crypto This module can enable managing a complete PKI infrastructure including creating private keys, CA's, certificates and CRLs. It includes the ability to generate a private key on a server, and have the corresponding publ...
saltstack/salt
salt/states/x509.py
private_key_managed
python
def private_key_managed(name, bits=2048, passphrase=None, cipher='aes_128_cbc', new=False, overwrite=False, verbose=True, **kwargs): ''' Manage ...
Manage a private key's existence. name: Path to the private key bits: Key length in bits. Default 2048. passphrase: Passphrase for encrypting the private key. cipher: Cipher for encrypting the private key. new: Always create a new key. Defaults to False. ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/x509.py#L246-L320
[ "def _get_file_args(name, **kwargs):\n valid_file_args = ['user',\n 'group',\n 'mode',\n 'makedirs',\n 'dir_mode',\n 'backup',\n 'create',\n 'follow_symlinks',...
# -*- coding: utf-8 -*- ''' Manage X509 Certificates .. versionadded:: 2015.8.0 :depends: M2Crypto This module can enable managing a complete PKI infrastructure including creating private keys, CA's, certificates and CRLs. It includes the ability to generate a private key on a server, and have the corresponding publ...
saltstack/salt
salt/states/x509.py
csr_managed
python
def csr_managed(name, **kwargs): ''' Manage a Certificate Signing Request name: Path to the CSR properties: The properties to be added to the certificate request, including items like subject, extensions and public key. See above for valid properties. kwarg...
Manage a Certificate Signing Request name: Path to the CSR properties: The properties to be added to the certificate request, including items like subject, extensions and public key. See above for valid properties. kwargs: Any arguments supported by :py:func:`file.managed ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/x509.py#L323-L385
[ "def _get_file_args(name, **kwargs):\n valid_file_args = ['user',\n 'group',\n 'mode',\n 'makedirs',\n 'dir_mode',\n 'backup',\n 'create',\n 'follow_symlinks',...
# -*- coding: utf-8 -*- ''' Manage X509 Certificates .. versionadded:: 2015.8.0 :depends: M2Crypto This module can enable managing a complete PKI infrastructure including creating private keys, CA's, certificates and CRLs. It includes the ability to generate a private key on a server, and have the corresponding publ...
saltstack/salt
salt/states/x509.py
certificate_managed
python
def certificate_managed(name, days_remaining=90, managed_private_key=None, append_certs=None, **kwargs): ''' Manage a Certificate name Path to the certificate days_remaining : 90 The minimum...
Manage a Certificate name Path to the certificate days_remaining : 90 The minimum number of days remaining when the certificate should be recreated. A value of 0 disables automatic renewal. managed_private_key Manages the private key corresponding to the certificate. All o...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/x509.py#L388-L610
[ "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 -*- ''' Manage X509 Certificates .. versionadded:: 2015.8.0 :depends: M2Crypto This module can enable managing a complete PKI infrastructure including creating private keys, CA's, certificates and CRLs. It includes the ability to generate a private key on a server, and have the corresponding publ...
saltstack/salt
salt/states/x509.py
crl_managed
python
def crl_managed(name, signing_private_key, signing_private_key_passphrase=None, signing_cert=None, revoked=None, days_valid=100, digest="", days_remaining=30, include_expired=False, ...
Manage a Certificate Revocation List name Path to the certificate signing_private_key The private key that will be used to sign this crl. This is usually your CA's private key. signing_private_key_passphrase Passphrase to decrypt the private key. signing_cert ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/x509.py#L613-L731
[ "def _revoked_to_list(revs):\n '''\n Turn the mess of OrderedDicts and Lists into a list of dicts for\n use in the CRL module.\n '''\n list_ = []\n\n for rev in revs:\n for rev_name, props in six.iteritems(\n rev): # pylint: disable=unused-variable\n di...
# -*- coding: utf-8 -*- ''' Manage X509 Certificates .. versionadded:: 2015.8.0 :depends: M2Crypto This module can enable managing a complete PKI infrastructure including creating private keys, CA's, certificates and CRLs. It includes the ability to generate a private key on a server, and have the corresponding publ...
saltstack/salt
salt/states/x509.py
pem_managed
python
def pem_managed(name, text, backup=False, **kwargs): ''' Manage the contents of a PEM file directly with the content in text, ensuring correct formatting. name: The path to the file to manage text: The PEM formatted text to write. kw...
Manage the contents of a PEM file directly with the content in text, ensuring correct formatting. name: The path to the file to manage text: The PEM formatted text to write. kwargs: Any arguments supported by :py:func:`file.managed <salt.states.file.managed>` are supported.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/x509.py#L734-L753
[ "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 -*- ''' Manage X509 Certificates .. versionadded:: 2015.8.0 :depends: M2Crypto This module can enable managing a complete PKI infrastructure including creating private keys, CA's, certificates and CRLs. It includes the ability to generate a private key on a server, and have the corresponding publ...
saltstack/salt
salt/utils/dateutils.py
date_cast
python
def date_cast(date): ''' Casts any object into a datetime.datetime object date any datetime, time string representation... ''' if date is None: return datetime.datetime.now() elif isinstance(date, datetime.datetime): return date # fuzzy date try: if isinst...
Casts any object into a datetime.datetime object date any datetime, time string representation...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dateutils.py#L25-L60
null
# -*- coding: utf-8 -*- ''' Convenience functions for dealing with datetime classes ''' from __future__ import absolute_import, division, print_function, unicode_literals # Import Python libs import datetime # Import Salt libs import salt.utils.stringutils from salt.utils.decorators.jinja import jinja_filter # Impo...
saltstack/salt
salt/states/mssql_user.py
present
python
def present(name, login=None, domain=None, database=None, roles=None, options=None, **kwargs): ''' Checks existance of the named user. If not present, creates the user with the specified roles and options. name The name of the user to manage login If not specified, will be created W...
Checks existance of the named user. If not present, creates the user with the specified roles and options. name The name of the user to manage login If not specified, will be created WITHOUT LOGIN domain Creates a Windows authentication user. Needs to be NetBIOS domain o...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/mssql_user.py#L37-L85
[ "def _normalize_options(options):\n if type(options) in [dict, collections.OrderedDict]:\n return ['{0}={1}'.format(k, v) for k, v in options.items()]\n if type(options) is list and (not options or type(options[0]) is str):\n return options\n # Invalid options\n if type(options) is not lis...
# -*- coding: utf-8 -*- ''' Management of Microsoft SQLServer Users ======================================= The mssql_user module is used to create and manage SQL Server Users .. code-block:: yaml frank: mssql_user.present: - database: yolo ''' from __future__ import absolute_import, print_function...
saltstack/salt
salt/states/mssql_user.py
absent
python
def absent(name, **kwargs): ''' Ensure that the named user is absent name The username of the user to remove ''' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} if not __salt__['mssql.user_exists'](name): ret['comment'] = 'Use...
Ensure that the named user is absent name The username of the user to remove
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/mssql_user.py#L88-L114
null
# -*- coding: utf-8 -*- ''' Management of Microsoft SQLServer Users ======================================= The mssql_user module is used to create and manage SQL Server Users .. code-block:: yaml frank: mssql_user.present: - database: yolo ''' from __future__ import absolute_import, print_function...
saltstack/salt
salt/modules/jinja.py
_strip_odict
python
def _strip_odict(wrapped): ''' dump to json and load it again, replaces OrderedDicts with regular ones ''' @functools.wraps(wrapped) def strip(*args): return salt.utils.json.loads(salt.utils.json.dumps(wrapped(*args))) return strip
dump to json and load it again, replaces OrderedDicts with regular ones
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/jinja.py#L23-L30
null
# -*- coding: utf-8 -*- ''' Module for checking jinja maps and verifying the result of loading JSON/YAML files .. versionadded:: Neon ''' from __future__ import absolute_import, print_function, unicode_literals # Import Python libs import functools import logging import textwrap # Import Salt libs import salt.loader...
saltstack/salt
salt/modules/jinja.py
load_map
python
def load_map(path, value): ''' Loads the map at the specified path, and returns the specified value from that map. CLI Example: .. code-block:: bash # Assuming the map is loaded in your formula SLS as follows: # # {% from "myformula/map.jinja" import myformula with context...
Loads the map at the specified path, and returns the specified value from that map. CLI Example: .. code-block:: bash # Assuming the map is loaded in your formula SLS as follows: # # {% from "myformula/map.jinja" import myformula with context %} # # the following s...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/jinja.py#L34-L60
[ "def compile_template_str(template, renderers, default, blacklist, whitelist):\n '''\n Take template as a string and return the high data structure\n derived from the template.\n '''\n fn_ = salt.utils.files.mkstemp()\n with salt.utils.files.fopen(fn_, 'wb') as ofile:\n ofile.write(SLS_ENCO...
# -*- coding: utf-8 -*- ''' Module for checking jinja maps and verifying the result of loading JSON/YAML files .. versionadded:: Neon ''' from __future__ import absolute_import, print_function, unicode_literals # Import Python libs import functools import logging import textwrap # Import Salt libs import salt.loader...
saltstack/salt
salt/modules/pillar.py
get
python
def get(key, default=KeyError, merge=False, merge_nested_lists=None, delimiter=DEFAULT_TARGET_DELIM, pillarenv=None, saltenv=None): ''' .. versionadded:: 0.14 Attempt to retrieve the named value from :ref:`in-memory pillar data <pillar-in-memory>`. If the...
.. versionadded:: 0.14 Attempt to retrieve the named value from :ref:`in-memory pillar data <pillar-in-memory>`. If the pillar key is not present in the in-memory pillar, then the value specified in the ``default`` option (described below) will be returned. If the merge parameter is set to ``True`...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pillar.py#L32-L189
[ "def items(*args, **kwargs):\n '''\n Calls the master for a fresh pillar and generates the pillar data on the\n fly\n\n Contrast with :py:func:`raw` which returns the pillar data that is\n currently loaded into the minion.\n\n pillar\n If specified, allows for a dictionary of pillar data to...
# -*- coding: utf-8 -*- ''' Extract the pillar data for this minion ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import collections # Import third party libs import copy import os import logging from salt.ext import six # Import salt libs import salt.pillar import...
saltstack/salt
salt/modules/pillar.py
items
python
def items(*args, **kwargs): ''' Calls the master for a fresh pillar and generates the pillar data on the fly Contrast with :py:func:`raw` which returns the pillar data that is currently loaded into the minion. pillar If specified, allows for a dictionary of pillar data to be made ...
Calls the master for a fresh pillar and generates the pillar data on the fly Contrast with :py:func:`raw` which returns the pillar data that is currently loaded into the minion. pillar If specified, allows for a dictionary of pillar data to be made available to pillar and ext_pillar re...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pillar.py#L192-L277
[ "def item(*args, **kwargs):\n '''\n .. versionadded:: 0.16.2\n\n Return one or more pillar entries from the :ref:`in-memory pillar data\n <pillar-in-memory>`.\n\n delimiter\n Delimiter used to traverse nested dictionaries.\n\n .. note::\n This is different from :py:func:`pill...
# -*- coding: utf-8 -*- ''' Extract the pillar data for this minion ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import collections # Import third party libs import copy import os import logging from salt.ext import six # Import salt libs import salt.pillar import...
saltstack/salt
salt/modules/pillar.py
_obfuscate_inner
python
def _obfuscate_inner(var): ''' Recursive obfuscation of collection types. Leaf or unknown Python types get replaced by the type name Known collection types trigger recursion. In the special case of mapping types, keys are not obfuscated ''' if isinstance(var, (dict, salt.utils.odict.Ordered...
Recursive obfuscation of collection types. Leaf or unknown Python types get replaced by the type name Known collection types trigger recursion. In the special case of mapping types, keys are not obfuscated
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pillar.py#L284-L298
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n" ]
# -*- coding: utf-8 -*- ''' Extract the pillar data for this minion ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import collections # Import third party libs import copy import os import logging from salt.ext import six # Import salt libs import salt.pillar import...
saltstack/salt
salt/modules/pillar.py
item
python
def item(*args, **kwargs): ''' .. versionadded:: 0.16.2 Return one or more pillar entries from the :ref:`in-memory pillar data <pillar-in-memory>`. delimiter Delimiter used to traverse nested dictionaries. .. note:: This is different from :py:func:`pillar.get ...
.. versionadded:: 0.16.2 Return one or more pillar entries from the :ref:`in-memory pillar data <pillar-in-memory>`. delimiter Delimiter used to traverse nested dictionaries. .. note:: This is different from :py:func:`pillar.get <salt.modules.pillar.get>` in that n...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pillar.py#L350-L423
[ "def items(*args, **kwargs):\n '''\n Calls the master for a fresh pillar and generates the pillar data on the\n fly\n\n Contrast with :py:func:`raw` which returns the pillar data that is\n currently loaded into the minion.\n\n pillar\n If specified, allows for a dictionary of pillar data to...
# -*- coding: utf-8 -*- ''' Extract the pillar data for this minion ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import collections # Import third party libs import copy import os import logging from salt.ext import six # Import salt libs import salt.pillar import...
saltstack/salt
salt/modules/pillar.py
ext
python
def ext(external, pillar=None): ''' .. versionchanged:: 2016.3.6,2016.11.3,2017.7.0 The supported ext_pillar types are now tunable using the :conf_master:`on_demand_ext_pillar` config option. Earlier releases used a hard-coded default. Generate the pillar and apply an explicit exter...
.. versionchanged:: 2016.3.6,2016.11.3,2017.7.0 The supported ext_pillar types are now tunable using the :conf_master:`on_demand_ext_pillar` config option. Earlier releases used a hard-coded default. Generate the pillar and apply an explicit external pillar external A single e...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pillar.py#L452-L516
[ "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", "def get_pillar(opts, grains, minion_id, saltenv=None, ext=None, funcs=None,\n pill...
# -*- coding: utf-8 -*- ''' Extract the pillar data for this minion ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import collections # Import third party libs import copy import os import logging from salt.ext import six # Import salt libs import salt.pillar import...
saltstack/salt
salt/modules/pillar.py
file_exists
python
def file_exists(path, saltenv=None): ''' .. versionadded:: 2016.3.0 This is a master-only function. Calling from the minion is not supported. Use the given path and search relative to the pillar environments to see if a file exists at that path. If the ``saltenv`` argument is given, restrict ...
.. versionadded:: 2016.3.0 This is a master-only function. Calling from the minion is not supported. Use the given path and search relative to the pillar environments to see if a file exists at that path. If the ``saltenv`` argument is given, restrict search to that environment only. Will on...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pillar.py#L549-L594
null
# -*- coding: utf-8 -*- ''' Extract the pillar data for this minion ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import collections # Import third party libs import copy import os import logging from salt.ext import six # Import salt libs import salt.pillar import...
saltstack/salt
salt/modules/pillar.py
filter_by
python
def filter_by(lookup_dict, pillar, merge=None, default='default', base=None): ''' .. versionadded:: 2017.7.0 Look up the given pillar in a given dictionary and return the result :param lookup_dict: A dictionary, keyed by a pillar, containing a va...
.. versionadded:: 2017.7.0 Look up the given pillar in a given dictionary and return the result :param lookup_dict: A dictionary, keyed by a pillar, containing a value or values relevant to systems matching that pillar. For example, a key could be a pillar for a role and the value could the na...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pillar.py#L601-L658
[ "def filter_by(lookup_dict,\n lookup,\n traverse,\n merge=None,\n default='default',\n base=None):\n '''\n Common code to filter data structures like grains and pillar\n '''\n ret = None\n # Default value would be an empty list if looku...
# -*- coding: utf-8 -*- ''' Extract the pillar data for this minion ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import collections # Import third party libs import copy import os import logging from salt.ext import six # Import salt libs import salt.pillar import...
saltstack/salt
salt/modules/purefa.py
_get_system
python
def _get_system(): ''' Get Pure Storage FlashArray configuration 1) From the minion config pure_tags: fa: san_ip: management vip or hostname for the FlashArray api_token: A valid api token for the FlashArray being managed 2) From environment (PUREFA_IP and PURE...
Get Pure Storage FlashArray configuration 1) From the minion config pure_tags: fa: san_ip: management vip or hostname for the FlashArray api_token: A valid api token for the FlashArray being managed 2) From environment (PUREFA_IP and PUREFA_API) 3) From the pillar ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/purefa.py#L94-L139
null
# -*- coding: utf-8 -*- ## # Copyright 2017 Pure Storage Inc # # 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 required by applicable ...
saltstack/salt
salt/modules/purefa.py
_get_snapshot
python
def _get_snapshot(name, suffix, array): '''Private function to check snapshot''' snapshot = name + '.' + suffix try: for snap in array.get_volume(name, snap=True): if snap['name'] == snapshot: return snapshot except purestorage.PureError: return None
Private function to check snapshot
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/purefa.py#L150-L158
null
# -*- coding: utf-8 -*- ## # Copyright 2017 Pure Storage Inc # # 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 required by applicable ...
saltstack/salt
salt/modules/purefa.py
_get_pgroup
python
def _get_pgroup(name, array): '''Private function to check protection group''' pgroup = None for temp in array.list_pgroups(): if temp['name'] == name: pgroup = temp break return pgroup
Private function to check protection group
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/purefa.py#L169-L176
null
# -*- coding: utf-8 -*- ## # Copyright 2017 Pure Storage Inc # # 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 required by applicable ...
saltstack/salt
salt/modules/purefa.py
_get_hgroup
python
def _get_hgroup(name, array): '''Private function to check hostgroup''' hostgroup = None for temp in array.list_hgroups(): if temp['name'] == name: hostgroup = temp break return hostgroup
Private function to check hostgroup
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/purefa.py#L187-L194
null
# -*- coding: utf-8 -*- ## # Copyright 2017 Pure Storage Inc # # 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 required by applicable ...
saltstack/salt
salt/modules/purefa.py
_get_host
python
def _get_host(name, array): '''Private function to check host''' host = None for temp in array.list_hosts(): if temp['name'] == name: host = temp break return host
Private function to check host
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/purefa.py#L197-L204
null
# -*- coding: utf-8 -*- ## # Copyright 2017 Pure Storage Inc # # 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 required by applicable ...
saltstack/salt
salt/states/boto_sns.py
present
python
def present( name, subscriptions=None, region=None, key=None, keyid=None, profile=None): ''' Ensure the SNS topic exists. name Name of the SNS topic. subscriptions List of SNS subscriptions. Each subscription is a dictionary with...
Ensure the SNS topic exists. name Name of the SNS topic. subscriptions List of SNS subscriptions. Each subscription is a dictionary with a protocol and endpoint key: .. code-block:: python [ {'protocol': 'https', 'endpoint': 'https://www.example.com/s...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_sns.py#L70-L207
null
# -*- coding: utf-8 -*- ''' Manage SNS Topics Create and destroy SNS topics. Be aware that this interacts with Amazon's services, and so may incur charges. This module uses ``boto``, which can be installed via package, or pip. This module accepts explicit AWS credentials but can also utilize IAM roles assigned to t...
saltstack/salt
salt/states/boto_sns.py
absent
python
def absent( name, region=None, key=None, keyid=None, profile=None, unsubscribe=False): ''' Ensure the named sns topic is deleted. name Name of the SNS topic. region Region to connect to. key Secret key to be used. keyid ...
Ensure the named sns topic is deleted. name Name of the SNS topic. region Region to connect to. key Secret key to be used. keyid Access key to be used. profile A dict with region, key and keyid, or a pillar key (string) that contains a dict with r...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/boto_sns.py#L210-L287
null
# -*- coding: utf-8 -*- ''' Manage SNS Topics Create and destroy SNS topics. Be aware that this interacts with Amazon's services, and so may incur charges. This module uses ``boto``, which can be installed via package, or pip. This module accepts explicit AWS credentials but can also utilize IAM roles assigned to t...
saltstack/salt
salt/cloud/clouds/softlayer_hw.py
avail_locations
python
def avail_locations(call=None): ''' List all available locations ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_locations function must be called with ' '-f or --function, or with the --list-locations option' ) ret = {} conn = get_conn(ser...
List all available locations
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/softlayer_hw.py#L117-L144
[ "def get_conn(service='SoftLayer_Hardware'):\n '''\n Return a conn object for the passed VM data\n '''\n client = SoftLayer.Client(\n username=config.get_cloud_config_value(\n 'user', get_configured_provider(), __opts__, search_global=False\n ),\n api_key=config.get_cloud...
# -*- coding: utf-8 -*- ''' SoftLayer HW Cloud Module ========================= The SoftLayer HW cloud module is used to control access to the SoftLayer hardware cloud system Use of this module only requires the ``apikey`` parameter. Set up the cloud configuration at: ``/etc/salt/cloud.providers`` or ``/etc/salt/clo...
saltstack/salt
salt/cloud/clouds/softlayer_hw.py
avail_images
python
def avail_images(call=None): ''' Return a dict of all available VM images on the cloud provider. ''' if call == 'action': raise SaltCloudSystemExit( 'The avail_images function must be called with ' '-f or --function, or with the --list-images option' ) ret = ...
Return a dict of all available VM images on the cloud provider.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/softlayer_hw.py#L171-L190
[ "def get_conn(service='SoftLayer_Hardware'):\n '''\n Return a conn object for the passed VM data\n '''\n client = SoftLayer.Client(\n username=config.get_cloud_config_value(\n 'user', get_configured_provider(), __opts__, search_global=False\n ),\n api_key=config.get_cloud...
# -*- coding: utf-8 -*- ''' SoftLayer HW Cloud Module ========================= The SoftLayer HW cloud module is used to control access to the SoftLayer hardware cloud system Use of this module only requires the ``apikey`` parameter. Set up the cloud configuration at: ``/etc/salt/cloud.providers`` or ``/etc/salt/clo...
saltstack/salt
salt/cloud/clouds/softlayer_hw.py
create
python
def create(vm_): ''' Create a single VM from a data dict ''' try: # Check for required profile parameters before sending any API calls. if vm_['profile'] and config.is_profile_configured(__opts__, __active_provider_name__ or 'sof...
Create a single VM from a data dict
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/softlayer_hw.py#L212-L425
[ "def get_cloud_config_value(name, vm_, opts, default=None, search_global=True):\n '''\n Search and return a setting in a known order:\n\n 1. In the virtual machine's configuration\n 2. In the virtual machine's profile configuration\n 3. In the virtual machine's provider configuration\n ...
# -*- coding: utf-8 -*- ''' SoftLayer HW Cloud Module ========================= The SoftLayer HW cloud module is used to control access to the SoftLayer hardware cloud system Use of this module only requires the ``apikey`` parameter. Set up the cloud configuration at: ``/etc/salt/cloud.providers`` or ``/etc/salt/clo...
saltstack/salt
salt/cloud/clouds/softlayer_hw.py
list_nodes_full
python
def list_nodes_full(mask='mask[id, hostname, primaryIpAddress, \ primaryBackendIpAddress, processorPhysicalCoreAmount, memoryCount]', call=None): ''' Return a list of the VMs that are on the provider ''' if call == 'action': raise SaltCloudSystemExit( 'The list_nodes_...
Return a list of the VMs that are on the provider
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/softlayer_hw.py#L428-L446
[ "def get_conn(service='SoftLayer_Hardware'):\n '''\n Return a conn object for the passed VM data\n '''\n client = SoftLayer.Client(\n username=config.get_cloud_config_value(\n 'user', get_configured_provider(), __opts__, search_global=False\n ),\n api_key=config.get_cloud...
# -*- coding: utf-8 -*- ''' SoftLayer HW Cloud Module ========================= The SoftLayer HW cloud module is used to control access to the SoftLayer hardware cloud system Use of this module only requires the ``apikey`` parameter. Set up the cloud configuration at: ``/etc/salt/cloud.providers`` or ``/etc/salt/clo...
saltstack/salt
salt/cloud/clouds/softlayer_hw.py
show_pricing
python
def show_pricing(kwargs=None, call=None): ''' Show pricing for a particular profile. This is only an estimate, based on unofficial pricing sources. CLI Examples: .. code-block:: bash salt-cloud -f show_pricing my-softlayerhw-config profile=my-profile If pricing sources have not been ...
Show pricing for a particular profile. This is only an estimate, based on unofficial pricing sources. CLI Examples: .. code-block:: bash salt-cloud -f show_pricing my-softlayerhw-config profile=my-profile If pricing sources have not been cached, they will be downloaded. Once they have be...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/softlayer_hw.py#L566-L616
[ "def get_conn(service='SoftLayer_Hardware'):\n '''\n Return a conn object for the passed VM data\n '''\n client = SoftLayer.Client(\n username=config.get_cloud_config_value(\n 'user', get_configured_provider(), __opts__, search_global=False\n ),\n api_key=config.get_cloud...
# -*- coding: utf-8 -*- ''' SoftLayer HW Cloud Module ========================= The SoftLayer HW cloud module is used to control access to the SoftLayer hardware cloud system Use of this module only requires the ``apikey`` parameter. Set up the cloud configuration at: ``/etc/salt/cloud.providers`` or ``/etc/salt/clo...
saltstack/salt
salt/cloud/clouds/softlayer_hw.py
show_all_prices
python
def show_all_prices(call=None, kwargs=None): ''' Return a dict of all prices on the cloud provider. ''' if call == 'action': raise SaltCloudSystemExit( 'The show_all_prices function must be called with -f or --function.' ) if kwargs is None: kwargs = {} conn...
Return a dict of all prices on the cloud provider.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/softlayer_hw.py#L619-L643
[ "def get_conn(service='SoftLayer_Hardware'):\n '''\n Return a conn object for the passed VM data\n '''\n client = SoftLayer.Client(\n username=config.get_cloud_config_value(\n 'user', get_configured_provider(), __opts__, search_global=False\n ),\n api_key=config.get_cloud...
# -*- coding: utf-8 -*- ''' SoftLayer HW Cloud Module ========================= The SoftLayer HW cloud module is used to control access to the SoftLayer hardware cloud system Use of this module only requires the ``apikey`` parameter. Set up the cloud configuration at: ``/etc/salt/cloud.providers`` or ``/etc/salt/clo...
saltstack/salt
salt/cloud/clouds/softlayer_hw.py
show_all_categories
python
def show_all_categories(call=None): ''' Return a dict of all available categories on the cloud provider. .. versionadded:: 2016.3.0 ''' if call == 'action': raise SaltCloudSystemExit( 'The show_all_categories function must be called with -f or --function.' ) conn = ...
Return a dict of all available categories on the cloud provider. .. versionadded:: 2016.3.0
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/softlayer_hw.py#L646-L663
[ "def get_conn(service='SoftLayer_Hardware'):\n '''\n Return a conn object for the passed VM data\n '''\n client = SoftLayer.Client(\n username=config.get_cloud_config_value(\n 'user', get_configured_provider(), __opts__, search_global=False\n ),\n api_key=config.get_cloud...
# -*- coding: utf-8 -*- ''' SoftLayer HW Cloud Module ========================= The SoftLayer HW cloud module is used to control access to the SoftLayer hardware cloud system Use of this module only requires the ``apikey`` parameter. Set up the cloud configuration at: ``/etc/salt/cloud.providers`` or ``/etc/salt/clo...
saltstack/salt
salt/modules/mysql.py
_connect
python
def _connect(**kwargs): ''' wrap authentication credentials here ''' connargs = dict() def _connarg(name, key=None, get_opts=True): ''' Add key to connargs, only if name exists in our kwargs or, if get_opts is true, as mysql.<name> in __opts__ or __pillar__ If get_o...
wrap authentication credentials here
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L329-L400
[ "def _connarg(name, key=None, get_opts=True):\n '''\n Add key to connargs, only if name exists in our kwargs or,\n if get_opts is true, as mysql.<name> in __opts__ or __pillar__\n\n If get_opts is true, evaluate in said order - kwargs, opts\n then pillar. To avoid collision with other functions,\n ...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
quote_identifier
python
def quote_identifier(identifier, for_grants=False): r''' Return an identifier name (column, table, database, etc) escaped for MySQL This means surrounded by "`" character and escaping this character inside. It also means doubling the '%' character for MySQLdb internal usage. :param identifier: the...
r''' Return an identifier name (column, table, database, etc) escaped for MySQL This means surrounded by "`" character and escaping this character inside. It also means doubling the '%' character for MySQLdb internal usage. :param identifier: the table, column or database identifier :param for_gr...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L562-L587
null
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
_execute
python
def _execute(cur, qry, args=None): ''' Internal wrapper around MySQLdb cursor.execute() function MySQLDb does not apply the same filters when arguments are used with the query. For example '%' characters on the query must be encoded as '%%' and will be restored as '%' when arguments are applied. Bu...
Internal wrapper around MySQLdb cursor.execute() function MySQLDb does not apply the same filters when arguments are used with the query. For example '%' characters on the query must be encoded as '%%' and will be restored as '%' when arguments are applied. But when there're no arguments the '%%' is no...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L590-L607
null
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
query
python
def query(database, query, **connection_args): ''' Run an arbitrary SQL query and return the results or the number of affected rows. CLI Example: .. code-block:: bash salt '*' mysql.query mydb "UPDATE mytable set myfield=1 limit 1" Return data: .. code-block:: python {'...
Run an arbitrary SQL query and return the results or the number of affected rows. CLI Example: .. code-block:: bash salt '*' mysql.query mydb "UPDATE mytable set myfield=1 limit 1" Return data: .. code-block:: python {'query time': {'human': '39.0ms', 'raw': '0.03899'}, 'rows a...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L610-L739
[ "def _connect(**kwargs):\n '''\n wrap authentication credentials here\n '''\n connargs = dict()\n\n def _connarg(name, key=None, get_opts=True):\n '''\n Add key to connargs, only if name exists in our kwargs or,\n if get_opts is true, as mysql.<name> in __opts__ or __pillar__\n\n...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
file_query
python
def file_query(database, file_name, **connection_args): ''' Run an arbitrary SQL query from the specified file and return the the number of affected rows. .. versionadded:: 2017.7.0 database database to run script inside file_name File name of the script. This can be on the...
Run an arbitrary SQL query from the specified file and return the the number of affected rows. .. versionadded:: 2017.7.0 database database to run script inside file_name File name of the script. This can be on the minion, or a file that is reachable by the fileserver CLI Exam...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L742-L813
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as ...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
status
python
def status(**connection_args): ''' Return the status of a MySQL server using the output from the ``SHOW STATUS`` query. CLI Example: .. code-block:: bash salt '*' mysql.status ''' dbc = _connect(**connection_args) if dbc is None: return {} cur = dbc.cursor() qr...
Return the status of a MySQL server using the output from the ``SHOW STATUS`` query. CLI Example: .. code-block:: bash salt '*' mysql.status
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L816-L844
[ "def _connect(**kwargs):\n '''\n wrap authentication credentials here\n '''\n connargs = dict()\n\n def _connarg(name, key=None, get_opts=True):\n '''\n Add key to connargs, only if name exists in our kwargs or,\n if get_opts is true, as mysql.<name> in __opts__ or __pillar__\n\n...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
version
python
def version(**connection_args): ''' Return the version of a MySQL server using the output from the ``SELECT VERSION()`` query. CLI Example: .. code-block:: bash salt '*' mysql.version ''' dbc = _connect(**connection_args) if dbc is None: return '' cur = dbc.cursor(...
Return the version of a MySQL server using the output from the ``SELECT VERSION()`` query. CLI Example: .. code-block:: bash salt '*' mysql.version
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L847-L874
[ "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 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
slave_lag
python
def slave_lag(**connection_args): ''' Return the number of seconds that a slave SQL server is lagging behind the master, if the host is not a slave it will return -1. If the server is configured to be a slave for replication but slave IO is not running then -2 will be returned. If there was an erro...
Return the number of seconds that a slave SQL server is lagging behind the master, if the host is not a slave it will return -1. If the server is configured to be a slave for replication but slave IO is not running then -2 will be returned. If there was an error connecting to the database or checking t...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L877-L916
[ "def _connect(**kwargs):\n '''\n wrap authentication credentials here\n '''\n connargs = dict()\n\n def _connarg(name, key=None, get_opts=True):\n '''\n Add key to connargs, only if name exists in our kwargs or,\n if get_opts is true, as mysql.<name> in __opts__ or __pillar__\n\n...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
free_slave
python
def free_slave(**connection_args): ''' Frees a slave from its master. This is a WIP, do not use. CLI Example: .. code-block:: bash salt '*' mysql.free_slave ''' slave_db = _connect(**connection_args) if slave_db is None: return '' slave_cur = slave_db.cursor(MySQLdb.c...
Frees a slave from its master. This is a WIP, do not use. CLI Example: .. code-block:: bash salt '*' mysql.free_slave
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L919-L961
[ "def _connect(**kwargs):\n '''\n wrap authentication credentials here\n '''\n connargs = dict()\n\n def _connarg(name, key=None, get_opts=True):\n '''\n Add key to connargs, only if name exists in our kwargs or,\n if get_opts is true, as mysql.<name> in __opts__ or __pillar__\n\n...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
db_list
python
def db_list(**connection_args): ''' Return a list of databases of a MySQL server using the output from the ``SHOW DATABASES`` query. CLI Example: .. code-block:: bash salt '*' mysql.db_list ''' dbc = _connect(**connection_args) if dbc is None: return [] cur = dbc.c...
Return a list of databases of a MySQL server using the output from the ``SHOW DATABASES`` query. CLI Example: .. code-block:: bash salt '*' mysql.db_list
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L965-L995
[ "def _connect(**kwargs):\n '''\n wrap authentication credentials here\n '''\n connargs = dict()\n\n def _connarg(name, key=None, get_opts=True):\n '''\n Add key to connargs, only if name exists in our kwargs or,\n if get_opts is true, as mysql.<name> in __opts__ or __pillar__\n\n...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
alter_db
python
def alter_db(name, character_set=None, collate=None, **connection_args): ''' Modify database using ``ALTER DATABASE %(dbname)s CHARACTER SET %(charset)s COLLATE %(collation)s;`` query. CLI Example: .. code-block:: bash salt '*' mysql.alter_db testdb charset='latin1' ''' dbc = _con...
Modify database using ``ALTER DATABASE %(dbname)s CHARACTER SET %(charset)s COLLATE %(collation)s;`` query. CLI Example: .. code-block:: bash salt '*' mysql.alter_db testdb charset='latin1'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L998-L1019
[ "def _connect(**kwargs):\n '''\n wrap authentication credentials here\n '''\n connargs = dict()\n\n def _connarg(name, key=None, get_opts=True):\n '''\n Add key to connargs, only if name exists in our kwargs or,\n if get_opts is true, as mysql.<name> in __opts__ or __pillar__\n\n...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
db_get
python
def db_get(name, **connection_args): ''' Return a list of databases of a MySQL server using the output from the ``SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='dbname';`` query. CLI Example: .. code-block:: bash salt '*' ...
Return a list of databases of a MySQL server using the output from the ``SELECT DEFAULT_CHARACTER_SET_NAME, DEFAULT_COLLATION_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME='dbname';`` query. CLI Example: .. code-block:: bash salt '*' mysql.db_get test
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1022-L1046
[ "def _connect(**kwargs):\n '''\n wrap authentication credentials here\n '''\n connargs = dict()\n\n def _connarg(name, key=None, get_opts=True):\n '''\n Add key to connargs, only if name exists in our kwargs or,\n if get_opts is true, as mysql.<name> in __opts__ or __pillar__\n\n...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
db_tables
python
def db_tables(name, **connection_args): ''' Shows the tables in the given MySQL database (if exists) CLI Example: .. code-block:: bash salt '*' mysql.db_tables 'database' ''' if not db_exists(name, **connection_args): log.info('Database \'%s\' does not exist', name) re...
Shows the tables in the given MySQL database (if exists) CLI Example: .. code-block:: bash salt '*' mysql.db_tables 'database'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1049-L1083
[ "def db_exists(name, **connection_args):\n '''\n Checks if a database exists on the MySQL server.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' mysql.db_exists 'dbname'\n '''\n dbc = _connect(**connection_args)\n if dbc is None:\n return False\n cur = dbc.cursor()\n ...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
db_exists
python
def db_exists(name, **connection_args): ''' Checks if a database exists on the MySQL server. CLI Example: .. code-block:: bash salt '*' mysql.db_exists 'dbname' ''' dbc = _connect(**connection_args) if dbc is None: return False cur = dbc.cursor() # Warn: here db id...
Checks if a database exists on the MySQL server. CLI Example: .. code-block:: bash salt '*' mysql.db_exists 'dbname'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1086-L1113
[ "def _connect(**kwargs):\n '''\n wrap authentication credentials here\n '''\n connargs = dict()\n\n def _connarg(name, key=None, get_opts=True):\n '''\n Add key to connargs, only if name exists in our kwargs or,\n if get_opts is true, as mysql.<name> in __opts__ or __pillar__\n\n...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
db_create
python
def db_create(name, character_set=None, collate=None, **connection_args): ''' Adds a databases to the MySQL server. name The name of the database to manage character_set The character set, if left empty the MySQL default will be used collate The collation, if left empty th...
Adds a databases to the MySQL server. name The name of the database to manage character_set The character set, if left empty the MySQL default will be used collate The collation, if left empty the MySQL default will be used CLI Example: .. code-block:: bash salt...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1116-L1166
[ "def db_exists(name, **connection_args):\n '''\n Checks if a database exists on the MySQL server.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' mysql.db_exists 'dbname'\n '''\n dbc = _connect(**connection_args)\n if dbc is None:\n return False\n cur = dbc.cursor()\n ...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
db_remove
python
def db_remove(name, **connection_args): ''' Removes a databases from the MySQL server. CLI Example: .. code-block:: bash salt '*' mysql.db_remove 'dbname' ''' # check if db exists if not db_exists(name, **connection_args): log.info('DB \'%s\' does not exist', name) ...
Removes a databases from the MySQL server. CLI Example: .. code-block:: bash salt '*' mysql.db_remove 'dbname'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1169-L1209
[ "def db_exists(name, **connection_args):\n '''\n Checks if a database exists on the MySQL server.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' mysql.db_exists 'dbname'\n '''\n dbc = _connect(**connection_args)\n if dbc is None:\n return False\n cur = dbc.cursor()\n ...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
user_list
python
def user_list(**connection_args): ''' Return a list of users on a MySQL server CLI Example: .. code-block:: bash salt '*' mysql.user_list ''' dbc = _connect(**connection_args) if dbc is None: return [] cur = dbc.cursor(MySQLdb.cursors.DictCursor) try: qry =...
Return a list of users on a MySQL server CLI Example: .. code-block:: bash salt '*' mysql.user_list
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1213-L1237
[ "def _connect(**kwargs):\n '''\n wrap authentication credentials here\n '''\n connargs = dict()\n\n def _connarg(name, key=None, get_opts=True):\n '''\n Add key to connargs, only if name exists in our kwargs or,\n if get_opts is true, as mysql.<name> in __opts__ or __pillar__\n\n...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
user_exists
python
def user_exists(user, host='localhost', password=None, password_hash=None, passwordless=False, unix_socket=False, password_column=None, **connection_args): ''' Checks if a user exists on the MySQL ser...
Checks if a user exists on the MySQL server. A login can be checked to see if passwordless login is permitted by omitting ``password`` and ``password_hash``, and using ``passwordless=True``. .. versionadded:: 0.16.2 The ``passwordless`` option was added. CLI Example: .. code-block:: bash ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1240-L1325
[ "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 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
user_info
python
def user_info(user, host='localhost', **connection_args): ''' Get full info on a MySQL user CLI Example: .. code-block:: bash salt '*' mysql.user_info root localhost ''' dbc = _connect(**connection_args) if dbc is None: return False cur = dbc.cursor(MySQLdb.cursors.Di...
Get full info on a MySQL user CLI Example: .. code-block:: bash salt '*' mysql.user_info root localhost
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1328-L1358
[ "def _connect(**kwargs):\n '''\n wrap authentication credentials here\n '''\n connargs = dict()\n\n def _connarg(name, key=None, get_opts=True):\n '''\n Add key to connargs, only if name exists in our kwargs or,\n if get_opts is true, as mysql.<name> in __opts__ or __pillar__\n\n...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
user_create
python
def user_create(user, host='localhost', password=None, password_hash=None, allow_passwordless=False, unix_socket=False, password_column=None, **connection_args): ''' Creates a MySQL user host ...
Creates a MySQL user host Host for which this user/password combo applies password The password to use for the new user. Will take precedence over the ``password_hash`` option if both are specified. password_hash The password in hashed form. Be sure to quote the password b...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1361-L1471
[ "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 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
user_chpass
python
def user_chpass(user, host='localhost', password=None, password_hash=None, allow_passwordless=False, unix_socket=None, password_column=None, **connection_args): ''' Change password for a MySQL user ...
Change password for a MySQL user host Host for which this user/password combo applies password The password to set for the new user. Will take precedence over the ``password_hash`` option if both are specified. password_hash The password in hashed form. Be sure to quote th...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1474-L1602
[ "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 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
user_remove
python
def user_remove(user, host='localhost', **connection_args): ''' Delete MySQL user CLI Example: .. code-block:: bash salt '*' mysql.user_remove frank localhost ''' dbc = _connect(**connection_args) if dbc is None: return False cur = dbc....
Delete MySQL user CLI Example: .. code-block:: bash salt '*' mysql.user_remove frank localhost
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1605-L1639
[ "def _connect(**kwargs):\n '''\n wrap authentication credentials here\n '''\n connargs = dict()\n\n def _connarg(name, key=None, get_opts=True):\n '''\n Add key to connargs, only if name exists in our kwargs or,\n if get_opts is true, as mysql.<name> in __opts__ or __pillar__\n\n...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
db_check
python
def db_check(name, table=None, **connection_args): ''' Repairs the full database or just a given table CLI Example: .. code-block:: bash salt '*' mysql.db_check dbname salt '*' mysql.db_check dbname dbtable ''' ret = [] if table is None: #...
Repairs the full database or just a given table CLI Example: .. code-block:: bash salt '*' mysql.db_check dbname salt '*' mysql.db_check dbname dbtable
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1659-L1682
[ "def __check_table(name, table, **connection_args):\n dbc = _connect(**connection_args)\n if dbc is None:\n return {}\n cur = dbc.cursor(MySQLdb.cursors.DictCursor)\n s_name = quote_identifier(name)\n s_table = quote_identifier(table)\n # identifiers cannot be used as values\n qry = 'CHE...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
db_repair
python
def db_repair(name, table=None, **connection_args): ''' Repairs the full database or just a given table CLI Example: .. code-block:: bash salt '*' mysql.db_repair dbname ''' ret = [] if table is None: # we need to repair all tables table...
Repairs the full database or just a given table CLI Example: .. code-block:: bash salt '*' mysql.db_repair dbname
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1685-L1707
[ "def __repair_table(name, table, **connection_args):\n dbc = _connect(**connection_args)\n if dbc is None:\n return {}\n cur = dbc.cursor(MySQLdb.cursors.DictCursor)\n s_name = quote_identifier(name)\n s_table = quote_identifier(table)\n # identifiers cannot be used as values\n qry = 'RE...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
db_optimize
python
def db_optimize(name, table=None, **connection_args): ''' Optimizes the full database or just a given table CLI Example: .. code-block:: bash salt '*' mysql.db_optimize dbname ''' ret = [] if table is None: # we need to optimize all tables ...
Optimizes the full database or just a given table CLI Example: .. code-block:: bash salt '*' mysql.db_optimize dbname
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1710-L1732
[ "def __optimize_table(name, table, **connection_args):\n dbc = _connect(**connection_args)\n if dbc is None:\n return {}\n cur = dbc.cursor(MySQLdb.cursors.DictCursor)\n s_name = quote_identifier(name)\n s_table = quote_identifier(table)\n # identifiers cannot be used as values\n qry = '...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
__grant_generate
python
def __grant_generate(grant, database, user, host='localhost', grant_option=False, escape=True, ssl_option=False): ''' Validate grants and build the query that could set the given grants N...
Validate grants and build the query that could set the given grants Note that this query contains arguments for user and host but not for grants or database.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1778-L1818
[ "def is_true(value=None):\n '''\n Returns a boolean value representing the \"truth\" of the value passed. The\n rules for what is a \"True\" value are:\n\n 1. Integer/float values greater than 0\n 2. The string values \"True\" and \"true\"\n 3. Any object for which bool(obj) returns Tr...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
user_grants
python
def user_grants(user, host='localhost', **connection_args): ''' Shows the grants for the given MySQL user (if it exists) CLI Example: .. code-block:: bash salt '*' mysql.user_grants 'frank' 'localhost' ''' if not user_exists(user, host, **connection_args): log....
Shows the grants for the given MySQL user (if it exists) CLI Example: .. code-block:: bash salt '*' mysql.user_grants 'frank' 'localhost'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1821-L1860
[ "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 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
grant_exists
python
def grant_exists(grant, database, user, host='localhost', grant_option=False, escape=True, **connection_args): ''' Checks to see if a grant exists in the database CLI Example: .. code-block:: bash ...
Checks to see if a grant exists in the database CLI Example: .. code-block:: bash salt '*' mysql.grant_exists \ 'SELECT,INSERT,UPDATE,...' 'database.*' 'frank' 'localhost'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1863-L1949
[ "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 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
grant_add
python
def grant_add(grant, database, user, host='localhost', grant_option=False, escape=True, ssl_option=False, **connection_args): ''' Adds a grant to the MySQL server. For database, make sure you specify database....
Adds a grant to the MySQL server. For database, make sure you specify database.table or database.* CLI Example: .. code-block:: bash salt '*' mysql.grant_add \ 'SELECT,INSERT,UPDATE,...' 'database.*' 'frank' 'localhost'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L1952-L2004
[ "def _connect(**kwargs):\n '''\n wrap authentication credentials here\n '''\n connargs = dict()\n\n def _connarg(name, key=None, get_opts=True):\n '''\n Add key to connargs, only if name exists in our kwargs or,\n if get_opts is true, as mysql.<name> in __opts__ or __pillar__\n\n...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
grant_revoke
python
def grant_revoke(grant, database, user, host='localhost', grant_option=False, escape=True, **connection_args): ''' Removes a grant from the MySQL server. CLI Example: .. code-block:: bash sal...
Removes a grant from the MySQL server. CLI Example: .. code-block:: bash salt '*' mysql.grant_revoke \ 'SELECT,INSERT,UPDATE' 'database.*' 'frank' 'localhost'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L2007-L2081
[ "def is_true(value=None):\n '''\n Returns a boolean value representing the \"truth\" of the value passed. The\n rules for what is a \"True\" value are:\n\n 1. Integer/float values greater than 0\n 2. The string values \"True\" and \"true\"\n 3. Any object for which bool(obj) returns Tr...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
processlist
python
def processlist(**connection_args): ''' Retrieves the processlist from the MySQL server via "SHOW FULL PROCESSLIST". Returns: a list of dicts, with each dict representing a process: .. code-block:: python {'Command': 'Query', 'Host': 'localhost', 'Id': 39, 'Info': ...
Retrieves the processlist from the MySQL server via "SHOW FULL PROCESSLIST". Returns: a list of dicts, with each dict representing a process: .. code-block:: python {'Command': 'Query', 'Host': 'localhost', 'Id': 39, 'Info': 'SHOW FULL PROCESSLIST', 'Rows_examined'...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L2084-L2127
[ "def _connect(**kwargs):\n '''\n wrap authentication credentials here\n '''\n connargs = dict()\n\n def _connarg(name, key=None, get_opts=True):\n '''\n Add key to connargs, only if name exists in our kwargs or,\n if get_opts is true, as mysql.<name> in __opts__ or __pillar__\n\n...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
__do_query_into_hash
python
def __do_query_into_hash(conn, sql_str): ''' Perform the query that is passed to it (sql_str). Returns: results in a dict. ''' mod = sys._getframe().f_code.co_name log.debug('%s<--(%s)', mod, sql_str) rtn_results = [] try: cursor = conn.cursor() except MySQLdb.MySQ...
Perform the query that is passed to it (sql_str). Returns: results in a dict.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L2130-L2173
[ "def _execute(cur, qry, args=None):\n '''\n Internal wrapper around MySQLdb cursor.execute() function\n\n MySQLDb does not apply the same filters when arguments are used with the\n query. For example '%' characters on the query must be encoded as '%%' and\n will be restored as '%' when arguments are ...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
get_master_status
python
def get_master_status(**connection_args): ''' Retrieves the master status from the minion. Returns:: {'host.domain.com': {'Binlog_Do_DB': '', 'Binlog_Ignore_DB': '', 'File': 'mysql-bin.000021', 'Position': 107}} CLI Ex...
Retrieves the master status from the minion. Returns:: {'host.domain.com': {'Binlog_Do_DB': '', 'Binlog_Ignore_DB': '', 'File': 'mysql-bin.000021', 'Position': 107}} CLI Example: .. code-block:: bash salt '*' mys...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L2176-L2207
[ "def _connect(**kwargs):\n '''\n wrap authentication credentials here\n '''\n connargs = dict()\n\n def _connarg(name, key=None, get_opts=True):\n '''\n Add key to connargs, only if name exists in our kwargs or,\n if get_opts is true, as mysql.<name> in __opts__ or __pillar__\n\n...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/modules/mysql.py
verify_login
python
def verify_login(user, password=None, **connection_args): ''' Attempt to login using the provided credentials. If successful, return true. Otherwise, return False. CLI Example: .. code-block:: bash salt '*' mysql.verify_login root password ''' # Override the connection args for u...
Attempt to login using the provided credentials. If successful, return true. Otherwise, return False. CLI Example: .. code-block:: bash salt '*' mysql.verify_login root password
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mysql.py#L2336-L2358
[ "def _connect(**kwargs):\n '''\n wrap authentication credentials here\n '''\n connargs = dict()\n\n def _connarg(name, key=None, get_opts=True):\n '''\n Add key to connargs, only if name exists in our kwargs or,\n if get_opts is true, as mysql.<name> in __opts__ or __pillar__\n\n...
# -*- coding: utf-8 -*- ''' Module to provide MySQL compatibility to salt. :depends: - MySQLdb Python module .. note:: On CentOS 5 (and possibly RHEL 5) both MySQL-python and python26-mysqldb need to be installed. :configuration: In order to connect to MySQL, certain configuration is required in /etc/...
saltstack/salt
salt/wheel/__init__.py
WheelClient.call_func
python
def call_func(self, fun, **kwargs): ''' Backwards compatibility ''' return self.low(fun, kwargs, print_event=kwargs.get('print_event', True), full_return=kwargs.get('full_return', False))
Backwards compatibility
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/wheel/__init__.py#L53-L57
[ "def low(self, fun, low, print_event=True, full_return=False):\n '''\n Execute a function from low data\n Low data includes:\n required:\n - fun: the name of the function to run\n optional:\n - arg: a list of args to pass to fun\n - kwarg: kwargs for fun\n ...
class WheelClient(salt.client.mixins.SyncClientMixin, salt.client.mixins.AsyncClientMixin, object): ''' An interface to Salt's wheel modules :ref:`Wheel modules <all-salt.wheel>` interact with various parts of the Salt Master. Importing and using ``WheelClient`` must be done on t...
saltstack/salt
salt/wheel/__init__.py
WheelClient.master_call
python
def master_call(self, **kwargs): ''' Execute a wheel function through the master network interface (eauth). ''' load = kwargs load['cmd'] = 'wheel' interface = self.opts['interface'] if interface == '0.0.0.0': interface = '127.0.0.1' master_uri...
Execute a wheel function through the master network interface (eauth).
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/wheel/__init__.py#L61-L85
[ "def ip_bracket(addr):\n '''\n Convert IP address representation to ZMQ (URL) format. ZMQ expects\n brackets around IPv6 literals, since they are used in URLs.\n '''\n addr = ipaddress.ip_address(addr)\n return ('[{}]' if addr.version == 6 else '{}').format(addr)\n", "def factory(opts, **kwargs)...
class WheelClient(salt.client.mixins.SyncClientMixin, salt.client.mixins.AsyncClientMixin, object): ''' An interface to Salt's wheel modules :ref:`Wheel modules <all-salt.wheel>` interact with various parts of the Salt Master. Importing and using ``WheelClient`` must be done on t...
saltstack/salt
salt/wheel/__init__.py
WheelClient.cmd_async
python
def cmd_async(self, low): ''' Execute a function asynchronously; eauth is respected This function requires that :conf_master:`external_auth` is configured and the user is authorized .. code-block:: python >>> wheel.cmd_async({ 'fun': 'key.finger', ...
Execute a function asynchronously; eauth is respected This function requires that :conf_master:`external_auth` is configured and the user is authorized .. code-block:: python >>> wheel.cmd_async({ 'fun': 'key.finger', 'match': 'jerry', ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/wheel/__init__.py#L109-L128
[ "def asynchronous(self, fun, low, user='UNKNOWN', pub=None):\n '''\n Execute the function in a multiprocess and return the event tag to use\n to watch for the return\n '''\n async_pub = pub if pub is not None else self._gen_async_pub()\n\n proc = salt.utils.process.SignalHandlingMultiprocessingPro...
class WheelClient(salt.client.mixins.SyncClientMixin, salt.client.mixins.AsyncClientMixin, object): ''' An interface to Salt's wheel modules :ref:`Wheel modules <all-salt.wheel>` interact with various parts of the Salt Master. Importing and using ``WheelClient`` must be done on t...
saltstack/salt
salt/wheel/__init__.py
WheelClient.cmd
python
def cmd(self, fun, arg=None, pub_data=None, kwarg=None, print_event=True, full_return=False): ''' Execute a function .. code-block:: python >>> wheel.cmd('key.finger', ['jerry']) {'minions': {'jerry': '5d:f6:79:43:5e:d4:42:3f:57:b8:45:a8:7e:a4:6e:ca'}} ''' ...
Execute a function .. code-block:: python >>> wheel.cmd('key.finger', ['jerry']) {'minions': {'jerry': '5d:f6:79:43:5e:d4:42:3f:57:b8:45:a8:7e:a4:6e:ca'}}
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/wheel/__init__.py#L130-L144
[ "def cmd(self, fun, arg=None, pub_data=None, kwarg=None, print_event=True, full_return=False):\n '''\n Execute a function\n\n .. code-block:: python\n\n >>> opts = salt.config.master_config('/etc/salt/master')\n >>> runner = salt.runner.RunnerClient(opts)\n >>> runner.cmd('jobs.list_jo...
class WheelClient(salt.client.mixins.SyncClientMixin, salt.client.mixins.AsyncClientMixin, object): ''' An interface to Salt's wheel modules :ref:`Wheel modules <all-salt.wheel>` interact with various parts of the Salt Master. Importing and using ``WheelClient`` must be done on t...
saltstack/salt
salt/modules/makeconf.py
_add_var
python
def _add_var(var, value): ''' Add a new var to the make.conf. If using layman, the source line for the layman make.conf needs to be at the very end of the config. This ensures that the new var will be above the source line. ''' makeconf = _get_makeconf() layman = 'source /var/lib/layman/...
Add a new var to the make.conf. If using layman, the source line for the layman make.conf needs to be at the very end of the config. This ensures that the new var will be above the source line.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/makeconf.py#L36-L54
[ "def _get_makeconf():\n '''\n Find the correct make.conf. Gentoo recently moved the make.conf\n but still supports the old location, using the old location first\n '''\n old_conf = '/etc/make.conf'\n new_conf = '/etc/portage/make.conf'\n if __salt__['file.file_exists'](old_conf):\n retur...
# -*- coding: utf-8 -*- ''' Support for modifying make.conf under Gentoo ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt libs import salt.utils.data import salt.utils.files def __virtual__(): ''' Only work on Gentoo ''' if __grains__['o...
saltstack/salt
salt/modules/makeconf.py
set_var
python
def set_var(var, value): ''' Set a variable in the make.conf Return a dict containing the new value for variable:: {'<variable>': {'old': '<old-value>', 'new': '<new-value>'}} CLI Example: .. code-block:: bash salt '*' makeconf.set_var 'LINGUAS' 'en' ...
Set a variable in the make.conf Return a dict containing the new value for variable:: {'<variable>': {'old': '<old-value>', 'new': '<new-value>'}} CLI Example: .. code-block:: bash salt '*' makeconf.set_var 'LINGUAS' 'en'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/makeconf.py#L57-L85
[ "def _get_makeconf():\n '''\n Find the correct make.conf. Gentoo recently moved the make.conf\n but still supports the old location, using the old location first\n '''\n old_conf = '/etc/make.conf'\n new_conf = '/etc/portage/make.conf'\n if __salt__['file.file_exists'](old_conf):\n retur...
# -*- coding: utf-8 -*- ''' Support for modifying make.conf under Gentoo ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt libs import salt.utils.data import salt.utils.files def __virtual__(): ''' Only work on Gentoo ''' if __grains__['o...
saltstack/salt
salt/modules/makeconf.py
remove_var
python
def remove_var(var): ''' Remove a variable from the make.conf Return a dict containing the new value for the variable:: {'<variable>': {'old': '<old-value>', 'new': '<new-value>'}} CLI Example: .. code-block:: bash salt '*' makeconf.remove_var 'LINGUAS' ...
Remove a variable from the make.conf Return a dict containing the new value for the variable:: {'<variable>': {'old': '<old-value>', 'new': '<new-value>'}} CLI Example: .. code-block:: bash salt '*' makeconf.remove_var 'LINGUAS'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/makeconf.py#L88-L112
[ "def _get_makeconf():\n '''\n Find the correct make.conf. Gentoo recently moved the make.conf\n but still supports the old location, using the old location first\n '''\n old_conf = '/etc/make.conf'\n new_conf = '/etc/portage/make.conf'\n if __salt__['file.file_exists'](old_conf):\n retur...
# -*- coding: utf-8 -*- ''' Support for modifying make.conf under Gentoo ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt libs import salt.utils.data import salt.utils.files def __virtual__(): ''' Only work on Gentoo ''' if __grains__['o...
saltstack/salt
salt/modules/makeconf.py
append_var
python
def append_var(var, value): ''' Add to or create a new variable in the make.conf Return a dict containing the new value for variable:: {'<variable>': {'old': '<old-value>', 'new': '<new-value>'}} CLI Example: .. code-block:: bash salt '*' makeconf.append_...
Add to or create a new variable in the make.conf Return a dict containing the new value for variable:: {'<variable>': {'old': '<old-value>', 'new': '<new-value>'}} CLI Example: .. code-block:: bash salt '*' makeconf.append_var 'LINGUAS' 'en'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/makeconf.py#L115-L143
[ "def _get_makeconf():\n '''\n Find the correct make.conf. Gentoo recently moved the make.conf\n but still supports the old location, using the old location first\n '''\n old_conf = '/etc/make.conf'\n new_conf = '/etc/portage/make.conf'\n if __salt__['file.file_exists'](old_conf):\n retur...
# -*- coding: utf-8 -*- ''' Support for modifying make.conf under Gentoo ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt libs import salt.utils.data import salt.utils.files def __virtual__(): ''' Only work on Gentoo ''' if __grains__['o...
saltstack/salt
salt/modules/makeconf.py
trim_var
python
def trim_var(var, value): ''' Remove a value from a variable in the make.conf Return a dict containing the new value for variable:: {'<variable>': {'old': '<old-value>', 'new': '<new-value>'}} CLI Example: .. code-block:: bash salt '*' makeconf.trim_var '...
Remove a value from a variable in the make.conf Return a dict containing the new value for variable:: {'<variable>': {'old': '<old-value>', 'new': '<new-value>'}} CLI Example: .. code-block:: bash salt '*' makeconf.trim_var 'LINGUAS' 'en'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/makeconf.py#L146-L170
[ "def _get_makeconf():\n '''\n Find the correct make.conf. Gentoo recently moved the make.conf\n but still supports the old location, using the old location first\n '''\n old_conf = '/etc/make.conf'\n new_conf = '/etc/portage/make.conf'\n if __salt__['file.file_exists'](old_conf):\n retur...
# -*- coding: utf-8 -*- ''' Support for modifying make.conf under Gentoo ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt libs import salt.utils.data import salt.utils.files def __virtual__(): ''' Only work on Gentoo ''' if __grains__['o...
saltstack/salt
salt/modules/makeconf.py
get_var
python
def get_var(var): ''' Get the value of a variable in make.conf Return the value of the variable or None if the variable is not in make.conf CLI Example: .. code-block:: bash salt '*' makeconf.get_var 'LINGUAS' ''' makeconf = _get_makeconf() # Open makeconf with salt.u...
Get the value of a variable in make.conf Return the value of the variable or None if the variable is not in make.conf CLI Example: .. code-block:: bash salt '*' makeconf.get_var 'LINGUAS'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/makeconf.py#L173-L199
[ "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 -*- ''' Support for modifying make.conf under Gentoo ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt libs import salt.utils.data import salt.utils.files def __virtual__(): ''' Only work on Gentoo ''' if __grains__['o...
saltstack/salt
salt/modules/makeconf.py
var_contains
python
def var_contains(var, value): ''' Verify if variable contains a value in make.conf Return True if value is set for var CLI Example: .. code-block:: bash salt '*' makeconf.var_contains 'LINGUAS' 'en' ''' setval = get_var(var) # Remove any escaping that was needed to past throu...
Verify if variable contains a value in make.conf Return True if value is set for var CLI Example: .. code-block:: bash salt '*' makeconf.var_contains 'LINGUAS' 'en'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/makeconf.py#L202-L219
[ "def get_var(var):\n '''\n Get the value of a variable in make.conf\n\n Return the value of the variable or None if the variable is not in\n make.conf\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' makeconf.get_var 'LINGUAS'\n '''\n makeconf = _get_makeconf()\n # Open makec...
# -*- coding: utf-8 -*- ''' Support for modifying make.conf under Gentoo ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt libs import salt.utils.data import salt.utils.files def __virtual__(): ''' Only work on Gentoo ''' if __grains__['o...
saltstack/salt
salt/returners/carbon_return.py
_carbon
python
def _carbon(host, port): ''' Context manager to ensure the clean creation and destruction of a socket. host The IP or hostname of the carbon server port The port that carbon is listening on ''' carbon_sock = None try: carbon_sock = socket.socket(socket.AF_INET, sock...
Context manager to ensure the clean creation and destruction of a socket. host The IP or hostname of the carbon server port The port that carbon is listening on
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/carbon_return.py#L129-L157
null
# -*- coding: utf-8 -*- ''' Take data from salt and "return" it into a carbon receiver Add the following configuration to the minion configuration file: .. code-block:: yaml carbon.host: <server ip address> carbon.port: 2003 Errors when trying to convert data to numbers may be ignored by setting ``carbon.sk...
saltstack/salt
salt/returners/carbon_return.py
_send_picklemetrics
python
def _send_picklemetrics(metrics): ''' Format metrics for the carbon pickle protocol ''' metrics = [(metric_name, (timestamp, value)) for (metric_name, value, timestamp) in metrics] data = cPickle.dumps(metrics, -1) payload = struct.pack(b'!L', len(data)) + data return paylo...
Format metrics for the carbon pickle protocol
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/carbon_return.py#L160-L171
null
# -*- coding: utf-8 -*- ''' Take data from salt and "return" it into a carbon receiver Add the following configuration to the minion configuration file: .. code-block:: yaml carbon.host: <server ip address> carbon.port: 2003 Errors when trying to convert data to numbers may be ignored by setting ``carbon.sk...
saltstack/salt
salt/returners/carbon_return.py
_send_textmetrics
python
def _send_textmetrics(metrics): ''' Format metrics for the carbon plaintext protocol ''' data = [' '.join(map(six.text_type, metric)) for metric in metrics] + [''] return '\n'.join(data)
Format metrics for the carbon plaintext protocol
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/carbon_return.py#L174-L181
null
# -*- coding: utf-8 -*- ''' Take data from salt and "return" it into a carbon receiver Add the following configuration to the minion configuration file: .. code-block:: yaml carbon.host: <server ip address> carbon.port: 2003 Errors when trying to convert data to numbers may be ignored by setting ``carbon.sk...
saltstack/salt
salt/returners/carbon_return.py
_walk
python
def _walk(path, value, metrics, timestamp, skip): ''' Recursively include metrics from *value*. path The dot-separated path of the metric. value A dictionary or value from a dictionary. If a dictionary, ``_walk`` will be called again with the each key/value pair as a new set of ...
Recursively include metrics from *value*. path The dot-separated path of the metric. value A dictionary or value from a dictionary. If a dictionary, ``_walk`` will be called again with the each key/value pair as a new set of metrics. metrics The list of metrics that ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/carbon_return.py#L184-L224
null
# -*- coding: utf-8 -*- ''' Take data from salt and "return" it into a carbon receiver Add the following configuration to the minion configuration file: .. code-block:: yaml carbon.host: <server ip address> carbon.port: 2003 Errors when trying to convert data to numbers may be ignored by setting ``carbon.sk...
saltstack/salt
salt/returners/carbon_return.py
_send
python
def _send(saltdata, metric_base, opts): ''' Send the data to carbon ''' host = opts.get('host') port = opts.get('port') skip = opts.get('skip') metric_base_pattern = opts.get('carbon.metric_base_pattern') mode = opts.get('mode').lower() if 'mode' in opts else 'text' log.debug('Carb...
Send the data to carbon
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/carbon_return.py#L227-L266
[ "def _send_picklemetrics(metrics):\n '''\n Format metrics for the carbon pickle protocol\n '''\n\n metrics = [(metric_name, (timestamp, value))\n for (metric_name, value, timestamp) in metrics]\n\n data = cPickle.dumps(metrics, -1)\n payload = struct.pack(b'!L', len(data)) + data\n\n...
# -*- coding: utf-8 -*- ''' Take data from salt and "return" it into a carbon receiver Add the following configuration to the minion configuration file: .. code-block:: yaml carbon.host: <server ip address> carbon.port: 2003 Errors when trying to convert data to numbers may be ignored by setting ``carbon.sk...
saltstack/salt
salt/returners/carbon_return.py
event_return
python
def event_return(events): ''' Return event data to remote carbon server Provide a list of events to be stored in carbon ''' opts = _get_options({}) # Pass in empty ret, since this is a list of events opts['skip'] = True for event in events: log.trace('Carbon returner received event...
Return event data to remote carbon server Provide a list of events to be stored in carbon
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/carbon_return.py#L269-L281
[ "def _send(saltdata, metric_base, opts):\n '''\n Send the data to carbon\n '''\n\n host = opts.get('host')\n port = opts.get('port')\n skip = opts.get('skip')\n metric_base_pattern = opts.get('carbon.metric_base_pattern')\n mode = opts.get('mode').lower() if 'mode' in opts else 'text'\n\n ...
# -*- coding: utf-8 -*- ''' Take data from salt and "return" it into a carbon receiver Add the following configuration to the minion configuration file: .. code-block:: yaml carbon.host: <server ip address> carbon.port: 2003 Errors when trying to convert data to numbers may be ignored by setting ``carbon.sk...
saltstack/salt
salt/returners/carbon_return.py
returner
python
def returner(ret): ''' Return data to a remote carbon server using the text metric protocol Each metric will look like:: [module].[function].[minion_id].[metric path [...]].[metric name] ''' opts = _get_options(ret) metric_base = ret['fun'] # Strip the hostname from the carbon bas...
Return data to a remote carbon server using the text metric protocol Each metric will look like:: [module].[function].[minion_id].[metric path [...]].[metric name]
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/carbon_return.py#L284-L302
[ "def _send(saltdata, metric_base, opts):\n '''\n Send the data to carbon\n '''\n\n host = opts.get('host')\n port = opts.get('port')\n skip = opts.get('skip')\n metric_base_pattern = opts.get('carbon.metric_base_pattern')\n mode = opts.get('mode').lower() if 'mode' in opts else 'text'\n\n ...
# -*- coding: utf-8 -*- ''' Take data from salt and "return" it into a carbon receiver Add the following configuration to the minion configuration file: .. code-block:: yaml carbon.host: <server ip address> carbon.port: 2003 Errors when trying to convert data to numbers may be ignored by setting ``carbon.sk...
saltstack/salt
salt/modules/boto_cfn.py
exists
python
def exists(name, region=None, key=None, keyid=None, profile=None): ''' Check to see if a stack exists. CLI Example: .. code-block:: bash salt myminion boto_cfn.exists mystack region=us-east-1 ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: ...
Check to see if a stack exists. CLI Example: .. code-block:: bash salt myminion boto_cfn.exists mystack region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_cfn.py#L71-L90
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon Cloud Formation .. versionadded:: 2015.5.0 :configuration: This module accepts explicit AWS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API a...
saltstack/salt
salt/modules/boto_cfn.py
describe
python
def describe(name, region=None, key=None, keyid=None, profile=None): ''' Describe a stack. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_cfn.describe mystack region=us-east-1 ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profi...
Describe a stack. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_cfn.describe mystack region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_cfn.py#L93-L133
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon Cloud Formation .. versionadded:: 2015.5.0 :configuration: This module accepts explicit AWS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API a...
saltstack/salt
salt/modules/boto_cfn.py
create
python
def create(name, template_body=None, template_url=None, parameters=None, notification_arns=None, disable_rollback=None, timeout_in_minutes=None, capabilities=None, tags=None, on_failure=None, stack_policy_body=None, stack_policy_url=None, region=None, key=None, keyid=None, profile=None): ''' ...
Create a CFN stack. CLI Example: .. code-block:: bash salt myminion boto_cfn.create mystack template_url='https://s3.amazonaws.com/bucket/template.cft' \ region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_cfn.py#L136-L158
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon Cloud Formation .. versionadded:: 2015.5.0 :configuration: This module accepts explicit AWS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API a...
saltstack/salt
salt/modules/boto_cfn.py
update_stack
python
def update_stack(name, template_body=None, template_url=None, parameters=None, notification_arns=None, disable_rollback=False, timeout_in_minutes=None, capabilities=None, tags=None, use_previous_template=None, stack_policy_during_update_body=None, stack_policy_during_update_url=None, ...
Update a CFN stack. .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_cfn.update_stack mystack template_url='https://s3.amazonaws.com/bucket/template.cft' \ region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_cfn.py#L161-L190
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon Cloud Formation .. versionadded:: 2015.5.0 :configuration: This module accepts explicit AWS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API a...
saltstack/salt
salt/modules/boto_cfn.py
delete
python
def delete(name, region=None, key=None, keyid=None, profile=None): ''' Delete a CFN stack. CLI Example: .. code-block:: bash salt myminion boto_cfn.delete mystack region=us-east-1 ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: return conn....
Delete a CFN stack. CLI Example: .. code-block:: bash salt myminion boto_cfn.delete mystack region=us-east-1
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_cfn.py#L193-L211
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon Cloud Formation .. versionadded:: 2015.5.0 :configuration: This module accepts explicit AWS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API a...
saltstack/salt
salt/modules/boto_cfn.py
get_template
python
def get_template(name, region=None, key=None, keyid=None, profile=None): ''' Check to see if attributes are set on a CFN stack. CLI Example: .. code-block:: bash salt myminion boto_cfn.get_template mystack ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) ...
Check to see if attributes are set on a CFN stack. CLI Example: .. code-block:: bash salt myminion boto_cfn.get_template mystack
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_cfn.py#L214-L234
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon Cloud Formation .. versionadded:: 2015.5.0 :configuration: This module accepts explicit AWS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API a...
saltstack/salt
salt/modules/boto_cfn.py
validate_template
python
def validate_template(template_body=None, template_url=None, region=None, key=None, keyid=None, profile=None): ''' Validate cloudformation template .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_cfn.validate_template mystack-template ''' conn = _g...
Validate cloudformation template .. versionadded:: 2015.8.0 CLI Example: .. code-block:: bash salt myminion boto_cfn.validate_template mystack-template
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_cfn.py#L237-L258
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon Cloud Formation .. versionadded:: 2015.5.0 :configuration: This module accepts explicit AWS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles. Dynamic credentials are then automatically obtained from AWS API a...
saltstack/salt
salt/modules/service.py
run
python
def run(name, action): ''' Run the specified service with an action. .. versionadded:: 2015.8.1 name Service name. action Action name (like start, stop, reload, restart). CLI Example: .. code-block:: bash salt '*' service.run apache2 reload salt '*' s...
Run the specified service with an action. .. versionadded:: 2015.8.1 name Service name. action Action name (like start, stop, reload, restart). CLI Example: .. code-block:: bash salt '*' service.run apache2 reload salt '*' service.run postgresql initdb
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/service.py#L60-L83
null
# -*- coding: utf-8 -*- ''' If Salt's OS detection does not identify a different virtual service module, the minion will fall back to using this basic module, which simply wraps sysvinit scripts. ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import fnmatch ...