INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Execute ilom commands | def __execute_cmd(name, xml):
'''
Execute ilom commands
'''
ret = {name.replace('_', ' '): {}}
id_num = 0
tmp_dir = os.path.join(__opts__['cachedir'], 'tmp')
if not os.path.isdir(tmp_dir):
os.mkdir(tmp_dir)
with tempfile.NamedTemporaryFile(dir=tmp_dir,
... |
Configure the port HTTP should listen on
CLI Example:
.. code-block:: bash
salt '*' ilo.set_http_port 8080 | def set_http_port(port=80):
'''
Configure the port HTTP should listen on
CLI Example:
.. code-block:: bash
salt '*' ilo.set_http_port 8080
'''
_current = global_settings()
if _current['Global Settings']['HTTP_PORT']['VALUE'] == port:
return True
_xml = """<RIBCL VERS... |
Configure the port HTTPS should listen on
CLI Example:
.. code-block:: bash
salt '*' ilo.set_https_port 4334 | def set_https_port(port=443):
'''
Configure the port HTTPS should listen on
CLI Example:
.. code-block:: bash
salt '*' ilo.set_https_port 4334
'''
_current = global_settings()
if _current['Global Settings']['HTTP_PORT']['VALUE'] == port:
return True
_xml = """<RIBCL ... |
Enable SSH on a user defined port
CLI Example:
.. code-block:: bash
salt '*' ilo.set_ssh_port 2222 | def set_ssh_port(port=22):
'''
Enable SSH on a user defined port
CLI Example:
.. code-block:: bash
salt '*' ilo.set_ssh_port 2222
'''
_current = global_settings()
if _current['Global Settings']['SSH_PORT']['VALUE'] == port:
return True
_xml = """<RIBCL VERSION="2.0">... |
Create user
CLI Example:
.. code-block:: bash
salt '*' ilo.create_user damian secretagent VIRTUAL_MEDIA_PRIV
If no permissions are specify the user will only have a read-only account.
Supported privelges:
* ADMIN_PRIV
Enables the user to administer user accounts.
* REMOTE_CO... | def create_user(name, password, *privileges):
'''
Create user
CLI Example:
.. code-block:: bash
salt '*' ilo.create_user damian secretagent VIRTUAL_MEDIA_PRIV
If no permissions are specify the user will only have a read-only account.
Supported privelges:
* ADMIN_PRIV
Enab... |
Configure Network Interface
CLI Example:
.. code-block:: bash
salt '*' ilo.configure_network [IP ADDRESS] [NETMASK] [GATEWAY] | def configure_network(ip, netmask, gateway):
'''
Configure Network Interface
CLI Example:
.. code-block:: bash
salt '*' ilo.configure_network [IP ADDRESS] [NETMASK] [GATEWAY]
'''
current = network()
# Check to see if the network is already configured
if (ip in current['Networ... |
Configure SNMP
CLI Example:
.. code-block:: bash
salt '*' ilo.configure_snmp [COMMUNITY STRING] [SNMP PORT] [SNMP TRAP PORT] | def configure_snmp(community, snmp_port=161, snmp_trapport=161):
'''
Configure SNMP
CLI Example:
.. code-block:: bash
salt '*' ilo.configure_snmp [COMMUNITY STRING] [SNMP PORT] [SNMP TRAP PORT]
'''
_xml = """<RIBCL VERSION="2.2">
<LOGIN USER_LOGIN="x" PASSWORD="y">
... |
Enable the RDP service and make sure access to the RDP
port is allowed in the firewall configuration | def enabled(name):
'''
Enable the RDP service and make sure access to the RDP
port is allowed in the firewall configuration
'''
ret = {'name': name,
'result': True,
'changes': {},
'comment': ''}
stat = __salt__['rdp.status']()
if not stat:
if __opts... |
Disable the RDP service | def disabled(name):
'''
Disable the RDP service
'''
ret = {'name': name,
'result': True,
'changes': {},
'comment': ''}
stat = __salt__['rdp.status']()
if stat:
if __opts__['test']:
ret['result'] = None
ret['comment'] = 'RDP will ... |
Ensure that a task is present and up-to-date in Kapacitor.
name
Name of the task.
tick_script
Path to the TICK script for the task. Can be a salt:// source.
task_type
Task type. Defaults to 'stream'
dbrps
A list of databases and retention policies in "dbname"."rpname"... | def task_present(name,
tick_script,
task_type='stream',
database=None,
retention_policy='default',
enable=True,
dbrps=None):
'''
Ensure that a task is present and up-to-date in Kapacitor.
name
Name... |
Ensure that a task is absent from Kapacitor.
name
Name of the task. | def task_absent(name):
'''
Ensure that a task is absent from Kapacitor.
name
Name of the task.
'''
ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''}
task = __salt__['kapacitor.get_task'](name)
if task:
if __opts__['test']:
ret['result'] = None
... |
Set Windows to use a list of NTP servers
CLI Example:
.. code-block:: bash
salt '*' ntp.set_servers 'pool.ntp.org' 'us.pool.ntp.org' | def set_servers(*servers):
'''
Set Windows to use a list of NTP servers
CLI Example:
.. code-block:: bash
salt '*' ntp.set_servers 'pool.ntp.org' 'us.pool.ntp.org'
'''
service_name = 'w32time'
if not __salt__['service.status'](service_name):
if not __salt__['service.start'... |
Get list of configured NTP servers
CLI Example:
.. code-block:: bash
salt '*' ntp.get_servers | def get_servers():
'''
Get list of configured NTP servers
CLI Example:
.. code-block:: bash
salt '*' ntp.get_servers
'''
cmd = ['w32tm', '/query', '/configuration']
lines = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
for line in lines:
try:
if... |
Displays the facts gathered during the connection.
These facts are also stored in Salt grains.
CLI Example:
.. code-block:: bash
salt 'device_name' junos.facts | def facts():
'''
Displays the facts gathered during the connection.
These facts are also stored in Salt grains.
CLI Example:
.. code-block:: bash
salt 'device_name' junos.facts
'''
ret = {}
try:
ret['facts'] = __proxy__['junos.get_serialized_facts']()
ret['out'... |
Reload the facts dictionary from the device. Usually only needed if,
the device configuration is changed by some other actor.
This function will also refresh the facts stored in the salt grains.
CLI Example:
.. code-block:: bash
salt 'device_name' junos.facts_refresh | def facts_refresh():
'''
Reload the facts dictionary from the device. Usually only needed if,
the device configuration is changed by some other actor.
This function will also refresh the facts stored in the salt grains.
CLI Example:
.. code-block:: bash
salt 'device_name' junos.facts_... |
Set the device's hostname
hostname
The name to be set
comment
Provide a comment to the commit
dev_timeout : 30
The NETCONF RPC timeout (in seconds)
confirm
Provide time in minutes for commit confirmation. If this option is
specified, the commit will be rolled back... | def set_hostname(hostname=None, **kwargs):
'''
Set the device's hostname
hostname
The name to be set
comment
Provide a comment to the commit
dev_timeout : 30
The NETCONF RPC timeout (in seconds)
confirm
Provide time in minutes for commit confirmation. If this op... |
To commit the changes loaded in the candidate configuration.
dev_timeout : 30
The NETCONF RPC timeout (in seconds)
comment
Provide a comment for the commit
confirm
Provide time in minutes for commit confirmation. If this option is
specified, the commit will be rolled back in the... | def commit(**kwargs):
'''
To commit the changes loaded in the candidate configuration.
dev_timeout : 30
The NETCONF RPC timeout (in seconds)
comment
Provide a comment for the commit
confirm
Provide time in minutes for commit confirmation. If this option is
specified, the... |
Roll back the last committed configuration changes and commit
id : 0
The rollback ID value (0-49)
dev_timeout : 30
The NETCONF RPC timeout (in seconds)
comment
Provide a comment for the commit
confirm
Provide time in minutes for commit confirmation. If this option is
... | def rollback(**kwargs):
'''
Roll back the last committed configuration changes and commit
id : 0
The rollback ID value (0-49)
dev_timeout : 30
The NETCONF RPC timeout (in seconds)
comment
Provide a comment for the commit
confirm
Provide time in minutes for commit ... |
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 hops) allowed between source and
dest... | 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... |
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 | 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... |
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 (either ``text`` or ``xml``)
dev_timeout : ... | 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.
.. note::
One of ``shutdown`` or ``reboot`` must be set to ``True`` or no
action will be taken.
shutdown : False
Set this to ``True... | 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.
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
... | 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
CLI Example:
.. code-block:: bash
salt 'device_name' junos.zeroize | 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.
path (required)
Path where the image file is present on the proxy minion
remote_path :
If the value of path is a file path on the local... | 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 :
... |
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 include a step in the
... | 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.
CLI Example:
.. code-block:: bash
salt 'device_name' junos.unlock | 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.
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`` extension, the content is treated as XML format. If... | 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
CLI Example:
.. code-block:: bash
salt 'device_name' junos.commit_check | 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
table (required)
Name of PyEZ Table
table_file (required)
YAML file that has the table specified in table parameter
path:
Path of location of the YAML file.
defaults to op directory in jnpr.junos.op
target:
... | 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
CLI Example:
.. code-block:: bash
salt '*' guest.mount /srv/images/fedora.qcow | 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
name:
The users username
password
The password used to authenticate
permission
The permissions that should be assigned to a user | 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
CLI Example:
.. code-block:: bash
salt-run reactor.list | 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
CLI Example:
.. code-block:: bash
salt-run reactor.add 'salt/cloud/*/destroyed' reactors='/srv/reactor/destroy/*.sls' | 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
CLI Example:
.. code-block:: bash
salt-run reactor.delete 'salt/cloud/*/destroyed' | 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``
CLI Example:
.. code-block:: bash
salt -G 'os_family:Windows' ip.is_enabled 'Local Area Connection #2' | 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
CLI Example:
.. code-block:: bash
salt -G 'os_family:Windows' ip.enable 'Local Area Connection #2' | 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
CLI Example:
.. code-block:: bash
salt -G 'os_family:Windows' ip.disable 'Local Area Connection #2' | 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
CLI Example:
.. code-block:: bash
salt -G 'os_family:Windows' ip.get_subnet_length 255.255.255.0 | 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
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>`
function can be used to calculate the subnet length from a ne... | 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
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 ``None`` no
changes will be made.
... | 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
CLI Example:
.. code-block:: bash
salt -G 'os_family:Windows' ip.get_default_gateway | 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
CLI Example:
.. code-block:: bash
salt '*' group.add foo 3456 | 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
CLI Example:
.. code-block:: bash
salt '*' group.delete foo | 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.
.. versionadded:: 2016.3.0
CLI Example:
salt '*' group.members foo 'user1,user2,user3,...'
Replaces a membership list for a local group 'foo'. | 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
CLI Example:
.. code-block:: bash
salt '*' group.info foo | 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
CLI Example:
.. code-block:: bash
salt '*' group.getent | 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
CLI Example:
.. code-block:: bash
salt '*' group.chgid foo 4376 | 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
Recurse through etcd and return all values | 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.
name
The version of ruby to install
default : False
Whether to make this ruby the default.
user: None
The user to run rvm as.
env: None
A list of environment variables to set (i... | 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.
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 | 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``.
name
The name of the tablespace to create/manage.
directory
The directory where the tablespace will be located, must already exist... | 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... |
Search an LDAP database.
:param connect_spec:
See the documentation for the ``connect_spec`` parameter for
:py:func:`connect`.
:param base:
Distinguished name of the entry at which to start the search.
:param scope:
One of the following:
* ``'subtree'``
... | 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.
: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 of the new entry's attributes to a
non... | 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.
: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 exception otherwise.
CLI example:
... | 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.
: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 that indicate how to modify the entry.
E... | 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.
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, computes the directives, and executes them.
Any attri... | 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.
name
Name of the grafana dashboard.
dashboard
A dict that defines a dashboard that should be managed.
dashboard_from_pillar
A pillar key that contains a grafana dashboard dict. Mutually exclusive
with dashboard.
rows... | 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.
name
Name of the grafana dashboard.
profile
A pillar key or dict that contains a list of hosts and an
elasticsearch index to use. | 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.
**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 }}
{{ my_list|sequence|first }}
{{... | 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.
.. code-block:: jinja
{{ 'yes' | to_bool }}
will be rendered as:
.. code-block:: text
True | 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.
.. code-block:: jinja
{% set my_text = 'abcd' %}
{{ my_text | regex_search('^(.*)BC(.*)$', ignorecase=True) }}
will be rendered as:
.. code-block:: text
('a', 'd') | 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.
.. code-block:: jinja
{% set my_text = 'abcd' %}
{{ my_text | regex_match('^(.*)BC(.*)$', ignorecase=True) }}
will be rendered as:
.. code-block:: text
('a', 'd') | 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')
''... |
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 | 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.
.. code-block:: jinja
{% set my_list = ['a', 'b', 'c', 'a', 'b'] -%}
{{ my_list | unique }}
will be rendered as:
.. code-block:: text
['a', 'b', 'c'] | 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.
.. code-block:: jinja
{% my_list = [1,2,3,4] -%}
{{ set my_list | avg }}
will be rendered as:
.. code-block:: yaml
2.5 | 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.
.. 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] | 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.
.. 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] | 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.
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 template name
begins with './' or '../' then the import will be... | 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.
:param value: Complex data structure representing XML contents
:returns: Formatted XML string rendered with newlines and indentation
:rtype: str | 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.
name
Name of the index alias to remove
index
Name of the index for the alias | 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.
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
**Example:**
.. code-block:: yaml
mytestal... | 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.
name
Name of the index to remove | 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.
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-templates.html
check_definition
If the template already exists and the defin... | 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
name
Name of the pipeline to remove | 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.
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:: yaml
test_pipeline:
elasticsear... | 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
name
Name of the search template to remove | 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.
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
**Example:**
.. code-block:: yaml
test_pipelin... | 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
*... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.