INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
PRIVATE METHOD
Updates the return dictionary and returns it.
ret : dict<str,obj>
The original return dict to update. The ret param should have
been created from _get_return_dict()
success : boolean (True)
True indicates a successful result.
data : dict<str,obj> ({})
Data... | def _update_return_dict(ret, success, data, errors=None, warnings=None):
'''
PRIVATE METHOD
Updates the return dictionary and returns it.
ret : dict<str,obj>
The original return dict to update. The ret param should have
been created from _get_return_dict()
success : boolean (True)
... |
PRIVATE METHOD
Formats the URL based on parameters, and if cores are used or not
handler : str
The request handler to hit.
host : str (None)
The solr host to query. __opts__['host'] is default
core_name : str (None)
The name of the solr core if using cores. Leave this blank if y... | def _format_url(handler, host=None, core_name=None, extra=None):
'''
PRIVATE METHOD
Formats the URL based on parameters, and if cores are used or not
handler : str
The request handler to hit.
host : str (None)
The solr host to query. __opts__['host'] is default
core_name : str (... |
Install an auth handler for urllib2 | def _auth(url):
'''
Install an auth handler for urllib2
'''
user = __salt__['config.get']('solr.user', False)
password = __salt__['config.get']('solr.passwd', False)
realm = __salt__['config.get']('solr.auth_realm', 'Solr')
if user and password:
basic = _HTTPBasicAuthHandler()
... |
PRIVATE METHOD
Uses salt.utils.json.load to fetch the JSON results from the solr API.
url : str
a complete URL that can be passed to urllib.open
request_timeout : int (None)
The number of seconds before the timeout should fail. Leave blank/None
to use the default. __opts__['solr.req... | def _http_request(url, request_timeout=None):
'''
PRIVATE METHOD
Uses salt.utils.json.load to fetch the JSON results from the solr API.
url : str
a complete URL that can be passed to urllib.open
request_timeout : int (None)
The number of seconds before the timeout should fail. Leave... |
PRIVATE METHOD
Performs the requested replication command and returns a dictionary with
success, errors and data as keys. The data object will contain the JSON
response.
command : str
The replication command to execute.
host : str (None)
The solr host to query. __opts__['host'] is d... | def _replication_request(command, host=None, core_name=None, params=None):
'''
PRIVATE METHOD
Performs the requested replication command and returns a dictionary with
success, errors and data as keys. The data object will contain the JSON
response.
command : str
The replication command ... |
PRIVATE METHOD
Calls the _http_request method and passes the admin command to execute
and stores the data. This data is fairly static but should be refreshed
periodically to make sure everything this OK. The data object will contain
the JSON response.
command : str
The admin command to exec... | def _get_admin_info(command, host=None, core_name=None):
'''
PRIVATE METHOD
Calls the _http_request method and passes the admin command to execute
and stores the data. This data is fairly static but should be refreshed
periodically to make sure everything this OK. The data object will contain
th... |
PRIVATE METHOD
updates the default import options from __opts__['solr.dih.import_options']
with the dictionary passed in. Also converts booleans to strings
to pass to solr.
options : dict<str,boolean>
Dictionary the over rides the default options defined in
__opts__['solr.dih.import_op... | def _merge_options(options):
'''
PRIVATE METHOD
updates the default import options from __opts__['solr.dih.import_options']
with the dictionary passed in. Also converts booleans to strings
to pass to solr.
options : dict<str,boolean>
Dictionary the over rides the default options define... |
PRIVATE METHOD
Traverses a dictionary of dictionaries/lists to find key
and return the value stored.
TODO:// this method doesn't really work very well, and it's not really
very useful in its current state. The purpose for this method is
to simplify parsing the JSON output so you can ... | def _find_value(ret_dict, key, path=None):
'''
PRIVATE METHOD
Traverses a dictionary of dictionaries/lists to find key
and return the value stored.
TODO:// this method doesn't really work very well, and it's not really
very useful in its current state. The purpose for this method is
... |
Gets the lucene version that solr is using. If you are running a multi-core
setup you should specify a core name since all the cores run under the same
servlet container, they will all have the same version.
core_name : str (None)
The name of the solr core if using cores. Leave this blank if you ar... | def lucene_version(core_name=None):
'''
Gets the lucene version that solr is using. If you are running a multi-core
setup you should specify a core name since all the cores run under the same
servlet container, they will all have the same version.
core_name : str (None)
The name of the solr... |
Gets the solr version for the core specified. You should specify a core
here as all the cores will run under the same servlet container and so will
all have the same version.
core_name : str (None)
The name of the solr core if using cores. Leave this blank if you are
not using cores or if ... | def version(core_name=None):
'''
Gets the solr version for the core specified. You should specify a core
here as all the cores will run under the same servlet container and so will
all have the same version.
core_name : str (None)
The name of the solr core if using cores. Leave this blank ... |
Search queries fast, but it is a very expensive operation. The ideal
process is to run this with a master/slave configuration. Then you
can optimize the master, and push the optimized index to the slaves.
If you are running a single solr instance, or if you are going to run
this on a slave be aware tha... | def optimize(host=None, core_name=None):
'''
Search queries fast, but it is a very expensive operation. The ideal
process is to run this with a master/slave configuration. Then you
can optimize the master, and push the optimized index to the slaves.
If you are running a single solr instance, or if ... |
Does a health check on solr, makes sure solr can talk to the indexes.
host : str (None)
The solr host to query. __opts__['host'] is default.
core_name : str (None)
The name of the solr core if using cores. Leave this blank if you are
not using cores or if you want to check all cores.
... | def ping(host=None, core_name=None):
'''
Does a health check on solr, makes sure solr can talk to the indexes.
host : str (None)
The solr host to query. __opts__['host'] is default.
core_name : str (None)
The name of the solr core if using cores. Leave this blank if you are
not ... |
SLAVE CALL
Check for errors, and determine if a slave is replicating or not.
host : str (None)
The solr host to query. __opts__['host'] is default.
core_name : str (None)
The name of the solr core if using cores. Leave this blank if you are
not using cores or if you want to check al... | def is_replication_enabled(host=None, core_name=None):
'''
SLAVE CALL
Check for errors, and determine if a slave is replicating or not.
host : str (None)
The solr host to query. __opts__['host'] is default.
core_name : str (None)
The name of the solr core if using cores. Leave this ... |
SLAVE CALL
Verifies that the master and the slave versions are in sync by
comparing the index version. If you are constantly pushing updates
the index the master and slave versions will seldom match. A solution
to this is pause indexing every so often to allow the slave to replicate
and then call th... | def match_index_versions(host=None, core_name=None):
'''
SLAVE CALL
Verifies that the master and the slave versions are in sync by
comparing the index version. If you are constantly pushing updates
the index the master and slave versions will seldom match. A solution
to this is pause indexing ev... |
Get the full replication details.
host : str (None)
The solr host to query. __opts__['host'] is default.
core_name : str (None)
The name of the solr core if using cores. Leave this blank if you are
not using cores or if you want to check all cores.
Return : dict<str,obj>::
... | def replication_details(host=None, core_name=None):
'''
Get the full replication details.
host : str (None)
The solr host to query. __opts__['host'] is default.
core_name : str (None)
The name of the solr core if using cores. Leave this blank if you are
not using cores or if you... |
Tell solr make a backup. This method can be mis-leading since it uses the
backup API. If an error happens during the backup you are not notified.
The status: 'OK' in the response simply means that solr received the
request successfully.
host : str (None)
The solr host to query. __opts__['host... | def backup(host=None, core_name=None, append_core_to_path=False):
'''
Tell solr make a backup. This method can be mis-leading since it uses the
backup API. If an error happens during the backup you are not notified.
The status: 'OK' in the response simply means that solr received the
request succe... |
SLAVE CALL
Prevent the slaves from polling the master for updates.
polling : boolean
True will enable polling. False will disable it.
host : str (None)
The solr host to query. __opts__['host'] is default.
core_name : str (None)
The name of the solr core if using cores. Leave thi... | def set_is_polling(polling, host=None, core_name=None):
'''
SLAVE CALL
Prevent the slaves from polling the master for updates.
polling : boolean
True will enable polling. False will disable it.
host : str (None)
The solr host to query. __opts__['host'] is default.
core_name : st... |
MASTER ONLY
Sets the master to ignore poll requests from the slaves. Useful when you
don't want the slaves replicating during indexing or when clearing the
index.
status : boolean
Sets the replication status to the specified state.
host : str (None)
The solr host to query. __opts__[... | def set_replication_enabled(status, host=None, core_name=None):
'''
MASTER ONLY
Sets the master to ignore poll requests from the slaves. Useful when you
don't want the slaves replicating during indexing or when clearing the
index.
status : boolean
Sets the replication status to the spec... |
Signals Apache Solr to start, stop, or restart. Obviously this is only
going to work if the minion resides on the solr host. Additionally Solr
doesn't ship with an init script so one must be created.
signal : str (None)
The command to pass to the apache solr init valid values are 'start',
'... | def signal(signal=None):
'''
Signals Apache Solr to start, stop, or restart. Obviously this is only
going to work if the minion resides on the solr host. Additionally Solr
doesn't ship with an init script so one must be created.
signal : str (None)
The command to pass to the apache solr ini... |
MULTI-CORE HOSTS ONLY
Load a new core from the same configuration as an existing registered core.
While the "new" core is initializing, the "old" one will continue to accept
requests. Once it has finished, all new request will go to the "new" core,
and the "old" core will be unloaded.
host : str (N... | def reload_core(host=None, core_name=None):
'''
MULTI-CORE HOSTS ONLY
Load a new core from the same configuration as an existing registered core.
While the "new" core is initializing, the "old" one will continue to accept
requests. Once it has finished, all new request will go to the "new" core,
... |
MASTER ONLY
re-loads the handler config XML file.
This command can only be run if the minion is a 'master' type
handler : str
The name of the data import handler.
host : str (None)
The solr host to query. __opts__['host'] is default.
core : str (None)
The core the handler be... | def reload_import_config(handler, host=None, core_name=None, verbose=False):
'''
MASTER ONLY
re-loads the handler config XML file.
This command can only be run if the minion is a 'master' type
handler : str
The name of the data import handler.
host : str (None)
The solr host to ... |
MASTER ONLY
Submits an import command to the specified handler using specified options.
This command can only be run if the minion is configured with
solr.type=master
handler : str
The name of the data import handler.
host : str (None)
The solr host to query. __opts__['host'] is def... | def full_import(handler, host=None, core_name=None, options=None, extra=None):
'''
MASTER ONLY
Submits an import command to the specified handler using specified options.
This command can only be run if the minion is configured with
solr.type=master
handler : str
The name of the data im... |
Submits an import command to the specified handler using specified options.
This command can only be run if the minion is configured with
solr.type: 'master'
handler : str
The name of the data import handler.
host : str (None)
The solr host to query. __opts__['host'] is default.
cor... | def import_status(handler, host=None, core_name=None, verbose=False):
'''
Submits an import command to the specified handler using specified options.
This command can only be run if the minion is configured with
solr.type: 'master'
handler : str
The name of the data import handler.
host... |
Decorator wrapper to log execution time, for profiling purposes | def timing(function):
'''
Decorator wrapper to log execution time, for profiling purposes
'''
@wraps(function)
def wrapped(*args, **kwargs):
start_time = time.time()
ret = function(*args, **salt.utils.args.clean_kwargs(**kwargs))
end_time = time.time()
if function.__m... |
Memoize aka cache the return output of a function
given a specific set of arguments
.. versionedited:: 2016.3.4
Added **kwargs support. | def memoize(func):
'''
Memoize aka cache the return output of a function
given a specific set of arguments
.. versionedited:: 2016.3.4
Added **kwargs support.
'''
cache = {}
@wraps(func)
def _memoize(*args, **kwargs):
str_args = []
for arg in args:
if n... |
Decorator to filter out unexpected keyword arguments from the call
kwarg_names:
List of argument names to ignore | def ignores_kwargs(*kwarg_names):
'''
Decorator to filter out unexpected keyword arguments from the call
kwarg_names:
List of argument names to ignore
'''
def _ignores_kwargs(fn):
def __ignores_kwargs(*args, **kwargs):
kwargs_filtered = kwargs.copy()
for name... |
Decodes all arguments passed to the wrapped function | def ensure_unicode_args(function):
'''
Decodes all arguments passed to the wrapped function
'''
@wraps(function)
def wrapped(*args, **kwargs):
if six.PY2:
return function(
*salt.utils.data.decode_list(args),
**salt.utils.data.decode_dict(kwargs)
... |
Mark function as external.
:param func:
:return: | def external(func):
'''
Mark function as external.
:param func:
:return:
'''
def f(*args, **kwargs):
'''
Stub.
:param args:
:param kwargs:
:return:
'''
return func(*args, **kwargs)
f.external = True
f.__doc__ = func.__doc__
... |
This is a class global method to enforce the dependencies that you
currently know about.
It will modify the "functions" dict and remove/replace modules that
are missing dependencies. | def enforce_dependencies(cls, functions, kind):
'''
This is a class global method to enforce the dependencies that you
currently know about.
It will modify the "functions" dict and remove/replace modules that
are missing dependencies.
'''
for dependency, dependent... |
Discard all keywords which aren't function-specific from the kwargs.
:param kwargs:
:return: | def _get_args(self, kwargs):
'''
Discard all keywords which aren't function-specific from the kwargs.
:param kwargs:
:return:
'''
_args = list()
_kwargs = salt.utils.args.clean_kwargs(**kwargs)
return _args, _kwargs |
Call target function that has been decorated.
:return: | def _call_function(self, kwargs):
'''
Call target function that has been decorated.
:return:
'''
if self._raise_later:
raise self._raise_later # pylint: disable=E0702
if self._function:
args, kwargs = self._get_args(kwargs)
try:
... |
Based on the configuration, set to execute an old or a new function.
:return: | def _set_function(self, function):
'''
Based on the configuration, set to execute an old or a new function.
:return:
'''
full_name = "{m_name}.{f_name}".format(
m_name=self._globals.get(self.MODULE_NAME, '') or self._globals['__name__'].split('.')[-1],
f_n... |
Returns True, if a component configuration explicitly is
asking to use an old version of the deprecated function.
:return: | def _is_used_deprecated(self):
'''
Returns True, if a component configuration explicitly is
asking to use an old version of the deprecated function.
:return:
'''
func_path = "{m_name}.{f_name}".format(
m_name=self._globals.get(self.MODULE_NAME, '') or self._g... |
Connect to a mongo database and read per-node tops data.
Parameters:
* `collection`: The mongodb collection to read data from. Defaults to
``'tops'``.
* `id_field`: The field in the collection that represents an individual
minion id. Defaults to ``'_id'``.
* `re_pattern`... | def top(**kwargs):
'''
Connect to a mongo database and read per-node tops data.
Parameters:
* `collection`: The mongodb collection to read data from. Defaults to
``'tops'``.
* `id_field`: The field in the collection that represents an individual
minion id. Defaults to ``... |
Fix up broken reverse dependencies
lib
Search for reverse dependencies for a particular library rather
than every library on the system. It can be a full path to a
library or basic regular expression.
CLI Example:
.. code-block:: bash
salt '*' gentoolkit.revdep_rebuild | def revdep_rebuild(lib=None):
'''
Fix up broken reverse dependencies
lib
Search for reverse dependencies for a particular library rather
than every library on the system. It can be a full path to a
library or basic regular expression.
CLI Example:
.. code-block:: bash
... |
Print sizes in a similar fashion as eclean | def _pretty_size(size):
'''
Print sizes in a similar fashion as eclean
'''
units = [' G', ' M', ' K', ' B']
while units and size >= 1000:
size = size / 1024.0
units.pop()
return '{0}{1}'.format(round(size, 1), units[-1]) |
Parse an exclude file.
Returns a dict as defined in gentoolkit.eclean.exclude.parseExcludeFile | def _parse_exclude(exclude_file):
'''
Parse an exclude file.
Returns a dict as defined in gentoolkit.eclean.exclude.parseExcludeFile
'''
if os.path.isfile(exclude_file):
exclude = excludemod.parseExcludeFile(exclude_file, lambda x: None)
else:
exclude = dict()
return exclude |
Clean obsolete portage sources
destructive
Only keep minimum for reinstallation
package_names
Protect all versions of installed packages. Only meaningful if used
with destructive=True
size_limit <size>
Don't delete distfiles bigger than <size>.
<size> is a size spe... | def eclean_dist(destructive=False, package_names=False, size_limit=0,
time_limit=0, fetch_restricted=False,
exclude_file='/etc/eclean/distfiles.exclude'):
'''
Clean obsolete portage sources
destructive
Only keep minimum for reinstallation
package_names
P... |
Clean obsolete binary packages
destructive
Only keep minimum for reinstallation
package_names
Protect all versions of installed packages. Only meaningful if used
with destructive=True
time_limit <time>
Don't delete distfiles files modified since <time>
<time> is an... | def eclean_pkg(destructive=False, package_names=False, time_limit=0,
exclude_file='/etc/eclean/packages.exclude'):
'''
Clean obsolete binary packages
destructive
Only keep minimum for reinstallation
package_names
Protect all versions of installed packages. Only meaningfu... |
Process output from glsa_check_list into a dict
Returns a dict containing the glsa id, description, status, and CVEs | def _glsa_list_process_output(output):
'''
Process output from glsa_check_list into a dict
Returns a dict containing the glsa id, description, status, and CVEs
'''
ret = dict()
for line in output:
try:
glsa_id, status, desc = line.split(None, 2)
if 'U' in status:... |
List the status of Gentoo Linux Security Advisories
glsa_list
can contain an arbitrary number of GLSA ids, filenames
containing GLSAs or the special identifiers 'all' and 'affected'
Returns a dict containing glsa ids with a description, status, and CVEs:
.. code-block:: python
... | def glsa_check_list(glsa_list):
'''
List the status of Gentoo Linux Security Advisories
glsa_list
can contain an arbitrary number of GLSA ids, filenames
containing GLSAs or the special identifiers 'all' and 'affected'
Returns a dict containing glsa ids with a description, status, and... |
Display a summary from monit
CLI Example:
.. code-block:: bash
salt '*' monit.summary
salt '*' monit.summary <service name> | def summary(svc_name=''):
'''
Display a summary from monit
CLI Example:
.. code-block:: bash
salt '*' monit.summary
salt '*' monit.summary <service name>
'''
ret = {}
cmd = 'monit summary'
res = __salt__['cmd.run'](cmd).splitlines()
for line in res:
if 'dae... |
Display a process status from monit
CLI Example:
.. code-block:: bash
salt '*' monit.status
salt '*' monit.status <service name> | def status(svc_name=''):
'''
Display a process status from monit
CLI Example:
.. code-block:: bash
salt '*' monit.status
salt '*' monit.status <service name>
'''
cmd = 'monit status'
res = __salt__['cmd.run'](cmd)
prostr = 'Process'+' '*28
s = res.replace('Process'... |
.. versionadded:: 2016.3.0
Return monit unique id.
reset : False
Reset current id and generate a new id when it's True.
CLI Example:
.. code-block:: bash
salt '*' monit.id [reset=True] | def id_(reset=False):
'''
.. versionadded:: 2016.3.0
Return monit unique id.
reset : False
Reset current id and generate a new id when it's True.
CLI Example:
.. code-block:: bash
salt '*' monit.id [reset=True]
'''
if reset:
id_pattern = re.compile(r'Monit id... |
For a particular low chunk, search relevant onfail related states | def search_onfail_requisites(sid, highstate):
'''
For a particular low chunk, search relevant onfail related states
'''
onfails = []
if '_|-' in sid:
st = salt.state.split_low_tag(sid)
else:
st = {'__id__': sid}
for fstate, fchunks in six.iteritems(highstate):
if fsta... |
When a state fail and is part of a highstate, check
if there is onfail requisites.
When we find onfail requisites, we will consider the state failed
only if at least one of those onfail requisites also failed
Returns:
True: if onfail handlers suceeded
False: if one on those handler fai... | def check_onfail_requisites(state_id, state_result, running, highstate):
'''
When a state fail and is part of a highstate, check
if there is onfail requisites.
When we find onfail requisites, we will consider the state failed
only if at least one of those onfail requisites also failed
Returns:
... |
Check the total return value of the run and determine if the running
dict has any issues | def check_result(running, recurse=False, highstate=None):
'''
Check the total return value of the run and determine if the running
dict has any issues
'''
if not isinstance(running, dict):
return False
if not running:
return False
ret = True
for state_id, state_result i... |
Update an existing state return (`original_return`) in place
with another state return (`sub_return`), i.e. for a subresource.
Returns:
dict: The updated state return.
The existing state return does not need to have all the required fields,
as this is meant to be called from the internals of a... | def merge_subreturn(original_return, sub_return, subkey=None):
'''
Update an existing state return (`original_return`) in place
with another state return (`sub_return`), i.e. for a subresource.
Returns:
dict: The updated state return.
The existing state return does not need to have all the... |
Return a copy of the opts for use, optionally load a local config on top | def get_sls_opts(opts, **kwargs):
'''
Return a copy of the opts for use, optionally load a local config on top
'''
opts = copy.deepcopy(opts)
if 'localconfig' in kwargs:
return salt.config.minion_config(kwargs['localconfig'], defaults=opts)
if 'saltenv' in kwargs:
saltenv = kwa... |
Checks to see if the specific site symlink is in /etc/apache2/sites-enabled.
This will only be functional on Debian-based operating systems (Ubuntu,
Mint, etc).
CLI Examples:
.. code-block:: bash
salt '*' apache.check_site_enabled example.com
salt '*' apache.check_site_enabled exampl... | def check_site_enabled(site):
'''
Checks to see if the specific site symlink is in /etc/apache2/sites-enabled.
This will only be functional on Debian-based operating systems (Ubuntu,
Mint, etc).
CLI Examples:
.. code-block:: bash
salt '*' apache.check_site_enabled example.com
... |
Runs a2dissite for the given site.
This will only be functional on Debian-based operating systems (Ubuntu,
Mint, etc).
CLI Examples:
.. code-block:: bash
salt '*' apache.a2dissite example.com | def a2dissite(site):
'''
Runs a2dissite for the given site.
This will only be functional on Debian-based operating systems (Ubuntu,
Mint, etc).
CLI Examples:
.. code-block:: bash
salt '*' apache.a2dissite example.com
'''
ret = {}
command = ['a2dissite', site]
try:
... |
Checks to see if the specific mod symlink is in /etc/apache2/mods-enabled.
This will only be functional on Debian-based operating systems (Ubuntu,
Mint, etc).
CLI Examples:
.. code-block:: bash
salt '*' apache.check_mod_enabled status
salt '*' apache.check_mod_enabled status.load
... | def check_mod_enabled(mod):
'''
Checks to see if the specific mod symlink is in /etc/apache2/mods-enabled.
This will only be functional on Debian-based operating systems (Ubuntu,
Mint, etc).
CLI Examples:
.. code-block:: bash
salt '*' apache.check_mod_enabled status
salt '*' ... |
Runs a2enmod for the given mod.
This will only be functional on Debian-based operating systems (Ubuntu,
Mint, etc).
CLI Examples:
.. code-block:: bash
salt '*' apache.a2enmod vhost_alias | def a2enmod(mod):
'''
Runs a2enmod for the given mod.
This will only be functional on Debian-based operating systems (Ubuntu,
Mint, etc).
CLI Examples:
.. code-block:: bash
salt '*' apache.a2enmod vhost_alias
'''
ret = {}
command = ['a2enmod', mod]
try:
statu... |
.. versionadded:: 2016.3.0
Checks to see if the specific conf symlink is in /etc/apache2/conf-enabled.
This will only be functional on Debian-based operating systems (Ubuntu,
Mint, etc).
CLI Examples:
.. code-block:: bash
salt '*' apache.check_conf_enabled security
salt '*' apac... | def check_conf_enabled(conf):
'''
.. versionadded:: 2016.3.0
Checks to see if the specific conf symlink is in /etc/apache2/conf-enabled.
This will only be functional on Debian-based operating systems (Ubuntu,
Mint, etc).
CLI Examples:
.. code-block:: bash
salt '*' apache.check_c... |
.. versionadded:: 2016.3.0
Runs a2enconf for the given conf.
This will only be functional on Debian-based operating systems (Ubuntu,
Mint, etc).
CLI Examples:
.. code-block:: bash
salt '*' apache.a2enconf security | def a2enconf(conf):
'''
.. versionadded:: 2016.3.0
Runs a2enconf for the given conf.
This will only be functional on Debian-based operating systems (Ubuntu,
Mint, etc).
CLI Examples:
.. code-block:: bash
salt '*' apache.a2enconf security
'''
ret = {}
command = ['a2en... |
Return the data from `uwsgi --connect-and-read` as a dictionary.
socket
The socket the uWSGI stats server is listening on
CLI Example:
.. code-block:: bash
salt '*' uwsgi.stats /var/run/mystatsserver.sock
salt '*' uwsgi.stats 127.0.0.1:5050 | def stats(socket):
'''
Return the data from `uwsgi --connect-and-read` as a dictionary.
socket
The socket the uWSGI stats server is listening on
CLI Example:
.. code-block:: bash
salt '*' uwsgi.stats /var/run/mystatsserver.sock
salt '*' uwsgi.stats 127.0.0.1:5050
'''... |
Cycle through all the possible credentials and return the first one that
works | def _find_credentials():
'''
Cycle through all the possible credentials and return the first one that
works
'''
usernames = []
usernames.append(__pillar__['proxy'].get('admin_username', 'root'))
if 'fallback_admin_username' in __pillar__.get('proxy'):
usernames.append(__pillar__['pro... |
Get the grains from the proxied device | def _grains():
'''
Get the grains from the proxied device
'''
(username, password) = _find_credentials()
r = salt.modules.dracr.system_info(host=__pillar__['proxy']['host'],
admin_username=username,
admin_password=password... |
Return a list of containers.
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra arguments for the driver's list_containers method
:type libcloud_kwargs: ``dict``
CLI Example:
.. code-block:: bash
salt myminion libcloud_storage.list_containers prof... | def list_containers(profile, **libcloud_kwargs):
'''
Return a list of containers.
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra arguments for the driver's list_containers method
:type libcloud_kwargs: ``dict``
CLI Example:
.. code-block:: bash... |
List container objects (e.g. files) for the given container_id on the given profile
:param container_name: Container name
:type container_name: ``str``
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra arguments for the driver's list_container_objects method
... | def list_container_objects(container_name, profile, **libcloud_kwargs):
'''
List container objects (e.g. files) for the given container_id on the given profile
:param container_name: Container name
:type container_name: ``str``
:param profile: The profile key
:type profile: ``str``
:par... |
Create a container in the cloud
:param container_name: Container name
:type container_name: ``str``
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra arguments for the driver's create_container method
:type libcloud_kwargs: ``dict``
CLI Example:
... | def create_container(container_name, profile, **libcloud_kwargs):
'''
Create a container in the cloud
:param container_name: Container name
:type container_name: ``str``
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra arguments for the driver's creat... |
Get the details for a container object (file or object in the cloud)
:param container_name: Container name
:type container_name: ``str``
:param object_name: Object name
:type object_name: ``str``
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra argu... | def get_container_object(container_name, object_name, profile, **libcloud_kwargs):
'''
Get the details for a container object (file or object in the cloud)
:param container_name: Container name
:type container_name: ``str``
:param object_name: Object name
:type object_name: ``str``
:par... |
Download an object to the specified destination path.
:param container_name: Container name
:type container_name: ``str``
:param object_name: Object name
:type object_name: ``str``
:param destination_path: Full path to a file or a directory where the
incoming fil... | def download_object(container_name, object_name, destination_path, profile,
overwrite_existing=False, delete_on_failure=True, **libcloud_kwargs):
'''
Download an object to the specified destination path.
:param container_name: Container name
:type container_name: ``str``
:para... |
Upload an object currently located on a disk.
:param file_path: Path to the object on disk.
:type file_path: ``str``
:param container_name: Destination container.
:type container_name: ``str``
:param object_name: Object name.
:type object_name: ``str``
:param profile: The profile key
... | def upload_object(file_path, container_name, object_name, profile, extra=None,
verify_hash=True, headers=None, **libcloud_kwargs):
'''
Upload an object currently located on a disk.
:param file_path: Path to the object on disk.
:type file_path: ``str``
:param container_name: Desti... |
Delete an object in the cloud
:param container_name: Container name
:type container_name: ``str``
:param object_name: Object name
:type object_name: ``str``
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra arguments for the driver's delete_object me... | def delete_object(container_name, object_name, profile, **libcloud_kwargs):
'''
Delete an object in the cloud
:param container_name: Container name
:type container_name: ``str``
:param object_name: Object name
:type object_name: ``str``
:param profile: The profile key
:type profile... |
Delete an object container in the cloud
:param container_name: Container name
:type container_name: ``str``
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra arguments for the driver's delete_container method
:type libcloud_kwargs: ``dict``
:return: ... | def delete_container(container_name, profile, **libcloud_kwargs):
'''
Delete an object container in the cloud
:param container_name: Container name
:type container_name: ``str``
:param profile: The profile key
:type profile: ``str``
:param libcloud_kwargs: Extra arguments for the driver... |
Get a token with correct policies for the minion, and the url to the Vault
service | def _get_token_and_url_from_master():
'''
Get a token with correct policies for the minion, and the url to the Vault
service
'''
minion_id = __grains__['id']
pki_dir = __opts__['pki_dir']
# When rendering pillars, the module executes on the master, but the token
# should be issued for t... |
Get the connection details for calling Vault, from local configuration if
it exists, or from the master otherwise | def get_vault_connection():
'''
Get the connection details for calling Vault, from local configuration if
it exists, or from the master otherwise
'''
def _use_local_config():
log.debug('Using Vault connection details from local config')
try:
if __opts__['vault']['auth']['... |
Make a request to Vault | def make_request(method, resource, token=None, vault_url=None, get_token_url=False, **args):
'''
Make a request to Vault
'''
if not token or not vault_url:
connection = get_vault_connection()
token, vault_url = connection['token'], connection['url']
if 'verify' not in args:
... |
Return the current load average for the specified minion. Available values
for name are `1-min`, `5-min` and `15-min`. `minimum` and `maximum` values
should be passed in as strings. | def loadavg(name, maximum=None, minimum=None):
'''
Return the current load average for the specified minion. Available values
for name are `1-min`, `5-min` and `15-min`. `minimum` and `maximum` values
should be passed in as strings.
'''
# Monitoring state, no changes will be made so no test inte... |
Return whether the specified signature is found in the process tree. This
differs slightly from the services states, in that it may refer to a
process that is not managed via the init system. | def process(name):
'''
Return whether the specified signature is found in the process tree. This
differs slightly from the services states, in that it may refer to a
process that is not managed via the init system.
'''
# Monitoring state, no changes will be made so no test interface needed
r... |
Manage options of block device
name
The name of the block device
opts:
- read-ahead
Read-ahead buffer size
- filesystem-read-ahead
Filesystem Read-ahead buffer size
- read-only
Set Read-Only
- read-write
Set Read-Write | def tuned(name, **kwargs):
'''
Manage options of block device
name
The name of the block device
opts:
- read-ahead
Read-ahead buffer size
- filesystem-read-ahead
Filesystem Read-ahead buffer size
- read-only
Set Read-Only
- read-write
... |
Manage filesystems of partitions.
name
The name of the block device
fs_type
The filesystem it should be formatted as
force
Force mke2fs to create a filesystem, even if the specified device is
not a partition on a block special device. This option is only enabled
fo... | def formatted(name, fs_type='ext4', force=False, **kwargs):
'''
Manage filesystems of partitions.
name
The name of the block device
fs_type
The filesystem it should be formatted as
force
Force mke2fs to create a filesystem, even if the specified device is
not a par... |
Check if the blk exists and return its fstype if ok | def _checkblk(name):
'''
Check if the blk exists and return its fstype if ok
'''
blk = __salt__['cmd.run']('blkid -o value -s TYPE {0}'.format(name),
ignore_retcode=True)
return '' if not blk else blk |
Removes a configuration element from the SNMP configuration.
:param chassis_id: (optional) Chassis ID
:param community: (optional) A dictionary having the following optional keys:
- acl (if any policy / ACL need to be set)
- mode: rw or ro. Default: ro
:param contact: Contact details
:param... | def remove_config(chassis_id=None,
community=None,
contact=None,
location=None,
test=False,
commit=True,
**kwargs): # pylint: disable=unused-argument
'''
Removes a configuration element from the SNMP co... |
Use libnacl to generate a keypair.
If no `sk_file` is defined return a keypair.
If only the `sk_file` is defined `pk_file` will use the same name with a postfix `.pub`.
When the `sk_file` is already existing, but `pk_file` is not. The `pk_file` will be generated
using the `sk_file`.
CLI Examples... | def keygen(sk_file=None, pk_file=None, **kwargs):
'''
Use libnacl to generate a keypair.
If no `sk_file` is defined return a keypair.
If only the `sk_file` is defined `pk_file` will use the same name with a postfix `.pub`.
When the `sk_file` is already existing, but `pk_file` is not. The `pk_file... |
Alias to `{box_type}_encrypt`
box_type: secretbox, sealedbox(default) | def enc(data, **kwargs):
'''
Alias to `{box_type}_encrypt`
box_type: secretbox, sealedbox(default)
'''
kwargs['opts'] = __opts__
return salt.utils.nacl.enc(data, **kwargs) |
This is a helper function to encrypt a file and return its contents.
You can provide an optional output file using `out`
`name` can be a local file or when not using `salt-run` can be a url like `salt://`, `https://` etc.
CLI Examples:
.. code-block:: bash
salt-run nacl.enc_file name=/tmp/i... | def enc_file(name, out=None, **kwargs):
'''
This is a helper function to encrypt a file and return its contents.
You can provide an optional output file using `out`
`name` can be a local file or when not using `salt-run` can be a url like `salt://`, `https://` etc.
CLI Examples:
.. code-bloc... |
Alias to `{box_type}_decrypt`
box_type: secretbox, sealedbox(default) | def dec(data, **kwargs):
'''
Alias to `{box_type}_decrypt`
box_type: secretbox, sealedbox(default)
'''
kwargs['opts'] = __opts__
return salt.utils.nacl.dec(data, **kwargs) |
This is a helper function to decrypt a file and return its contents.
You can provide an optional output file using `out`
`name` can be a local file or when not using `salt-run` can be a url like `salt://`, `https://` etc.
CLI Examples:
.. code-block:: bash
salt-run nacl.dec_file name=/tmp/i... | def dec_file(name, out=None, **kwargs):
'''
This is a helper function to decrypt a file and return its contents.
You can provide an optional output file using `out`
`name` can be a local file or when not using `salt-run` can be a url like `salt://`, `https://` etc.
CLI Examples:
.. code-bloc... |
Encrypt data using a public key generated from `nacl.keygen`.
The encryptd data can be decrypted using `nacl.sealedbox_decrypt` only with the secret key.
CLI Examples:
.. code-block:: bash
salt-run nacl.sealedbox_encrypt datatoenc
salt-call --local nacl.sealedbox_encrypt datatoenc pk_file... | def sealedbox_encrypt(data, **kwargs):
'''
Encrypt data using a public key generated from `nacl.keygen`.
The encryptd data can be decrypted using `nacl.sealedbox_decrypt` only with the secret key.
CLI Examples:
.. code-block:: bash
salt-run nacl.sealedbox_encrypt datatoenc
salt-ca... |
Decrypt data using a secret key that was encrypted using a public key with `nacl.sealedbox_encrypt`.
CLI Examples:
.. code-block:: bash
salt-call nacl.sealedbox_decrypt pEXHQM6cuaF7A=
salt-call --local nacl.sealedbox_decrypt data='pEXHQM6cuaF7A=' sk_file=/etc/salt/pki/master/nacl
salt... | def sealedbox_decrypt(data, **kwargs):
'''
Decrypt data using a secret key that was encrypted using a public key with `nacl.sealedbox_encrypt`.
CLI Examples:
.. code-block:: bash
salt-call nacl.sealedbox_decrypt pEXHQM6cuaF7A=
salt-call --local nacl.sealedbox_decrypt data='pEXHQM6cuaF... |
Encrypt data using a secret key generated from `nacl.keygen`.
The same secret key can be used to decrypt the data using `nacl.secretbox_decrypt`.
CLI Examples:
.. code-block:: bash
salt-run nacl.secretbox_encrypt datatoenc
salt-call --local nacl.secretbox_encrypt datatoenc sk_file=/etc/sa... | def secretbox_encrypt(data, **kwargs):
'''
Encrypt data using a secret key generated from `nacl.keygen`.
The same secret key can be used to decrypt the data using `nacl.secretbox_decrypt`.
CLI Examples:
.. code-block:: bash
salt-run nacl.secretbox_encrypt datatoenc
salt-call --loc... |
Decrypt data that was encrypted using `nacl.secretbox_encrypt` using the secret key
that was generated from `nacl.keygen`.
CLI Examples:
.. code-block:: bash
salt-call nacl.secretbox_decrypt pEXHQM6cuaF7A=
salt-call --local nacl.secretbox_decrypt data='pEXHQM6cuaF7A=' sk_file=/etc/salt/pk... | def secretbox_decrypt(data, **kwargs):
'''
Decrypt data that was encrypted using `nacl.secretbox_encrypt` using the secret key
that was generated from `nacl.keygen`.
CLI Examples:
.. code-block:: bash
salt-call nacl.secretbox_decrypt pEXHQM6cuaF7A=
salt-call --local nacl.secretbox... |
Executes a query that requires a job for completion. This function will wait for the job to complete
and return the results. | def _get_job_results(query=None):
'''
Executes a query that requires a job for completion. This function will wait for the job to complete
and return the results.
'''
if not query:
raise CommandExecutionError("Query parameters cannot be empty.")
response = __proxy__['panos.call'](query)... |
Deactivates an installed license.
Required version 7.0.0 or greater.
key_name(str): The file name of the license key installed.
CLI Example:
.. code-block:: bash
salt '*' panos.deactivate_license key_name=License_File_Name.key | def deactivate_license(key_name=None):
'''
Deactivates an installed license.
Required version 7.0.0 or greater.
key_name(str): The file name of the license key installed.
CLI Example:
.. code-block:: bash
salt '*' panos.deactivate_license key_name=License_File_Name.key
'''
... |
Download software packages by filename.
Args:
filename(str): The filename of the PANOS file to download.
synch (bool): If true then the file will synch to the peer unit.
CLI Example:
.. code-block:: bash
salt '*' panos.download_software_file PanOS_5000-8.0.0
salt '*' pan... | def download_software_file(filename=None, synch=False):
'''
Download software packages by filename.
Args:
filename(str): The filename of the PANOS file to download.
synch (bool): If true then the file will synch to the peer unit.
CLI Example:
.. code-block:: bash
salt '*... |
Download software packages by version number.
Args:
version(str): The version of the PANOS file to download.
synch (bool): If true then the file will synch to the peer unit.
CLI Example:
.. code-block:: bash
salt '*' panos.download_software_version 8.0.0
salt '*' panos.d... | def download_software_version(version=None, synch=False):
'''
Download software packages by version number.
Args:
version(str): The version of the PANOS file to download.
synch (bool): If true then the file will synch to the peer unit.
CLI Example:
.. code-block:: bash
s... |
List all jobs on the device.
state
The state of the jobs to display. Valid options are all, pending, or processed. Pending jobs are jobs
that are currently in a running or waiting state. Processed jobs are jobs that have completed
execution.
CLI Example:
.. code-block:: bash
... | def get_jobs(state='all'):
'''
List all jobs on the device.
state
The state of the jobs to display. Valid options are all, pending, or processed. Pending jobs are jobs
that are currently in a running or waiting state. Processed jobs are jobs that have completed
execution.
CLI E... |
Show all local administrator accounts.
CLI Example:
.. code-block:: bash
salt '*' panos.get_local_admins | def get_local_admins():
'''
Show all local administrator accounts.
CLI Example:
.. code-block:: bash
salt '*' panos.get_local_admins
'''
admin_list = get_users_config()
response = []
if 'users' not in admin_list['result']:
return response
if isinstance(admin_lis... |
Retrieve a list of all uncommitted changes on the device.
Requires PANOS version 8.0.0 or greater.
CLI Example:
.. code-block:: bash
salt '*' panos.get_uncommitted_changes | def get_uncommitted_changes():
'''
Retrieve a list of all uncommitted changes on the device.
Requires PANOS version 8.0.0 or greater.
CLI Example:
.. code-block:: bash
salt '*' panos.get_uncommitted_changes
'''
_required_version = '8.0.0'
if not __proxy__['panos.is_required_v... |
Force refreshes all FQDNs used in rules.
force
Forces all fqdn refresh
CLI Example:
.. code-block:: bash
salt '*' panos.refresh_fqdn_cache
salt '*' panos.refresh_fqdn_cache force=True | def refresh_fqdn_cache(force=False):
'''
Force refreshes all FQDNs used in rules.
force
Forces all fqdn refresh
CLI Example:
.. code-block:: bash
salt '*' panos.refresh_fqdn_cache
salt '*' panos.refresh_fqdn_cache force=True
'''
if not isinstance(force, bool):
... |
Resolve address to ip address.
Required version 7.0.0 or greater.
address
Address name you want to resolve.
vsys
The vsys name.
CLI Example:
.. code-block:: bash
salt '*' panos.resolve_address foo.bar.com
salt '*' panos.resolve_address foo.bar.com vsys=2 | def resolve_address(address=None, vsys=None):
'''
Resolve address to ip address.
Required version 7.0.0 or greater.
address
Address name you want to resolve.
vsys
The vsys name.
CLI Example:
.. code-block:: bash
salt '*' panos.resolve_address foo.bar.com
... |
Install anti-virus packages.
Args:
version(str): The version of the PANOS file to install.
latest(bool): If true, the latest anti-virus file will be installed.
The specified version option will be ignored.
synch(bool): If true, the anti-virus will synch to the peer u... | def install_antivirus(version=None, latest=False, synch=False, skip_commit=False,):
'''
Install anti-virus packages.
Args:
version(str): The version of the PANOS file to install.
latest(bool): If true, the latest anti-virus file will be installed.
The specified versio... |
Set the authentication profile of the Palo Alto proxy minion. A commit will be required before this is processed.
CLI Example:
Args:
profile (str): The name of the authentication profile to set.
deploy (bool): If true then commit the full candidate configuration, if false only set pending cha... | def set_authentication_profile(profile=None, deploy=False):
'''
Set the authentication profile of the Palo Alto proxy minion. A commit will be required before this is processed.
CLI Example:
Args:
profile (str): The name of the authentication profile to set.
deploy (bool): If true the... |
Set the hostname of the Palo Alto proxy minion. A commit will be required before this is processed.
CLI Example:
Args:
hostname (str): The hostname to set
deploy (bool): If true then commit the full candidate configuration, if false only set pending change.
.. code-block:: bash
... | def set_hostname(hostname=None, deploy=False):
'''
Set the hostname of the Palo Alto proxy minion. A commit will be required before this is processed.
CLI Example:
Args:
hostname (str): The hostname to set
deploy (bool): If true then commit the full candidate configuration, if false o... |
Enables or disables the ICMP management service on the device.
CLI Example:
Args:
enabled (bool): If true the service will be enabled. If false the service will be disabled.
deploy (bool): If true then commit the full candidate configuration, if false only set pending change.
.. code-blo... | def set_management_icmp(enabled=True, deploy=False):
'''
Enables or disables the ICMP management service on the device.
CLI Example:
Args:
enabled (bool): If true the service will be enabled. If false the service will be disabled.
deploy (bool): If true then commit the full candidate ... |
Set the NTP authentication of the Palo Alto proxy minion. A commit will be required before this is processed.
CLI Example:
Args:
target(str): Determines the target of the authentication. Valid options are primary, secondary, or both.
authentication_type(str): The authentication type to be use... | def set_ntp_authentication(target=None,
authentication_type=None,
key_id=None,
authentication_key=None,
algorithm=None,
deploy=False):
'''
Set the NTP authentication of the Palo... |
Set the NTP servers of the Palo Alto proxy minion. A commit will be required before this is processed.
CLI Example:
Args:
primary_server(str): The primary NTP server IP address or FQDN.
secondary_server(str): The secondary NTP server IP address or FQDN.
deploy (bool): If true then co... | def set_ntp_servers(primary_server=None, secondary_server=None, deploy=False):
'''
Set the NTP servers of the Palo Alto proxy minion. A commit will be required before this is processed.
CLI Example:
Args:
primary_server(str): The primary NTP server IP address or FQDN.
secondary_server... |
Add an IPv4 address or network to the permitted IP list.
CLI Example:
Args:
address (str): The IPv4 address or network to allow access to add to the Palo Alto device.
deploy (bool): If true then commit the full candidate configuration, if false only set pending change.
.. code-block:: ba... | def set_permitted_ip(address=None, deploy=False):
'''
Add an IPv4 address or network to the permitted IP list.
CLI Example:
Args:
address (str): The IPv4 address or network to allow access to add to the Palo Alto device.
deploy (bool): If true then commit the full candidate configurat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.