INSTRUCTION stringlengths 1 46.3k | RESPONSE stringlengths 75 80.2k |
|---|---|
Do the DRY thing and only call subprocess.Popen() once | def _run(cmd,
cwd=None,
stdin=None,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
output_encoding=None,
output_loglevel='debug',
log_callback=None,
runas=None,
group=None,
shell=DEFAULT_SHELL,
python_shell=False,
... |
Helper for running commands quietly for minion startup | def _run_quiet(cmd,
cwd=None,
stdin=None,
output_encoding=None,
runas=None,
shell=DEFAULT_SHELL,
python_shell=False,
env=None,
template=None,
umask=None,
timeout=None,
... |
Check if we are running in the globalzone | def _is_globalzone():
'''
Check if we are running in the globalzone
'''
if not __grains__['kernel'] == 'SunOS':
return False
zonename = __salt__['cmd.run_all']('zonename')
if zonename['retcode']:
return False
if zonename['stdout'] == 'global':
return True
return... |
List all zones
verbose : boolean
display additional zone information
installed : boolean
include installed zones in output
configured : boolean
include configured zones in output
hide_global : boolean
do not include global zone
CLI Example:
.. code-block:: bash... | def list_zones(verbose=True, installed=False, configured=False, hide_global=True):
'''
List all zones
verbose : boolean
display additional zone information
installed : boolean
include installed zones in output
configured : boolean
include configured zones in output
hide_... |
Boot (or activate) the specified zone.
zone : string
name or uuid of the zone
single : boolean
boots only to milestone svc:/milestone/single-user:default.
altinit : string
valid path to an alternative executable to be the primordial process.
smf_options : string
include ... | def boot(zone, single=False, altinit=None, smf_options=None):
'''
Boot (or activate) the specified zone.
zone : string
name or uuid of the zone
single : boolean
boots only to milestone svc:/milestone/single-user:default.
altinit : string
valid path to an alternative executab... |
Attach the specified zone.
zone : string
name of the zone
force : boolean
force the zone into the "installed" state with no validation
brand_opts : string
brand specific options to pass
CLI Example:
.. code-block:: bash
salt '*' zoneadm.attach lawrence
sal... | def attach(zone, force=False, brand_opts=None):
'''
Attach the specified zone.
zone : string
name of the zone
force : boolean
force the zone into the "installed" state with no validation
brand_opts : string
brand specific options to pass
CLI Example:
.. code-block:... |
Prepares a zone for running applications.
zone : string
name or uuid of the zone
CLI Example:
.. code-block:: bash
salt '*' zoneadm.ready clementine | def ready(zone):
'''
Prepares a zone for running applications.
zone : string
name or uuid of the zone
CLI Example:
.. code-block:: bash
salt '*' zoneadm.ready clementine
'''
ret = {'status': True}
## ready zone
res = __salt__['cmd.run_all']('zoneadm {zone} ready'... |
Check to make sure the configuration of the specified
zone can safely be installed on the machine.
zone : string
name of the zone
CLI Example:
.. code-block:: bash
salt '*' zoneadm.verify dolores | def verify(zone):
'''
Check to make sure the configuration of the specified
zone can safely be installed on the machine.
zone : string
name of the zone
CLI Example:
.. code-block:: bash
salt '*' zoneadm.verify dolores
'''
ret = {'status': True}
## verify zone
... |
Move zone to new zonepath.
zone : string
name or uuid of the zone
zonepath : string
new zonepath
CLI Example:
.. code-block:: bash
salt '*' zoneadm.move meave /sweetwater/meave | def move(zone, zonepath):
'''
Move zone to new zonepath.
zone : string
name or uuid of the zone
zonepath : string
new zonepath
CLI Example:
.. code-block:: bash
salt '*' zoneadm.move meave /sweetwater/meave
'''
ret = {'status': True}
## verify zone
re... |
Install the specified zone from the system.
zone : string
name of the zone
nodataset : boolean
do not create a ZFS file system
brand_opts : string
brand specific options to pass
CLI Example:
.. code-block:: bash
salt '*' zoneadm.install dolores
salt '*' zo... | def install(zone, nodataset=False, brand_opts=None):
'''
Install the specified zone from the system.
zone : string
name of the zone
nodataset : boolean
do not create a ZFS file system
brand_opts : string
brand specific options to pass
CLI Example:
.. code-block:: b... |
Install a zone by copying an existing installed zone.
zone : string
name of the zone
source : string
zone to clone from
snapshot : string
optional name of snapshot to use as source
CLI Example:
.. code-block:: bash
salt '*' zoneadm.clone clementine dolores | def clone(zone, source, snapshot=None):
'''
Install a zone by copying an existing installed zone.
zone : string
name of the zone
source : string
zone to clone from
snapshot : string
optional name of snapshot to use as source
CLI Example:
.. code-block:: bash
... |
Search the environment for the relative path | def find_file(path, saltenv='base', **kwargs):
'''
Search the environment for the relative path
'''
fnd = {'path': '',
'rel': ''}
for container in __opts__.get('azurefs', []):
if container.get('saltenv', 'base') != saltenv:
continue
full = os.path.join(_get_con... |
Each container configuration can have an environment setting, or defaults
to base | def envs():
'''
Each container configuration can have an environment setting, or defaults
to base
'''
saltenvs = []
for container in __opts__.get('azurefs', []):
saltenvs.append(container.get('saltenv', 'base'))
# Remove duplicates
return list(set(saltenvs)) |
Return a chunk from a file based on the data received | def serve_file(load, fnd):
'''
Return a chunk from a file based on the data received
'''
ret = {'data': '',
'dest': ''}
required_load_keys = ('path', 'loc', 'saltenv')
if not all(x in load for x in required_load_keys):
log.debug(
'Not all of the required keys prese... |
Update caches of the storage containers.
Compares the md5 of the files on disk to the md5 of the blobs in the
container, and only updates if necessary.
Also processes deletions by walking the container caches and comparing
with the list of blobs in the container | def update():
'''
Update caches of the storage containers.
Compares the md5 of the files on disk to the md5 of the blobs in the
container, and only updates if necessary.
Also processes deletions by walking the container caches and comparing
with the list of blobs in the container
'''
f... |
Return a file hash based on the hash type set in the master config | def file_hash(load, fnd):
'''
Return a file hash based on the hash type set in the master config
'''
if not all(x in load for x in ('path', 'saltenv')):
return '', None
ret = {'hash_type': __opts__['hash_type']}
relpath = fnd['rel']
path = fnd['path']
hash_cachedir = os.path.join... |
Return a list of all files in a specified environment | def file_list(load):
'''
Return a list of all files in a specified environment
'''
ret = set()
try:
for container in __opts__['azurefs']:
if container.get('saltenv', 'base') != load['saltenv']:
continue
container_list = _get_container_path(container) +... |
Return a list of all directories in a specified environment | def dir_list(load):
'''
Return a list of all directories in a specified environment
'''
ret = set()
files = file_list(load)
for f in files:
dirname = f
while dirname:
dirname = os.path.dirname(dirname)
if dirname:
ret.add(dirname)
retur... |
Get the cache path for the container in question
Cache paths are generate by combining the account name, container name,
and saltenv, separated by underscores | def _get_container_path(container):
'''
Get the cache path for the container in question
Cache paths are generate by combining the account name, container name,
and saltenv, separated by underscores
'''
root = os.path.join(__opts__['cachedir'], 'azurefs')
container_dir = '{0}_{1}_{2}'.forma... |
Get the azure block blob service for the container in question
Try account_key, sas_token, and no auth in that order | def _get_container_service(container):
'''
Get the azure block blob service for the container in question
Try account_key, sas_token, and no auth in that order
'''
if 'account_key' in container:
account = azure.storage.CloudStorageAccount(container['account_name'], account_key=container['ac... |
Validate azurefs config, return False if it doesn't validate | def _validate_config():
'''
Validate azurefs config, return False if it doesn't validate
'''
if not isinstance(__opts__['azurefs'], list):
log.error('azurefs configuration is not formed as a list, skipping azurefs')
return False
for container in __opts__['azurefs']:
if not is... |
Return useful information from a SmartOS compute node | def _smartos_computenode_data():
'''
Return useful information from a SmartOS compute node
'''
# Provides:
# vms_total
# vms_running
# vms_stopped
# vms_type
# sdc_version
# vm_capable
# vm_hw_virt
grains = {}
# collect vm data
vms = {}
for vm ... |
Return useful information from a SmartOS zone | def _smartos_zone_data():
'''
Return useful information from a SmartOS zone
'''
# Provides:
# zoneid
# zonename
# imageversion
grains = {
'zoneid': __salt__['cmd.run']('zoneadm list -p | awk -F: \'{ print $1 }\'', python_shell=True),
'zonename': __salt__['cmd.run']... |
SmartOS zone pkgsrc information | def _smartos_zone_pkgsrc_data():
'''
SmartOS zone pkgsrc information
'''
# Provides:
# pkgsrcversion
# pkgsrcpath
grains = {
'pkgsrcversion': 'Unknown',
'pkgsrcpath': 'Unknown',
}
pkgsrcversion = re.compile('^release:\\s(.+)')
if os.path.isfile('/etc/pkgsrc_... |
SmartOS zone pkgsrc information | def _smartos_zone_pkgin_data():
'''
SmartOS zone pkgsrc information
'''
# Provides:
# pkgin_repositories
grains = {
'pkgin_repositories': [],
}
pkginrepo = re.compile('^(?:https|http|ftp|file)://.*$')
if os.path.isfile('/opt/local/etc/pkgin/repositories.conf'):
wi... |
Provide grains for SmartOS | def smartos():
'''
Provide grains for SmartOS
'''
grains = {}
if salt.utils.platform.is_smartos_zone():
grains = salt.utils.dictupdate.update(grains, _smartos_zone_data(), merge_lists=True)
grains = salt.utils.dictupdate.update(grains, _smartos_zone_pkgsrc_data(), merge_lists=True)
... |
Listen to salt events and forward them to Logentries | def start(endpoint='data.logentries.com',
port=10000,
token=None,
tag='salt/engines/logentries'):
'''
Listen to salt events and forward them to Logentries
'''
if __opts__.get('id').endswith('_master'):
event_bus = salt.utils.event.get_master_event(
__opt... |
Check if node is peered.
name
The remote host with which to peer.
.. code-block:: yaml
peer-cluster:
glusterfs.peered:
- name: two
peer-clusters:
glusterfs.peered:
- names:
- one
- two
- three
... | def peered(name):
'''
Check if node is peered.
name
The remote host with which to peer.
.. code-block:: yaml
peer-cluster:
glusterfs.peered:
- name: two
peer-clusters:
glusterfs.peered:
- names:
- one
- t... |
Ensure that the volume exists
name
name of the volume
bricks
list of brick paths
replica
replica count for volume
arbiter
use every third brick as arbiter (metadata only)
.. versionadded:: 2019.2.0
start
ensure that the volume is also started
... | def volume_present(name, bricks, stripe=False, replica=False, device_vg=False,
transport='tcp', start=False, force=False, arbiter=False):
'''
Ensure that the volume exists
name
name of the volume
bricks
list of brick paths
replica
replica count for volum... |
Check if volume has been started
name
name of the volume
.. code-block:: yaml
mycluster:
glusterfs.started: [] | def started(name):
'''
Check if volume has been started
name
name of the volume
.. code-block:: yaml
mycluster:
glusterfs.started: []
'''
ret = {'name': name,
'changes': {},
'comment': '',
'result': False}
volinfo = __salt__['glu... |
Add brick(s) to an existing volume
name
Volume name
bricks
List of bricks to add to the volume
.. code-block:: yaml
myvolume:
glusterfs.add_volume_bricks:
- bricks:
- host1:/srv/gluster/drive1
- host2:/srv/gluster/drive2
... | def add_volume_bricks(name, bricks):
'''
Add brick(s) to an existing volume
name
Volume name
bricks
List of bricks to add to the volume
.. code-block:: yaml
myvolume:
glusterfs.add_volume_bricks:
- bricks:
- host1:/srv/gluster/drive1
... |
.. versionadded:: 2019.2.0
Add brick(s) to an existing volume
name
Volume name
version
Version to which the cluster.op-version should be set
.. code-block:: yaml
myvolume:
glusterfs.op_version:
- name: volume1
- version: 30707 | def op_version(name, version):
'''
.. versionadded:: 2019.2.0
Add brick(s) to an existing volume
name
Volume name
version
Version to which the cluster.op-version should be set
.. code-block:: yaml
myvolume:
glusterfs.op_version:
- name: volume1
... |
.. versionadded:: 2019.2.0
Add brick(s) to an existing volume
name
Volume name
.. code-block:: yaml
myvolume:
glusterfs.max_op_version:
- name: volume1
- version: 30707 | def max_op_version(name):
'''
.. versionadded:: 2019.2.0
Add brick(s) to an existing volume
name
Volume name
.. code-block:: yaml
myvolume:
glusterfs.max_op_version:
- name: volume1
- version: 30707
'''
ret = {'name': name,
'ch... |
Get the requests options from salt. | def _prepare_xml(options=None, state=None):
'''
Get the requests options from salt.
'''
if state:
_state = '0'
else:
_state = '2'
xml = "<?xml version='1.0'?>\n<checkresults>\n"
# No service defined then we set the status of the hostname
if 'service' in options and opt... |
Simple function to return value from XML | def _getText(nodelist):
'''
Simple function to return value from XML
'''
rc = []
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc.append(node.data)
return ''.join(rc) |
Post data to Nagios NRDP | def _post_data(options=None, xml=None):
'''
Post data to Nagios NRDP
'''
params = {'token': options['token'].strip(), 'cmd': 'submitcheck', 'XMLDATA': xml}
res = salt.utils.http.query(
url=options['url'],
method='POST',
params=params,
data='',
decode=True,
... |
Send a message to Nagios with the data | def returner(ret):
'''
Send a message to Nagios with the data
'''
_options = _get_options(ret)
log.debug('_options %s', _options)
_options['hostname'] = ret.get('id')
if 'url' not in _options or _options['url'] == '':
log.error('nagios_nrdp.url not defined in salt config')
... |
Return an influxdb client object | def _get_serv(ret=None):
'''
Return an influxdb client object
'''
_options = _get_options(ret)
host = _options.get('host')
port = _options.get('port')
database = _options.get('db')
user = _options.get('user')
password = _options.get('password')
version = _get_version(host, port, ... |
Return data to a influxdb data store | def returner(ret):
'''
Return data to a influxdb data store
'''
serv = _get_serv(ret)
# strip the 'return' key to avoid data duplication in the database
json_return = salt.utils.json.dumps(ret['return'])
del ret['return']
json_full_ret = salt.utils.json.dumps(ret)
# create legacy r... |
Save the load to the specified jid | def save_load(jid, load, minions=None):
'''
Save the load to the specified jid
'''
serv = _get_serv(ret=None)
# create legacy request in case an InfluxDB 0.8.x version is used
if "influxdb08" in serv.__module__:
req = [
{
'name': 'jids',
'colu... |
Return the load data that marks a specified jid | def get_load(jid):
'''
Return the load data that marks a specified jid
'''
serv = _get_serv(ret=None)
sql = "select load from jids where jid = '{0}'".format(jid)
log.debug(">> Now in get_load %s", jid)
data = serv.query(sql)
log.debug(">> Now Data: %s", data)
if data:
return... |
Return the information returned when the specified job id was executed | def get_jid(jid):
'''
Return the information returned when the specified job id was executed
'''
serv = _get_serv(ret=None)
sql = "select id, full_ret from returns where jid = '{0}'".format(jid)
data = serv.query(sql)
ret = {}
if data:
points = data[0]['points']
for poi... |
Return a dict of the last function called for all minions | def get_fun(fun):
'''
Return a dict of the last function called for all minions
'''
serv = _get_serv(ret=None)
sql = '''select first(id) as fid, first(full_ret) as fret
from returns
where fun = '{0}'
group by fun, id
'''.format(fun)
data = serv.que... |
Return a list of all job ids | def get_jids():
'''
Return a list of all job ids
'''
serv = _get_serv(ret=None)
sql = "select distinct(jid) from jids group by load"
# [{u'points': [[0, jid, load],
# [0, jid, load]],
# u'name': u'jids',
# u'columns': [u'time', u'distinct', u'load']}]
data = se... |
Return a list of minions | def get_minions():
'''
Return a list of minions
'''
serv = _get_serv(ret=None)
sql = "select distinct(id) from returns"
data = serv.query(sql)
ret = []
if data:
for jid in data[0]['points']:
ret.append(jid[1])
return ret |
Return the running jobs on the master | def get_running_jobs(opts):
'''
Return the running jobs on the master
'''
ret = []
proc_dir = os.path.join(opts['cachedir'], 'proc')
if not os.path.isdir(proc_dir):
return ret
for fn_ in os.listdir(proc_dir):
path = os.path.join(proc_dir, fn_)
data = read_proc_file(p... |
Return a dict of JID metadata, or None | def read_proc_file(path, opts):
'''
Return a dict of JID metadata, or None
'''
serial = salt.payload.Serial(opts)
with salt.utils.files.fopen(path, 'rb') as fp_:
try:
data = serial.load(fp_)
except Exception as err:
# need to add serial exception here
... |
This is a health check that will confirm the PID is running
and executed by salt.
If pusutil is available:
* all architectures are checked
if psutil is not available:
* Linux/Solaris/etc: archs with `/proc/cmdline` available are checked
* AIX/Windows: assume PID is healhty and retu... | def is_pid_healthy(pid):
'''
This is a health check that will confirm the PID is running
and executed by salt.
If pusutil is available:
* all architectures are checked
if psutil is not available:
* Linux/Solaris/etc: archs with `/proc/cmdline` available are checked
* AIX/Wi... |
Check a whitelist and/or blacklist to see if the value matches it. | def get_values_of_matching_keys(pattern_dict, user_name):
'''
Check a whitelist and/or blacklist to see if the value matches it.
'''
ret = []
for expr in pattern_dict:
if salt.utils.stringutils.expr_match(user_name, expr):
ret.extend(pattern_dict[expr])
return ret |
Get pillar data for the targeted minions, either by fetching the
cached minion data on the master, or by compiling the minion's
pillar data on the master.
For runner modules that need access minion pillar data, this
function should be used instead of getting the pillar data by
e... | def get_minion_pillar(self):
'''
Get pillar data for the targeted minions, either by fetching the
cached minion data on the master, or by compiling the minion's
pillar data on the master.
For runner modules that need access minion pillar data, this
function should be use... |
Get grains data for the targeted minions, either by fetching the
cached minion data on the master, or by fetching the grains
directly on the minion.
By default, this function tries hard to get the grains data:
- Try to get the cached minion grains if the master
has m... | def get_minion_grains(self):
'''
Get grains data for the targeted minions, either by fetching the
cached minion data on the master, or by fetching the grains
directly on the minion.
By default, this function tries hard to get the grains data:
- Try to get the cached ... |
Clear the cached data/files for the targeted minions. | def clear_cached_minion_data(self,
clear_pillar=False,
clear_grains=False,
clear_mine=False,
clear_mine_func=None):
'''
Clear the cached data/files for the targeted minions... |
Get cached mine data for the targeted minions. | def get_cached_mine_data(self):
'''
Get cached mine data for the targeted minions.
'''
mine_data = {}
minion_ids = self._tgt_to_list()
log.debug('Getting cached mine data for: %s', minion_ids)
mine_data = self._get_cached_mine_data(*minion_ids)
return mine... |
main loop that fires the event every second | def run(self):
'''
main loop that fires the event every second
'''
context = zmq.Context()
# the socket for outgoing timer events
socket = context.socket(zmq.PUB)
socket.setsockopt(zmq.LINGER, 100)
socket.bind('ipc://' + self.timer_sock)
count = 0... |
Gather currently connected minions and update the cache | def run(self):
'''
Gather currently connected minions and update the cache
'''
new_mins = list(salt.utils.minions.CkMinions(self.opts).connected_ids())
cc = cache_cli(self.opts)
cc.get_cached()
cc.put_cache([new_mins])
log.debug('ConCache CacheWorker updat... |
remove sockets on shutdown | def cleanup(self):
'''
remove sockets on shutdown
'''
log.debug('ConCache cleaning up')
if os.path.exists(self.cache_sock):
os.remove(self.cache_sock)
if os.path.exists(self.update_sock):
os.remove(self.update_sock)
if os.path.exists(self.u... |
secure the sockets for root-only access | def secure(self):
'''
secure the sockets for root-only access
'''
log.debug('ConCache securing sockets')
if os.path.exists(self.cache_sock):
os.chmod(self.cache_sock, 0o600)
if os.path.exists(self.update_sock):
os.chmod(self.update_sock, 0o600)
... |
shutdown cache process | def stop(self):
'''
shutdown cache process
'''
# avoid getting called twice
self.cleanup()
if self.running:
self.running = False
self.timer_stop.set()
self.timer.join() |
Main loop of the ConCache, starts updates in intervals and
answers requests from the MWorkers | def run(self):
'''
Main loop of the ConCache, starts updates in intervals and
answers requests from the MWorkers
'''
context = zmq.Context()
# the socket for incoming cache requests
creq_in = context.socket(zmq.REP)
creq_in.setsockopt(zmq.LINGER, 100)
... |
Return a response in an SMS message | def returner(ret):
'''
Return a response in an SMS message
'''
_options = _get_options(ret)
sid = _options.get('sid', None)
token = _options.get('token', None)
sender = _options.get('from', None)
receiver = _options.get('to', None)
if sid is None or token is None:
log.error... |
Returns: None if group wasn't found, otherwise a group object | def _common(kwargs):
'''
Returns: None if group wasn't found, otherwise a group object
'''
search_kwargs = {'name': kwargs['name']}
if 'domain' in kwargs:
domain = __salt__['keystoneng.get_entity'](
'domain', name=kwargs.pop('domain'))
domain_id = domain.id ... |
Ensure group does not exist
name
Name of the group
domain
The name or id of the domain | def absent(name, auth=None, **kwargs):
'''
Ensure group does not exist
name
Name of the group
domain
The name or id of the domain
'''
ret = {'name': name,
'changes': {},
'result': True,
'comment': ''}
kwargs = __utils__['args.clean_kwargs']... |
Return a dict of the files located with the given path and environment | def find(path, saltenv='base'):
'''
Return a dict of the files located with the given path and environment
'''
# Return a list of paths + text or bin
ret = []
if saltenv not in __opts__['pillar_roots']:
return ret
for root in __opts__['pillar_roots'][saltenv]:
full = os.path.... |
Return all of the file paths found in an environment | def list_env(saltenv='base'):
'''
Return all of the file paths found in an environment
'''
ret = {}
if saltenv not in __opts__['pillar_roots']:
return ret
for f_root in __opts__['pillar_roots'][saltenv]:
ret[f_root] = {}
for root, dirs, files in salt.utils.path.os_walk(f_... |
Return all of the files names in all available environments | def list_roots():
'''
Return all of the files names in all available environments
'''
ret = {}
for saltenv in __opts__['pillar_roots']:
ret[saltenv] = []
ret[saltenv].append(list_env(saltenv))
return ret |
Read the contents of a text file, if the file is binary then | def read(path, saltenv='base'):
'''
Read the contents of a text file, if the file is binary then
'''
# Return a dict of paths + content
ret = []
files = find(path, saltenv)
for fn_ in files:
full = next(six.iterkeys(fn_))
form = fn_[full]
if form == 'txt':
... |
Write the named file, by default the first file found is written, but the
index of the file can be specified to write to a lower priority file root | def write(data, path, saltenv='base', index=0):
'''
Write the named file, by default the first file found is written, but the
index of the file can be specified to write to a lower priority file root
'''
if saltenv not in __opts__['pillar_roots']:
return 'Named environment {0} is not present... |
.. versionadded:: 2019.2.0
Ensure a resource group exists.
:param name:
Name of the resource group.
:param location:
The Azure location in which to create the resource group. This value cannot be updated once
the resource group is created.
:param managed_by:
The ID of... | def resource_group_present(name, location, managed_by=None, tags=None, connection_auth=None, **kwargs):
'''
.. versionadded:: 2019.2.0
Ensure a resource group exists.
:param name:
Name of the resource group.
:param location:
The Azure location in which to create the resource group... |
.. versionadded:: 2019.2.0
Ensure a resource group does not exist in the current subscription.
:param name:
Name of the resource group.
:param connection_auth:
A dict with subscription and authentication parameters to be used in connecting to the
Azure Resource Manager API. | def resource_group_absent(name, connection_auth=None):
'''
.. versionadded:: 2019.2.0
Ensure a resource group does not exist in the current subscription.
:param name:
Name of the resource group.
:param connection_auth:
A dict with subscription and authentication parameters to be u... |
.. versionadded:: 2019.2.0
Ensure a security policy definition exists.
:param name:
Name of the policy definition.
:param policy_rule:
A YAML dictionary defining the policy rule. See `Azure Policy Definition documentation
<https://docs.microsoft.com/en-us/azure/azure-policy/policy... | def policy_definition_present(name, policy_rule=None, policy_type=None, mode=None, display_name=None, description=None,
metadata=None, parameters=None, policy_rule_json=None, policy_rule_file=None,
template='jinja', source_hash=None, source_hash_name=None, ski... |
.. versionadded:: 2019.2.0
Ensure a policy definition does not exist in the current subscription.
:param name:
Name of the policy definition.
:param connection_auth:
A dict with subscription and authentication parameters to be used in connecting to the
Azure Resource Manager API. | def policy_definition_absent(name, connection_auth=None):
'''
.. versionadded:: 2019.2.0
Ensure a policy definition does not exist in the current subscription.
:param name:
Name of the policy definition.
:param connection_auth:
A dict with subscription and authentication parameter... |
.. versionadded:: 2019.2.0
Ensure a security policy assignment exists.
:param name:
Name of the policy assignment.
:param scope:
The scope of the policy assignment.
:param definition_name:
The name of the policy definition to assign.
:param display_name:
The disp... | def policy_assignment_present(name, scope, definition_name, display_name=None, description=None, assignment_type=None,
parameters=None, connection_auth=None, **kwargs):
'''
.. versionadded:: 2019.2.0
Ensure a security policy assignment exists.
:param name:
Name of... |
Send an xmpp message with the data | def returner(ret):
'''
Send an xmpp message with the data
'''
_options = _get_options(ret)
from_jid = _options.get('from_jid')
password = _options.get('password')
recipient_jid = _options.get('recipient_jid')
if not from_jid:
log.error('xmpp.jid not defined in salt config')
... |
Combine the host header, IP address, and TCP port into bindingInformation format. | def _get_binding_info(hostheader='', ipaddress='*', port=80):
'''
Combine the host header, IP address, and TCP port into bindingInformation format.
'''
ret = r'{0}:{1}:{2}'.format(ipaddress, port, hostheader.replace(' ', ''))
return ret |
Delete a website from IIS.
:param str name: The IIS site name.
Usage:
.. code-block:: yaml
defaultwebsite-remove:
win_iis.remove_site:
- name: Default Web Site | def remove_site(name):
'''
Delete a website from IIS.
:param str name: The IIS site name.
Usage:
.. code-block:: yaml
defaultwebsite-remove:
win_iis.remove_site:
- name: Default Web Site
'''
ret = {'name': name,
'changes': {},
'r... |
Ensure the website has been deployed.
.. note:
This function only validates against the site name, and will return True even
if the site already exists with a different configuration. It will not modify
the configuration of an existing site.
:param str name: The IIS site name.
:pa... | def deployed(name, sourcepath, apppool='', hostheader='', ipaddress='*', port=80, protocol='http', preload=''):
'''
Ensure the website has been deployed.
.. note:
This function only validates against the site name, and will return True even
if the site already exists with a different confi... |
Create an IIS binding.
.. note:
This function only validates against the binding ipaddress:port:hostheader combination,
and will return True even if the binding already exists with a different configuration.
It will not modify the configuration of an existing binding.
:param str site:... | def create_binding(name, site, hostheader='', ipaddress='*', port=80, protocol='http', sslflags=0):
'''
Create an IIS binding.
.. note:
This function only validates against the binding ipaddress:port:hostheader combination,
and will return True even if the binding already exists with a dif... |
Remove an IIS binding.
:param str site: The IIS site name.
:param str hostheader: The host header of the binding.
:param str ipaddress: The IP address of the binding.
:param str port: The TCP port of the binding.
Example of usage with only the required arguments:
.. code-block:: yaml
... | def remove_binding(name, site, hostheader='', ipaddress='*', port=80):
'''
Remove an IIS binding.
:param str site: The IIS site name.
:param str hostheader: The host header of the binding.
:param str ipaddress: The IP address of the binding.
:param str port: The TCP port of the binding.
Ex... |
Assign a certificate to an IIS binding.
.. note:
The web binding that the certificate is being assigned to must already exist.
:param str name: The thumbprint of the certificate.
:param str site: The IIS site name.
:param str hostheader: The host header of the binding.
:param str ipaddres... | def create_cert_binding(name, site, hostheader='', ipaddress='*', port=443, sslflags=0):
'''
Assign a certificate to an IIS binding.
.. note:
The web binding that the certificate is being assigned to must already exist.
:param str name: The thumbprint of the certificate.
:param str site: ... |
Remove a certificate from an IIS binding.
.. note:
This function only removes the certificate from the web binding. It does
not remove the web binding itself.
:param str name: The thumbprint of the certificate.
:param str site: The IIS site name.
:param str hostheader: The host header... | def remove_cert_binding(name, site, hostheader='', ipaddress='*', port=443):
'''
Remove a certificate from an IIS binding.
.. note:
This function only removes the certificate from the web binding. It does
not remove the web binding itself.
:param str name: The thumbprint of the certif... |
Create an IIS application pool.
.. note:
This function only validates against the application pool name, and will return
True even if the application pool already exists with a different configuration.
It will not modify the configuration of an existing application pool.
:param str na... | def create_apppool(name):
'''
Create an IIS application pool.
.. note:
This function only validates against the application pool name, and will return
True even if the application pool already exists with a different configuration.
It will not modify the configuration of an existin... |
Remove an IIS application pool.
:param str name: The name of the IIS application pool.
Usage:
.. code-block:: yaml
defaultapppool-remove:
win_iis.remove_apppool:
- name: DefaultAppPool | def remove_apppool(name):
# Remove IIS AppPool
'''
Remove an IIS application pool.
:param str name: The name of the IIS application pool.
Usage:
.. code-block:: yaml
defaultapppool-remove:
win_iis.remove_apppool:
- name: DefaultAppPool
'''
ret = {... |
Set the value of the setting for an IIS container.
:param str name: The name of the IIS container.
:param str container: The type of IIS container. The container types are:
AppPools, Sites, SslBindings
:param str settings: A dictionary of the setting names and their values.
Example of usage... | def container_setting(name, container, settings=None):
'''
Set the value of the setting for an IIS container.
:param str name: The name of the IIS container.
:param str container: The type of IIS container. The container types are:
AppPools, Sites, SslBindings
:param str settings: A diction... |
Create an IIS application.
.. note:
This function only validates against the application name, and will return True
even if the application already exists with a different configuration. It will not
modify the configuration of an existing application.
:param str name: The IIS applicat... | def create_app(name, site, sourcepath, apppool=None):
'''
Create an IIS application.
.. note:
This function only validates against the application name, and will return True
even if the application already exists with a different configuration. It will not
modify the configuration ... |
Remove an IIS application.
:param str name: The application name.
:param str site: The IIS site name.
Usage:
.. code-block:: yaml
site0-v1-app-remove:
win_iis.remove_app:
- name: v1
- site: site0 | def remove_app(name, site):
'''
Remove an IIS application.
:param str name: The application name.
:param str site: The IIS site name.
Usage:
.. code-block:: yaml
site0-v1-app-remove:
win_iis.remove_app:
- name: v1
- site: site0
'''
... |
Create an IIS virtual directory.
.. note:
This function only validates against the virtual directory name, and will return
True even if the virtual directory already exists with a different configuration.
It will not modify the configuration of an existing virtual directory.
:param st... | def create_vdir(name, site, sourcepath, app='/'):
'''
Create an IIS virtual directory.
.. note:
This function only validates against the virtual directory name, and will return
True even if the virtual directory already exists with a different configuration.
It will not modify the ... |
Remove an IIS virtual directory.
:param str name: The virtual directory name.
:param str site: The IIS site name.
:param str app: The IIS application.
Example of usage with only the required arguments:
.. code-block:: yaml
site0-foo-vdir-remove:
win_iis.remove_vdir:
... | def remove_vdir(name, site, app='/'):
'''
Remove an IIS virtual directory.
:param str name: The virtual directory name.
:param str site: The IIS site name.
:param str app: The IIS application.
Example of usage with only the required arguments:
.. code-block:: yaml
site0-foo-vdir-... |
.. versionadded:: 2017.7.0
Set the value of the setting for an IIS web application.
.. note::
This function only configures existing app. Params are case sensitive.
:param str name: The IIS application.
:param str site: The IIS site name.
:param str settings: A dictionary of the setting n... | def set_app(name, site, settings=None):
# pylint: disable=anomalous-backslash-in-string
'''
.. versionadded:: 2017.7.0
Set the value of the setting for an IIS web application.
.. note::
This function only configures existing app. Params are case sensitive.
:param str name: The IIS app... |
r'''
Set the value of webconfiguration settings.
:param str name: The name of the IIS PSPath containing the settings.
Possible PSPaths are :
MACHINE, MACHINE/WEBROOT, IIS:\, IIS:\Sites\sitename, ...
:param str location: The location of the settings.
:param dict settings: Dictionaries of... | def webconfiguration_settings(name, location='', settings=None):
r'''
Set the value of webconfiguration settings.
:param str name: The name of the IIS PSPath containing the settings.
Possible PSPaths are :
MACHINE, MACHINE/WEBROOT, IIS:\, IIS:\Sites\sitename, ...
:param str location: Th... |
Tries to guess the url of zabbix frontend.
.. versionadded:: 2016.3.0 | def _frontend_url():
'''
Tries to guess the url of zabbix frontend.
.. versionadded:: 2016.3.0
'''
hostname = socket.gethostname()
frontend_url = 'http://' + hostname + '/zabbix/api_jsonrpc.php'
try:
try:
response = salt.utils.http.query(frontend_url)
error =... |
JSON request to Zabbix API.
.. versionadded:: 2016.3.0
:param method: actual operation to perform via the API
:param params: parameters required for specific method
:param url: url of zabbix api
:param auth: auth token for zabbix api (only for methods with required authentication)
:return: Re... | def _query(method, params, url, auth=None):
'''
JSON request to Zabbix API.
.. versionadded:: 2016.3.0
:param method: actual operation to perform via the API
:param params: parameters required for specific method
:param url: url of zabbix api
:param auth: auth token for zabbix api (only fo... |
Log in to the API and generate the authentication token.
.. versionadded:: 2016.3.0
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring... | def _login(**kwargs):
'''
Log in to the API and generate the authentication token.
.. versionadded:: 2016.3.0
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_password: Optional - zabbix password (can also be set in opts... |
Extends the params dictionary by values from keyword arguments.
.. versionadded:: 2016.3.0
:param params: Dictionary with parameters for zabbix API.
:param _ignore_name: Salt State module is passing first line as 'name' parameter. If API uses optional parameter
'name' (for ex. host_create, user_create... | def _params_extend(params, _ignore_name=False, **kwargs):
'''
Extends the params dictionary by values from keyword arguments.
.. versionadded:: 2016.3.0
:param params: Dictionary with parameters for zabbix API.
:param _ignore_name: Salt State module is passing first line as 'name' parameter. If AP... |
.. versionadded:: 2017.7
Go through Zabbix object params specification and if needed get given object ID from Zabbix API and put it back
as a value. Definition of the object is done via dict with keys "query_object" and "query_name".
:param input_object: Zabbix object type specified in state file
:par... | def substitute_params(input_object, extend_params=None, filter_key='name', **kwargs):
'''
.. versionadded:: 2017.7
Go through Zabbix object params specification and if needed get given object ID from Zabbix API and put it back
as a value. Definition of the object is done via dict with keys "query_objec... |
.. versionadded:: 2017.7
Compares Zabbix object definition against existing Zabbix object.
:param defined: Zabbix object definition taken from sls file.
:param existing: Existing Zabbix object taken from result of an API call.
:param return_old_value: Default False. If True, returns dict("old"=old_val... | def compare_params(defined, existing, return_old_value=False):
'''
.. versionadded:: 2017.7
Compares Zabbix object definition against existing Zabbix object.
:param defined: Zabbix object definition taken from sls file.
:param existing: Existing Zabbix object taken from result of an API call.
... |
.. versionadded:: 2017.7
Get ID of single Zabbix object specified by its name.
:param obj: Zabbix object type
:param params: Parameters by which object is uniquely identified
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connect... | def get_object_id_by_params(obj, params=None, **kwargs):
'''
.. versionadded:: 2017.7
Get ID of single Zabbix object specified by its name.
:param obj: Zabbix object type
:param params: Parameters by which object is uniquely identified
:param _connection_user: Optional - zabbix user (can also ... |
Retrieve the version of the Zabbix API.
.. versionadded:: 2016.3.0
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
:param _con... | def apiinfo_version(**kwargs):
'''
Retrieve the version of the Zabbix API.
.. versionadded:: 2016.3.0
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_password: Optional - zabbix password (can also be set in opts or pill... |
.. versionadded:: 2016.3.0
Create new zabbix user
.. note::
This function accepts all standard user properties: keyword argument
names differ depending on your zabbix version, see here__.
.. __: https://www.zabbix.com/documentation/2.0/manual/appendix/api/user/definitions#user
:p... | def user_create(alias, passwd, usrgrps, **kwargs):
'''
.. versionadded:: 2016.3.0
Create new zabbix user
.. note::
This function accepts all standard user properties: keyword argument
names differ depending on your zabbix version, see here__.
.. __: https://www.zabbix.com/docu... |
Delete zabbix users.
.. versionadded:: 2016.3.0
:param users: array of users (userids) to delete
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see m... | def user_delete(users, **kwargs):
'''
Delete zabbix users.
.. versionadded:: 2016.3.0
:param users: array of users (userids) to delete
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_password: Optional - zabbix pass... |
Checks if user with given alias exists.
.. versionadded:: 2016.3.0
:param alias: user alias
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module... | def user_exists(alias, **kwargs):
'''
Checks if user with given alias exists.
.. versionadded:: 2016.3.0
:param alias: user alias
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_password: Optional - zabbix password ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.