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/state.py
RemoteHighState.compile_master
python
def compile_master(self): ''' Return the state data from the master ''' load = {'grains': self.grains, 'opts': self.opts, 'cmd': '_master_state'} try: return self.channel.send(load, tries=3, timeout=72000) except SaltReqTimeoutE...
Return the state data from the master
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/state.py#L4348-L4358
null
class RemoteHighState(object): ''' Manage gathering the data from the master ''' # XXX: This class doesn't seem to be used anywhere def __init__(self, opts, grains): self.opts = opts self.grains = grains self.serial = salt.payload.Serial(self.opts) # self.auth = salt....
saltstack/salt
salt/output/txt.py
output
python
def output(data, **kwargs): # pylint: disable=unused-argument ''' Output the data in lines, very nice for running commands ''' ret = '' if hasattr(data, 'keys'): for key in data: value = data[key] # Don't blow up on non-strings try: for li...
Output the data in lines, very nice for running commands
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/txt.py#L16-L37
null
# -*- coding: utf-8 -*- ''' Simple text outputter ===================== The txt outputter has been developed to make the output from shell commands on minions appear as they do when the command is executed on the minion. ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs...
saltstack/salt
salt/utils/configcomparer.py
compare_and_update_config
python
def compare_and_update_config(config, update_config, changes, namespace=''): ''' Recursively compare two configs, writing any needed changes to the update_config and capturing changes in the changes dict. ''' if isinstance(config, dict): if not update_config: if config: ...
Recursively compare two configs, writing any needed changes to the update_config and capturing changes in the changes dict.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/configcomparer.py#L14-L112
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "def compare_and_update_config(config, update_config, changes, namespace=''):\n '''\n Recursively compare two configs, writing any needed changes to the\n update_config and capturing changes in the changes dict.\n '''\n if isinstance(config...
# -*- coding: utf-8 -*- ''' Utilities for comparing and updating configurations while keeping track of changes in a way that can be easily reported in a state. ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt libs from salt.ext import six
saltstack/salt
salt/states/memcached.py
managed
python
def managed(name, value=None, host=DEFAULT_HOST, port=DEFAULT_PORT, time=DEFAULT_TIME, min_compress_len=DEFAULT_MIN_COMPRESS_LEN): ''' Manage a memcached key. name The key to manage value The value to set for that key hos...
Manage a memcached key. name The key to manage value The value to set for that key host The memcached server IP address port The memcached server port .. code-block:: yaml foo: memcached.managed: - value: bar
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/memcached.py#L34-L101
null
# -*- coding: utf-8 -*- ''' States for Management of Memcached Keys ======================================= .. versionadded:: 2014.1.0 ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt libs from salt.modules.memcached import ( DEFAULT_HOST, DEFAUL...
saltstack/salt
salt/modules/dnsutil.py
parse_hosts
python
def parse_hosts(hostsfile='/etc/hosts', hosts=None): ''' Parse /etc/hosts file. CLI Example: .. code-block:: bash salt '*' dnsutil.parse_hosts ''' if not hosts: try: with salt.utils.files.fopen(hostsfile, 'r') as fp_: hosts = salt.utils.stringutils....
Parse /etc/hosts file. CLI Example: .. code-block:: bash salt '*' dnsutil.parse_hosts
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dnsutil.py#L32-L60
[ "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 with open or dup), this bit is\n initially cleared on the ...
# -*- coding: utf-8 -*- ''' Compendium of generic DNS utilities. .. note:: Some functions in the ``dnsutil`` execution module depend on ``dig``. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import socket import time # Import salt libs import sal...
saltstack/salt
salt/modules/dnsutil.py
hosts_append
python
def hosts_append(hostsfile='/etc/hosts', ip_addr=None, entries=None): ''' Append a single line to the /etc/hosts file. CLI Example: .. code-block:: bash salt '*' dnsutil.hosts_append /etc/hosts 127.0.0.1 ad1.yuk.co,ad2.yuk.co ''' host_list = entries.split(',') hosts = parse_hosts(...
Append a single line to the /etc/hosts file. CLI Example: .. code-block:: bash salt '*' dnsutil.hosts_append /etc/hosts 127.0.0.1 ad1.yuk.co,ad2.yuk.co
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dnsutil.py#L63-L88
[ "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 with open or dup), this bit is\n initially cleared on the ...
# -*- coding: utf-8 -*- ''' Compendium of generic DNS utilities. .. note:: Some functions in the ``dnsutil`` execution module depend on ``dig``. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import socket import time # Import salt libs import sal...
saltstack/salt
salt/modules/dnsutil.py
hosts_remove
python
def hosts_remove(hostsfile='/etc/hosts', entries=None): ''' Remove a host from the /etc/hosts file. If doing so will leave a line containing only an IP address, then the line will be deleted. This function will leave comments and blank lines intact. CLI Examples: .. code-block:: bash ...
Remove a host from the /etc/hosts file. If doing so will leave a line containing only an IP address, then the line will be deleted. This function will leave comments and blank lines intact. CLI Examples: .. code-block:: bash salt '*' dnsutil.hosts_remove /etc/hosts ad1.yuk.co salt '*'...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dnsutil.py#L91-L119
[ "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 with open or dup), this bit is\n initially cleared on the ...
# -*- coding: utf-8 -*- ''' Compendium of generic DNS utilities. .. note:: Some functions in the ``dnsutil`` execution module depend on ``dig``. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import socket import time # Import salt libs import sal...
saltstack/salt
salt/modules/dnsutil.py
parse_zone
python
def parse_zone(zonefile=None, zone=None): ''' Parses a zone file. Can be passed raw zone data on the API level. CLI Example: .. code-block:: bash salt ns1 dnsutil.parse_zone /var/lib/named/example.com.zone ''' if zonefile: try: with salt.utils.files.fopen(zonefile,...
Parses a zone file. Can be passed raw zone data on the API level. CLI Example: .. code-block:: bash salt ns1 dnsutil.parse_zone /var/lib/named/example.com.zone
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dnsutil.py#L122-L197
[ "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 with open or dup), this bit is\n initially cleared on the ...
# -*- coding: utf-8 -*- ''' Compendium of generic DNS utilities. .. note:: Some functions in the ``dnsutil`` execution module depend on ``dig``. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import socket import time # Import salt libs import sal...
saltstack/salt
salt/modules/dnsutil.py
_to_seconds
python
def _to_seconds(timestr): ''' Converts a time value to seconds. As per RFC1035 (page 45), max time is 1 week, so anything longer (or unreadable) will be set to one week (604800 seconds). ''' timestr = timestr.upper() if 'H' in timestr: seconds = int(timestr.replace('H', '')) * 3600 ...
Converts a time value to seconds. As per RFC1035 (page 45), max time is 1 week, so anything longer (or unreadable) will be set to one week (604800 seconds).
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dnsutil.py#L200-L221
null
# -*- coding: utf-8 -*- ''' Compendium of generic DNS utilities. .. note:: Some functions in the ``dnsutil`` execution module depend on ``dig``. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import socket import time # Import salt libs import sal...
saltstack/salt
salt/modules/dnsutil.py
A
python
def A(host, nameserver=None): ''' Return the A record(s) for ``host``. Always returns a list. CLI Example: .. code-block:: bash salt ns1 dnsutil.A www.google.com ''' if _has_dig(): return __salt__['dig.A'](host, nameserver) elif nameserver is None: # fall back...
Return the A record(s) for ``host``. Always returns a list. CLI Example: .. code-block:: bash salt ns1 dnsutil.A www.google.com
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dnsutil.py#L249-L271
[ "def _has_dig():\n '''\n The dig-specific functions have been moved into their own module, but\n because they are also DNS utilities, a compatibility layer exists. This\n function helps add that layer.\n '''\n return salt.utils.path.which('dig') is not None\n" ]
# -*- coding: utf-8 -*- ''' Compendium of generic DNS utilities. .. note:: Some functions in the ``dnsutil`` execution module depend on ``dig``. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import socket import time # Import salt libs import sal...
saltstack/salt
salt/modules/dnsutil.py
AAAA
python
def AAAA(host, nameserver=None): ''' Return the AAAA record(s) for ``host``. Always returns a list. .. versionadded:: 2014.7.5 CLI Example: .. code-block:: bash salt ns1 dnsutil.AAAA www.google.com ''' if _has_dig(): return __salt__['dig.AAAA'](host, nameserver) ...
Return the AAAA record(s) for ``host``. Always returns a list. .. versionadded:: 2014.7.5 CLI Example: .. code-block:: bash salt ns1 dnsutil.AAAA www.google.com
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dnsutil.py#L274-L298
[ "def _has_dig():\n '''\n The dig-specific functions have been moved into their own module, but\n because they are also DNS utilities, a compatibility layer exists. This\n function helps add that layer.\n '''\n return salt.utils.path.which('dig') is not None\n" ]
# -*- coding: utf-8 -*- ''' Compendium of generic DNS utilities. .. note:: Some functions in the ``dnsutil`` execution module depend on ``dig``. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import socket import time # Import salt libs import sal...
saltstack/salt
salt/modules/dnsutil.py
NS
python
def NS(domain, resolve=True, nameserver=None): ''' Return a list of IPs of the nameservers for ``domain`` If 'resolve' is False, don't resolve names. CLI Example: .. code-block:: bash salt ns1 dnsutil.NS google.com ''' if _has_dig(): return __salt__['dig.NS'](domain, res...
Return a list of IPs of the nameservers for ``domain`` If 'resolve' is False, don't resolve names. CLI Example: .. code-block:: bash salt ns1 dnsutil.NS google.com
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dnsutil.py#L301-L317
[ "def _has_dig():\n '''\n The dig-specific functions have been moved into their own module, but\n because they are also DNS utilities, a compatibility layer exists. This\n function helps add that layer.\n '''\n return salt.utils.path.which('dig') is not None\n" ]
# -*- coding: utf-8 -*- ''' Compendium of generic DNS utilities. .. note:: Some functions in the ``dnsutil`` execution module depend on ``dig``. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import socket import time # Import salt libs import sal...
saltstack/salt
salt/modules/dnsutil.py
MX
python
def MX(domain, resolve=False, nameserver=None): ''' Return a list of lists for the MX of ``domain``. If the 'resolve' argument is True, resolve IPs for the servers. It's limited to one IP, because although in practice it's very rarely a round robin, it is an acceptable configuration and pulling ju...
Return a list of lists for the MX of ``domain``. If the 'resolve' argument is True, resolve IPs for the servers. It's limited to one IP, because although in practice it's very rarely a round robin, it is an acceptable configuration and pulling just one IP lets the data be similar to the non-resolved v...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dnsutil.py#L340-L360
[ "def _has_dig():\n '''\n The dig-specific functions have been moved into their own module, but\n because they are also DNS utilities, a compatibility layer exists. This\n function helps add that layer.\n '''\n return salt.utils.path.which('dig') is not None\n" ]
# -*- coding: utf-8 -*- ''' Compendium of generic DNS utilities. .. note:: Some functions in the ``dnsutil`` execution module depend on ``dig``. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import socket import time # Import salt libs import sal...
saltstack/salt
salt/modules/dnsutil.py
serial
python
def serial(zone='', update=False): ''' Return, store and update a dns serial for your zone files. zone: a keyword for a specific zone update: store an updated version of the serial in a grain If ``update`` is False, the function will retrieve an existing serial or return the current date if n...
Return, store and update a dns serial for your zone files. zone: a keyword for a specific zone update: store an updated version of the serial in a grain If ``update`` is False, the function will retrieve an existing serial or return the current date if no serial is stored. Nothing will be stored ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/dnsutil.py#L363-L401
null
# -*- coding: utf-8 -*- ''' Compendium of generic DNS utilities. .. note:: Some functions in the ``dnsutil`` execution module depend on ``dig``. ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import socket import time # Import salt libs import sal...
saltstack/salt
salt/master.py
Maintenance._post_fork_init
python
def _post_fork_init(self): ''' Some things need to be init'd after the fork has completed The easiest example is that one of these module types creates a thread in the parent process, then once the fork happens you'll start getting errors like "WARNING: Mixing fork() and threads ...
Some things need to be init'd after the fork has completed The easiest example is that one of these module types creates a thread in the parent process, then once the fork happens you'll start getting errors like "WARNING: Mixing fork() and threads detected; memory leaked."
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L179-L212
null
class Maintenance(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' A generalized maintenance process which performs maintenance routines. ''' def __init__(self, opts, **kwargs): ''' Create a maintenance instance :param dict opts: The salt options ''' ...
saltstack/salt
salt/master.py
Maintenance.run
python
def run(self): ''' This is the general passive maintenance process controller for the Salt master. This is where any data that needs to be cleanly maintained from the master is maintained. ''' salt.utils.process.appendproctitle(self.__class__.__name__) #...
This is the general passive maintenance process controller for the Salt master. This is where any data that needs to be cleanly maintained from the master is maintained.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L214-L245
[ "def appendproctitle(name):\n '''\n Append \"name\" to the current process title\n '''\n if HAS_SETPROCTITLE:\n setproctitle.setproctitle(setproctitle.getproctitle() + ' ' + name)\n", "def clean_old_jobs(opts):\n '''\n Clean out the old jobs from the job cache\n '''\n # TODO: better...
class Maintenance(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' A generalized maintenance process which performs maintenance routines. ''' def __init__(self, opts, **kwargs): ''' Create a maintenance instance :param dict opts: The salt options ''' ...
saltstack/salt
salt/master.py
Maintenance.handle_key_cache
python
def handle_key_cache(self): ''' Evaluate accepted keys and create a msgpack file which contains a list ''' if self.opts['key_cache'] == 'sched': keys = [] #TODO DRY from CKMinions if self.opts['transport'] in ('zeromq', 'tcp'): ...
Evaluate accepted keys and create a msgpack file which contains a list
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L247-L270
[ "def atomic_open(filename, mode='w'):\n '''\n Works like a regular `open()` but writes updates into a temporary\n file instead of the given file and moves it over when the file is\n closed. The file returned behaves as if it was a regular Python\n '''\n if mode in ('r', 'rb', 'r+', 'rb+', 'a', 'a...
class Maintenance(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' A generalized maintenance process which performs maintenance routines. ''' def __init__(self, opts, **kwargs): ''' Create a maintenance instance :param dict opts: The salt options ''' ...
saltstack/salt
salt/master.py
Maintenance.handle_key_rotate
python
def handle_key_rotate(self, now): ''' Rotate the AES key rotation ''' to_rotate = False dfn = os.path.join(self.opts['cachedir'], '.dfn') try: stats = os.stat(dfn) # Basic Windows permissions don't distinguish between # user/group/all. ...
Rotate the AES key rotation
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L272-L310
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n" ]
class Maintenance(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' A generalized maintenance process which performs maintenance routines. ''' def __init__(self, opts, **kwargs): ''' Create a maintenance instance :param dict opts: The salt options ''' ...
saltstack/salt
salt/master.py
Maintenance.handle_git_pillar
python
def handle_git_pillar(self): ''' Update git pillar ''' try: for pillar in self.git_pillar: pillar.fetch_remotes() except Exception as exc: log.error('Exception caught while updating git_pillar', exc_info=True)
Update git pillar
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L312-L321
null
class Maintenance(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' A generalized maintenance process which performs maintenance routines. ''' def __init__(self, opts, **kwargs): ''' Create a maintenance instance :param dict opts: The salt options ''' ...
saltstack/salt
salt/master.py
Maintenance.handle_schedule
python
def handle_schedule(self): ''' Evaluate the scheduler ''' try: self.schedule.eval() # Check if scheduler requires lower loop interval than # the loop_interval setting if self.schedule.loop_interval < self.loop_interval: self...
Evaluate the scheduler
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L323-L334
null
class Maintenance(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' A generalized maintenance process which performs maintenance routines. ''' def __init__(self, opts, **kwargs): ''' Create a maintenance instance :param dict opts: The salt options ''' ...
saltstack/salt
salt/master.py
Maintenance.handle_presence
python
def handle_presence(self, old_present): ''' Fire presence events if enabled ''' # On the first run it may need more time for the EventPublisher # to come up and be ready. Set the timeout to account for this. if self.presence_events and self.event.connect_pull(timeout=3): ...
Fire presence events if enabled
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L336-L354
[ "def tagify(suffix='', prefix='', base=SALT):\n '''\n convenience function to build a namespaced event tag string\n from joining with the TABPART character the base, prefix and suffix\n\n If string prefix is a valid key in TAGS Then use the value of key prefix\n Else use prefix string\n\n If suffi...
class Maintenance(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' A generalized maintenance process which performs maintenance routines. ''' def __init__(self, opts, **kwargs): ''' Create a maintenance instance :param dict opts: The salt options ''' ...
saltstack/salt
salt/master.py
FileserverUpdate.fill_buckets
python
def fill_buckets(self): ''' Get the configured backends and the intervals for any backend which supports them, and set up the update "buckets". There will be one bucket for each thing being updated at a given interval. ''' update_intervals = self.fileserver.update_interva...
Get the configured backends and the intervals for any backend which supports them, and set up the update "buckets". There will be one bucket for each thing being updated at a given interval.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L385-L436
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n" ]
class FileserverUpdate(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' A process from which to update any dynamic fileserver backends ''' def __init__(self, opts, **kwargs): super(FileserverUpdate, self).__init__(**kwargs) self.opts = opts self.update_threads = {} ...
saltstack/salt
salt/master.py
FileserverUpdate.update_fileserver
python
def update_fileserver(self, interval, backends): ''' Threading target which handles all updates for a given wait interval ''' def _do_update(): log.debug( 'Performing fileserver updates for items with an update ' 'interval of %d', interval ...
Threading target which handles all updates for a given wait interval
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L438-L477
[ "def _do_update():\n log.debug(\n 'Performing fileserver updates for items with an update '\n 'interval of %d', interval\n )\n for backend, update_args in six.iteritems(backends):\n backend_name, update_func = backend\n try:\n if update_args:\n log.debu...
class FileserverUpdate(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' A process from which to update any dynamic fileserver backends ''' def __init__(self, opts, **kwargs): super(FileserverUpdate, self).__init__(**kwargs) self.opts = opts self.update_threads = {} ...
saltstack/salt
salt/master.py
FileserverUpdate.run
python
def run(self): ''' Start the update threads ''' salt.utils.process.appendproctitle(self.__class__.__name__) # Clean out the fileserver backend cache salt.daemons.masterapi.clean_fsbackend(self.opts) for interval in self.buckets: self.update_threads[in...
Start the update threads
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L479-L496
[ "def appendproctitle(name):\n '''\n Append \"name\" to the current process title\n '''\n if HAS_SETPROCTITLE:\n setproctitle.setproctitle(setproctitle.getproctitle() + ' ' + name)\n", "def clean_fsbackend(opts):\n '''\n Clean out the old fileserver backends\n '''\n # Clear remote fi...
class FileserverUpdate(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' A process from which to update any dynamic fileserver backends ''' def __init__(self, opts, **kwargs): super(FileserverUpdate, self).__init__(**kwargs) self.opts = opts self.update_threads = {} ...
saltstack/salt
salt/master.py
Master._pre_flight
python
def _pre_flight(self): ''' Run pre flight checks. If anything in this method fails then the master should not start up. ''' errors = [] critical_errors = [] try: os.chdir('/') except OSError as err: errors.append( '...
Run pre flight checks. If anything in this method fails then the master should not start up.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L563-L644
null
class Master(SMaster): ''' The salt master server ''' def __init__(self, opts): ''' Create a salt master server instance :param dict: The salt options ''' if zmq and ZMQ_VERSION_INFO < (3, 2): log.warning( 'You have a version of ZMQ le...
saltstack/salt
salt/master.py
Master.start
python
def start(self): ''' Turn on the master server components ''' self._pre_flight() log.info('salt-master is starting as user \'%s\'', salt.utils.user.get_user()) enable_sigusr1_handler() enable_sigusr2_handler() self.__set_max_open_files() # Reset...
Turn on the master server components
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L646-L774
[ "def get_user():\n '''\n Get the current user\n '''\n if HAS_PWD:\n ret = pwd.getpwuid(os.geteuid()).pw_name\n elif HAS_WIN_FUNCTIONS and salt.utils.win_functions.HAS_WIN32:\n ret = salt.utils.win_functions.get_current_user()\n else:\n raise CommandExecutionError(\n ...
class Master(SMaster): ''' The salt master server ''' def __init__(self, opts): ''' Create a salt master server instance :param dict: The salt options ''' if zmq and ZMQ_VERSION_INFO < (3, 2): log.warning( 'You have a version of ZMQ le...
saltstack/salt
salt/master.py
Halite.run
python
def run(self): ''' Fire up halite! ''' salt.utils.process.appendproctitle(self.__class__.__name__) halite.start(self.hopts)
Fire up halite!
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L817-L822
[ "def appendproctitle(name):\n '''\n Append \"name\" to the current process title\n '''\n if HAS_SETPROCTITLE:\n setproctitle.setproctitle(setproctitle.getproctitle() + ' ' + name)\n" ]
class Halite(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' Manage the Halite server ''' def __init__(self, hopts, **kwargs): ''' Create a halite instance :param dict hopts: The halite options ''' super(Halite, self).__init__(**kwargs) self...
saltstack/salt
salt/master.py
ReqServer.__bind
python
def __bind(self): ''' Binds the reply server ''' if self.log_queue is not None: salt.log.setup.set_multiprocessing_logging_queue(self.log_queue) if self.log_queue_level is not None: salt.log.setup.set_multiprocessing_logging_level(self.log_queue_level) ...
Binds the reply server
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L876-L937
null
class ReqServer(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' Starts up the master request server, minions send results to this interface. ''' def __init__(self, opts, key, mkey, secrets=None, **kwargs): ''' Create a request server :param dict opts: The salt ...
saltstack/salt
salt/master.py
MWorker.__bind
python
def __bind(self): ''' Bind to the local port ''' # using ZMQIOLoop since we *might* need zmq in there install_zmq() self.io_loop = ZMQDefaultLoop() self.io_loop.make_current() for req_channel in self.req_channels: req_channel.post_fork(self._ha...
Bind to the local port
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1024-L1038
null
class MWorker(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' The worker multiprocess instance to manage the backend operations for the salt master. ''' def __init__(self, opts, mkey, key, req_channels, ...
saltstack/salt
salt/master.py
MWorker._handle_payload
python
def _handle_payload(self, payload): ''' The _handle_payload method is the key method used to figure out what needs to be done with communication to the server Example cleartext payload generated for 'salt myminion test.ping': {'enc': 'clear', 'load': {'arg': [], ...
The _handle_payload method is the key method used to figure out what needs to be done with communication to the server Example cleartext payload generated for 'salt myminion test.ping': {'enc': 'clear', 'load': {'arg': [], 'cmd': 'publish', 'fun': '...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1041-L1066
null
class MWorker(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' The worker multiprocess instance to manage the backend operations for the salt master. ''' def __init__(self, opts, mkey, key, req_channels, ...
saltstack/salt
salt/master.py
MWorker._post_stats
python
def _post_stats(self, stats): ''' Fire events with stat info if it's time ''' end_time = time.time() if end_time - self.stat_clock > self.opts['master_stats_event_iter']: # Fire the event with the stats and wipe the tracker self.aes_funcs.event.fire_event(...
Fire events with stat info if it's time
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1068-L1077
null
class MWorker(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' The worker multiprocess instance to manage the backend operations for the salt master. ''' def __init__(self, opts, mkey, key, req_channels, ...
saltstack/salt
salt/master.py
MWorker._handle_clear
python
def _handle_clear(self, load): ''' Process a cleartext command :param dict load: Cleartext payload :return: The result of passing the load to a function in ClearFuncs corresponding to the command specified in the load's 'cmd' key. ''' log.trace('Clear pa...
Process a cleartext command :param dict load: Cleartext payload :return: The result of passing the load to a function in ClearFuncs corresponding to the command specified in the load's 'cmd' key.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1079-L1097
null
class MWorker(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' The worker multiprocess instance to manage the backend operations for the salt master. ''' def __init__(self, opts, mkey, key, req_channels, ...
saltstack/salt
salt/master.py
MWorker._handle_aes
python
def _handle_aes(self, data): ''' Process a command sent via an AES key :param str load: Encrypted payload :return: The result of passing the load to a function in AESFuncs corresponding to the command specified in the load's 'cmd' key. ''' if 'cmd' not i...
Process a command sent via an AES key :param str load: Encrypted payload :return: The result of passing the load to a function in AESFuncs corresponding to the command specified in the load's 'cmd' key.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1099-L1128
null
class MWorker(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' The worker multiprocess instance to manage the backend operations for the salt master. ''' def __init__(self, opts, mkey, key, req_channels, ...
saltstack/salt
salt/master.py
MWorker.run
python
def run(self): ''' Start a Master Worker ''' salt.utils.process.appendproctitle(self.name) self.clear_funcs = ClearFuncs( self.opts, self.key, ) self.aes_funcs = AESFuncs(self.opts) salt.utils.crypt.reinit_crypto() self.__b...
Start a Master Worker
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1130-L1141
[ "def reinit_crypto():\n '''\n When a fork arises, pycrypto needs to reinit\n From its doc::\n\n Caveat: For the random number generator to work correctly,\n you must call Random.atfork() in both the parent and\n child processes after using os.fork()\n\n '''\n if HAS_CRYPTO:\n ...
class MWorker(salt.utils.process.SignalHandlingMultiprocessingProcess): ''' The worker multiprocess instance to manage the backend operations for the salt master. ''' def __init__(self, opts, mkey, key, req_channels, ...
saltstack/salt
salt/master.py
AESFuncs.__setup_fileserver
python
def __setup_fileserver(self): ''' Set the local file objects from the file server interface ''' # Avoid circular import import salt.fileserver self.fs_ = salt.fileserver.Fileserver(self.opts) self._serve_file = self.fs_.serve_file self._file_find = self.fs...
Set the local file objects from the file server interface
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1176-L1191
null
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs.__verify_minion
python
def __verify_minion(self, id_, token): ''' Take a minion id and a string signed with the minion private key The string needs to verify as 'salt' with the minion public key :param str id_: A minion ID :param str token: A string signed with the minion private key :rtype: ...
Take a minion id and a string signed with the minion private key The string needs to verify as 'salt' with the minion public key :param str id_: A minion ID :param str token: A string signed with the minion private key :rtype: bool :return: Boolean indicating whether or not the...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1193-L1229
[ "def valid_id(opts, id_):\n '''\n Returns if the passed id is valid\n '''\n try:\n if any(x in id_ for x in ('/', '\\\\', str('\\0'))):\n return False\n return bool(clean_path(opts['pki_dir'], id_))\n except (AttributeError, KeyError, TypeError, UnicodeDecodeError):\n ...
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs.__verify_minion_publish
python
def __verify_minion_publish(self, clear_load): ''' Verify that the passed information authorized a minion to execute :param dict clear_load: A publication load from a minion :rtype: bool :return: A boolean indicating if the minion is allowed to publish the command in the load ...
Verify that the passed information authorized a minion to execute :param dict clear_load: A publication load from a minion :rtype: bool :return: A boolean indicating if the minion is allowed to publish the command in the load
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1244-L1294
[ "def __verify_minion(self, id_, token):\n '''\n Take a minion id and a string signed with the minion private key\n The string needs to verify as 'salt' with the minion public key\n\n :param str id_: A minion ID\n :param str token: A string signed with the minion private key\n\n :rtype: bool\n :...
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs.__verify_load
python
def __verify_load(self, load, verify_keys): ''' A utility function to perform common verification steps. :param dict load: A payload received from a minion :param list verify_keys: A list of strings that should be present in a given load :rtype: bool :rtype: dic...
A utility function to perform common verification steps. :param dict load: A payload received from a minion :param list verify_keys: A list of strings that should be present in a given load :rtype: bool :rtype: dict :return: The original load (except for the token) if t...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1296-L1326
[ "def inspect_stack():\n '''\n Return a string of which function we are currently in.\n '''\n return {'co_name': inspect.stack()[1][3]}\n", "def __verify_minion(self, id_, token):\n '''\n Take a minion id and a string signed with the minion private key\n The string needs to verify as 'salt' wi...
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs._master_tops
python
def _master_tops(self, load): ''' Return the results from an external node classifier if one is specified :param dict load: A payload received from a minion :return: The results from an external node classifier ''' load = self.__verify_load(load, ('id', 'tok')) ...
Return the results from an external node classifier if one is specified :param dict load: A payload received from a minion :return: The results from an external node classifier
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1328-L1339
null
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs._mine_get
python
def _mine_get(self, load): ''' Gathers the data from the specified minions' mine :param dict load: A payload received from a minion :rtype: dict :return: Mine data from the specified minions ''' load = self.__verify_load(load, ('id', 'tgt', 'fun', 'tok')) ...
Gathers the data from the specified minions' mine :param dict load: A payload received from a minion :rtype: dict :return: Mine data from the specified minions
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1379-L1392
null
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs._mine
python
def _mine(self, load): ''' Store the mine data :param dict load: A payload received from a minion :rtype: bool :return: True if the data has been stored in the mine ''' load = self.__verify_load(load, ('id', 'data', 'tok')) if load is False: ...
Store the mine data :param dict load: A payload received from a minion :rtype: bool :return: True if the data has been stored in the mine
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1394-L1406
null
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs._mine_delete
python
def _mine_delete(self, load): ''' Allow the minion to delete a specific function from its own mine :param dict load: A payload received from a minion :rtype: bool :return: Boolean indicating whether or not the given function was deleted from the mine ''' load = ...
Allow the minion to delete a specific function from its own mine :param dict load: A payload received from a minion :rtype: bool :return: Boolean indicating whether or not the given function was deleted from the mine
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1408-L1421
null
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs._mine_flush
python
def _mine_flush(self, load): ''' Allow the minion to delete all of its own mine contents :param dict load: A payload received from a minion ''' load = self.__verify_load(load, ('id', 'tok')) if load is False: return {} else: return self.ma...
Allow the minion to delete all of its own mine contents :param dict load: A payload received from a minion
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1423-L1433
null
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs._file_recv
python
def _file_recv(self, load): ''' Allows minions to send files to the master, files are sent to the master file cache ''' if any(key not in load for key in ('id', 'path', 'loc')): return False if not isinstance(load['path'], list): return False ...
Allows minions to send files to the master, files are sent to the master file cache
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1435-L1514
null
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs._pillar
python
def _pillar(self, load): ''' Return the pillar data for the minion :param dict load: Minion payload :rtype: dict :return: The pillar data for the minion ''' if any(key not in load for key in ('id', 'grains')): return False if not salt.utils.v...
Return the pillar data for the minion :param dict load: Minion payload :rtype: dict :return: The pillar data for the minion
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1516-L1549
null
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs._minion_event
python
def _minion_event(self, load): ''' Receive an event from the minion and fire it on the master event interface :param dict load: The minion payload ''' load = self.__verify_load(load, ('id', 'tok')) if load is False: return {} # Route to master...
Receive an event from the minion and fire it on the master event interface :param dict load: The minion payload
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1551-L1564
null
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs._handle_minion_event
python
def _handle_minion_event(self, load): ''' Act on specific events from minions ''' id_ = load['id'] if load.get('tag', '') == '_salt_error': log.error( 'Received minion error from [%s]: %s', id_, load['data']['message'] ) ...
Act on specific events from minions
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1566-L1595
null
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs._return
python
def _return(self, load): ''' Handle the return data sent from the minions. Takes the return, verifies it and fires it on the master event bus. Typically, this event is consumed by the Salt CLI waiting on the other end of the event bus but could be heard by any listener on the bu...
Handle the return data sent from the minions. Takes the return, verifies it and fires it on the master event bus. Typically, this event is consumed by the Salt CLI waiting on the other end of the event bus but could be heard by any listener on the bus. :param dict load: The minion payl...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1597-L1636
null
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs._syndic_return
python
def _syndic_return(self, load): ''' Receive a syndic minion return and format it to look like returns from individual minions. :param dict load: The minion payload ''' loads = load.get('load') if not isinstance(loads, list): loads = [load] # support ...
Receive a syndic minion return and format it to look like returns from individual minions. :param dict load: The minion payload
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1638-L1681
null
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs.minion_runner
python
def minion_runner(self, clear_load): ''' Execute a runner from a minion, return the runner's function data :param dict clear_load: The minion payload :rtype: dict :return: The runner function data ''' load = self.__verify_load(clear_load, ('fun', 'arg', 'id', 't...
Execute a runner from a minion, return the runner's function data :param dict clear_load: The minion payload :rtype: dict :return: The runner function data
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1683-L1696
[ "def __verify_load(self, load, verify_keys):\n '''\n A utility function to perform common verification steps.\n\n :param dict load: A payload received from a minion\n :param list verify_keys: A list of strings that should be present in a\n given load\n\n :rtype: bool\n :rtype: dict\n :return...
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs.pub_ret
python
def pub_ret(self, load): ''' Request the return data from a specific jid, only allowed if the requesting minion also initialted the execution. :param dict load: The minion payload :rtype: dict :return: Return data corresponding to a given JID ''' load = ...
Request the return data from a specific jid, only allowed if the requesting minion also initialted the execution. :param dict load: The minion payload :rtype: dict :return: Return data corresponding to a given JID
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1698-L1722
[ "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 with open or dup), this bit is\n initially cleared on the ...
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs.minion_pub
python
def minion_pub(self, clear_load): ''' Publish a command initiated from a minion, this method executes minion restrictions so that the minion publication will only work if it is enabled in the config. The configuration on the master allows minions to be matched to salt fu...
Publish a command initiated from a minion, this method executes minion restrictions so that the minion publication will only work if it is enabled in the config. The configuration on the master allows minions to be matched to salt functions, so the minions can only publish allowed salt ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1724-L1757
[ "def __verify_minion_publish(self, clear_load):\n '''\n Verify that the passed information authorized a minion to execute\n\n :param dict clear_load: A publication load from a minion\n\n :rtype: bool\n :return: A boolean indicating if the minion is allowed to publish the command in the load\n '''\...
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs.minion_publish
python
def minion_publish(self, clear_load): ''' Publish a command initiated from a minion, this method executes minion restrictions so that the minion publication will only work if it is enabled in the config. The configuration on the master allows minions to be matched to sal...
Publish a command initiated from a minion, this method executes minion restrictions so that the minion publication will only work if it is enabled in the config. The configuration on the master allows minions to be matched to salt functions, so the minions can only publish allowed salt ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1759-L1792
[ "def __verify_minion_publish(self, clear_load):\n '''\n Verify that the passed information authorized a minion to execute\n\n :param dict clear_load: A publication load from a minion\n\n :rtype: bool\n :return: A boolean indicating if the minion is allowed to publish the command in the load\n '''\...
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs.revoke_auth
python
def revoke_auth(self, load): ''' Allow a minion to request revocation of its own key :param dict load: The minion payload :rtype: dict :return: If the load is invalid, it may be returned. No key operation is performed. :rtype: bool :return: True if key was revo...
Allow a minion to request revocation of its own key :param dict load: The minion payload :rtype: dict :return: If the load is invalid, it may be returned. No key operation is performed. :rtype: bool :return: True if key was revoked, False if not
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1794-L1818
[ "def __verify_load(self, load, verify_keys):\n '''\n A utility function to perform common verification steps.\n\n :param dict load: A payload received from a minion\n :param list verify_keys: A list of strings that should be present in a\n given load\n\n :rtype: bool\n :rtype: dict\n :return...
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
AESFuncs.run_func
python
def run_func(self, func, load): ''' Wrapper for running functions executed with AES encryption :param function func: The function to run :return: The result of the master function that was called ''' # Don't honor private functions if func.startswith('__'): ...
Wrapper for running functions executed with AES encryption :param function func: The function to run :return: The result of the master function that was called
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1820-L1859
null
class AESFuncs(object): ''' Set up functions that are available when the load is encrypted with AES ''' # The AES Functions: # def __init__(self, opts): ''' Create a new AESFuncs :param dict opts: The salt options :rtype: AESFuncs :returns: Instance for ...
saltstack/salt
salt/master.py
ClearFuncs.runner
python
def runner(self, clear_load): ''' Send a master control function back to the runner system ''' # All runner ops pass through eauth auth_type, err_name, key, sensitive_load_keys = self._prep_auth_info(clear_load) # Authenticate auth_check = self.loadauth.check_aut...
Send a master control function back to the runner system
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1894-L1947
[ "def get_user():\n '''\n Get the current user\n '''\n if HAS_PWD:\n ret = pwd.getpwuid(os.geteuid()).pw_name\n elif HAS_WIN_FUNCTIONS and salt.utils.win_functions.HAS_WIN32:\n ret = salt.utils.win_functions.get_current_user()\n else:\n raise CommandExecutionError(\n ...
class ClearFuncs(object): ''' Set up functions that are safe to execute when commands sent to the master without encryption and authentication ''' # The ClearFuncs object encapsulates the functions that can be executed in # the clear: # publish (The publish from the LocalClient) # _auth ...
saltstack/salt
salt/master.py
ClearFuncs.wheel
python
def wheel(self, clear_load): ''' Send a master control function back to the wheel system ''' # All wheel ops pass through eauth auth_type, err_name, key, sensitive_load_keys = self._prep_auth_info(clear_load) # Authenticate auth_check = self.loadauth.check_authen...
Send a master control function back to the wheel system
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L1949-L2018
[ "def get_user():\n '''\n Get the current user\n '''\n if HAS_PWD:\n ret = pwd.getpwuid(os.geteuid()).pw_name\n elif HAS_WIN_FUNCTIONS and salt.utils.win_functions.HAS_WIN32:\n ret = salt.utils.win_functions.get_current_user()\n else:\n raise CommandExecutionError(\n ...
class ClearFuncs(object): ''' Set up functions that are safe to execute when commands sent to the master without encryption and authentication ''' # The ClearFuncs object encapsulates the functions that can be executed in # the clear: # publish (The publish from the LocalClient) # _auth ...
saltstack/salt
salt/master.py
ClearFuncs.mk_token
python
def mk_token(self, clear_load): ''' Create and return an authentication token, the clear load needs to contain the eauth key and the needed authentication creds. ''' token = self.loadauth.mk_token(clear_load) if not token: log.warning('Authentication failure o...
Create and return an authentication token, the clear load needs to contain the eauth key and the needed authentication creds.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L2020-L2029
null
class ClearFuncs(object): ''' Set up functions that are safe to execute when commands sent to the master without encryption and authentication ''' # The ClearFuncs object encapsulates the functions that can be executed in # the clear: # publish (The publish from the LocalClient) # _auth ...
saltstack/salt
salt/master.py
ClearFuncs.publish
python
def publish(self, clear_load): ''' This method sends out publications to the minions, it can only be used by the LocalClient. ''' extra = clear_load.get('kwargs', {}) publisher_acl = salt.acl.PublisherACL(self.opts['publisher_acl_blacklist']) if publisher_acl.us...
This method sends out publications to the minions, it can only be used by the LocalClient.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L2063-L2174
[ "def user_is_blacklisted(self, user):\n '''\n Takes a username as a string and returns a boolean. True indicates that\n the provided user has been blacklisted\n '''\n return not salt.utils.stringutils.check_whitelist_blacklist(user, blacklist=self.blacklist.get('users', []))\n" ]
class ClearFuncs(object): ''' Set up functions that are safe to execute when commands sent to the master without encryption and authentication ''' # The ClearFuncs object encapsulates the functions that can be executed in # the clear: # publish (The publish from the LocalClient) # _auth ...
saltstack/salt
salt/master.py
ClearFuncs._prep_jid
python
def _prep_jid(self, clear_load, extra): ''' Return a jid for this publication ''' # the jid in clear_load can be None, '', or something else. this is an # attempt to clean up the value before passing to plugins passed_jid = clear_load['jid'] if clear_load.get('jid') else ...
Return a jid for this publication
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L2194-L2217
null
class ClearFuncs(object): ''' Set up functions that are safe to execute when commands sent to the master without encryption and authentication ''' # The ClearFuncs object encapsulates the functions that can be executed in # the clear: # publish (The publish from the LocalClient) # _auth ...
saltstack/salt
salt/master.py
ClearFuncs._send_pub
python
def _send_pub(self, load): ''' Take a load and send it across the network to connected minions ''' for transport, opts in iter_transport_opts(self.opts): chan = salt.transport.server.PubServerChannel.factory(opts) chan.publish(load)
Take a load and send it across the network to connected minions
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L2219-L2225
null
class ClearFuncs(object): ''' Set up functions that are safe to execute when commands sent to the master without encryption and authentication ''' # The ClearFuncs object encapsulates the functions that can be executed in # the clear: # publish (The publish from the LocalClient) # _auth ...
saltstack/salt
salt/master.py
ClearFuncs._send_ssh_pub
python
def _send_ssh_pub(self, load, ssh_minions=False): ''' Take a load and send it across the network to ssh minions ''' if self.opts['enable_ssh_minions'] is True and ssh_minions is True: log.debug('Send payload to ssh minions') threading.Thread(target=self.ssh_client...
Take a load and send it across the network to ssh minions
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L2233-L2239
null
class ClearFuncs(object): ''' Set up functions that are safe to execute when commands sent to the master without encryption and authentication ''' # The ClearFuncs object encapsulates the functions that can be executed in # the clear: # publish (The publish from the LocalClient) # _auth ...
saltstack/salt
salt/master.py
ClearFuncs._prep_pub
python
def _prep_pub(self, minions, jid, clear_load, extra, missing): ''' Take a given load and perform the necessary steps to prepare a publication. TODO: This is really only bound by temporal cohesion and thus should be refactored even further. ''' clear_load['jid'] =...
Take a given load and perform the necessary steps to prepare a publication. TODO: This is really only bound by temporal cohesion and thus should be refactored even further.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/master.py#L2241-L2378
[ "def get_function_argspec(func, is_class_method=None):\n '''\n A small wrapper around getargspec that also supports callable classes\n :param is_class_method: Pass True if you are sure that the function being passed\n is a class method. The reason for this is that on Python 3\n ...
class ClearFuncs(object): ''' Set up functions that are safe to execute when commands sent to the master without encryption and authentication ''' # The ClearFuncs object encapsulates the functions that can be executed in # the clear: # publish (The publish from the LocalClient) # _auth ...
saltstack/salt
salt/states/sqlite3.py
row_absent
python
def row_absent(name, db, table, where_sql, where_args=None): ''' Makes sure the specified row is absent in db. If multiple rows match where_sql, then the state will fail. name Only used as the unique ID db The database file name table The table name to check wher...
Makes sure the specified row is absent in db. If multiple rows match where_sql, then the state will fail. name Only used as the unique ID db The database file name table The table name to check where_sql The sql to select the row to check where_args ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/sqlite3.py#L117-L191
[ "def _query(conn, sql, parameters=None):\n cursor = None\n if parameters is None:\n cursor = conn.execute(sql)\n else:\n cursor = conn.execute(sql, parameters)\n return cursor.fetchall()\n" ]
# -*- coding: utf-8 -*- ''' Management of SQLite3 databases =============================== .. versionadded:: 2016.3.0 :depends: - SQLite3 Python Module :configuration: See :py:mod:`salt.modules.sqlite3` for setup instructions The sqlite3 module is used to create and manage sqlite3 databases and execute queries H...
saltstack/salt
salt/states/sqlite3.py
row_present
python
def row_present(name, db, table, data, where_sql, where_args=None, update=False): ''' Checks to make sure the given row exists. If row exists and update is True then row will be updated with data. Otherwise it wi...
Checks to make sure the given row exists. If row exists and update is True then row will be updated with data. Otherwise it will leave existing row unmodified and check it against data. If the existing data doesn't match data_check the state will fail. If the row doesn't exist then it will insert data ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/sqlite3.py#L194-L331
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "def _query(conn, sql, parameters=None):\n cursor = None\n if parameters is None:\n cursor = conn.execute(sql)\n else:\n cursor = conn.execute(sql, parameters)\n return cursor.fetchall()\n" ]
# -*- coding: utf-8 -*- ''' Management of SQLite3 databases =============================== .. versionadded:: 2016.3.0 :depends: - SQLite3 Python Module :configuration: See :py:mod:`salt.modules.sqlite3` for setup instructions The sqlite3 module is used to create and manage sqlite3 databases and execute queries H...
saltstack/salt
salt/states/sqlite3.py
table_absent
python
def table_absent(name, db): ''' Make sure the specified table does not exist name The name of the table db The name of the database file ''' changes = {'name': name, 'changes': {}, 'result': None, 'comment': ''} conn = None t...
Make sure the specified table does not exist name The name of the table db The name of the database file
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/sqlite3.py#L334-L380
[ "def _query(conn, sql, parameters=None):\n cursor = None\n if parameters is None:\n cursor = conn.execute(sql)\n else:\n cursor = conn.execute(sql, parameters)\n return cursor.fetchall()\n" ]
# -*- coding: utf-8 -*- ''' Management of SQLite3 databases =============================== .. versionadded:: 2016.3.0 :depends: - SQLite3 Python Module :configuration: See :py:mod:`salt.modules.sqlite3` for setup instructions The sqlite3 module is used to create and manage sqlite3 databases and execute queries H...
saltstack/salt
salt/states/sqlite3.py
table_present
python
def table_present(name, db, schema, force=False): ''' Make sure the specified table exists with the specified schema name The name of the table db The name of the database file schema The dictionary containing the schema information force If the name of the ta...
Make sure the specified table exists with the specified schema name The name of the table db The name of the database file schema The dictionary containing the schema information force If the name of the table exists and force is set to False, the state will f...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/sqlite3.py#L383-L471
[ "def _query(conn, sql, parameters=None):\n cursor = None\n if parameters is None:\n cursor = conn.execute(sql)\n else:\n cursor = conn.execute(sql, parameters)\n return cursor.fetchall()\n", "def _get_sql_from_schema(name, schema):\n return \"CREATE TABLE `\" + name + \"` (\" + \",\"....
# -*- coding: utf-8 -*- ''' Management of SQLite3 databases =============================== .. versionadded:: 2016.3.0 :depends: - SQLite3 Python Module :configuration: See :py:mod:`salt.modules.sqlite3` for setup instructions The sqlite3 module is used to create and manage sqlite3 databases and execute queries H...
saltstack/salt
salt/matchers/range_match.py
match
python
def match(tgt, opts=None): ''' Matches based on range cluster ''' if not opts: opts = __opts__ if HAS_RANGE: range_ = seco.range.Range(opts['range_server']) try: return opts['grains']['fqdn'] in range_.expand(tgt) except seco.range.RangeException as exc: ...
Matches based on range cluster
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/matchers/range_match.py#L19-L32
null
# -*- coding: utf-8 -*- ''' This is the default range matcher. ''' from __future__ import absolute_import, print_function, unicode_literals import logging HAS_RANGE = False try: import seco.range HAS_RANGE = True except ImportError: pass log = logging.getLogger(__name__)
saltstack/salt
salt/returners/cassandra_return.py
returner
python
def returner(ret): ''' Return data to a Cassandra ColumnFamily ''' consistency_level = getattr(pycassa.ConsistencyLevel, __opts__['cassandra.consistency_level']) pool = pycassa.ConnectionPool(__opts__['cassandra.keyspace'], __opts__...
Return data to a Cassandra ColumnFamily
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/cassandra_return.py#L54-L76
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n" ]
# -*- coding: utf-8 -*- ''' Return data to a Cassandra ColumnFamily Here's an example Keyspace / ColumnFamily setup that works with this returner:: create keyspace salt; use salt; create column family returns with key_validation_class='UTF8Type' and comparator='UTF8Type' and default_vali...
saltstack/salt
salt/modules/seed.py
prep_bootstrap
python
def prep_bootstrap(mpt): ''' Update and get the random script to a random place CLI Example: .. code-block:: bash salt '*' seed.prep_bootstrap /tmp ''' # Verify that the boostrap script is downloaded bs_ = __salt__['config.gather_bootstrap_script']() fpd_ = os.path.join(mpt, ...
Update and get the random script to a random place CLI Example: .. code-block:: bash salt '*' seed.prep_bootstrap /tmp
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/seed.py#L39-L61
null
# -*- coding: utf-8 -*- ''' Virtual machine image management tools ''' from __future__ import absolute_import, unicode_literals, print_function # Import python libs import os import shutil import logging import tempfile # Import salt libs import salt.crypt import salt.utils.cloud import salt.utils.files import salt....
saltstack/salt
salt/modules/seed.py
apply_
python
def apply_(path, id_=None, config=None, approve_key=True, install=True, prep_install=False, pub_key=None, priv_key=None, mount_point=None): ''' Seed a location (disk image, directory, or block device) with the minion config, approve the minion's key, and/or install salt-minion. CLI Example: ...
Seed a location (disk image, directory, or block device) with the minion config, approve the minion's key, and/or install salt-minion. CLI Example: .. code-block:: bash salt 'minion' seed.apply path id [config=config_data] \\ [gen_key=(true|false)] [approve_key=(true|false)] \\ ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/seed.py#L94-L187
[ "def minion_config(path,\n env_var='SALT_MINION_CONFIG',\n defaults=None,\n cache_minion_id=False,\n ignore_config_errors=True,\n minion_id=None,\n role='minion'):\n '''\n Reads in the minion configuration fi...
# -*- coding: utf-8 -*- ''' Virtual machine image management tools ''' from __future__ import absolute_import, unicode_literals, print_function # Import python libs import os import shutil import logging import tempfile # Import salt libs import salt.crypt import salt.utils.cloud import salt.utils.files import salt....
saltstack/salt
salt/modules/seed.py
mkconfig
python
def mkconfig(config=None, tmp=None, id_=None, approve_key=True, pub_key=None, priv_key=None): ''' Generate keys and config and put them in a tmp directory. pub_key absolute path or file content of an optional preseeded salt key p...
Generate keys and config and put them in a tmp directory. pub_key absolute path or file content of an optional preseeded salt key priv_key absolute path or file content of an optional preseeded salt key CLI Example: .. code-block:: bash salt 'minion' seed.mkconfig [config=co...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/seed.py#L190-L246
[ "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 with open or dup), this bit is\n initially cleared on the ...
# -*- coding: utf-8 -*- ''' Virtual machine image management tools ''' from __future__ import absolute_import, unicode_literals, print_function # Import python libs import os import shutil import logging import tempfile # Import salt libs import salt.crypt import salt.utils.cloud import salt.utils.files import salt....
saltstack/salt
salt/modules/seed.py
_install
python
def _install(mpt): ''' Determine whether salt-minion is installed and, if not, install it. Return True if install is successful or already installed. ''' _check_resolv(mpt) boot_, tmppath = (prep_bootstrap(mpt) or salt.syspaths.BOOTSTRAP) # Exec the chroot command cmd = ...
Determine whether salt-minion is installed and, if not, install it. Return True if install is successful or already installed.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/seed.py#L249-L261
null
# -*- coding: utf-8 -*- ''' Virtual machine image management tools ''' from __future__ import absolute_import, unicode_literals, print_function # Import python libs import os import shutil import logging import tempfile # Import salt libs import salt.crypt import salt.utils.cloud import salt.utils.files import salt....
saltstack/salt
salt/modules/seed.py
_check_resolv
python
def _check_resolv(mpt): ''' Check that the resolv.conf is present and populated ''' resolv = os.path.join(mpt, 'etc/resolv.conf') replace = False if os.path.islink(resolv): resolv = os.path.realpath(resolv) if not os.path.isdir(os.path.dirname(resolv)): os.makedirs(os...
Check that the resolv.conf is present and populated
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/seed.py#L264-L284
null
# -*- coding: utf-8 -*- ''' Virtual machine image management tools ''' from __future__ import absolute_import, unicode_literals, print_function # Import python libs import os import shutil import logging import tempfile # Import salt libs import salt.crypt import salt.utils.cloud import salt.utils.files import salt....
saltstack/salt
salt/utils/win_lgpo_netsh.py
_netsh_file
python
def _netsh_file(content): ''' helper function to get the results of ``netsh -f content.txt`` Running ``netsh`` will drop you into a ``netsh`` prompt where you can issue ``netsh`` commands. You can put a series of commands in an external file and run them as if from a ``netsh`` prompt using the ``-f...
helper function to get the results of ``netsh -f content.txt`` Running ``netsh`` will drop you into a ``netsh`` prompt where you can issue ``netsh`` commands. You can put a series of commands in an external file and run them as if from a ``netsh`` prompt using the ``-f`` switch. That's what this functi...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/win_lgpo_netsh.py#L99-L126
null
# -*- coding: utf-8 -*- r''' A salt util for modifying firewall settings. .. versionadded:: 2018.3.4 .. versionadded:: 2019.2.0 This util allows you to modify firewall settings in the local group policy in addition to the normal firewall settings. Parameters are taken from the netsh advfirewall prompt. .. note:: ...
saltstack/salt
salt/utils/win_lgpo_netsh.py
get_settings
python
def get_settings(profile, section, store='local'): ''' Get the firewall property from the specified profile in the specified store as returned by ``netsh advfirewall``. Args: profile (str): The firewall profile to query. Valid options are: - domain - public...
Get the firewall property from the specified profile in the specified store as returned by ``netsh advfirewall``. Args: profile (str): The firewall profile to query. Valid options are: - domain - public - private section (str): The ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/win_lgpo_netsh.py#L148-L224
[ "def _netsh_command(command, store):\n if store.lower() not in ('local', 'lgpo'):\n raise ValueError('Incorrect store: {0}'.format(store))\n # set the store for local or lgpo\n if store.lower() == 'local':\n netsh_script = dedent('''\\\n advfirewall\n set store local\n ...
# -*- coding: utf-8 -*- r''' A salt util for modifying firewall settings. .. versionadded:: 2018.3.4 .. versionadded:: 2019.2.0 This util allows you to modify firewall settings in the local group policy in addition to the normal firewall settings. Parameters are taken from the netsh advfirewall prompt. .. note:: ...
saltstack/salt
salt/utils/win_lgpo_netsh.py
get_all_settings
python
def get_all_settings(profile, store='local'): ''' Gets all the properties for the specified profile in the specified store Args: profile (str): The firewall profile to query. Valid options are: - domain - public - private store (str): ...
Gets all the properties for the specified profile in the specified store Args: profile (str): The firewall profile to query. Valid options are: - domain - public - private store (str): The store to use. This is either the local firewall...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/win_lgpo_netsh.py#L227-L257
[ "def get_settings(profile, section, store='local'):\n '''\n Get the firewall property from the specified profile in the specified store\n as returned by ``netsh advfirewall``.\n\n Args:\n\n profile (str):\n The firewall profile to query. Valid options are:\n\n - domain\n ...
# -*- coding: utf-8 -*- r''' A salt util for modifying firewall settings. .. versionadded:: 2018.3.4 .. versionadded:: 2019.2.0 This util allows you to modify firewall settings in the local group policy in addition to the normal firewall settings. Parameters are taken from the netsh advfirewall prompt. .. note:: ...
saltstack/salt
salt/utils/win_lgpo_netsh.py
get_all_profiles
python
def get_all_profiles(store='local'): ''' Gets all properties for all profiles in the specified store Args: store (str): The store to use. This is either the local firewall policy or the policy defined by local group policy. Valid options are: - lgpo ...
Gets all properties for all profiles in the specified store Args: store (str): The store to use. This is either the local firewall policy or the policy defined by local group policy. Valid options are: - lgpo - local Default is ``local`` R...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/win_lgpo_netsh.py#L260-L282
[ "def get_all_settings(profile, store='local'):\n '''\n Gets all the properties for the specified profile in the specified store\n\n Args:\n\n profile (str):\n The firewall profile to query. Valid options are:\n\n - domain\n - public\n - private\n\n ...
# -*- coding: utf-8 -*- r''' A salt util for modifying firewall settings. .. versionadded:: 2018.3.4 .. versionadded:: 2019.2.0 This util allows you to modify firewall settings in the local group policy in addition to the normal firewall settings. Parameters are taken from the netsh advfirewall prompt. .. note:: ...
saltstack/salt
salt/utils/win_lgpo_netsh.py
set_firewall_settings
python
def set_firewall_settings(profile, inbound=None, outbound=None, store='local'): ''' Set the firewall inbound/outbound settings for the specified profile and store Args: profile (str): The firewall profile...
Set the firewall inbound/outbound settings for the specified profile and store Args: profile (str): The firewall profile to configure. Valid options are: - domain - public - private inbound (str): The inbound setting. If ``None`` is...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/win_lgpo_netsh.py#L285-L374
[ "def get_settings(profile, section, store='local'):\n '''\n Get the firewall property from the specified profile in the specified store\n as returned by ``netsh advfirewall``.\n\n Args:\n\n profile (str):\n The firewall profile to query. Valid options are:\n\n - domain\n ...
# -*- coding: utf-8 -*- r''' A salt util for modifying firewall settings. .. versionadded:: 2018.3.4 .. versionadded:: 2019.2.0 This util allows you to modify firewall settings in the local group policy in addition to the normal firewall settings. Parameters are taken from the netsh advfirewall prompt. .. note:: ...
saltstack/salt
salt/utils/win_lgpo_netsh.py
set_logging_settings
python
def set_logging_settings(profile, setting, value, store='local'): ''' Configure logging settings for the Windows firewall. Args: profile (str): The firewall profile to configure. Valid options are: - domain - public - private setting (str):...
Configure logging settings for the Windows firewall. Args: profile (str): The firewall profile to configure. Valid options are: - domain - public - private setting (str): The logging setting to configure. Valid options are: ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/win_lgpo_netsh.py#L377-L470
null
# -*- coding: utf-8 -*- r''' A salt util for modifying firewall settings. .. versionadded:: 2018.3.4 .. versionadded:: 2019.2.0 This util allows you to modify firewall settings in the local group policy in addition to the normal firewall settings. Parameters are taken from the netsh advfirewall prompt. .. note:: ...
saltstack/salt
salt/utils/win_lgpo_netsh.py
set_settings
python
def set_settings(profile, setting, value, store='local'): ''' Configure firewall settings. Args: profile (str): The firewall profile to configure. Valid options are: - domain - public - private setting (str): The firewall settin...
Configure firewall settings. Args: profile (str): The firewall profile to configure. Valid options are: - domain - public - private setting (str): The firewall setting to configure. Valid options are: - localfirewallrules ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/win_lgpo_netsh.py#L473-L538
[ "def _netsh_command(command, store):\n if store.lower() not in ('local', 'lgpo'):\n raise ValueError('Incorrect store: {0}'.format(store))\n # set the store for local or lgpo\n if store.lower() == 'local':\n netsh_script = dedent('''\\\n advfirewall\n set store local\n ...
# -*- coding: utf-8 -*- r''' A salt util for modifying firewall settings. .. versionadded:: 2018.3.4 .. versionadded:: 2019.2.0 This util allows you to modify firewall settings in the local group policy in addition to the normal firewall settings. Parameters are taken from the netsh advfirewall prompt. .. note:: ...
saltstack/salt
salt/utils/win_lgpo_netsh.py
set_state
python
def set_state(profile, state, store='local'): ''' Configure the firewall state. Args: profile (str): The firewall profile to configure. Valid options are: - domain - public - private state (str): The firewall state. Valid option...
Configure the firewall state. Args: profile (str): The firewall profile to configure. Valid options are: - domain - public - private state (str): The firewall state. Valid options are: - on - off - n...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/win_lgpo_netsh.py#L541-L591
[ "def _netsh_command(command, store):\n if store.lower() not in ('local', 'lgpo'):\n raise ValueError('Incorrect store: {0}'.format(store))\n # set the store for local or lgpo\n if store.lower() == 'local':\n netsh_script = dedent('''\\\n advfirewall\n set store local\n ...
# -*- coding: utf-8 -*- r''' A salt util for modifying firewall settings. .. versionadded:: 2018.3.4 .. versionadded:: 2019.2.0 This util allows you to modify firewall settings in the local group policy in addition to the normal firewall settings. Parameters are taken from the netsh advfirewall prompt. .. note:: ...
saltstack/salt
salt/modules/aliases.py
__parse_aliases
python
def __parse_aliases(): ''' Parse the aliases file, and return a list of line components: [ (alias1, target1, comment1), (alias2, target2, comment2), ] ''' afn = __get_aliases_filename() ret = [] if not os.path.isfile(afn): return ret with salt.utils.files.fopen(a...
Parse the aliases file, and return a list of line components: [ (alias1, target1, comment1), (alias2, target2, comment2), ]
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/aliases.py#L40-L61
[ "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 with open or dup), this bit is\n initially cleared on the ...
# -*- coding: utf-8 -*- ''' Manage the information in the aliases file ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import re import stat import tempfile # Import salt libs import salt.utils.files import salt.utils.path import salt.utils.stringutils from ...
saltstack/salt
salt/modules/aliases.py
__write_aliases_file
python
def __write_aliases_file(lines): ''' Write a new copy of the aliases file. Lines is a list of lines as returned by __parse_aliases. ''' afn = __get_aliases_filename() adir = os.path.dirname(afn) out = tempfile.NamedTemporaryFile(dir=adir, delete=False) if not __opts__.get('integration...
Write a new copy of the aliases file. Lines is a list of lines as returned by __parse_aliases.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/aliases.py#L64-L106
[ "def __get_aliases_filename():\n '''\n Return the path to the appropriate aliases file\n '''\n return os.path.realpath(__salt__['config.option']('aliases.file'))\n" ]
# -*- coding: utf-8 -*- ''' Manage the information in the aliases file ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import re import stat import tempfile # Import salt libs import salt.utils.files import salt.utils.path import salt.utils.stringutils from ...
saltstack/salt
salt/modules/aliases.py
list_aliases
python
def list_aliases(): ''' Return the aliases found in the aliases file in this format:: {'alias': 'target'} CLI Example: .. code-block:: bash salt '*' aliases.list_aliases ''' ret = dict((alias, target) for alias, target, comment in __parse_aliases() if alias) return ret
Return the aliases found in the aliases file in this format:: {'alias': 'target'} CLI Example: .. code-block:: bash salt '*' aliases.list_aliases
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/aliases.py#L109-L122
[ "def __parse_aliases():\n '''\n Parse the aliases file, and return a list of line components:\n\n [\n (alias1, target1, comment1),\n (alias2, target2, comment2),\n ]\n '''\n afn = __get_aliases_filename()\n ret = []\n if not os.path.isfile(afn):\n return ret\n with salt.u...
# -*- coding: utf-8 -*- ''' Manage the information in the aliases file ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import re import stat import tempfile # Import salt libs import salt.utils.files import salt.utils.path import salt.utils.stringutils from ...
saltstack/salt
salt/modules/aliases.py
has_target
python
def has_target(alias, target): ''' Return true if the alias/target is set CLI Example: .. code-block:: bash salt '*' aliases.has_target alias target ''' if target == '': raise SaltInvocationError('target can not be an empty string') aliases = list_aliases() if alias no...
Return true if the alias/target is set CLI Example: .. code-block:: bash salt '*' aliases.has_target alias target
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/aliases.py#L141-L158
[ "def list_aliases():\n '''\n Return the aliases found in the aliases file in this format::\n\n {'alias': 'target'}\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' aliases.list_aliases\n '''\n ret = dict((alias, target) for alias, target, comment in __parse_aliases() if alias)\...
# -*- coding: utf-8 -*- ''' Manage the information in the aliases file ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import re import stat import tempfile # Import salt libs import salt.utils.files import salt.utils.path import salt.utils.stringutils from ...
saltstack/salt
salt/modules/aliases.py
set_target
python
def set_target(alias, target): ''' Set the entry in the aliases file for the given alias, this will overwrite any previous entry for the given alias or create a new one if it does not exist. CLI Example: .. code-block:: bash salt '*' aliases.set_target alias target ''' if ali...
Set the entry in the aliases file for the given alias, this will overwrite any previous entry for the given alias or create a new one if it does not exist. CLI Example: .. code-block:: bash salt '*' aliases.set_target alias target
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/aliases.py#L161-L197
[ "def get_target(alias):\n '''\n Return the target associated with an alias\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' aliases.get_target alias\n '''\n aliases = list_aliases()\n if alias in aliases:\n return aliases[alias]\n return ''\n", "def __parse_aliases():\n...
# -*- coding: utf-8 -*- ''' Manage the information in the aliases file ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import re import stat import tempfile # Import salt libs import salt.utils.files import salt.utils.path import salt.utils.stringutils from ...
saltstack/salt
salt/modules/aliases.py
rm_alias
python
def rm_alias(alias): ''' Remove an entry from the aliases file CLI Example: .. code-block:: bash salt '*' aliases.rm_alias alias ''' if not get_target(alias): return True lines = __parse_aliases() out = [] for (line_alias, line_target, line_comment) in lines: ...
Remove an entry from the aliases file CLI Example: .. code-block:: bash salt '*' aliases.rm_alias alias
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/aliases.py#L200-L220
[ "def get_target(alias):\n '''\n Return the target associated with an alias\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' aliases.get_target alias\n '''\n aliases = list_aliases()\n if alias in aliases:\n return aliases[alias]\n return ''\n", "def __parse_aliases():\n...
# -*- coding: utf-8 -*- ''' Manage the information in the aliases file ''' from __future__ import absolute_import, print_function, unicode_literals # Import python libs import os import re import stat import tempfile # Import salt libs import salt.utils.files import salt.utils.path import salt.utils.stringutils from ...
saltstack/salt
salt/thorium/__init__.py
ThorState.gather_cache
python
def gather_cache(self): ''' Gather the specified data from the minion data cache ''' cache = {'grains': {}, 'pillar': {}} if self.grains or self.pillar: if self.opts.get('minion_data_cache'): minions = self.cache.list('minions') if not ...
Gather the specified data from the minion data cache
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/__init__.py#L70-L102
null
class ThorState(salt.state.HighState): ''' Compile the thorium state and manage it in the thorium runtime ''' def __init__( self, opts, grains=False, grain_keys=None, pillar=False, pillar_keys=None): self.grains = grains ...
saltstack/salt
salt/thorium/__init__.py
ThorState.start_runtime
python
def start_runtime(self): ''' Start the system! ''' while True: try: self.call_runtime() except Exception: log.error('Exception in Thorium: ', exc_info=True) time.sleep(self.opts['thorium_interval'])
Start the system!
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/__init__.py#L104-L113
[ "def call_runtime(self):\n '''\n Execute the runtime\n '''\n cache = self.gather_cache()\n chunks = self.get_chunks()\n interval = self.opts['thorium_interval']\n recompile = self.opts.get('thorium_recompile', 300)\n r_start = time.time()\n while True:\n events = self.get_events()\...
class ThorState(salt.state.HighState): ''' Compile the thorium state and manage it in the thorium runtime ''' def __init__( self, opts, grains=False, grain_keys=None, pillar=False, pillar_keys=None): self.grains = grains ...
saltstack/salt
salt/thorium/__init__.py
ThorState.get_chunks
python
def get_chunks(self, exclude=None, whitelist=None): ''' Compile the top file and return the lowstate for the thorium runtime to iterate over ''' ret = {} err = [] try: top = self.get_top() except SaltRenderError as err: return ret ...
Compile the top file and return the lowstate for the thorium runtime to iterate over
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/__init__.py#L115-L150
[ "def verify_tops(self, tops):\n '''\n Verify the contents of the top file data\n '''\n errors = []\n if not isinstance(tops, dict):\n errors.append('Top data was not formed as a dict')\n # No further checks will work, bail out\n return errors\n for saltenv, matches in six.iter...
class ThorState(salt.state.HighState): ''' Compile the thorium state and manage it in the thorium runtime ''' def __init__( self, opts, grains=False, grain_keys=None, pillar=False, pillar_keys=None): self.grains = grains ...
saltstack/salt
salt/thorium/__init__.py
ThorState.get_events
python
def get_events(self): ''' iterate over the available events and return a list of events ''' ret = [] while True: event = self.event.get_event(wait=1, full=True) if event is None: return ret ret.append(event)
iterate over the available events and return a list of events
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/__init__.py#L152-L161
null
class ThorState(salt.state.HighState): ''' Compile the thorium state and manage it in the thorium runtime ''' def __init__( self, opts, grains=False, grain_keys=None, pillar=False, pillar_keys=None): self.grains = grains ...
saltstack/salt
salt/thorium/__init__.py
ThorState.call_runtime
python
def call_runtime(self): ''' Execute the runtime ''' cache = self.gather_cache() chunks = self.get_chunks() interval = self.opts['thorium_interval'] recompile = self.opts.get('thorium_recompile', 300) r_start = time.time() while True: ev...
Execute the runtime
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/thorium/__init__.py#L163-L190
[ "def gather_cache(self):\n '''\n Gather the specified data from the minion data cache\n '''\n cache = {'grains': {}, 'pillar': {}}\n if self.grains or self.pillar:\n if self.opts.get('minion_data_cache'):\n minions = self.cache.list('minions')\n if not minions:\n ...
class ThorState(salt.state.HighState): ''' Compile the thorium state and manage it in the thorium runtime ''' def __init__( self, opts, grains=False, grain_keys=None, pillar=False, pillar_keys=None): self.grains = grains ...
saltstack/salt
salt/modules/container_resource.py
_validate
python
def _validate(wrapped): ''' Decorator for common function argument validation ''' @functools.wraps(wrapped) def wrapper(*args, **kwargs): container_type = kwargs.get('container_type') exec_driver = kwargs.get('exec_driver') valid_driver = { 'docker': ('lxc-attach'...
Decorator for common function argument validation
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/container_resource.py#L35-L64
null
# -*- coding: utf-8 -*- ''' Common resources for LXC and systemd-nspawn containers .. versionadded:: 2015.8.0 These functions are not designed to be called directly, but instead from the :mod:`lxc <salt.modules.lxc>`, :mod:`nspawn <salt.modules.nspawn>`, and :mod:`docker <salt.modules.docker>` execution modules. They...
saltstack/salt
salt/modules/container_resource.py
cache_file
python
def cache_file(source): ''' Wrapper for cp.cache_file which raises an error if the file was unable to be cached. CLI Example: .. code-block:: bash salt myminion container_resource.cache_file salt://foo/bar/baz.txt ''' try: # Don't just use cp.cache_file for this. Docker ha...
Wrapper for cp.cache_file which raises an error if the file was unable to be cached. CLI Example: .. code-block:: bash salt myminion container_resource.cache_file salt://foo/bar/baz.txt
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/container_resource.py#L91-L114
null
# -*- coding: utf-8 -*- ''' Common resources for LXC and systemd-nspawn containers .. versionadded:: 2015.8.0 These functions are not designed to be called directly, but instead from the :mod:`lxc <salt.modules.lxc>`, :mod:`nspawn <salt.modules.nspawn>`, and :mod:`docker <salt.modules.docker>` execution modules. They...
saltstack/salt
salt/modules/container_resource.py
run
python
def run(name, cmd, container_type=None, exec_driver=None, output=None, no_start=False, stdin=None, python_shell=True, output_loglevel='debug', ignore_retcode=False, path=None, use_vt=False, keep_env=None): ''' Common...
Common logic for running shell commands in containers path path to the container parent (for LXC only) default: /var/lib/lxc (system default) CLI Example: .. code-block:: bash salt myminion container_resource.run mycontainer 'ps aux' container_type=docker exec_driver=nsenter outp...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/container_resource.py#L118-L266
[ "def recv(self, maxsize=None):\n '''\n Receive data from the terminal as a (``stdout``, ``stderr``) tuple. If\n any of those is ``None`` we can no longer communicate with the\n terminal's child process.\n '''\n if maxsize is None:\n maxsize = 1024\n elif maxsize < 1:\n maxsize = 1...
# -*- coding: utf-8 -*- ''' Common resources for LXC and systemd-nspawn containers .. versionadded:: 2015.8.0 These functions are not designed to be called directly, but instead from the :mod:`lxc <salt.modules.lxc>`, :mod:`nspawn <salt.modules.nspawn>`, and :mod:`docker <salt.modules.docker>` execution modules. They...
saltstack/salt
salt/modules/container_resource.py
copy_to
python
def copy_to(name, source, dest, container_type=None, path=None, exec_driver=None, overwrite=False, makedirs=False): ''' Common logic for copying files to containers path path to the container parent (for LXC only) ...
Common logic for copying files to containers path path to the container parent (for LXC only) default: /var/lib/lxc (system default) CLI Example: .. code-block:: bash salt myminion container_resource.copy_to mycontainer /local/file/path /container/file/path container_type=docker ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/container_resource.py#L270-L404
[ "def cache_file(source):\n '''\n Wrapper for cp.cache_file which raises an error if the file was unable to\n be cached.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt myminion container_resource.cache_file salt://foo/bar/baz.txt\n '''\n try:\n # Don't just use cp.cache_file fo...
# -*- coding: utf-8 -*- ''' Common resources for LXC and systemd-nspawn containers .. versionadded:: 2015.8.0 These functions are not designed to be called directly, but instead from the :mod:`lxc <salt.modules.lxc>`, :mod:`nspawn <salt.modules.nspawn>`, and :mod:`docker <salt.modules.docker>` execution modules. They...
saltstack/salt
salt/executors/docker.py
execute
python
def execute(opts, data, func, args, kwargs): ''' Directly calls the given function with arguments ''' if data['fun'] == 'saltutil.find_job': return __executors__['direct_call.execute'](opts, data, func, args, kwargs) if data['fun'] in DOCKER_MOD_MAP: return __executors__['direct_call...
Directly calls the given function with arguments
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/executors/docker.py#L28-L36
null
# -*- coding: utf-8 -*- ''' Docker executor module .. versionadded: 2019.2.0 Used with the docker proxy minion. ''' from __future__ import absolute_import, unicode_literals __virtualname__ = 'docker' DOCKER_MOD_MAP = { 'state.sls': 'docker.sls', 'state.apply': 'docker.apply', 'state.highstate': 'docker....
saltstack/salt
salt/cli/salt.py
SaltCMD.run
python
def run(self): ''' Execute the salt command line ''' import salt.client self.parse_args() if self.config['log_level'] not in ('quiet', ): # Setup file logging! self.setup_logfile_logger() verify_log(self.config) try: ...
Execute the salt command line
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/salt.py#L36-L224
[ "def get_local_client(\n c_path=os.path.join(syspaths.CONFIG_DIR, 'master'),\n mopts=None,\n skip_perm_errors=False,\n io_loop=None,\n auto_reconnect=False):\n '''\n .. versionadded:: 2014.7.0\n\n Read in the config and return the correct LocalClient object based on\n ...
class SaltCMD(salt.utils.parsers.SaltCMDOptionParser): ''' The execution of a salt command happens here ''' def _preview_target(self): ''' Return a list of minions from a given target ''' return self.local_client.gather_minions(self.config['tgt'], self.selected_target_o...
saltstack/salt
salt/cli/salt.py
SaltCMD._print_returns_summary
python
def _print_returns_summary(self, ret): ''' Display returns summary ''' return_counter = 0 not_return_counter = 0 not_return_minions = [] not_response_minions = [] not_connected_minions = [] failed_minions = [] for each_minion in ret: ...
Display returns summary
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cli/salt.py#L301-L344
null
class SaltCMD(salt.utils.parsers.SaltCMDOptionParser): ''' The execution of a salt command happens here ''' def run(self): ''' Execute the salt command line ''' import salt.client self.parse_args() if self.config['log_level'] not in ('quiet', ): ...