repository_name stringclasses 316
values | func_path_in_repository stringlengths 6 223 | func_name stringlengths 1 134 | language stringclasses 1
value | func_code_string stringlengths 57 65.5k | func_documentation_string stringlengths 1 46.3k | split_name stringclasses 1
value | func_code_url stringlengths 91 315 | called_functions listlengths 1 156 ⌀ | enclosing_scope stringlengths 2 1.48M |
|---|---|---|---|---|---|---|---|---|---|
saltstack/salt | salt/pillar/virtkey.py | ext_pillar | python | def ext_pillar(hyper_id, pillar, name, key):
'''
Accept the key for the VM on the hyper, if authorized.
'''
vk = salt.utils.virt.VirtKey(hyper_id, name, __opts__)
ok = vk.accept(key)
pillar['virtkey'] = {name: ok}
return {} | Accept the key for the VM on the hyper, if authorized. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/pillar/virtkey.py#L21-L28 | [
"def accept(self, pub):\n '''\n Accept the provided key\n '''\n try:\n with salt.utils.files.fopen(self.path, 'r') as fp_:\n expiry = int(fp_.read())\n except (OSError, IOError):\n log.error(\n 'Request to sign key for minion \\'%s\\' on hyper \\'%s\\' '\n ... | # -*- coding: utf-8 -*-
'''
Accept a key from a hypervisor if the virt runner has already submitted an authorization request
'''
from __future__ import absolute_import, print_function, unicode_literals
# Don't "fix" the above docstring to put it on two lines, as the sphinx
# autosummary pulls only the first line for i... |
saltstack/salt | salt/states/lvm.py | pv_present | python | def pv_present(name, **kwargs):
'''
Set a Physical Device to be used as an LVM Physical Volume
name
The device name to initialize.
kwargs
Any supported options to pvcreate. See
:mod:`linux_lvm <salt.modules.linux_lvm>` for more details.
'''
ret = {'changes': {},
... | Set a Physical Device to be used as an LVM Physical Volume
name
The device name to initialize.
kwargs
Any supported options to pvcreate. See
:mod:`linux_lvm <salt.modules.linux_lvm>` for more details. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/lvm.py#L43-L74 | null | # -*- coding: utf-8 -*-
'''
Management of Linux logical volumes
===================================
A state module to manage LVMs
.. code-block:: yaml
/dev/sda:
lvm.pv_present
my_vg:
lvm.vg_present:
- devices: /dev/sda
lvroot:
lvm.lv_present:
- vgname: my_vg
- ... |
saltstack/salt | salt/states/lvm.py | pv_absent | python | def pv_absent(name):
'''
Ensure that a Physical Device is not being used by lvm
name
The device name to initialize.
'''
ret = {'changes': {},
'comment': '',
'name': name,
'result': True}
if not __salt__['lvm.pvdisplay'](name, quiet=True):
ret['c... | Ensure that a Physical Device is not being used by lvm
name
The device name to initialize. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/lvm.py#L77-L104 | null | # -*- coding: utf-8 -*-
'''
Management of Linux logical volumes
===================================
A state module to manage LVMs
.. code-block:: yaml
/dev/sda:
lvm.pv_present
my_vg:
lvm.vg_present:
- devices: /dev/sda
lvroot:
lvm.lv_present:
- vgname: my_vg
- ... |
saltstack/salt | salt/states/lvm.py | vg_present | python | def vg_present(name, devices=None, **kwargs):
'''
Create an LVM Volume Group
name
The Volume Group name to create
devices
A list of devices that will be added to the Volume Group
kwargs
Any supported options to vgcreate. See
:mod:`linux_lvm <salt.modules.linux_lvm>... | Create an LVM Volume Group
name
The Volume Group name to create
devices
A list of devices that will be added to the Volume Group
kwargs
Any supported options to vgcreate. See
:mod:`linux_lvm <salt.modules.linux_lvm>` for more details. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/lvm.py#L107-L173 | null | # -*- coding: utf-8 -*-
'''
Management of Linux logical volumes
===================================
A state module to manage LVMs
.. code-block:: yaml
/dev/sda:
lvm.pv_present
my_vg:
lvm.vg_present:
- devices: /dev/sda
lvroot:
lvm.lv_present:
- vgname: my_vg
- ... |
saltstack/salt | salt/states/lvm.py | lv_present | python | def lv_present(name,
vgname=None,
size=None,
extents=None,
snapshot=None,
pv='',
thinvolume=False,
thinpool=False,
force=False,
**kwargs):
'''
Create a new Logical Volume
n... | Create a new Logical Volume
name
The name of the Logical Volume
vgname
The name of the Volume Group on which the Logical Volume resides
size
The initial size of the Logical Volume
extents
The number of logical extents to allocate
snapshot
The name of the ... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/lvm.py#L206-L295 | null | # -*- coding: utf-8 -*-
'''
Management of Linux logical volumes
===================================
A state module to manage LVMs
.. code-block:: yaml
/dev/sda:
lvm.pv_present
my_vg:
lvm.vg_present:
- devices: /dev/sda
lvroot:
lvm.lv_present:
- vgname: my_vg
- ... |
saltstack/salt | salt/states/lvm.py | lv_absent | python | def lv_absent(name, vgname=None):
'''
Remove a given existing Logical Volume from a named existing volume group
name
The Logical Volume to remove
vgname
The name of the Volume Group on which the Logical Volume resides
'''
ret = {'changes': {},
'comment': '',
... | Remove a given existing Logical Volume from a named existing volume group
name
The Logical Volume to remove
vgname
The name of the Volume Group on which the Logical Volume resides | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/lvm.py#L298-L329 | null | # -*- coding: utf-8 -*-
'''
Management of Linux logical volumes
===================================
A state module to manage LVMs
.. code-block:: yaml
/dev/sda:
lvm.pv_present
my_vg:
lvm.vg_present:
- devices: /dev/sda
lvroot:
lvm.lv_present:
- vgname: my_vg
- ... |
saltstack/salt | salt/sdb/consul.py | get_conn | python | def get_conn(profile):
'''
Return a client object for accessing consul
'''
params = {}
for key in ('host', 'port', 'token', 'scheme', 'consistency', 'dc', 'verify'):
if key in profile:
params[key] = profile[key]
if HAS_CONSUL:
return consul.Consul(**params)
else:... | Return a client object for accessing consul | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/sdb/consul.py#L66-L81 | null | # -*- coding: utf-8 -*-
'''
Consul sdb Module
:maintainer: SaltStack
:maturity: New
:platform: all
This module allows access to Consul using an ``sdb://`` URI
Like all sdb modules, the Consul module requires a configuration profile to
be configured in either the minion or master configuration file. This... |
saltstack/salt | salt/returners/kafka_return.py | _delivery_report | python | def _delivery_report(err, msg):
''' Called once for each message produced to indicate delivery result.
Triggered by poll() or flush(). '''
if err is not None:
log.error('Message delivery failed: %s', err)
else:
log.debug('Message delivered to %s [%s]', msg.topic(), msg.partition()) | Called once for each message produced to indicate delivery result.
Triggered by poll() or flush(). | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/kafka_return.py#L61-L67 | null | # -*- coding: utf-8 -*-
'''
Return data to a Kafka topic
:maintainer: Justin Desilets (justin.desilets@gmail.com)
:maturity: 20181119
:depends: confluent-kafka
:platform: all
To enable this returner install confluent-kafka and enable the following
settings in the minion config:
returner.kafka.bootstrap:
-... |
saltstack/salt | salt/returners/kafka_return.py | returner | python | def returner(ret):
'''
Return information to a Kafka server
'''
if __salt__['config.option']('returner.kafka.topic'):
topic = __salt__['config.option']('returner.kafka.topic')
conn = _get_conn()
producer = Producer({'bootstrap.servers': conn})
producer.poll(0)
pr... | Return information to a Kafka server | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/kafka_return.py#L70-L84 | [
"def dumps(obj, **kwargs):\n '''\n .. versionadded:: 2018.3.0\n\n Wraps json.dumps, and assumes that ensure_ascii is False (unless explicitly\n passed as True) for unicode compatibility. Note that setting it to True\n will mess up any unicode characters, as they will be dumped as the string\n lite... | # -*- coding: utf-8 -*-
'''
Return data to a Kafka topic
:maintainer: Justin Desilets (justin.desilets@gmail.com)
:maturity: 20181119
:depends: confluent-kafka
:platform: all
To enable this returner install confluent-kafka and enable the following
settings in the minion config:
returner.kafka.bootstrap:
-... |
saltstack/salt | salt/states/composer.py | installed | python | def installed(name,
composer=None,
php=None,
user=None,
prefer_source=None,
prefer_dist=None,
no_scripts=None,
no_plugins=None,
optimize=None,
no_dev=None,
quiet=False,
... | Verify that the correct versions of composer dependencies are present.
name
Directory location of the ``composer.json`` file.
composer
Location of the ``composer.phar`` file. If not set composer will
just execute ``composer`` as if it is installed globally.
(i.e. ``/path/to/com... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/composer.py#L53-L182 | null | # -*- coding: utf-8 -*-
'''
Installation of Composer Packages
=================================
These states manage the installed packages for composer for PHP. Note that
either composer is installed and accessible via a bin directory or you can pass
the location of composer in the state.
.. code-block:: yaml
ge... |
saltstack/salt | salt/states/composer.py | update | python | def update(name,
composer=None,
php=None,
user=None,
prefer_source=None,
prefer_dist=None,
no_scripts=None,
no_plugins=None,
optimize=None,
no_dev=None,
quiet=False,
composer_home='/root',
... | Composer update the directory to ensure we have the latest versions
of all project dependencies.
name
Directory location of the ``composer.json`` file.
composer
Location of the ``composer.phar`` file. If not set composer will
just execute ``composer`` as if it is installed globally... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/composer.py#L185-L301 | null | # -*- coding: utf-8 -*-
'''
Installation of Composer Packages
=================================
These states manage the installed packages for composer for PHP. Note that
either composer is installed and accessible via a bin directory or you can pass
the location of composer in the state.
.. code-block:: yaml
ge... |
saltstack/salt | salt/modules/boto_elasticache.py | exists | python | def exists(name, region=None, key=None, keyid=None, profile=None):
'''
Check to see if a cache cluster exists.
CLI example::
salt myminion boto_elasticache.exists myelasticache
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
try:
conn.describe_cache_... | Check to see if a cache cluster exists.
CLI example::
salt myminion boto_elasticache.exists myelasticache | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L87-L102 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/modules/boto_elasticache.py | group_exists | python | def group_exists(name, region=None, key=None, keyid=None, profile=None):
'''
Check to see if a replication group exists.
CLI example::
salt myminion boto_elasticache.group_exists myelasticache
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
try:
conn... | Check to see if a replication group exists.
CLI example::
salt myminion boto_elasticache.group_exists myelasticache | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L105-L120 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/modules/boto_elasticache.py | create_replication_group | python | def create_replication_group(name, primary_cluster_id, replication_group_description,
wait=None, region=None, key=None,
keyid=None, profile=None):
'''
Create replication group.
CLI example::
salt myminion boto_elasticache.create_replication... | Create replication group.
CLI example::
salt myminion boto_elasticache.create_replication_group myelasticache myprimarycluster description | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L123-L154 | [
"def describe_replication_group(name, region=None, key=None, keyid=None,\n profile=None, parameter=None):\n '''\n Get replication group information.\n\n CLI example::\n\n salt myminion boto_elasticache.describe_replication_group mygroup\n '''\n conn = _get_conn(re... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/modules/boto_elasticache.py | describe_replication_group | python | def describe_replication_group(name, region=None, key=None, keyid=None,
profile=None, parameter=None):
'''
Get replication group information.
CLI example::
salt myminion boto_elasticache.describe_replication_group mygroup
'''
conn = _get_conn(region=region, k... | Get replication group information.
CLI example::
salt myminion boto_elasticache.describe_replication_group mygroup | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L181-L241 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n"
] | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/modules/boto_elasticache.py | get_config | python | def get_config(name, region=None, key=None, keyid=None, profile=None):
'''
Get the configuration for a cache cluster.
CLI example::
salt myminion boto_elasticache.get_config myelasticache
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
if not conn:
r... | Get the configuration for a cache cluster.
CLI example::
salt myminion boto_elasticache.get_config myelasticache | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L244-L307 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n"
] | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/modules/boto_elasticache.py | get_node_host | python | def get_node_host(name, region=None, key=None, keyid=None, profile=None):
'''
Get hostname from cache node
CLI example::
salt myminion boto_elasticache.get_node_host myelasticache
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
if not conn:
return No... | Get hostname from cache node
CLI example::
salt myminion boto_elasticache.get_node_host myelasticache | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L310-L333 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/modules/boto_elasticache.py | get_group_host | python | def get_group_host(name, region=None, key=None, keyid=None, profile=None):
'''
Get hostname from replication cache group
CLI example::
salt myminion boto_elasticache.get_group_host myelasticachegroup
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
if not con... | Get hostname from replication cache group
CLI example::
salt myminion boto_elasticache.get_group_host myelasticachegroup | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L336-L359 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/modules/boto_elasticache.py | get_all_cache_subnet_groups | python | def get_all_cache_subnet_groups(name=None, region=None, key=None,
keyid=None, profile=None):
'''
Return a list of all cache subnet groups with details
CLI example::
salt myminion boto_elasticache.get_all_subnet_groups region=us-east-1
'''
conn = _get_conn(re... | Return a list of all cache subnet groups with details
CLI example::
salt myminion boto_elasticache.get_all_subnet_groups region=us-east-1 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L362-L387 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/modules/boto_elasticache.py | list_cache_subnet_groups | python | def list_cache_subnet_groups(name=None, region=None, key=None,
keyid=None, profile=None):
'''
Return a list of all cache subnet group names
CLI example::
salt myminion boto_elasticache.list_subnet_groups region=us-east-1
'''
return [g['CacheSubnetGroupName'] fo... | Return a list of all cache subnet group names
CLI example::
salt myminion boto_elasticache.list_subnet_groups region=us-east-1 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L390-L400 | [
"def get_all_cache_subnet_groups(name=None, region=None, key=None,\n keyid=None, profile=None):\n '''\n Return a list of all cache subnet groups with details\n\n CLI example::\n\n salt myminion boto_elasticache.get_all_subnet_groups region=us-east-1\n '''\n conn ... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/modules/boto_elasticache.py | subnet_group_exists | python | def subnet_group_exists(name, tags=None, region=None, key=None, keyid=None, profile=None):
'''
Check to see if an ElastiCache subnet group exists.
CLI example::
salt myminion boto_elasticache.subnet_group_exists my-param-group \
region=us-east-1
'''
conn = _get_conn(region=... | Check to see if an ElastiCache subnet group exists.
CLI example::
salt myminion boto_elasticache.subnet_group_exists my-param-group \
region=us-east-1 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L403-L424 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/modules/boto_elasticache.py | create_subnet_group | python | def create_subnet_group(name, description, subnet_ids=None, subnet_names=None, tags=None,
region=None, key=None, keyid=None, profile=None):
'''
Create an ElastiCache subnet group
CLI example to create an ElastiCache subnet group::
salt myminion boto_elasticache.create_subne... | Create an ElastiCache subnet group
CLI example to create an ElastiCache subnet group::
salt myminion boto_elasticache.create_subnet_group my-subnet-group \
"group description" subnet_ids='[subnet-12345678, subnet-87654321]' \
region=us-east-1 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L427-L468 | [
"def subnet_group_exists(name, tags=None, region=None, key=None, keyid=None, profile=None):\n '''\n Check to see if an ElastiCache subnet group exists.\n\n CLI example::\n\n salt myminion boto_elasticache.subnet_group_exists my-param-group \\\n region=us-east-1\n '''\n conn = _g... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/modules/boto_elasticache.py | get_cache_subnet_group | python | def get_cache_subnet_group(name, region=None, key=None, keyid=None,
profile=None):
'''
Get information about a cache subnet group.
CLI example::
salt myminion boto_elasticache.get_cache_subnet_group mycache_subnet_group
'''
conn = _get_conn(region=region, key=key... | Get information about a cache subnet group.
CLI example::
salt myminion boto_elasticache.get_cache_subnet_group mycache_subnet_group | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L471-L513 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n"
] | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/modules/boto_elasticache.py | delete_subnet_group | python | def delete_subnet_group(name, region=None, key=None, keyid=None, profile=None):
'''
Delete an ElastiCache subnet group.
CLI example::
salt myminion boto_elasticache.delete_subnet_group my-subnet-group \
region=us-east-1
'''
conn = _get_conn(region=region, key=key, keyid=key... | Delete an ElastiCache subnet group.
CLI example::
salt myminion boto_elasticache.delete_subnet_group my-subnet-group \
region=us-east-1 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L516-L537 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/modules/boto_elasticache.py | create | python | def create(name, num_cache_nodes=None, engine=None, cache_node_type=None,
replication_group_id=None, engine_version=None,
cache_parameter_group_name=None, cache_subnet_group_name=None,
cache_security_group_names=None, security_group_ids=None,
snapshot_arns=None, preferred_ava... | Create a cache cluster.
CLI example::
salt myminion boto_elasticache.create myelasticache 1 redis cache.t1.micro
cache_security_group_names='["myelasticachesg"]' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L540-L581 | [
"def get_config(name, region=None, key=None, keyid=None, profile=None):\n '''\n Get the configuration for a cache cluster.\n\n CLI example::\n\n salt myminion boto_elasticache.get_config myelasticache\n '''\n conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)\n\n if not ... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/modules/boto_elasticache.py | delete | python | def delete(name, wait=False, region=None, key=None, keyid=None, profile=None):
'''
Delete a cache cluster.
CLI example::
salt myminion boto_elasticache.delete myelasticache
'''
conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)
try:
conn.delete_cache_cluste... | Delete a cache cluster.
CLI example::
salt myminion boto_elasticache.delete myelasticache | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L584-L612 | [
"def get_config(name, region=None, key=None, keyid=None, profile=None):\n '''\n Get the configuration for a cache cluster.\n\n CLI example::\n\n salt myminion boto_elasticache.get_config myelasticache\n '''\n conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile)\n\n if not ... | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/modules/boto_elasticache.py | create_cache_security_group | python | def create_cache_security_group(name, description, region=None, key=None,
keyid=None, profile=None):
'''
Create a cache security group.
CLI example::
salt myminion boto_elasticache.create_cache_security_group myelasticachesg 'My Cache Security Group'
'''
con... | Create a cache security group.
CLI example::
salt myminion boto_elasticache.create_cache_security_group myelasticachesg 'My Cache Security Group' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L615-L633 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/modules/boto_elasticache.py | delete_cache_security_group | python | def delete_cache_security_group(name, region=None, key=None, keyid=None,
profile=None):
'''
Delete a cache security group.
CLI example::
salt myminion boto_elasticache.delete_cache_security_group myelasticachesg 'My Cache Security Group'
'''
conn = _get_conn... | Delete a cache security group.
CLI example::
salt myminion boto_elasticache.delete_cache_security_group myelasticachesg 'My Cache Security Group' | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L636-L654 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/modules/boto_elasticache.py | authorize_cache_security_group_ingress | python | def authorize_cache_security_group_ingress(name, ec2_security_group_name,
ec2_security_group_owner_id,
region=None, key=None, keyid=None,
profile=None):
'''
Authorize network ingress ... | Authorize network ingress from an ec2 security group to a cache security
group.
CLI example::
salt myminion boto_elasticache.authorize_cache_security_group_ingress myelasticachesg myec2sg 879879 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L657-L689 | null | # -*- coding: utf-8 -*-
'''
Connection module for Amazon Elasticache
.. versionadded:: 2014.7.0
:configuration: This module accepts explicit elasticache credentials but can
also utilize IAM roles assigned to the instance through Instance Profiles.
Dynamic credentials are then automatically obtained from AWS A... |
saltstack/salt | salt/output/__init__.py | try_printout | python | def try_printout(data, out, opts, **kwargs):
'''
Safely get the string to print out, try the configured outputter, then
fall back to nested and then to raw
'''
try:
printout = get_printout(out, opts)(data, **kwargs)
if printout is not None:
return printout.rstrip()
ex... | Safely get the string to print out, try the configured outputter, then
fall back to nested and then to raw | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L37-L56 | [
"def get_printout(out, opts=None, **kwargs):\n '''\n Return a printer function\n '''\n if opts is None:\n opts = {}\n\n if 'output' in opts and opts['output'] != 'highstate':\n # new --out option, but don't choke when using --out=highstate at CLI\n # See Issue #29796 for more inf... | # -*- coding: utf-8 -*-
'''
Used to manage the outputter system. This package is the modular system used
for managing outputters.
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import errno
import logging
import io
import os
import re
import sys
import traceback
# I... |
saltstack/salt | salt/output/__init__.py | get_progress | python | def get_progress(opts, out, progress):
'''
Get the progress bar from the given outputter
'''
return salt.loader.raw_mod(opts,
out,
'rawmodule',
mod='output')['{0}.progress_iter'.format(out)](progress) | Get the progress bar from the given outputter | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L59-L66 | null | # -*- coding: utf-8 -*-
'''
Used to manage the outputter system. This package is the modular system used
for managing outputters.
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import errno
import logging
import io
import os
import re
import sys
import traceback
# I... |
saltstack/salt | salt/output/__init__.py | update_progress | python | def update_progress(opts, progress, progress_iter, out):
'''
Update the progress iterator for the given outputter
'''
# Look up the outputter
try:
progress_outputter = salt.loader.outputters(opts)[out]
except KeyError: # Outputter is not loaded
log.warning('Progress outputter no... | Update the progress iterator for the given outputter | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L69-L79 | null | # -*- coding: utf-8 -*-
'''
Used to manage the outputter system. This package is the modular system used
for managing outputters.
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import errno
import logging
import io
import os
import re
import sys
import traceback
# I... |
saltstack/salt | salt/output/__init__.py | display_output | python | def display_output(data, out=None, opts=None, **kwargs):
'''
Print the passed data using the desired output
'''
if opts is None:
opts = {}
display_data = try_printout(data, out, opts, **kwargs)
output_filename = opts.get('output_file', None)
log.trace('data = %s', data)
try:
... | Print the passed data using the desired output | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L90-L132 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Used to manage the outputter system. This package is the modular system used
for managing outputters.
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import errno
import logging
import io
import os
import re
import sys
import traceback
# I... |
saltstack/salt | salt/output/__init__.py | get_printout | python | def get_printout(out, opts=None, **kwargs):
'''
Return a printer function
'''
if opts is None:
opts = {}
if 'output' in opts and opts['output'] != 'highstate':
# new --out option, but don't choke when using --out=highstate at CLI
# See Issue #29796 for more information.
... | Return a printer function | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L135-L198 | null | # -*- coding: utf-8 -*-
'''
Used to manage the outputter system. This package is the modular system used
for managing outputters.
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import errno
import logging
import io
import os
import re
import sys
import traceback
# I... |
saltstack/salt | salt/output/__init__.py | out_format | python | def out_format(data, out, opts=None, **kwargs):
'''
Return the formatted outputter string for the passed data
'''
return try_printout(data, out, opts, **kwargs) | Return the formatted outputter string for the passed data | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L201-L205 | [
"def try_printout(data, out, opts, **kwargs):\n '''\n Safely get the string to print out, try the configured outputter, then\n fall back to nested and then to raw\n '''\n try:\n printout = get_printout(out, opts)(data, **kwargs)\n if printout is not None:\n return printout.rs... | # -*- coding: utf-8 -*-
'''
Used to manage the outputter system. This package is the modular system used
for managing outputters.
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import errno
import logging
import io
import os
import re
import sys
import traceback
# I... |
saltstack/salt | salt/output/__init__.py | string_format | python | def string_format(data, out, opts=None, **kwargs):
'''
Return the formatted outputter string, removing the ANSI escape sequences.
'''
raw_output = try_printout(data, out, opts, **kwargs)
ansi_escape = re.compile(r'\x1b[^m]*m')
return ansi_escape.sub('', raw_output) | Return the formatted outputter string, removing the ANSI escape sequences. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L208-L214 | [
"def try_printout(data, out, opts, **kwargs):\n '''\n Safely get the string to print out, try the configured outputter, then\n fall back to nested and then to raw\n '''\n try:\n printout = get_printout(out, opts)(data, **kwargs)\n if printout is not None:\n return printout.rs... | # -*- coding: utf-8 -*-
'''
Used to manage the outputter system. This package is the modular system used
for managing outputters.
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import errno
import logging
import io
import os
import re
import sys
import traceback
# I... |
saltstack/salt | salt/output/__init__.py | html_format | python | def html_format(data, out, opts=None, **kwargs):
'''
Return the formatted string as HTML.
'''
ansi_escaped_string = string_format(data, out, opts, **kwargs)
return ansi_escaped_string.replace(' ', ' ').replace('\n', '<br />') | Return the formatted string as HTML. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L217-L222 | [
"def string_format(data, out, opts=None, **kwargs):\n '''\n Return the formatted outputter string, removing the ANSI escape sequences.\n '''\n raw_output = try_printout(data, out, opts, **kwargs)\n ansi_escape = re.compile(r'\\x1b[^m]*m')\n return ansi_escape.sub('', raw_output)\n"
] | # -*- coding: utf-8 -*-
'''
Used to manage the outputter system. This package is the modular system used
for managing outputters.
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import errno
import logging
import io
import os
import re
import sys
import traceback
# I... |
saltstack/salt | salt/output/__init__.py | strip_esc_sequence | python | def strip_esc_sequence(txt):
'''
Replace ESC (ASCII 27/Oct 33) to prevent unsafe strings
from writing their own terminal manipulation commands
'''
if isinstance(txt, six.string_types):
try:
return txt.replace('\033', '?')
except UnicodeDecodeError:
return txt.... | Replace ESC (ASCII 27/Oct 33) to prevent unsafe strings
from writing their own terminal manipulation commands | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L225-L236 | null | # -*- coding: utf-8 -*-
'''
Used to manage the outputter system. This package is the modular system used
for managing outputters.
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
import errno
import logging
import io
import os
import re
import sys
import traceback
# I... |
saltstack/salt | salt/utils/dns.py | _tree | python | def _tree(domain, tld=False):
'''
Split out a domain in its parents
Leverages tldextract to take the TLDs from publicsuffix.org
or makes a valiant approximation of that
:param domain: dc2.ams2.example.com
:param tld: Include TLD in list
:return: [ 'dc2.ams2.example.com', 'ams2.example.com'... | Split out a domain in its parents
Leverages tldextract to take the TLDs from publicsuffix.org
or makes a valiant approximation of that
:param domain: dc2.ams2.example.com
:param tld: Include TLD in list
:return: [ 'dc2.ams2.example.com', 'ams2.example.com', 'example.com'] | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L134-L166 | null | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | _data2rec | python | def _data2rec(schema, rec_data):
'''
schema = OrderedDict({
'prio': int,
'weight': int,
'port': to_port,
'name': str,
})
rec_data = '10 20 25 myawesome.nl'
res = {'prio': 10, 'weight': 20, 'port': 25 'name': 'myawesome.nl'}
'''
try:
rec_fields = rec_d... | schema = OrderedDict({
'prio': int,
'weight': int,
'port': to_port,
'name': str,
})
rec_data = '10 20 25 myawesome.nl'
res = {'prio': 10, 'weight': 20, 'port': 25 'name': 'myawesome.nl'} | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L195-L228 | [
"def _cast(rec_data, rec_cast):\n if isinstance(rec_cast, dict):\n rec_data = type(rec_cast.keys()[0])(rec_data)\n res = rec_cast[rec_data]\n return res\n elif isinstance(rec_cast, (list, tuple)):\n return RFC.validate(rec_data, rec_cast)\n else:\n return rec_cast(rec_dat... | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | _lookup_dig | python | def _lookup_dig(name, rdtype, timeout=None, servers=None, secure=None):
'''
Use dig to lookup addresses
:param name: Name of record to search
:param rdtype: DNS record type
:param timeout: server response timeout
:param servers: [] of servers to use
:return: [] of records or False if error
... | Use dig to lookup addresses
:param name: Name of record to search
:param rdtype: DNS record type
:param timeout: server response timeout
:param servers: [] of servers to use
:return: [] of records or False if error | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L271-L319 | null | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | _lookup_drill | python | def _lookup_drill(name, rdtype, timeout=None, servers=None, secure=None):
'''
Use drill to lookup addresses
:param name: Name of record to search
:param rdtype: DNS record type
:param timeout: command return timeout
:param servers: [] of servers to use
:return: [] of records or False if erro... | Use drill to lookup addresses
:param name: Name of record to search
:param rdtype: DNS record type
:param timeout: command return timeout
:param servers: [] of servers to use
:return: [] of records or False if error | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L322-L375 | null | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | _lookup_gai | python | def _lookup_gai(name, rdtype, timeout=None):
'''
Use Python's socket interface to lookup addresses
:param name: Name of record to search
:param rdtype: A or AAAA
:param timeout: ignored
:return: [] of addresses or False if error
'''
try:
sock_t = {
'A': socket.AF_I... | Use Python's socket interface to lookup addresses
:param name: Name of record to search
:param rdtype: A or AAAA
:param timeout: ignored
:return: [] of addresses or False if error | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L378-L401 | null | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | _lookup_host | python | def _lookup_host(name, rdtype, timeout=None, server=None):
'''
Use host to lookup addresses
:param name: Name of record to search
:param server: Server to query
:param rdtype: DNS record type
:param timeout: server response wait
:return: [] of records or False if error
'''
cmd = 'hos... | Use host to lookup addresses
:param name: Name of record to search
:param server: Server to query
:param rdtype: DNS record type
:param timeout: server response wait
:return: [] of records or False if error | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L404-L443 | null | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | _lookup_dnspython | python | def _lookup_dnspython(name, rdtype, timeout=None, servers=None, secure=None):
'''
Use dnspython to lookup addresses
:param name: Name of record to search
:param rdtype: DNS record type
:param timeout: query timeout
:param server: [] of server(s) to try in order
:return: [] of records or Fals... | Use dnspython to lookup addresses
:param name: Name of record to search
:param rdtype: DNS record type
:param timeout: query timeout
:param server: [] of server(s) to try in order
:return: [] of records or False if error | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L446-L474 | null | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | _lookup_nslookup | python | def _lookup_nslookup(name, rdtype, timeout=None, server=None):
'''
Use nslookup to lookup addresses
:param name: Name of record to search
:param rdtype: DNS record type
:param timeout: server response timeout
:param server: server to query
:return: [] of records or False if error
'''
... | Use nslookup to lookup addresses
:param name: Name of record to search
:param rdtype: DNS record type
:param timeout: server response timeout
:param server: server to query
:return: [] of records or False if error | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L477-L543 | null | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | lookup | python | def lookup(
name,
rdtype,
method=None,
servers=None,
timeout=None,
walk=False,
walk_tld=False,
secure=None
):
'''
Lookup DNS records and return their data
:param name: name to lookup
:param rdtype: DNS record type
:param method: gai (getaddrinfo()), dnspython, dig, d... | Lookup DNS records and return their data
:param name: name to lookup
:param rdtype: DNS record type
:param method: gai (getaddrinfo()), dnspython, dig, drill, host, nslookup or auto (default)
:param servers: (list of) server(s) to try in-order
:param timeout: query timeout or a valiant approximatio... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L546-L654 | null | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | query | python | def query(
name,
rdtype,
method=None,
servers=None,
timeout=None,
walk=False,
walk_tld=False,
secure=None
):
'''
Query DNS for information.
Where `lookup()` returns record data, `query()` tries to interpret the data and return it's results
:param name: name to lookup
... | Query DNS for information.
Where `lookup()` returns record data, `query()` tries to interpret the data and return it's results
:param name: name to lookup
:param rdtype: DNS record type
:param method: gai (getaddrinfo()), pydns, dig, drill, host, nslookup or auto (default)
:param servers: (list of)... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L657-L723 | [
"def lookup(\n name,\n rdtype,\n method=None,\n servers=None,\n timeout=None,\n walk=False,\n walk_tld=False,\n secure=None\n):\n '''\n Lookup DNS records and return their data\n\n :param name: name to lookup\n :param rdtype: DNS record type\n :param method: gai (getaddrinfo()... | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | host | python | def host(name, ip4=True, ip6=True, **kwargs):
'''
Return a list of addresses for name
ip6:
Return IPv6 addresses
ip4:
Return IPv4 addresses
the rest is passed on to lookup()
'''
res = {}
if ip6:
ip6 = lookup(name, 'AAAA', **kwargs)
if ip6:
re... | Return a list of addresses for name
ip6:
Return IPv6 addresses
ip4:
Return IPv4 addresses
the rest is passed on to lookup() | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L726-L747 | [
"def lookup(\n name,\n rdtype,\n method=None,\n servers=None,\n timeout=None,\n walk=False,\n walk_tld=False,\n secure=None\n):\n '''\n Lookup DNS records and return their data\n\n :param name: name to lookup\n :param rdtype: DNS record type\n :param method: gai (getaddrinfo()... | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | caa_rec | python | def caa_rec(rdatas):
'''
Validate and parse DNS record data for a CAA record
:param rdata: DNS record data
:return: dict w/fields
'''
rschema = OrderedDict((
('flags', lambda flag: ['critical'] if int(flag) > 0 else []),
('tag', RFC.CAA_TAGS),
('value', lambda val: val.st... | Validate and parse DNS record data for a CAA record
:param rdata: DNS record data
:return: dict w/fields | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L774-L799 | [
"def _data2rec_group(schema, recs_data, group_key):\n if not isinstance(recs_data, (list, tuple)):\n recs_data = [recs_data]\n\n res = OrderedDict()\n\n try:\n for rdata in recs_data:\n rdata = _data2rec(schema, rdata)\n assert rdata and group_key in rdata\n\n ... | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | ptr_name | python | def ptr_name(rdata):
'''
Return PTR name of given IP
:param rdata: IP address
:return: PTR record name
'''
try:
return ipaddress.ip_address(rdata).reverse_pointer
except ValueError:
log.error(
'Unable to generate PTR record; %s is not a valid IP address',
... | Return PTR name of given IP
:param rdata: IP address
:return: PTR record name | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L825-L838 | null | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | soa_rec | python | def soa_rec(rdata):
'''
Validate and parse DNS record data for SOA record(s)
:param rdata: DNS record data
:return: dict w/fields
'''
rschema = OrderedDict((
('mname', str),
('rname', str),
('serial', int),
('refresh', int),
('retry', int),
('expir... | Validate and parse DNS record data for SOA record(s)
:param rdata: DNS record data
:return: dict w/fields | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L841-L856 | [
"def _data2rec(schema, rec_data):\n '''\n schema = OrderedDict({\n 'prio': int,\n 'weight': int,\n 'port': to_port,\n 'name': str,\n })\n rec_data = '10 20 25 myawesome.nl'\n\n res = {'prio': 10, 'weight': 20, 'port': 25 'name': 'myawesome.nl'}\n '''\n try:\n ... | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | spf_rec | python | def spf_rec(rdata):
'''
Validate and parse DNS record data for SPF record(s)
:param rdata: DNS record data
:return: dict w/fields
'''
spf_fields = rdata.split(' ')
if not spf_fields.pop(0).startswith('v=spf'):
raise ValueError('Not an SPF record')
res = OrderedDict()
mods = ... | Validate and parse DNS record data for SPF record(s)
:param rdata: DNS record data
:return: dict w/fields | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L859-L911 | null | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | srv_data | python | def srv_data(target, port, prio=10, weight=10):
'''
Generate SRV record data
:param target:
:param port:
:param prio:
:param weight:
:return:
'''
return _rec2data(prio, weight, port, target) | Generate SRV record data
:param target:
:param port:
:param prio:
:param weight:
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L914-L923 | [
"def _rec2data(*rdata):\n return ' '.join(rdata)\n"
] | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | srv_name | python | def srv_name(svc, proto='tcp', domain=None):
'''
Generate SRV record name
:param svc: ldap, 389 etc
:param proto: tcp, udp, sctp etc.
:param domain: name to append
:return:
'''
proto = RFC.validate(proto, RFC.SRV_PROTO)
if isinstance(svc, int) or svc.isdigit():
svc = _to_port... | Generate SRV record name
:param svc: ldap, 389 etc
:param proto: tcp, udp, sctp etc.
:param domain: name to append
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L926-L940 | [
"def _to_port(port):\n try:\n port = int(port)\n assert 1 <= port <= 65535\n return port\n except (ValueError, AssertionError):\n raise ValueError('Invalid port {0}'.format(port))\n",
"def validate(lookup, ref, match=None):\n if lookup in ref:\n return lookup\n elif ... | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | srv_rec | python | def srv_rec(rdatas):
'''
Validate and parse DNS record data for SRV record(s)
:param rdata: DNS record data
:return: dict w/fields
'''
rschema = OrderedDict((
('prio', int),
('weight', int),
('port', _to_port),
('name', str),
))
return _data2rec_group(rsch... | Validate and parse DNS record data for SRV record(s)
:param rdata: DNS record data
:return: dict w/fields | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L943-L955 | [
"def _data2rec_group(schema, recs_data, group_key):\n if not isinstance(recs_data, (list, tuple)):\n recs_data = [recs_data]\n\n res = OrderedDict()\n\n try:\n for rdata in recs_data:\n rdata = _data2rec(schema, rdata)\n assert rdata and group_key in rdata\n\n ... | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | sshfp_data | python | def sshfp_data(key_t, hash_t, pub):
'''
Generate an SSHFP record
:param key_t: rsa/dsa/ecdsa/ed25519
:param hash_t: sha1/sha256
:param pub: the SSH public key
'''
key_t = RFC.validate(key_t, RFC.SSHFP_ALGO, 'in')
hash_t = RFC.validate(hash_t, RFC.SSHFP_HASH)
hasher = hashlib.new(has... | Generate an SSHFP record
:param key_t: rsa/dsa/ecdsa/ed25519
:param hash_t: sha1/sha256
:param pub: the SSH public key | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L958-L974 | [
"def _rec2data(*rdata):\n return ' '.join(rdata)\n",
"def validate(lookup, ref, match=None):\n if lookup in ref:\n return lookup\n elif match == 'in':\n return [code for code, name in ref.items() if lookup in name][-1]\n else:\n # OrderedDicts only!(?)\n return ref.keys()[r... | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | sshfp_rec | python | def sshfp_rec(rdata):
'''
Validate and parse DNS record data for TLSA record(s)
:param rdata: DNS record data
:return: dict w/fields
'''
rschema = OrderedDict((
('algorithm', RFC.SSHFP_ALGO),
('fp_hash', RFC.SSHFP_HASH),
('fingerprint', lambda val: val.lower()) # resolve... | Validate and parse DNS record data for TLSA record(s)
:param rdata: DNS record data
:return: dict w/fields | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L977-L989 | [
"def _data2rec(schema, rec_data):\n '''\n schema = OrderedDict({\n 'prio': int,\n 'weight': int,\n 'port': to_port,\n 'name': str,\n })\n rec_data = '10 20 25 myawesome.nl'\n\n res = {'prio': 10, 'weight': 20, 'port': 25 'name': 'myawesome.nl'}\n '''\n try:\n ... | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | tlsa_data | python | def tlsa_data(pub, usage, selector, matching):
'''
Generate a TLSA rec
:param pub: Pub key in PEM format
:param usage:
:param selector:
:param matching:
:return: TLSA data portion
'''
usage = RFC.validate(usage, RFC.TLSA_USAGE)
selector = RFC.validate(selector, RFC.TLSA_SELECT)
... | Generate a TLSA rec
:param pub: Pub key in PEM format
:param usage:
:param selector:
:param matching:
:return: TLSA data portion | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L992-L1015 | [
"def _rec2data(*rdata):\n return ' '.join(rdata)\n",
"def validate(lookup, ref, match=None):\n if lookup in ref:\n return lookup\n elif match == 'in':\n return [code for code, name in ref.items() if lookup in name][-1]\n else:\n # OrderedDicts only!(?)\n return ref.keys()[r... | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | tlsa_rec | python | def tlsa_rec(rdata):
'''
Validate and parse DNS record data for TLSA record(s)
:param rdata: DNS record data
:return: dict w/fields
'''
rschema = OrderedDict((
('usage', RFC.TLSA_USAGE),
('selector', RFC.TLSA_SELECT),
('matching', RFC.TLSA_MATCHING),
('pub', str)
... | Validate and parse DNS record data for TLSA record(s)
:param rdata: DNS record data
:return: dict w/fields | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L1018-L1031 | [
"def _data2rec(schema, rec_data):\n '''\n schema = OrderedDict({\n 'prio': int,\n 'weight': int,\n 'port': to_port,\n 'name': str,\n })\n rec_data = '10 20 25 myawesome.nl'\n\n res = {'prio': 10, 'weight': 20, 'port': 25 'name': 'myawesome.nl'}\n '''\n try:\n ... | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | service | python | def service(
svc,
proto='tcp',
domain=None,
walk=False,
secure=None
):
'''
Find an SRV service in a domain or it's parents
:param svc: service to find (ldap, 389, etc)
:param proto: protocol the service talks (tcp, udp, etc)
:param domain: domain to start search in
:param wal... | Find an SRV service in a domain or it's parents
:param svc: service to find (ldap, 389, etc)
:param proto: protocol the service talks (tcp, udp, etc)
:param domain: domain to start search in
:param walk: walk the parents if domain doesn't provide the service
:param secure: only return DNSSEC-validat... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L1034-L1061 | [
"def query(\n name,\n rdtype,\n method=None,\n servers=None,\n timeout=None,\n walk=False,\n walk_tld=False,\n secure=None\n):\n '''\n Query DNS for information.\n Where `lookup()` returns record data, `query()` tries to interpret the data and return it's results\n\n :param name:... | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | services | python | def services(services_file='/etc/services'):
'''
Parse through system-known services
:return: {
'svc': [
{ 'port': port
'proto': proto,
'desc': comment
},
],
}
'''
res = {}
with salt.utils.files.fopen(services_file, 'r') as svc_d... | Parse through system-known services
:return: {
'svc': [
{ 'port': port
'proto': proto,
'desc': comment
},
],
} | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L1064-L1125 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/utils/dns.py | parse_resolv | python | def parse_resolv(src='/etc/resolv.conf'):
'''
Parse a resolver configuration file (traditionally /etc/resolv.conf)
'''
nameservers = []
ip4_nameservers = []
ip6_nameservers = []
search = []
sortlist = []
domain = ''
options = []
try:
with salt.utils.files.fopen(src)... | Parse a resolver configuration file (traditionally /etc/resolv.conf) | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L1128-L1224 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Compendium of generic DNS utilities
# Examples:
dns.lookup(name, rdtype, ...)
dns.query(name, rdtype, ...)
dns.srv_rec(data)
dns.srv_data('my1.example.com', 389, prio=10, weight=100)
dns.srv_name('ldap/tcp', 'example.com')
'''
from __future__ import absolute_import, print_function, unicode... |
saltstack/salt | salt/returners/__init__.py | get_returner_options | python | def get_returner_options(virtualname=None,
ret=None,
attrs=None,
**kwargs):
'''
Get the returner options from salt.
:param str virtualname: The returner virtualname (as returned
by __virtual__()
:param ret: result of the... | Get the returner options from salt.
:param str virtualname: The returner virtualname (as returned
by __virtual__()
:param ret: result of the module that ran. dict-like object
May contain a `ret_config` key pointing to a string
If a `ret_config` is specified, config options are read fro... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/__init__.py#L16-L107 | [
"def _fetch_ret_config(ret):\n \"\"\"\n Fetches 'ret_config' if available.\n\n @see :func:`get_returner_options`\n \"\"\"\n if not ret:\n return None\n if 'ret_config' not in ret:\n return ''\n return six.text_type(ret['ret_config'])\n",
"def _options_browser(cfg, ret_config, de... | # -*- coding: utf-8 -*-
'''
Returners Directory
:func:`get_returner_options` is a general purpose function that returners may
use to fetch their configuration options.
'''
from __future__ import absolute_import, print_function, unicode_literals
import logging
from salt.ext import six
log = logging.getLogger(__name__... |
saltstack/salt | salt/returners/__init__.py | _fetch_option | python | def _fetch_option(cfg, ret_config, virtualname, attr_name):
# c_cfg is a dictionary returned from config.option for
# any options configured for this returner.
if isinstance(cfg, dict):
c_cfg = cfg
else:
c_cfg = cfg('{0}'.format(virtualname), {})
default_cfg_key = '{0}.{1}'.format(v... | Fetch a given option value from the config.
@see :func:`get_returner_options` | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/__init__.py#L123-L166 | null | # -*- coding: utf-8 -*-
'''
Returners Directory
:func:`get_returner_options` is a general purpose function that returners may
use to fetch their configuration options.
'''
from __future__ import absolute_import, print_function, unicode_literals
import logging
from salt.ext import six
log = logging.getLogger(__name__... |
saltstack/salt | salt/returners/__init__.py | _options_browser | python | def _options_browser(cfg, ret_config, defaults, virtualname, options):
for option in options:
# default place for the option in the config
value = _fetch_option(cfg, ret_config, virtualname, options[option])
if value:
yield option, value
continue
# Attribu... | Iterator generating all duples ```option name -> value```
@see :func:`get_returner_options` | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/__init__.py#L169-L193 | [
"def _fetch_option(cfg, ret_config, virtualname, attr_name):\n \"\"\"\n Fetch a given option value from the config.\n\n @see :func:`get_returner_options`\n \"\"\"\n # c_cfg is a dictionary returned from config.option for\n # any options configured for this returner.\n if isinstance(cfg, dict):\... | # -*- coding: utf-8 -*-
'''
Returners Directory
:func:`get_returner_options` is a general purpose function that returners may
use to fetch their configuration options.
'''
from __future__ import absolute_import, print_function, unicode_literals
import logging
from salt.ext import six
log = logging.getLogger(__name__... |
saltstack/salt | salt/returners/__init__.py | _fetch_profile_opts | python | def _fetch_profile_opts(
cfg, virtualname,
__salt__,
_options,
profile_attr,
profile_attrs
):
if (not profile_attr) or (profile_attr not in _options):
return {}
# Using a profile and it is in _options
creds = {}
profile = _options[profile_attr]
... | Fetches profile specific options if applicable
@see :func:`get_returner_options`
:return: a options dict | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/__init__.py#L196-L235 | null | # -*- coding: utf-8 -*-
'''
Returners Directory
:func:`get_returner_options` is a general purpose function that returners may
use to fetch their configuration options.
'''
from __future__ import absolute_import, print_function, unicode_literals
import logging
from salt.ext import six
log = logging.getLogger(__name__... |
saltstack/salt | salt/states/rabbitmq_plugin.py | enabled | python | def enabled(name, runas=None):
'''
Ensure the RabbitMQ plugin is enabled.
name
The name of the plugin
runas
The user to run the rabbitmq-plugin command as
'''
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
try:
plugin_enabled = __salt__['rabbitm... | Ensure the RabbitMQ plugin is enabled.
name
The name of the plugin
runas
The user to run the rabbitmq-plugin command as | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/rabbitmq_plugin.py#L35-L73 | null | # -*- coding: utf-8 -*-
'''
Manage RabbitMQ Plugins
=======================
.. versionadded:: 2014.1.0
Example:
.. code-block:: yaml
some_plugin:
rabbitmq_plugin.enabled: []
'''
# Import Python Libs
from __future__ import absolute_import, unicode_literals, print_function
import logging
# Import Salt Lib... |
saltstack/salt | salt/states/git.py | _revs_equal | python | def _revs_equal(rev1, rev2, rev_type):
'''
Shorthand helper function for comparing SHA1s. If rev_type == 'sha1' then
the comparison will be done using str.startwith() to allow short SHA1s to
compare successfully.
NOTE: This means that rev2 must be the short rev.
'''
if (rev1 is None and rev... | Shorthand helper function for comparing SHA1s. If rev_type == 'sha1' then
the comparison will be done using str.startwith() to allow short SHA1s to
compare successfully.
NOTE: This means that rev2 must be the short rev. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L47-L63 | null | # -*- coding: utf-8 -*-
'''
States to manage git repositories and git configuration
.. important::
Before using git over ssh, make sure your remote host fingerprint exists in
your ``~/.ssh/known_hosts`` file.
.. versionchanged:: 2015.8.8
This state module now requires git 1.6.5 (released 10 October 2009) ... |
saltstack/salt | salt/states/git.py | _get_branch_opts | python | def _get_branch_opts(branch, local_branch, all_local_branches,
desired_upstream, git_ver=None):
'''
DRY helper to build list of opts for git.branch, for the purposes of
setting upstream tracking branch
'''
if branch is not None and branch not in all_local_branches:
# We ... | DRY helper to build list of opts for git.branch, for the purposes of
setting upstream tracking branch | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L87-L110 | null | # -*- coding: utf-8 -*-
'''
States to manage git repositories and git configuration
.. important::
Before using git over ssh, make sure your remote host fingerprint exists in
your ``~/.ssh/known_hosts`` file.
.. versionchanged:: 2015.8.8
This state module now requires git 1.6.5 (released 10 October 2009) ... |
saltstack/salt | salt/states/git.py | _get_local_rev_and_branch | python | def _get_local_rev_and_branch(target, user, password, output_encoding=None):
'''
Return the local revision for before/after comparisons
'''
log.info('Checking local revision for %s', target)
try:
local_rev = __salt__['git.revision'](
target,
user=user,
pas... | Return the local revision for before/after comparisons | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L113-L141 | null | # -*- coding: utf-8 -*-
'''
States to manage git repositories and git configuration
.. important::
Before using git over ssh, make sure your remote host fingerprint exists in
your ``~/.ssh/known_hosts`` file.
.. versionchanged:: 2015.8.8
This state module now requires git 1.6.5 (released 10 October 2009) ... |
saltstack/salt | salt/states/git.py | present | python | def present(name,
force=False,
bare=True,
template=None,
separate_git_dir=None,
shared=None,
user=None,
password=None,
output_encoding=None):
'''
Ensure that a repository exists in the given directory
.. warning... | Ensure that a repository exists in the given directory
.. warning::
If the minion has Git 2.5 or later installed, ``name`` points to a
worktree_, and ``force`` is set to ``True``, then the worktree will be
deleted. This has been corrected in Salt 2015.8.0.
name
Path to the dire... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L2063-L2235 | [
"def _neutral_test(ret, comment):\n ret['result'] = None\n ret['comment'] = comment\n return ret\n"
] | # -*- coding: utf-8 -*-
'''
States to manage git repositories and git configuration
.. important::
Before using git over ssh, make sure your remote host fingerprint exists in
your ``~/.ssh/known_hosts`` file.
.. versionchanged:: 2015.8.8
This state module now requires git 1.6.5 (released 10 October 2009) ... |
saltstack/salt | salt/states/git.py | detached | python | def detached(name,
rev,
target=None,
remote='origin',
user=None,
password=None,
force_clone=False,
force_checkout=False,
fetch_remote=True,
hard_reset=False,
submodules=False,
identity=None,
... | .. versionadded:: 2016.3.0
Make sure a repository is cloned to the given target directory and is
a detached HEAD checkout of the commit ID resolved from ``rev``.
name
Address of the remote repository.
rev
The branch, tag, or commit ID to checkout after clone.
If a branch or ta... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L2238-L2761 | [
"def clean_kwargs(**kwargs):\n '''\n Return a dict without any of the __pub* keys (or any other keys starting\n with a dunder) from the kwargs dict passed into the execution module\n functions. These keys are useful for tracking what was used to invoke\n the function call, but they may not be desirab... | # -*- coding: utf-8 -*-
'''
States to manage git repositories and git configuration
.. important::
Before using git over ssh, make sure your remote host fingerprint exists in
your ``~/.ssh/known_hosts`` file.
.. versionchanged:: 2015.8.8
This state module now requires git 1.6.5 (released 10 October 2009) ... |
saltstack/salt | salt/states/git.py | cloned | python | def cloned(name,
target=None,
branch=None,
user=None,
password=None,
identity=None,
https_user=None,
https_pass=None,
output_encoding=None):
'''
.. versionadded:: 2018.3.3,2019.2.0
Ensure that a repository has been clon... | .. versionadded:: 2018.3.3,2019.2.0
Ensure that a repository has been cloned to the specified target directory.
If not, clone that repository. No fetches will be performed once cloned.
name
Address of the remote repository
target
Name of the target directory where repository should be... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L2764-L2957 | null | # -*- coding: utf-8 -*-
'''
States to manage git repositories and git configuration
.. important::
Before using git over ssh, make sure your remote host fingerprint exists in
your ``~/.ssh/known_hosts`` file.
.. versionchanged:: 2015.8.8
This state module now requires git 1.6.5 (released 10 October 2009) ... |
saltstack/salt | salt/states/git.py | config_unset | python | def config_unset(name,
value_regex=None,
repo=None,
user=None,
password=None,
output_encoding=None,
**kwargs):
r'''
.. versionadded:: 2015.8.0
Ensure that the named config key is not present
name
... | r'''
.. versionadded:: 2015.8.0
Ensure that the named config key is not present
name
The name of the configuration key to unset. This value can be a regex,
but the regex must match the entire key name. For example, ``foo\.``
would not match all keys in the ``foo`` section, it would... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L2960-L3217 | [
"def clean_kwargs(**kwargs):\n '''\n Return a dict without any of the __pub* keys (or any other keys starting\n with a dunder) from the kwargs dict passed into the execution module\n functions. These keys are useful for tracking what was used to invoke\n the function call, but they may not be desirab... | # -*- coding: utf-8 -*-
'''
States to manage git repositories and git configuration
.. important::
Before using git over ssh, make sure your remote host fingerprint exists in
your ``~/.ssh/known_hosts`` file.
.. versionchanged:: 2015.8.8
This state module now requires git 1.6.5 (released 10 October 2009) ... |
saltstack/salt | salt/states/git.py | config_set | python | def config_set(name,
value=None,
multivar=None,
repo=None,
user=None,
password=None,
output_encoding=None,
**kwargs):
'''
.. versionadded:: 2014.7.0
.. versionchanged:: 2015.8.0
Renamed from ``gi... | .. versionadded:: 2014.7.0
.. versionchanged:: 2015.8.0
Renamed from ``git.config`` to ``git.config_set``. For earlier
versions, use ``git.config``.
Ensure that a config value is set to the desired value(s)
name
Name of the git config value to set
value
Set a single va... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L3220-L3438 | [
"def clean_kwargs(**kwargs):\n '''\n Return a dict without any of the __pub* keys (or any other keys starting\n with a dunder) from the kwargs dict passed into the execution module\n functions. These keys are useful for tracking what was used to invoke\n the function call, but they may not be desirab... | # -*- coding: utf-8 -*-
'''
States to manage git repositories and git configuration
.. important::
Before using git over ssh, make sure your remote host fingerprint exists in
your ``~/.ssh/known_hosts`` file.
.. versionchanged:: 2015.8.8
This state module now requires git 1.6.5 (released 10 October 2009) ... |
saltstack/salt | salt/states/git.py | mod_run_check | python | def mod_run_check(cmd_kwargs, onlyif, unless):
'''
Execute the onlyif and unless logic. Return a result dict if:
* onlyif failed (onlyif != 0)
* unless succeeded (unless == 0)
Otherwise, returns ``True``
'''
cmd_kwargs = copy.deepcopy(cmd_kwargs)
cmd_kwargs.update({
'use_vt': F... | Execute the onlyif and unless logic. Return a result dict if:
* onlyif failed (onlyif != 0)
* unless succeeded (unless == 0)
Otherwise, returns ``True`` | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L3441-L3512 | null | # -*- coding: utf-8 -*-
'''
States to manage git repositories and git configuration
.. important::
Before using git over ssh, make sure your remote host fingerprint exists in
your ``~/.ssh/known_hosts`` file.
.. versionchanged:: 2015.8.8
This state module now requires git 1.6.5 (released 10 October 2009) ... |
saltstack/salt | salt/modules/pushbullet.py | push_note | python | def push_note(device=None, title=None, body=None):
'''
Pushing a text note.
:param device: Pushbullet target device
:param title: Note title
:param body: Note body
:return: Boolean if message was sent successfully.
CLI Example:
.. code-block:: bash
salt "... | Pushing a text note.
:param device: Pushbullet target device
:param title: Note title
:param body: Note body
:return: Boolean if message was sent successfully.
CLI Example:
.. code-block:: bash
salt "*" pushbullet.push_note device="Chrome" title="Example title" b... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pushbullet.py#L65-L84 | [
"def push_note(self, title, body):\n push = self.pb.push_note(title, body, device=self.target)\n return push\n"
] | # -*- coding: utf-8 -*-
'''
Module for sending messages to Pushbullet (https://www.pushbullet.com)
.. versionadded:: 2015.8.0
Requires an ``api_key`` in ``/etc/salt/minion``:
.. code-block: yaml
pushbullet:
api_key: 'ABC123abc123ABC123abc123ABC123ab'
For example:
.. code-block:: yaml
pushbullet:
... |
saltstack/salt | salt/modules/travisci.py | verify_webhook | python | def verify_webhook(signature, body):
'''
Verify the webhook signature from travisci
signature
The signature header from the webhook header
body
The full payload body from the webhook post
.. note:: The body needs to be the urlencoded version of the body.
CLI Example:
.. ... | Verify the webhook signature from travisci
signature
The signature header from the webhook header
body
The full payload body from the webhook post
.. note:: The body needs to be the urlencoded version of the body.
CLI Example:
.. code-block:: bash
salt '*' travisci.veri... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/travisci.py#L42-L77 | [
"def loads(s, **kwargs):\n '''\n .. versionadded:: 2018.3.0\n\n Wraps json.loads and prevents a traceback in the event that a bytestring is\n passed to the function. (Python < 3.6 cannot load bytestrings)\n\n You can pass an alternate json module (loaded via import_json() above)\n using the _json_... | # -*- coding: utf-8 -*-
'''
Commands for working with travisci.
:depends: pyOpenSSL >= 16.0.0
'''
# Import python libraries
from __future__ import absolute_import, unicode_literals, print_function
import base64
try:
import OpenSSL
import OpenSSL.crypto
HAS_OPENSSL = True
except ImportError:
HAS_OPENS... |
saltstack/salt | salt/states/network.py | managed | python | def managed(name, type, enabled=True, **kwargs):
'''
Ensure that the named interface is configured properly.
name
The name of the interface to manage
type
Type of interface and configuration.
enabled
Designates the state of this interface.
kwargs
The IP parame... | Ensure that the named interface is configured properly.
name
The name of the interface to manage
type
Type of interface and configuration.
enabled
Designates the state of this interface.
kwargs
The IP parameters for this interface. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/network.py#L359-L551 | [
"def interfaces():\n '''\n Return a dictionary of information about all the interfaces on the minion\n '''\n if salt.utils.platform.is_windows():\n return win_interfaces()\n elif salt.utils.platform.is_netbsd():\n return netbsd_interfaces()\n else:\n return linux_interfaces()\... | # -*- coding: utf-8 -*-
'''
Configuration of network interfaces
===================================
The network module is used to create and manage network settings,
interfaces can be set as either managed or ignored. By default
all interfaces are ignored unless specified.
.. note::
RedHat-based systems (RHEL, C... |
saltstack/salt | salt/states/network.py | routes | python | def routes(name, **kwargs):
'''
Manage network interface static routes.
name
Interface name to apply the route to.
kwargs
Named routes
'''
ret = {
'name': name,
'changes': {},
'result': True,
'comment': 'Interface {0} routes are up to date.'.form... | Manage network interface static routes.
name
Interface name to apply the route to.
kwargs
Named routes | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/network.py#L554-L614 | null | # -*- coding: utf-8 -*-
'''
Configuration of network interfaces
===================================
The network module is used to create and manage network settings,
interfaces can be set as either managed or ignored. By default
all interfaces are ignored unless specified.
.. note::
RedHat-based systems (RHEL, C... |
saltstack/salt | salt/states/network.py | system | python | def system(name, **kwargs):
'''
Ensure that global network settings are configured properly.
name
Custom name to represent this configuration change.
kwargs
The global parameters for the system.
'''
ret = {
'name': name,
'changes': {},
'result': True,
... | Ensure that global network settings are configured properly.
name
Custom name to represent this configuration change.
kwargs
The global parameters for the system. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/network.py#L617-L678 | null | # -*- coding: utf-8 -*-
'''
Configuration of network interfaces
===================================
The network module is used to create and manage network settings,
interfaces can be set as either managed or ignored. By default
all interfaces are ignored unless specified.
.. note::
RedHat-based systems (RHEL, C... |
saltstack/salt | salt/states/zabbix_mediatype.py | present | python | def present(name, mediatype, **kwargs):
'''
Creates new mediatype.
NOTE: This function accepts all standard mediatype properties: keyword argument names differ depending on your
zabbix version, see:
https://www.zabbix.com/documentation/3.0/manual/api/reference/host/object#host_inventory
:param ... | Creates new mediatype.
NOTE: This function accepts all standard mediatype properties: keyword argument names differ depending on your
zabbix version, see:
https://www.zabbix.com/documentation/3.0/manual/api/reference/host/object#host_inventory
:param name: name of the mediatype
:param _connection_u... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zabbix_mediatype.py#L23-L319 | null | # -*- coding: utf-8 -*-
'''
Management of Zabbix mediatypes.
:codeauthor: Raymond Kuiper <qix@the-wired.net>
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
# Import Salt libs
from salt.ext import six
def __virtual__():
'''
Only make these states available... |
saltstack/salt | salt/states/zabbix_mediatype.py | absent | python | def absent(name, **kwargs):
'''
Ensures that the mediatype does not exist, eventually deletes the mediatype.
:param name: name of the mediatype
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_password: Optional - zabbix ... | Ensures that the mediatype does not exist, eventually deletes the mediatype.
:param name: name of the mediatype
: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 pil... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zabbix_mediatype.py#L322-L386 | null | # -*- coding: utf-8 -*-
'''
Management of Zabbix mediatypes.
:codeauthor: Raymond Kuiper <qix@the-wired.net>
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
# Import Salt libs
from salt.ext import six
def __virtual__():
'''
Only make these states available... |
saltstack/salt | salt/utils/network.py | sanitize_host | python | def sanitize_host(host):
'''
Sanitize host string.
https://tools.ietf.org/html/rfc1123#section-2.1
'''
RFC952_characters = ascii_letters + digits + ".-"
return "".join([c for c in host[0:255] if c in RFC952_characters]) | Sanitize host string.
https://tools.ietf.org/html/rfc1123#section-2.1 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L58-L64 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | isportopen | python | def isportopen(host, port):
'''
Return status of a port
'''
if not 1 <= int(port) <= 65535:
return False
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
out = sock.connect_ex((sanitize_host(host), int(port)))
return out | Return status of a port | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L67-L78 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | host_to_ips | python | def host_to_ips(host):
'''
Returns a list of IP addresses of a given hostname or None if not found.
'''
ips = []
try:
for family, socktype, proto, canonname, sockaddr in socket.getaddrinfo(
host, 0, socket.AF_UNSPEC, socket.SOCK_STREAM):
if family == socket.AF_INE... | Returns a list of IP addresses of a given hostname or None if not found. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L81-L98 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | _generate_minion_id | python | def _generate_minion_id():
'''
Get list of possible host names and convention names.
:return:
'''
# There are three types of hostnames:
# 1. Network names. How host is accessed from the network.
# 2. Host aliases. They might be not available in all the network or only locally (/etc/hosts)
... | Get list of possible host names and convention names.
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L101-L170 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | generate_minion_id | python | def generate_minion_id():
'''
Return only first element of the hostname from all possible list.
:return:
'''
try:
ret = salt.utils.stringutils.to_unicode(_generate_minion_id().first())
except TypeError:
ret = None
return ret or 'localhost' | Return only first element of the hostname from all possible list.
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L173-L183 | [
"def to_unicode(s, encoding=None, errors='strict', normalize=False):\n '''\n Given str or unicode, return unicode (str for python 3)\n '''\n def _normalize(s):\n return unicodedata.normalize('NFC', s) if normalize else s\n\n if encoding is None:\n # Try utf-8 first, and fall back to det... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | get_socket | python | def get_socket(addr, type=socket.SOCK_STREAM, proto=0):
'''
Return a socket object for the addr
IP-version agnostic
'''
version = ipaddress.ip_address(addr).version
if version == 4:
family = socket.AF_INET
elif version == 6:
family = socket.AF_INET6
return socket.socket(... | Return a socket object for the addr
IP-version agnostic | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L186-L197 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | get_fqhostname | python | def get_fqhostname():
'''
Returns the fully qualified hostname
'''
# try getaddrinfo()
fqdn = None
try:
addrinfo = socket.getaddrinfo(
socket.gethostname(), 0, socket.AF_UNSPEC, socket.SOCK_STREAM,
socket.SOL_TCP, socket.AI_CANONNAME
)
for info in ... | Returns the fully qualified hostname | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L200-L224 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | ip_to_host | python | def ip_to_host(ip):
'''
Returns the hostname of a given IP
'''
try:
hostname, aliaslist, ipaddrlist = socket.gethostbyaddr(ip)
except Exception as exc:
log.debug('salt.utils.network.ip_to_host(%r) failed: %s', ip, exc)
hostname = None
return hostname | Returns the hostname of a given IP | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L227-L236 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | is_reachable_host | python | def is_reachable_host(entity_name):
'''
Returns a bool telling if the entity name is a reachable host (IPv4/IPv6/FQDN/etc).
:param hostname:
:return:
'''
try:
assert type(socket.getaddrinfo(entity_name, 0, 0, 0, 0)) == list
ret = True
except socket.gaierror:
ret = Fal... | Returns a bool telling if the entity name is a reachable host (IPv4/IPv6/FQDN/etc).
:param hostname:
:return: | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L241-L253 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | is_ip_filter | python | def is_ip_filter(ip, options=None):
'''
Returns a bool telling if the passed IP is a valid IPv4 or IPv6 address.
'''
return is_ipv4_filter(ip, options=options) or is_ipv6_filter(ip, options=options) | Returns a bool telling if the passed IP is a valid IPv4 or IPv6 address. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L311-L315 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | is_ipv4_filter | python | def is_ipv4_filter(ip, options=None):
'''
Returns a bool telling if the value passed to it was a valid IPv4 address.
ip
The IP address.
net: False
Consider IP addresses followed by netmask.
options
CSV of options regarding the nature of the IP address. E.g.: loopback, mult... | Returns a bool telling if the value passed to it was a valid IPv4 address.
ip
The IP address.
net: False
Consider IP addresses followed by netmask.
options
CSV of options regarding the nature of the IP address. E.g.: loopback, multicast, private etc. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L414-L428 | [
"def _is_ipv(ip, version, options=None):\n\n if not version:\n version = 4\n\n if version not in (4, 6):\n return None\n\n try:\n ip_obj = ipaddress.ip_address(ip)\n except ValueError:\n # maybe it is an IP network\n try:\n ip_obj = ipaddress.ip_interface(ip... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | is_ipv6_filter | python | def is_ipv6_filter(ip, options=None):
'''
Returns a bool telling if the value passed to it was a valid IPv6 address.
ip
The IP address.
net: False
Consider IP addresses followed by netmask.
options
CSV of options regarding the nature of the IP address. E.g.: loopback, mult... | Returns a bool telling if the value passed to it was a valid IPv6 address.
ip
The IP address.
net: False
Consider IP addresses followed by netmask.
options
CSV of options regarding the nature of the IP address. E.g.: loopback, multicast, private etc. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L432-L446 | [
"def _is_ipv(ip, version, options=None):\n\n if not version:\n version = 4\n\n if version not in (4, 6):\n return None\n\n try:\n ip_obj = ipaddress.ip_address(ip)\n except ValueError:\n # maybe it is an IP network\n try:\n ip_obj = ipaddress.ip_interface(ip... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | ipaddr | python | def ipaddr(value, options=None):
'''
Filters and returns only valid IP objects.
'''
ipv4_obj = ipv4(value, options=options)
ipv6_obj = ipv6(value, options=options)
if ipv4_obj is None or ipv6_obj is None:
# an IP address can be either IPv4 either IPv6
# therefofe if the value pas... | Filters and returns only valid IP objects. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L484-L496 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | ip_host | python | def ip_host(value, options=None, version=None):
'''
Returns the interfaces IP address, e.g.: 192.168.0.1/28.
'''
ipaddr_filter_out = _filter_ipaddr(value, options=options, version=version)
if not ipaddr_filter_out:
return
if not isinstance(value, (list, tuple, types.GeneratorType)):
... | Returns the interfaces IP address, e.g.: 192.168.0.1/28. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L516-L525 | [
"def _filter_ipaddr(value, options, version=None):\n ipaddr_filter_out = None\n if version:\n if version == 4:\n ipaddr_filter_out = ipv4(value, options)\n elif version == 6:\n ipaddr_filter_out = ipv6(value, options)\n else:\n ipaddr_filter_out = ipaddr(value, op... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | network_hosts | python | def network_hosts(value, options=None, version=None):
'''
Return the list of hosts within a network.
.. note::
When running this command with a large IPv6 network, the command will
take a long time to gather all of the hosts.
'''
ipaddr_filter_out = _filter_ipaddr(value, options=op... | Return the list of hosts within a network.
.. note::
When running this command with a large IPv6 network, the command will
take a long time to gather all of the hosts. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L536-L553 | [
"def _filter_ipaddr(value, options, version=None):\n ipaddr_filter_out = None\n if version:\n if version == 4:\n ipaddr_filter_out = ipv4(value, options)\n elif version == 6:\n ipaddr_filter_out = ipv6(value, options)\n else:\n ipaddr_filter_out = ipaddr(value, op... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | network_size | python | def network_size(value, options=None, version=None):
'''
Get the size of a network.
'''
ipaddr_filter_out = _filter_ipaddr(value, options=options, version=version)
if not ipaddr_filter_out:
return
if not isinstance(value, (list, tuple, types.GeneratorType)):
return _network_size(... | Get the size of a network. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L561-L573 | [
"def _filter_ipaddr(value, options, version=None):\n ipaddr_filter_out = None\n if version:\n if version == 4:\n ipaddr_filter_out = ipv4(value, options)\n elif version == 6:\n ipaddr_filter_out = ipv6(value, options)\n else:\n ipaddr_filter_out = ipaddr(value, op... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.