INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Returns the difference between the candidate and the current configuration | def diff(**kwargs):
'''
Returns the difference between the candidate and the current configuration
id : 0
The rollback ID value (0-49)
CLI Example:
.. code-block:: bash
salt 'device_name' junos.diff 3
'''
kwargs = salt.utils.args.clean_kwargs(**kwargs)
id_ = kwargs.po... |
Send a ping RPC to a device | def ping(dest_ip=None, **kwargs):
'''
Send a ping RPC to a device
dest_ip
The IP of the device to ping
dev_timeout : 30
The NETCONF RPC timeout (in seconds)
rapid : False
When ``True``, executes ping at 100pps instead of 1pps
ttl
Maximum number of IP routers (IP... |
Executes the CLI commands and returns the output in specified format. \ ( default is text ) The output can also be stored in a file. | def cli(command=None, **kwargs):
'''
Executes the CLI commands and returns the output in specified format. \
(default is text) The output can also be stored in a file.
command (required)
The command to execute on the Junos CLI
format : text
Format in which to get the CLI output (ei... |
Shut down ( power off ) or reboot a device running Junos OS. This includes all Routing Engines in a Virtual Chassis or a dual Routing Engine system. | def shutdown(**kwargs):
'''
Shut down (power off) or reboot a device running Junos OS. This includes
all Routing Engines in a Virtual Chassis or a dual Routing Engine system.
.. note::
One of ``shutdown`` or ``reboot`` must be set to ``True`` or no
action will be taken.
shutd... |
Installs the given configuration file into the candidate configuration. Commits the changes if the commit checks or throws an error. | def install_config(path=None, **kwargs):
'''
Installs the given configuration file into the candidate configuration.
Commits the changes if the commit checks or throws an error.
path (required)
Path where the configuration/template file is present. If the file has
a ``.conf`` extension,... |
Resets the device to default factory settings | def zeroize():
'''
Resets the device to default factory settings
CLI Example:
.. code-block:: bash
salt 'device_name' junos.zeroize
'''
conn = __proxy__['junos.conn']()
ret = {}
ret['out'] = True
try:
conn.cli('request system zeroize')
ret['message'] = 'Com... |
Installs the given image on the device. After the installation is complete \ the device is rebooted if reboot = True is given as a keyworded argument. | def install_os(path=None, **kwargs):
'''
Installs the given image on the device. After the installation is complete\
the device is rebooted,
if reboot=True is given as a keyworded argument.
path (required)
Path where the image file is present on the proxy minion
remote_path :
... |
Copies the file from the local device to the junos device | def file_copy(src=None, dest=None):
'''
Copies the file from the local device to the junos device
src
The source path where the file is kept.
dest
The destination path on the where the file will be copied
CLI Example:
.. code-block:: bash
salt 'device_name' junos.fil... |
Attempts an exclusive lock on the candidate configuration. This is a non - blocking call. | def lock():
'''
Attempts an exclusive lock on the candidate configuration. This
is a non-blocking call.
.. note::
When locking, it is important to remember to call
:py:func:`junos.unlock <salt.modules.junos.unlock>` once finished. If
locking during orchestration, remember to inc... |
Unlocks the candidate configuration. | def unlock():
'''
Unlocks the candidate configuration.
CLI Example:
.. code-block:: bash
salt 'device_name' junos.unlock
'''
conn = __proxy__['junos.conn']()
ret = {}
ret['out'] = True
try:
conn.cu.unlock()
ret['message'] = "Successfully unlocked the config... |
Loads the configuration from the file provided onto the device. | def load(path=None, **kwargs):
'''
Loads the configuration from the file provided onto the device.
path (required)
Path where the configuration/template file is present. If the file has
a ``.conf`` extension, the content is treated as text format. If the
file has a ``.xml`` extensio... |
Perform a commit check on the configuration | def commit_check():
'''
Perform a commit check on the configuration
CLI Example:
.. code-block:: bash
salt 'device_name' junos.commit_check
'''
conn = __proxy__['junos.conn']()
ret = {}
ret['out'] = True
try:
conn.cu.commit_check()
ret['message'] = 'Commit ... |
Retrieve data from a Junos device using Tables/ Views | def get_table(table, table_file, path=None, target=None, key=None, key_items=None,
filters=None, template_args=None):
'''
Retrieve data from a Junos device using Tables/Views
table (required)
Name of PyEZ Table
table_file (required)
YAML file that has the table specified ... |
Mount an image | def mount(location, access='rw', root=None):
'''
Mount an image
CLI Example:
.. code-block:: bash
salt '*' guest.mount /srv/images/fedora.qcow
'''
if root is None:
root = os.path.join(
tempfile.gettempdir(),
'guest',
location.lstrip(os.sep).... |
Ensure the user exists on the Dell DRAC | def present(name, password, permission):
'''
Ensure the user exists on the Dell DRAC
name:
The users username
password
The password used to authenticate
permission
The permissions that should be assigned to a user
'''
ret = {'name': name,
'result': True,... |
Ensure the DRAC network settings are consistent | def network(ip, netmask, gateway):
'''
Ensure the DRAC network settings are consistent
'''
ret = {'name': ip,
'result': True,
'changes': {},
'comment': ''}
current_network = __salt__['drac.network_info']()
new_network = {}
if ip != current_network['IPv4 set... |
If we have additional IPC transports other than UxD and TCP add them here | def factory(opts, **kwargs):
'''
If we have additional IPC transports other than UxD and TCP, add them here
'''
# FIXME for now, just UXD
# Obviously, this makes the factory approach pointless, but we'll extend later
import salt.transport.ipc
return salt.transport... |
If we have additional IPC transports other than UXD and TCP add them here | def factory(opts, **kwargs):
'''
If we have additional IPC transports other than UXD and TCP, add them here
'''
import salt.transport.ipc
return salt.transport.ipc.IPCMessageServer(opts, **kwargs) |
List currently configured reactors | def list_(saltenv='base', test=None):
'''
List currently configured reactors
CLI Example:
.. code-block:: bash
salt-run reactor.list
'''
sevent = salt.utils.event.get_event(
'master',
__opts__['sock_dir'],
__opts__['transport'],
opts=__o... |
Add a new reactor | def add(event, reactors, saltenv='base', test=None):
'''
Add a new reactor
CLI Example:
.. code-block:: bash
salt-run reactor.add 'salt/cloud/*/destroyed' reactors='/srv/reactor/destroy/*.sls'
'''
if isinstance(reactors, string_types):
reactors = [reactors]
sevent = salt.... |
Delete a reactor | def delete(event, saltenv='base', test=None):
'''
Delete a reactor
CLI Example:
.. code-block:: bash
salt-run reactor.delete 'salt/cloud/*/destroyed'
'''
sevent = salt.utils.event.get_event(
'master',
__opts__['sock_dir'],
__opts__['transport'],
... |
Convert IP address representation to ZMQ ( URL ) format. ZMQ expects brackets around IPv6 literals since they are used in URLs. | def ip_bracket(addr):
'''
Convert IP address representation to ZMQ (URL) format. ZMQ expects
brackets around IPv6 literals, since they are used in URLs.
'''
addr = ipaddress.ip_address(addr)
return ('[{}]' if addr.version == 6 else '{}').format(addr) |
Display output for the salt - run virt. query function | def output(data, **kwargs): # pylint: disable=unused-argument
'''
Display output for the salt-run virt.query function
'''
out = ''
for id_ in data['data']:
out += '{0}\n'.format(id_)
for vm_ in data['data'][id_]['vm_info']:
out += ' {0}\n'.format(vm_)
vm_dat... |
Return all interface configs | def _interface_configs():
'''
Return all interface configs
'''
cmd = ['netsh', 'interface', 'ip', 'show', 'config']
lines = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
ret = {}
current_iface = None
current_ip_list = None
for line in lines:
line = line.strip()
... |
Returns True if interface is enabled otherwise False | def is_enabled(iface):
'''
Returns ``True`` if interface is enabled, otherwise ``False``
CLI Example:
.. code-block:: bash
salt -G 'os_family:Windows' ip.is_enabled 'Local Area Connection #2'
'''
cmd = ['netsh', 'interface', 'show', 'interface', 'name={0}'.format(iface)]
iface_fou... |
Enable an interface | def enable(iface):
'''
Enable an interface
CLI Example:
.. code-block:: bash
salt -G 'os_family:Windows' ip.enable 'Local Area Connection #2'
'''
if is_enabled(iface):
return True
cmd = ['netsh', 'interface', 'set', 'interface',
'name={0}'.format(iface),
... |
Disable an interface | def disable(iface):
'''
Disable an interface
CLI Example:
.. code-block:: bash
salt -G 'os_family:Windows' ip.disable 'Local Area Connection #2'
'''
if is_disabled(iface):
return True
cmd = ['netsh', 'interface', 'set', 'interface',
'name={0}'.format(iface),
... |
Convenience function to convert the netmask to the CIDR subnet length | def get_subnet_length(mask):
'''
Convenience function to convert the netmask to the CIDR subnet length
CLI Example:
.. code-block:: bash
salt -G 'os_family:Windows' ip.get_subnet_length 255.255.255.0
'''
if not salt.utils.validate.net.netmask(mask):
raise SaltInvocationError(
... |
Set static IP configuration on a Windows NIC | def set_static_ip(iface, addr, gateway=None, append=False):
'''
Set static IP configuration on a Windows NIC
iface
The name of the interface to manage
addr
IP address with subnet length (ex. ``10.1.2.3/24``). The
:mod:`ip.get_subnet_length <salt.modules.win_ip.get_subnet_length... |
Set static DNS configuration on a Windows NIC | def set_static_dns(iface, *addrs):
'''
Set static DNS configuration on a Windows NIC
Args:
iface (str): The name of the interface to set
addrs (*):
One or more DNS servers to be added. To clear the list of DNS
servers pass an empty list (``[]``). If undefined or ``... |
Set DNS source to DHCP on Windows | def get_default_gateway():
'''
Set DNS source to DHCP on Windows
CLI Example:
.. code-block:: bash
salt -G 'os_family:Windows' ip.get_default_gateway
'''
try:
return next(iter(
x.split()[-1] for x in __salt__['cmd.run'](
['netsh', 'interface', 'ip',... |
Add the specified group | def add(name, gid=None, **kwargs):
'''
Add the specified group
CLI Example:
.. code-block:: bash
salt '*' group.add foo 3456
'''
### NOTE: **kwargs isn't used here but needs to be included in this
### function for compatibility with the group.present state
if info(name):
... |
Return a list of gids in use | def _list_gids():
'''
Return a list of gids in use
'''
output = __salt__['cmd.run'](
['dscacheutil', '-q', 'group'],
output_loglevel='quiet',
python_shell=False
)
ret = set()
for line in salt.utils.itertools.split(output, '\n'):
if line.startswith('gid:'):
... |
Remove the named group | def delete(name):
'''
Remove the named group
CLI Example:
.. code-block:: bash
salt '*' group.delete foo
'''
if salt.utils.stringutils.contains_whitespace(name):
raise SaltInvocationError('Group name cannot contain whitespace')
if name.startswith('_'):
raise SaltIn... |
Replaces members of the group with a provided list. | def members(name, members_list):
'''
Replaces members of the group with a provided list.
.. versionadded:: 2016.3.0
CLI Example:
salt '*' group.members foo 'user1,user2,user3,...'
Replaces a membership list for a local group 'foo'.
'''
retcode = 1
grp_info = __salt__['group.i... |
Return information about a group | def info(name):
'''
Return information about a group
CLI Example:
.. code-block:: bash
salt '*' group.info foo
'''
if salt.utils.stringutils.contains_whitespace(name):
raise SaltInvocationError('Group name cannot contain whitespace')
try:
# getgrnam seems to cache ... |
Return formatted information in a pretty way. | def _format_info(data):
'''
Return formatted information in a pretty way.
'''
return {'name': data.gr_name,
'gid': data.gr_gid,
'passwd': data.gr_passwd,
'members': data.gr_mem} |
Return info on all groups | def getent(refresh=False):
'''
Return info on all groups
CLI Example:
.. code-block:: bash
salt '*' group.getent
'''
if 'group.getent' in __context__ and not refresh:
return __context__['group.getent']
ret = []
for grinfo in grp.getgrall():
if not grinfo.gr_na... |
Change the gid for a named group | def chgid(name, gid):
'''
Change the gid for a named group
CLI Example:
.. code-block:: bash
salt '*' group.chgid foo 4376
'''
if not isinstance(gid, int):
raise SaltInvocationError('gid must be an integer')
pre_gid = __salt__['file.group_to_gid'](name)
pre_info = info... |
.. versionadded:: 2014. 7. 0 | def tree(self, path):
'''
.. versionadded:: 2014.7.0
Recurse through etcd and return all values
'''
ret = {}
try:
items = self.read(path)
except (etcd.EtcdKeyNotFound, ValueError):
return None
except etcd.EtcdConnectionFailed:
... |
Read pillar data from Cobbler via its API. | def ext_pillar(minion_id,
pillar, # pylint: disable=W0613
key=None,
only=()):
'''
Read pillar data from Cobbler via its API.
'''
url = __opts__['cobbler.url']
user = __opts__['cobbler.user']
password = __opts__['cobbler.password']
log.info("Quer... |
Verify that ruby is installed install if unavailable | def _check_and_install_ruby(ret, ruby, default=False, user=None, opts=None, env=None):
'''
Verify that ruby is installed, install if unavailable
'''
ret = _check_ruby(ret, ruby, user=user)
if not ret['result']:
if __salt__['rvm.install_ruby'](ruby, runas=user, opts=opts, env=env):
... |
Check that ruby is installed | def _check_ruby(ret, ruby, user=None):
'''
Check that ruby is installed
'''
match_version = True
match_micro_version = False
micro_version_regex = re.compile(r'-([0-9]{4}\.[0-9]{2}|p[0-9]+)$')
if micro_version_regex.search(ruby):
match_micro_version = True
if re.search('^[a-z]+$'... |
Verify that the specified ruby is installed with RVM. RVM is installed when necessary. | def installed(name, default=False, user=None, opts=None, env=None):
'''
Verify that the specified ruby is installed with RVM. RVM is
installed when necessary.
name
The version of ruby to install
default : False
Whether to make this ruby the default.
user: None
The user... |
Verify that the gemset is present. | def gemset_present(name, ruby='default', user=None):
'''
Verify that the gemset is present.
name
The name of the gemset.
ruby: default
The ruby version this gemset belongs to.
user: None
The user to run rvm as.
.. versionadded:: 0.17.0
'''
ret = {'name': n... |
Ensure that the named tablespace is present with the specified properties. For more information about all of these options run man 7 create_tablespace. | def present(name,
directory,
options=None,
owner=None,
user=None,
maintenance_db=None,
db_password=None,
db_host=None,
db_port=None,
db_user=None):
'''
Ensure that the named tablespace is present with the... |
Execute queries against SQLCipher merge and return as a dict | def ext_pillar(minion_id,
pillar,
*args,
**kwargs):
'''
Execute queries against SQLCipher, merge and return as a dict
'''
return SQLCipherExtPillar().fetch(minion_id, pillar, *args, **kwargs) |
Yield a SQLCipher cursor | def _get_cursor(self):
'''
Yield a SQLCipher cursor
'''
_options = self._get_options()
conn = sqlcipher.connect(_options.get('database'),
timeout=float(_options.get('timeout')))
conn.execute('pragma key="{0}"'.format(_options.get('pass')))... |
Convert an ldap backend exception to an LDAPError and raise it. | def _convert_exception(e):
'''Convert an ldap backend exception to an LDAPError and raise it.'''
args = ('exception in ldap backend: {0}'.format(repr(e)), e)
if six.PY2:
six.reraise(LDAPError, args, sys.exc_info()[2])
else:
six.raise_from(LDAPError(*args), e) |
Bind helper. | def _bind(l, bind=None):
'''Bind helper.'''
if bind is None:
return
method = bind.get('method', 'simple')
if method is None:
return
elif method == 'simple':
l.simple_bind_s(bind.get('dn', ''), bind.get('password', ''))
elif method == 'sasl':
sasl_class = getattr(l... |
Connect and optionally bind to an LDAP server. | def connect(connect_spec=None):
'''Connect and optionally bind to an LDAP server.
:param connect_spec:
This can be an LDAP connection object returned by a previous
call to :py:func:`connect` (in which case the argument is
simply returned), ``None`` (in which case an empty dict is
... |
Search an LDAP database. | def search(connect_spec, base, scope='subtree', filterstr='(objectClass=*)',
attrlist=None, attrsonly=0):
'''Search an LDAP database.
:param connect_spec:
See the documentation for the ``connect_spec`` parameter for
:py:func:`connect`.
:param base:
Distinguished name of ... |
Add an entry to an LDAP database. | def add(connect_spec, dn, attributes):
'''Add an entry to an LDAP database.
:param connect_spec:
See the documentation for the ``connect_spec`` parameter for
:py:func:`connect`.
:param dn:
Distinguished name of the entry.
:param attributes:
Non-empty dict mapping each ... |
Delete an entry from an LDAP database. | def delete(connect_spec, dn):
'''Delete an entry from an LDAP database.
:param connect_spec:
See the documentation for the ``connect_spec`` parameter for
:py:func:`connect`.
:param dn:
Distinguished name of the entry.
:returns:
``True`` if successful, raises an excepti... |
Modify an entry in an LDAP database. | def modify(connect_spec, dn, directives):
'''Modify an entry in an LDAP database.
:param connect_spec:
See the documentation for the ``connect_spec`` parameter for
:py:func:`connect`.
:param dn:
Distinguished name of the entry.
:param directives:
Iterable of directives... |
Modify an entry in an LDAP database. | def change(connect_spec, dn, before, after):
'''Modify an entry in an LDAP database.
This does the same thing as :py:func:`modify`, but with a simpler
interface. Instead of taking a list of directives, it takes a
before and after view of an entry, determines the differences
between the two, comput... |
From a pillar key or a dictionary return index and host keys. | def _parse_profile(profile):
'''
From a pillar key, or a dictionary, return index and host keys.
'''
if isinstance(profile, string_types):
_profile = __salt__['config.option'](profile)
if not _profile:
msg = 'Pillar key for profile {0} not found.'.format(profile)
... |
Check if grafana dashboard row and _row differ | def _rows_differ(row, _row):
'''
Check if grafana dashboard row and _row differ
'''
row_copy = copy.deepcopy(row)
_row_copy = copy.deepcopy(_row)
# Strip id from all panels in both rows, since they are always generated.
for panel in row_copy['panels']:
if 'id' in panel:
d... |
Ensure the grafana dashboard exists and is managed. | def dashboard_present(
name,
dashboard=None,
dashboard_from_pillar=None,
rows=None,
rows_from_pillar=None,
profile='grafana'):
'''
Ensure the grafana dashboard exists and is managed.
name
Name of the grafana dashboard.
dashboard
A dict th... |
Ensure the named grafana dashboard is deleted. | def dashboard_absent(
name,
hosts=None,
profile='grafana'):
'''
Ensure the named grafana dashboard is deleted.
name
Name of the grafana dashboard.
profile
A pillar key or dict that contains a list of hosts and an
elasticsearch index to use.
'''
r... |
Ensure sequenced data. | def ensure_sequence_filter(data):
'''
Ensure sequenced data.
**sequence**
ensure that parsed data is a sequence
.. code-block:: jinja
{% set my_string = "foo" %}
{% set my_list = ["bar", ] %}
{% set my_dict = {"baz": "qux"} %}
{{ my_string|sequence|first }}
... |
Returns the logical value. | def to_bool(val):
'''
Returns the logical value.
.. code-block:: jinja
{{ 'yes' | to_bool }}
will be rendered as:
.. code-block:: text
True
'''
if val is None:
return False
if isinstance(val, bool):
return val
if isinstance(val, (six.text_type, si... |
Implementation of tojson filter ( only present in Jinja 2. 9 and later ). If Jinja 2. 9 or later is installed then the upstream version of this filter will be used. | def tojson(val, indent=None):
'''
Implementation of tojson filter (only present in Jinja 2.9 and later). If
Jinja 2.9 or later is installed, then the upstream version of this filter
will be used.
'''
options = {'ensure_ascii': True}
if indent is not None:
options['indent'] = indent
... |
Searches for a pattern in the text. | def regex_search(txt, rgx, ignorecase=False, multiline=False):
'''
Searches for a pattern in the text.
.. code-block:: jinja
{% set my_text = 'abcd' %}
{{ my_text | regex_search('^(.*)BC(.*)$', ignorecase=True) }}
will be rendered as:
.. code-block:: text
('a', 'd')
... |
Searches for a pattern in the text. | def regex_match(txt, rgx, ignorecase=False, multiline=False):
'''
Searches for a pattern in the text.
.. code-block:: jinja
{% set my_text = 'abcd' %}
{{ my_text | regex_match('^(.*)BC(.*)$', ignorecase=True) }}
will be rendered as:
.. code-block:: text
('a', 'd')
''... |
r Searches for a pattern and replaces with a sequence of characters. | def regex_replace(txt, rgx, val, ignorecase=False, multiline=False):
r'''
Searches for a pattern and replaces with a sequence of characters.
.. code-block:: jinja
{% set my_text = 'lets replace spaces' %}
{{ my_text | regex_replace('\s+', '__') }}
will be rendered as:
.. code-blo... |
Returns a UUID corresponding to the value passed as argument. | def uuid_(val):
'''
Returns a UUID corresponding to the value passed as argument.
.. code-block:: jinja
{{ 'example' | uuid }}
will be rendered as:
.. code-block:: text
f4efeff8-c219-578a-bad7-3dc280612ec8
'''
return six.text_type(
uuid.uuid5(
GLOBAL_... |
Removes duplicates from a list. | def unique(values):
'''
Removes duplicates from a list.
.. code-block:: jinja
{% set my_list = ['a', 'b', 'c', 'a', 'b'] -%}
{{ my_list | unique }}
will be rendered as:
.. code-block:: text
['a', 'b', 'c']
'''
ret = None
if isinstance(values, collections.Hash... |
Returns the average value of a list. | def lst_avg(lst):
'''
Returns the average value of a list.
.. code-block:: jinja
{% my_list = [1,2,3,4] -%}
{{ set my_list | avg }}
will be rendered as:
.. code-block:: yaml
2.5
'''
salt.utils.versions.warn_until(
'Neon',
'This results of this fun... |
Returns the union of two lists. | def union(lst1, lst2):
'''
Returns the union of two lists.
.. code-block:: jinja
{% my_list = [1,2,3,4] -%}
{{ set my_list | union([2, 4, 6]) }}
will be rendered as:
.. code-block:: text
[1, 2, 3, 4, 6]
'''
if isinstance(lst1, collections.Hashable) and isinstance... |
Returns the intersection of two lists. | def intersect(lst1, lst2):
'''
Returns the intersection of two lists.
.. code-block:: jinja
{% my_list = [1,2,3,4] -%}
{{ set my_list | intersect([2, 4, 6]) }}
will be rendered as:
.. code-block:: text
[2, 4]
'''
if isinstance(lst1, collections.Hashable) and isin... |
Return a file client. Instantiates on first call. | def file_client(self):
'''
Return a file client. Instantiates on first call.
'''
if not self._file_client:
self._file_client = salt.fileclient.get_file_client(
self.opts, self.pillar_rend)
return self._file_client |
Cache a file from the salt master | def cache_file(self, template):
'''
Cache a file from the salt master
'''
saltpath = salt.utils.url.create(template)
self.file_client().get_file(saltpath, '', True, self.saltenv) |
Cache a file only once | def check_cache(self, template):
'''
Cache a file only once
'''
if template not in self.cached:
self.cache_file(template)
self.cached.append(template) |
Salt - specific loader to find imported jinja files. | def get_source(self, environment, template):
'''
Salt-specific loader to find imported jinja files.
Jinja imports will be interpreted as originating from the top
of each of the directories in the searchpath when the template
name does not begin with './' or '../'. When a templa... |
Ensure that printed mappings are YAML friendly. | def finalizer(self, data):
'''
Ensure that printed mappings are YAML friendly.
'''
def explore(data):
if isinstance(data, (dict, OrderedDict)):
return PrintableDict(
[(key, explore(value)) for key, value in six.iteritems(data)]
... |
Render a formatted multi - line XML string from a complex Python data structure. Supports tag attributes and nested dicts/ lists. | def format_xml(self, value):
"""Render a formatted multi-line XML string from a complex Python
data structure. Supports tag attributes and nested dicts/lists.
:param value: Complex data structure representing XML contents
:returns: Formatted XML string rendered with newlines and indenta... |
Ensure that the index alias is absent. | def alias_absent(name, index):
'''
Ensure that the index alias is absent.
name
Name of the index alias to remove
index
Name of the index for the alias
'''
ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''}
try:
alias = __salt__['elasticsearch.alias_... |
Ensure that the named index alias is present. | def alias_present(name, index, definition=None):
'''
Ensure that the named index alias is present.
name
Name of the alias
index
Name of the index
definition
Optional dict for filters as per https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html
... |
Ensure that the named index template is absent. | def index_template_absent(name):
'''
Ensure that the named index template is absent.
name
Name of the index to remove
'''
ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''}
try:
index_template = __salt__['elasticsearch.index_template_get'](name=name)
if... |
Ensure that the named index template is present. | def index_template_present(name, definition, check_definition=False):
'''
Ensure that the named index template is present.
name
Name of the index to add
definition
Required dict for creation parameters as per https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-templa... |
Ensure that the named pipeline is absent | def pipeline_absent(name):
'''
Ensure that the named pipeline is absent
name
Name of the pipeline to remove
'''
ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''}
try:
pipeline = __salt__['elasticsearch.pipeline_get'](id=name)
if pipeline and name in pi... |
Ensure that the named pipeline is present. | def pipeline_present(name, definition):
'''
Ensure that the named pipeline is present.
name
Name of the index to add
definition
Required dict for creation parameters as per https://www.elastic.co/guide/en/elasticsearch/reference/master/pipeline.html
**Example:**
.. code-block:... |
Ensure that the search template is absent | def search_template_absent(name):
'''
Ensure that the search template is absent
name
Name of the search template to remove
'''
ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''}
try:
template = __salt__['elasticsearch.search_template_get'](id=name)
if t... |
Ensure that the named search template is present. | def search_template_present(name, definition):
'''
Ensure that the named search template is present.
name
Name of the search template to add
definition
Required dict for creation parameters as per http://www.elastic.co/guide/en/elasticsearch/reference/current/search-template.html
*... |
Returns the prefix for a pkg command using - j if a jail is specified or - c if chroot is specified. | def _pkg(jail=None, chroot=None, root=None):
'''
Returns the prefix for a pkg command, using -j if a jail is specified, or
-c if chroot is specified.
'''
ret = ['pkg']
if jail:
ret.extend(['-j', jail])
elif chroot:
ret.extend(['-c', chroot])
elif root:
ret.extend(... |
return the version of pkg | def _get_pkgng_version(jail=None, chroot=None, root=None):
'''
return the version of 'pkg'
'''
cmd = _pkg(jail, chroot, root) + ['--version']
return __salt__['cmd.run'](cmd).strip() |
pkg search will return all packages for which the pattern is a match. Narrow this down and return the package version or None if no exact match. | def _get_version(name, results):
'''
``pkg search`` will return all packages for which the pattern is a match.
Narrow this down and return the package version, or None if no exact match.
'''
for line in salt.utils.itertools.split(results, '\n'):
if not line:
continue
try:... |
As this module is designed to manipulate packages in jails and chroots use the passed jail/ chroot to ensure that a key in the __context__ dict that is unique to that jail/ chroot is used. | def _contextkey(jail=None, chroot=None, root=None, prefix='pkg.list_pkgs'):
'''
As this module is designed to manipulate packages in jails and chroots, use
the passed jail/chroot to ensure that a key in the __context__ dict that is
unique to that jail/chroot is used.
'''
if jail:
return ... |
Return dict of uncommented global variables. | def parse_config(file_name='/usr/local/etc/pkg.conf'):
'''
Return dict of uncommented global variables.
CLI Example:
.. code-block:: bash
salt '*' pkg.parse_config
``NOTE:`` not working properly right now
'''
ret = {}
if not os.path.isfile(file_name):
return 'Unable t... |
Returns a string representing the package version or an empty string if not installed. If more than one package name is specified a dict of name/ version pairs is returned. | def version(*names, **kwargs):
'''
Returns a string representing the package version or an empty string if not
installed. If more than one package name is specified, a dict of
name/version pairs is returned.
.. note::
This function can accessed using ``pkg.info`` in addition to
``p... |
Refresh PACKAGESITE contents | def refresh_db(jail=None, chroot=None, root=None, force=False, **kwargs):
'''
Refresh PACKAGESITE contents
.. note::
This function can accessed using ``pkg.update`` in addition to
``pkg.refresh_db``, to more closely match the CLI usage of ``pkg(8)``.
CLI Example:
.. code-block:: ... |
List the packages currently installed as a dict:: | def list_pkgs(versions_as_list=False,
jail=None,
chroot=None,
root=None,
with_origin=False,
**kwargs):
'''
List the packages currently installed as a dict::
{'<package_name>': '<version>'}
jail
List the packages in the s... |
Return pkgng stats. | def stats(local=False, remote=False, jail=None, chroot=None, root=None):
'''
Return pkgng stats.
CLI Example:
.. code-block:: bash
salt '*' pkg.stats
local
Display stats only for the local package database.
CLI Example:
.. code-block:: bash
salt '*'... |
Export installed packages into yaml + mtree file | def backup(file_name, jail=None, chroot=None, root=None):
'''
Export installed packages into yaml+mtree file
CLI Example:
.. code-block:: bash
salt '*' pkg.backup /tmp/pkg
jail
Backup packages from the specified jail. Note that this will run the
command within the jail, a... |
Reads archive created by pkg backup - d and recreates the database. | def restore(file_name, jail=None, chroot=None, root=None):
'''
Reads archive created by pkg backup -d and recreates the database.
CLI Example:
.. code-block:: bash
salt '*' pkg.restore /tmp/pkg
jail
Restore database to the specified jail. Note that this will run the
comma... |
Audits installed packages against known vulnerabilities | def audit(jail=None, chroot=None, root=None):
'''
Audits installed packages against known vulnerabilities
CLI Example:
.. code-block:: bash
salt '*' pkg.audit
jail
Audit packages within the specified jail
CLI Example:
.. code-block:: bash
salt '*' p... |
Install package ( s ) from a repository | def install(name=None,
fromrepo=None,
pkgs=None,
sources=None,
jail=None,
chroot=None,
root=None,
orphan=False,
force=False,
glob=False,
local=False,
dryrun=False,
quiet=False,... |
Remove a package from the database and system | def remove(name=None,
pkgs=None,
jail=None,
chroot=None,
root=None,
all_installed=False,
force=False,
glob=False,
dryrun=False,
recurse=False,
regex=False,
pcre=False,
**kwargs):
'''
... |
Upgrade named or all packages ( run a pkg upgrade ). If <package name > is omitted the operation is executed on all packages. | def upgrade(*names, **kwargs):
'''
Upgrade named or all packages (run a ``pkg upgrade``). If <package name> is
omitted, the operation is executed on all packages.
Returns a dictionary containing the changes:
.. code-block:: python
{'<package>': {'old': '<old-version>',
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.