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/modules/redismod.py
ping
python
def ping(host=None, port=None, db=None, password=None): ''' Ping the server, returns False on connection errors CLI Example: .. code-block:: bash salt '*' redis.ping ''' server = _connect(host, port, db, password) try: return server.ping() except redis.ConnectionError:...
Ping the server, returns False on connection errors CLI Example: .. code-block:: bash salt '*' redis.ping
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/redismod.py#L557-L571
[ "def _connect(host=None, port=None, db=None, password=None):\n '''\n Returns an instance of the redis client\n '''\n if not host:\n host = __salt__['config.option']('redis.host')\n if not port:\n port = __salt__['config.option']('redis.port')\n if not db:\n db = __salt__['conf...
# -*- coding: utf-8 -*- ''' Module to provide redis functionality to Salt .. versionadded:: 2014.7.0 :configuration: This module requires the redis python module and uses the following defaults which may be overridden in the minion configuration: .. code-block:: yaml redis.host: 'salt' redis.port: 6379 ...
saltstack/salt
salt/modules/redismod.py
save
python
def save(host=None, port=None, db=None, password=None): ''' Synchronously save the dataset to disk CLI Example: .. code-block:: bash salt '*' redis.save ''' server = _connect(host, port, db, password) return server.save()
Synchronously save the dataset to disk CLI Example: .. code-block:: bash salt '*' redis.save
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/redismod.py#L574-L585
[ "def _connect(host=None, port=None, db=None, password=None):\n '''\n Returns an instance of the redis client\n '''\n if not host:\n host = __salt__['config.option']('redis.host')\n if not port:\n port = __salt__['config.option']('redis.port')\n if not db:\n db = __salt__['conf...
# -*- coding: utf-8 -*- ''' Module to provide redis functionality to Salt .. versionadded:: 2014.7.0 :configuration: This module requires the redis python module and uses the following defaults which may be overridden in the minion configuration: .. code-block:: yaml redis.host: 'salt' redis.port: 6379 ...
saltstack/salt
salt/modules/redismod.py
set_key
python
def set_key(key, value, host=None, port=None, db=None, password=None): ''' Set redis key value CLI Example: .. code-block:: bash salt '*' redis.set_key foo bar ''' server = _connect(host, port, db, password) return server.set(key, value)
Set redis key value CLI Example: .. code-block:: bash salt '*' redis.set_key foo bar
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/redismod.py#L588-L599
[ "def _connect(host=None, port=None, db=None, password=None):\n '''\n Returns an instance of the redis client\n '''\n if not host:\n host = __salt__['config.option']('redis.host')\n if not port:\n port = __salt__['config.option']('redis.port')\n if not db:\n db = __salt__['conf...
# -*- coding: utf-8 -*- ''' Module to provide redis functionality to Salt .. versionadded:: 2014.7.0 :configuration: This module requires the redis python module and uses the following defaults which may be overridden in the minion configuration: .. code-block:: yaml redis.host: 'salt' redis.port: 6379 ...
saltstack/salt
salt/modules/redismod.py
shutdown
python
def shutdown(host=None, port=None, db=None, password=None): ''' Synchronously save the dataset to disk and then shut down the server CLI Example: .. code-block:: bash salt '*' redis.shutdown ''' server = _connect(host, port, db, password) try: # Return false if unable to p...
Synchronously save the dataset to disk and then shut down the server CLI Example: .. code-block:: bash salt '*' redis.shutdown
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/redismod.py#L602-L625
[ "def _connect(host=None, port=None, db=None, password=None):\n '''\n Returns an instance of the redis client\n '''\n if not host:\n host = __salt__['config.option']('redis.host')\n if not port:\n port = __salt__['config.option']('redis.port')\n if not db:\n db = __salt__['conf...
# -*- coding: utf-8 -*- ''' Module to provide redis functionality to Salt .. versionadded:: 2014.7.0 :configuration: This module requires the redis python module and uses the following defaults which may be overridden in the minion configuration: .. code-block:: yaml redis.host: 'salt' redis.port: 6379 ...
saltstack/salt
salt/modules/redismod.py
slaveof
python
def slaveof(master_host=None, master_port=None, host=None, port=None, db=None, password=None): ''' Make the server a slave of another instance, or promote it as master CLI Example: .. code-block:: bash # Become slave of redis-n01.example.com:6379 salt '*' redis.slaveof red...
Make the server a slave of another instance, or promote it as master CLI Example: .. code-block:: bash # Become slave of redis-n01.example.com:6379 salt '*' redis.slaveof redis-n01.example.com 6379 salt '*' redis.slaveof redis-n01.example.com # Become master salt '*' r...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/redismod.py#L628-L646
[ "def _connect(host=None, port=None, db=None, password=None):\n '''\n Returns an instance of the redis client\n '''\n if not host:\n host = __salt__['config.option']('redis.host')\n if not port:\n port = __salt__['config.option']('redis.port')\n if not db:\n db = __salt__['conf...
# -*- coding: utf-8 -*- ''' Module to provide redis functionality to Salt .. versionadded:: 2014.7.0 :configuration: This module requires the redis python module and uses the following defaults which may be overridden in the minion configuration: .. code-block:: yaml redis.host: 'salt' redis.port: 6379 ...
saltstack/salt
salt/modules/redismod.py
smembers
python
def smembers(key, host=None, port=None, db=None, password=None): ''' Get members in a Redis set CLI Example: .. code-block:: bash salt '*' redis.smembers foo_set ''' server = _connect(host, port, db, password) return list(server.smembers(key))
Get members in a Redis set CLI Example: .. code-block:: bash salt '*' redis.smembers foo_set
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/redismod.py#L649-L660
[ "def _connect(host=None, port=None, db=None, password=None):\n '''\n Returns an instance of the redis client\n '''\n if not host:\n host = __salt__['config.option']('redis.host')\n if not port:\n port = __salt__['config.option']('redis.port')\n if not db:\n db = __salt__['conf...
# -*- coding: utf-8 -*- ''' Module to provide redis functionality to Salt .. versionadded:: 2014.7.0 :configuration: This module requires the redis python module and uses the following defaults which may be overridden in the minion configuration: .. code-block:: yaml redis.host: 'salt' redis.port: 6379 ...
saltstack/salt
salt/modules/redismod.py
time
python
def time(host=None, port=None, db=None, password=None): ''' Return the current server UNIX time in seconds CLI Example: .. code-block:: bash salt '*' redis.time ''' server = _connect(host, port, db, password) return server.time()[0]
Return the current server UNIX time in seconds CLI Example: .. code-block:: bash salt '*' redis.time
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/redismod.py#L663-L674
[ "def _connect(host=None, port=None, db=None, password=None):\n '''\n Returns an instance of the redis client\n '''\n if not host:\n host = __salt__['config.option']('redis.host')\n if not port:\n port = __salt__['config.option']('redis.port')\n if not db:\n db = __salt__['conf...
# -*- coding: utf-8 -*- ''' Module to provide redis functionality to Salt .. versionadded:: 2014.7.0 :configuration: This module requires the redis python module and uses the following defaults which may be overridden in the minion configuration: .. code-block:: yaml redis.host: 'salt' redis.port: 6379 ...
saltstack/salt
salt/modules/redismod.py
zcard
python
def zcard(key, host=None, port=None, db=None, password=None): ''' Get the length of a sorted set in Redis CLI Example: .. code-block:: bash salt '*' redis.zcard foo_sorted ''' server = _connect(host, port, db, password) return server.zcard(key)
Get the length of a sorted set in Redis CLI Example: .. code-block:: bash salt '*' redis.zcard foo_sorted
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/redismod.py#L677-L688
[ "def _connect(host=None, port=None, db=None, password=None):\n '''\n Returns an instance of the redis client\n '''\n if not host:\n host = __salt__['config.option']('redis.host')\n if not port:\n port = __salt__['config.option']('redis.port')\n if not db:\n db = __salt__['conf...
# -*- coding: utf-8 -*- ''' Module to provide redis functionality to Salt .. versionadded:: 2014.7.0 :configuration: This module requires the redis python module and uses the following defaults which may be overridden in the minion configuration: .. code-block:: yaml redis.host: 'salt' redis.port: 6379 ...
saltstack/salt
salt/modules/redismod.py
zrange
python
def zrange(key, start, stop, host=None, port=None, db=None, password=None): ''' Get a range of values from a sorted set in Redis by index CLI Example: .. code-block:: bash salt '*' redis.zrange foo_sorted 0 10 ''' server = _connect(host, port, db, password) return server.zrange(ke...
Get a range of values from a sorted set in Redis by index CLI Example: .. code-block:: bash salt '*' redis.zrange foo_sorted 0 10
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/redismod.py#L691-L702
[ "def _connect(host=None, port=None, db=None, password=None):\n '''\n Returns an instance of the redis client\n '''\n if not host:\n host = __salt__['config.option']('redis.host')\n if not port:\n port = __salt__['config.option']('redis.port')\n if not db:\n db = __salt__['conf...
# -*- coding: utf-8 -*- ''' Module to provide redis functionality to Salt .. versionadded:: 2014.7.0 :configuration: This module requires the redis python module and uses the following defaults which may be overridden in the minion configuration: .. code-block:: yaml redis.host: 'salt' redis.port: 6379 ...
saltstack/salt
salt/modules/redismod.py
sentinel_get_master_ip
python
def sentinel_get_master_ip(master, host=None, port=None, password=None): ''' Get ip for sentinel master .. versionadded: 2016.3.0 CLI Example: .. code-block:: bash salt '*' redis.sentinel_get_master_ip 'mymaster' ''' server = _sconnect(host, port, password) ret = server.senti...
Get ip for sentinel master .. versionadded: 2016.3.0 CLI Example: .. code-block:: bash salt '*' redis.sentinel_get_master_ip 'mymaster'
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/redismod.py#L705-L719
[ "def _sconnect(host=None, port=None, password=None):\n '''\n Returns an instance of the redis client\n '''\n if host is None:\n host = __salt__['config.option']('redis_sentinel.host', 'localhost')\n if port is None:\n port = __salt__['config.option']('redis_sentinel.port', 26379)\n i...
# -*- coding: utf-8 -*- ''' Module to provide redis functionality to Salt .. versionadded:: 2014.7.0 :configuration: This module requires the redis python module and uses the following defaults which may be overridden in the minion configuration: .. code-block:: yaml redis.host: 'salt' redis.port: 6379 ...
saltstack/salt
salt/modules/redismod.py
get_master_ip
python
def get_master_ip(host=None, port=None, password=None): ''' Get host information about slave .. versionadded: 2016.3.0 CLI Example: .. code-block:: bash salt '*' redis.get_master_ip ''' server = _connect(host, port, password) srv_info = server.info() ret = (srv_info.get('...
Get host information about slave .. versionadded: 2016.3.0 CLI Example: .. code-block:: bash salt '*' redis.get_master_ip
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/redismod.py#L722-L737
[ "def _connect(host=None, port=None, db=None, password=None):\n '''\n Returns an instance of the redis client\n '''\n if not host:\n host = __salt__['config.option']('redis.host')\n if not port:\n port = __salt__['config.option']('redis.port')\n if not db:\n db = __salt__['conf...
# -*- coding: utf-8 -*- ''' Module to provide redis functionality to Salt .. versionadded:: 2014.7.0 :configuration: This module requires the redis python module and uses the following defaults which may be overridden in the minion configuration: .. code-block:: yaml redis.host: 'salt' redis.port: 6379 ...
saltstack/salt
salt/modules/boto_efs.py
_get_conn
python
def _get_conn(key=None, keyid=None, profile=None, region=None, **kwargs): ''' Create a boto3 client connection to EFS ''' client = None if profile: if isinstance(profile, six.string_types): if profile in __pillar__: ...
Create a boto3 client connection to EFS
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_efs.py#L82-L121
null
# -*- coding: utf-8 -*- ''' Connection module for Amazon EFS .. versionadded:: 2017.7.0 :configuration: This module accepts explicit EFS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles or it can read them from the ~/.aws/credentials file or from these environm...
saltstack/salt
salt/modules/boto_efs.py
create_file_system
python
def create_file_system(name, performance_mode='generalPurpose', keyid=None, key=None, profile=None, region=None, creation_token=None, **kwargs): ''' Cr...
Creates a new, empty file system. name (string) - The name for the new file system performance_mode (string) - The PerformanceMode of the file system. Can be either generalPurpose or maxIO creation_token (string) - A unique name to be used as reference when creating an EFS...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_efs.py#L124-L172
[ "def _get_conn(key=None,\n keyid=None,\n profile=None,\n region=None,\n **kwargs):\n '''\n Create a boto3 client connection to EFS\n '''\n client = None\n if profile:\n if isinstance(profile, six.string_types):\n if profile in __pi...
# -*- coding: utf-8 -*- ''' Connection module for Amazon EFS .. versionadded:: 2017.7.0 :configuration: This module accepts explicit EFS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles or it can read them from the ~/.aws/credentials file or from these environm...
saltstack/salt
salt/modules/boto_efs.py
create_mount_target
python
def create_mount_target(filesystemid, subnetid, ipaddress=None, securitygroups=None, keyid=None, key=None, profile=None, region=None, ...
Creates a mount target for a file system. You can then mount the file system on EC2 instances via the mount target. You can create one mount target in each Availability Zone in your VPC. All EC2 instances in a VPC within a given Availability Zone share a single mount target for a given file system. ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_efs.py#L175-L240
[ "def _get_conn(key=None,\n keyid=None,\n profile=None,\n region=None,\n **kwargs):\n '''\n Create a boto3 client connection to EFS\n '''\n client = None\n if profile:\n if isinstance(profile, six.string_types):\n if profile in __pi...
# -*- coding: utf-8 -*- ''' Connection module for Amazon EFS .. versionadded:: 2017.7.0 :configuration: This module accepts explicit EFS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles or it can read them from the ~/.aws/credentials file or from these environm...
saltstack/salt
salt/modules/boto_efs.py
create_tags
python
def create_tags(filesystemid, tags, keyid=None, key=None, profile=None, region=None, **kwargs): ''' Creates or overwrites tags associated with a file system. Each tag is a key-value pair. If a tag key specified i...
Creates or overwrites tags associated with a file system. Each tag is a key-value pair. If a tag key specified in the request already exists on the file system, this operation overwrites its value with the value provided in the request. filesystemid (string) - ID of the file system for whose ta...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_efs.py#L243-L275
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "def _get_conn(key=None,\n keyid=None,\n profile=None,\n region=None,\n **kwargs):\n '''\n Create a boto3 client connection to EFS\n '''\n client = None\n if profile:\n if isinstanc...
# -*- coding: utf-8 -*- ''' Connection module for Amazon EFS .. versionadded:: 2017.7.0 :configuration: This module accepts explicit EFS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles or it can read them from the ~/.aws/credentials file or from these environm...
saltstack/salt
salt/modules/boto_efs.py
delete_file_system
python
def delete_file_system(filesystemid, keyid=None, key=None, profile=None, region=None, **kwargs): ''' Deletes a file system, permanently severing access to its contents. Upon return, the file sy...
Deletes a file system, permanently severing access to its contents. Upon return, the file system no longer exists and you can't access any contents of the deleted file system. You can't delete a file system that is in use. That is, if the file system has any mount targets, you must first delete them. ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_efs.py#L278-L303
[ "def _get_conn(key=None,\n keyid=None,\n profile=None,\n region=None,\n **kwargs):\n '''\n Create a boto3 client connection to EFS\n '''\n client = None\n if profile:\n if isinstance(profile, six.string_types):\n if profile in __pi...
# -*- coding: utf-8 -*- ''' Connection module for Amazon EFS .. versionadded:: 2017.7.0 :configuration: This module accepts explicit EFS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles or it can read them from the ~/.aws/credentials file or from these environm...
saltstack/salt
salt/modules/boto_efs.py
delete_mount_target
python
def delete_mount_target(mounttargetid, keyid=None, key=None, profile=None, region=None, **kwargs): ''' Deletes the specified mount target. This operation forcibly breaks any mounts of the file...
Deletes the specified mount target. This operation forcibly breaks any mounts of the file system via the mount target that is being deleted, which might disrupt instances or applications using those mounts. To avoid applications getting cut off abruptly, you might consider unmounting any mounts of the ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_efs.py#L306-L337
[ "def _get_conn(key=None,\n keyid=None,\n profile=None,\n region=None,\n **kwargs):\n '''\n Create a boto3 client connection to EFS\n '''\n client = None\n if profile:\n if isinstance(profile, six.string_types):\n if profile in __pi...
# -*- coding: utf-8 -*- ''' Connection module for Amazon EFS .. versionadded:: 2017.7.0 :configuration: This module accepts explicit EFS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles or it can read them from the ~/.aws/credentials file or from these environm...
saltstack/salt
salt/modules/boto_efs.py
delete_tags
python
def delete_tags(filesystemid, tags, keyid=None, key=None, profile=None, region=None, **kwargs): ''' Deletes the specified tags from a file system. filesystemid (string) - ID of the file system for whose ...
Deletes the specified tags from a file system. filesystemid (string) - ID of the file system for whose tags will be removed. tags (list[string]) - The tag keys to delete to the file system CLI Example: .. code-block:: bash salt 'my-minion' boto_efs.delete_tags
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_efs.py#L340-L365
[ "def _get_conn(key=None,\n keyid=None,\n profile=None,\n region=None,\n **kwargs):\n '''\n Create a boto3 client connection to EFS\n '''\n client = None\n if profile:\n if isinstance(profile, six.string_types):\n if profile in __pi...
# -*- coding: utf-8 -*- ''' Connection module for Amazon EFS .. versionadded:: 2017.7.0 :configuration: This module accepts explicit EFS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles or it can read them from the ~/.aws/credentials file or from these environm...
saltstack/salt
salt/modules/boto_efs.py
get_file_systems
python
def get_file_systems(filesystemid=None, keyid=None, key=None, profile=None, region=None, creation_token=None, **kwargs): ''' Get all EFS properties or a specific instance property if...
Get all EFS properties or a specific instance property if filesystemid is specified filesystemid (string) - ID of the file system to retrieve properties creation_token (string) - A unique token that identifies an EFS. If fileysystem created via create_file_system this would ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_efs.py#L368-L421
[ "def _get_conn(key=None,\n keyid=None,\n profile=None,\n region=None,\n **kwargs):\n '''\n Create a boto3 client connection to EFS\n '''\n client = None\n if profile:\n if isinstance(profile, six.string_types):\n if profile in __pi...
# -*- coding: utf-8 -*- ''' Connection module for Amazon EFS .. versionadded:: 2017.7.0 :configuration: This module accepts explicit EFS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles or it can read them from the ~/.aws/credentials file or from these environm...
saltstack/salt
salt/modules/boto_efs.py
get_mount_targets
python
def get_mount_targets(filesystemid=None, mounttargetid=None, keyid=None, key=None, profile=None, region=None, **kwargs): ''' Get all the EFS mount point properties for a specific f...
Get all the EFS mount point properties for a specific filesystemid or the properties for a specific mounttargetid. One or the other must be specified filesystemid (string) - ID of the file system whose mount targets to list Must be specified if mounttargetid is not mounttarg...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_efs.py#L424-L468
[ "def _get_conn(key=None,\n keyid=None,\n profile=None,\n region=None,\n **kwargs):\n '''\n Create a boto3 client connection to EFS\n '''\n client = None\n if profile:\n if isinstance(profile, six.string_types):\n if profile in __pi...
# -*- coding: utf-8 -*- ''' Connection module for Amazon EFS .. versionadded:: 2017.7.0 :configuration: This module accepts explicit EFS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles or it can read them from the ~/.aws/credentials file or from these environm...
saltstack/salt
salt/modules/boto_efs.py
get_tags
python
def get_tags(filesystemid, keyid=None, key=None, profile=None, region=None, **kwargs): ''' Return the tags associated with an EFS instance. filesystemid (string) - ID of the file system whose tags to list returns (list) -...
Return the tags associated with an EFS instance. filesystemid (string) - ID of the file system whose tags to list returns (list) - list of tags as key/value pairs CLI Example: .. code-block:: bash salt 'my-minion' boto_efs.get_tags efs-id
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_efs.py#L471-L501
[ "def _get_conn(key=None,\n keyid=None,\n profile=None,\n region=None,\n **kwargs):\n '''\n Create a boto3 client connection to EFS\n '''\n client = None\n if profile:\n if isinstance(profile, six.string_types):\n if profile in __pi...
# -*- coding: utf-8 -*- ''' Connection module for Amazon EFS .. versionadded:: 2017.7.0 :configuration: This module accepts explicit EFS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles or it can read them from the ~/.aws/credentials file or from these environm...
saltstack/salt
salt/modules/boto_efs.py
set_security_groups
python
def set_security_groups(mounttargetid, securitygroup, keyid=None, key=None, profile=None, region=None, **kwargs): ''' Modifies the set of security groups in effect for ...
Modifies the set of security groups in effect for a mount target mounttargetid (string) - ID of the mount target whose security groups will be modified securitygroups (list[string]) - list of no more than 5 VPC security group IDs. CLI Example: .. code-block:: bash salt 'my-m...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_efs.py#L504-L529
[ "def _get_conn(key=None,\n keyid=None,\n profile=None,\n region=None,\n **kwargs):\n '''\n Create a boto3 client connection to EFS\n '''\n client = None\n if profile:\n if isinstance(profile, six.string_types):\n if profile in __pi...
# -*- coding: utf-8 -*- ''' Connection module for Amazon EFS .. versionadded:: 2017.7.0 :configuration: This module accepts explicit EFS credentials but can also utilize IAM roles assigned to the instance through Instance Profiles or it can read them from the ~/.aws/credentials file or from these environm...
saltstack/salt
salt/states/win_wusa.py
installed
python
def installed(name, source): ''' Ensure an update is installed on the minion Args: name(str): Name of the Windows KB ("KB123456") source (str): Source of .msu file corresponding to the KB Example: .. code-block:: yaml KB123456: wusa.ins...
Ensure an update is installed on the minion Args: name(str): Name of the Windows KB ("KB123456") source (str): Source of .msu file corresponding to the KB Example: .. code-block:: yaml KB123456: wusa.installed: - source: salt://kb12...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_wusa.py#L37-L100
[ "def redact_http_basic_auth(output):\n '''\n Remove HTTP user and password\n '''\n # We can't use re.compile because re.compile(someregex).sub() doesn't\n # support flags even in Python 2.7.\n url_re = '(https?)://.*@'\n redacted = r'\\1://<redacted>@'\n if sys.version_info >= (2, 7):\n ...
# -*- coding: utf-8 -*- ''' Microsoft Updates (KB) Management This module provides the ability to enforce KB installations from files (.msu), without WSUS or Windows Update .. versionadded:: 2018.3.4 ''' # Import python libs from __future__ import absolute_import, unicode_literals import logging # Import salt libs ...
saltstack/salt
salt/states/win_wusa.py
uninstalled
python
def uninstalled(name): ''' Ensure an update is uninstalled from the minion Args: name(str): Name of the Windows KB ("KB123456") Example: .. code-block:: yaml KB123456: wusa.uninstalled ''' ret = {'name': name, 'changes': {}, 'r...
Ensure an update is uninstalled from the minion Args: name(str): Name of the Windows KB ("KB123456") Example: .. code-block:: yaml KB123456: wusa.uninstalled
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_wusa.py#L103-L148
null
# -*- coding: utf-8 -*- ''' Microsoft Updates (KB) Management This module provides the ability to enforce KB installations from files (.msu), without WSUS or Windows Update .. versionadded:: 2018.3.4 ''' # Import python libs from __future__ import absolute_import, unicode_literals import logging # Import salt libs ...
saltstack/salt
salt/utils/smtp.py
send
python
def send(kwargs, opts): ''' Send an email with the data ''' opt_keys = ( 'smtp.to', 'smtp.from', 'smtp.host', 'smtp.port', 'smtp.tls', 'smtp.username', 'smtp.password', 'smtp.subject', 'smtp.gpgowner', 'smtp.content', ) ...
Send an email with the data
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/smtp.py#L50-L127
null
# -*- coding: utf-8 -*- ''' Return salt data via email The following fields can be set in the minion conf file: smtp.from (required) smtp.to (required) smtp.host (required) smtp.port (optional, defaults to 25) smtp.username (optional) smtp.password (optional) smtp.tls (optional, defaults t...
saltstack/salt
salt/modules/netaddress.py
list_cidr_ips
python
def list_cidr_ips(cidr): ''' Get a list of IP addresses from a CIDR. CLI example:: salt myminion netaddress.list_cidr_ips 192.168.0.0/20 ''' ips = netaddr.IPNetwork(cidr) return [six.text_type(ip) for ip in list(ips)]
Get a list of IP addresses from a CIDR. CLI example:: salt myminion netaddress.list_cidr_ips 192.168.0.0/20
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netaddress.py#L35-L44
null
# -*- coding: utf-8 -*- ''' Module for getting information about network addresses. .. versionadded:: 2016.3.0 :depends: netaddr ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt libs from salt.ext import six __virtualname__ = 'netaddress' # Import thir...
saltstack/salt
salt/modules/netaddress.py
list_cidr_ips_ipv6
python
def list_cidr_ips_ipv6(cidr): ''' Get a list of IPv6 addresses from a CIDR. CLI example:: salt myminion netaddress.list_cidr_ips_ipv6 192.168.0.0/20 ''' ips = netaddr.IPNetwork(cidr) return [six.text_type(ip.ipv6()) for ip in list(ips)]
Get a list of IPv6 addresses from a CIDR. CLI example:: salt myminion netaddress.list_cidr_ips_ipv6 192.168.0.0/20
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netaddress.py#L47-L56
null
# -*- coding: utf-8 -*- ''' Module for getting information about network addresses. .. versionadded:: 2016.3.0 :depends: netaddr ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt libs from salt.ext import six __virtualname__ = 'netaddress' # Import thir...
saltstack/salt
salt/modules/netaddress.py
cidr_netmask
python
def cidr_netmask(cidr): ''' Get the netmask address associated with a CIDR address. CLI example:: salt myminion netaddress.cidr_netmask 192.168.0.0/20 ''' ips = netaddr.IPNetwork(cidr) return six.text_type(ips.netmask)
Get the netmask address associated with a CIDR address. CLI example:: salt myminion netaddress.cidr_netmask 192.168.0.0/20
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netaddress.py#L59-L68
null
# -*- coding: utf-8 -*- ''' Module for getting information about network addresses. .. versionadded:: 2016.3.0 :depends: netaddr ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt libs from salt.ext import six __virtualname__ = 'netaddress' # Import thir...
saltstack/salt
salt/modules/netaddress.py
cidr_broadcast
python
def cidr_broadcast(cidr): ''' Get the broadcast address associated with a CIDR address. CLI example:: salt myminion netaddress.cidr_netmask 192.168.0.0/20 ''' ips = netaddr.IPNetwork(cidr) return six.text_type(ips.broadcast)
Get the broadcast address associated with a CIDR address. CLI example:: salt myminion netaddress.cidr_netmask 192.168.0.0/20
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/netaddress.py#L71-L80
null
# -*- coding: utf-8 -*- ''' Module for getting information about network addresses. .. versionadded:: 2016.3.0 :depends: netaddr ''' # Import Python libs from __future__ import absolute_import, print_function, unicode_literals # Import Salt libs from salt.ext import six __virtualname__ = 'netaddress' # Import thir...
saltstack/salt
salt/modules/openstack_mng.py
restart_service
python
def restart_service(service_name, minimum_running_time=None): ''' Restart OpenStack service immediately, or only if it's running longer than specified value CLI Example: .. code-block:: bash salt '*' openstack_mng.restart_service neutron salt '*' openstack_mng.restart_service neut...
Restart OpenStack service immediately, or only if it's running longer than specified value CLI Example: .. code-block:: bash salt '*' openstack_mng.restart_service neutron salt '*' openstack_mng.restart_service neutron minimum_running_time=600
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/openstack_mng.py#L65-L104
[ "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 -*- ''' Module for OpenStack Management :codeauthor: Konrad Mosoń <mosonkonrad@gmail.com> :maturity: new :depends: openstack-utils :platform: linux ''' # Import python libs from __future__ import absolute_import, print_function, unicode_literals import logging import os.path # I...
saltstack/salt
salt/returners/mysql.py
_get_options
python
def _get_options(ret=None): ''' Returns options used for the MySQL connection. ''' defaults = {'host': 'salt', 'user': 'salt', 'pass': 'salt', 'db': 'salt', 'port': 3306, 'ssl_ca': None, 'ssl_cert': None, ...
Returns options used for the MySQL connection.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mysql.py#L190-L227
null
# -*- coding: utf-8 -*- ''' Return data to a mysql server :maintainer: Dave Boucha <dave@saltstack.com>, Seth House <shouse@saltstack.com> :maturity: mature :depends: python-mysqldb :platform: all To enable this returner, the minion will need the python client for mysql installed and the following ...
saltstack/salt
salt/returners/mysql.py
_get_serv
python
def _get_serv(ret=None, commit=False): ''' Return a mysql cursor ''' _options = _get_options(ret) connect = True if __context__ and 'mysql_returner_conn' in __context__: try: log.debug('Trying to reuse MySQL connection pool') conn = __context__['mysql_returner_co...
Return a mysql cursor
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mysql.py#L231-L286
null
# -*- coding: utf-8 -*- ''' Return data to a mysql server :maintainer: Dave Boucha <dave@saltstack.com>, Seth House <shouse@saltstack.com> :maturity: mature :depends: python-mysqldb :platform: all To enable this returner, the minion will need the python client for mysql installed and the following ...
saltstack/salt
salt/returners/mysql.py
returner
python
def returner(ret): ''' Return data to a mysql server ''' # if a minion is returning a standalone job, get a jobid if ret['jid'] == 'req': ret['jid'] = prep_jid(nocache=ret.get('nocache', False)) save_load(ret['jid'], ret) try: with _get_serv(ret, commit=True) as cur: ...
Return data to a mysql server
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mysql.py#L289-L311
[ "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 mysql server :maintainer: Dave Boucha <dave@saltstack.com>, Seth House <shouse@saltstack.com> :maturity: mature :depends: python-mysqldb :platform: all To enable this returner, the minion will need the python client for mysql installed and the following ...
saltstack/salt
salt/returners/mysql.py
event_return
python
def event_return(events): ''' Return event to mysql server Requires that configuration be enabled via 'event_return' option in master config. ''' with _get_serv(events, commit=True) as cur: for event in events: tag = event.get('tag', '') data = event.get('data', ...
Return event to mysql server Requires that configuration be enabled via 'event_return' option in master config.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mysql.py#L314-L327
[ "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 mysql server :maintainer: Dave Boucha <dave@saltstack.com>, Seth House <shouse@saltstack.com> :maturity: mature :depends: python-mysqldb :platform: all To enable this returner, the minion will need the python client for mysql installed and the following ...
saltstack/salt
salt/returners/mysql.py
save_load
python
def save_load(jid, load, minions=None): ''' Save the load to the specified jid id ''' with _get_serv(commit=True) as cur: sql = '''INSERT INTO `jids` (`jid`, `load`) VALUES (%s, %s)''' try: cur.execute(sql, (jid, salt.utils.json.dumps(load))) except MySQLdb.Integrit...
Save the load to the specified jid id
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mysql.py#L330-L344
[ "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 mysql server :maintainer: Dave Boucha <dave@saltstack.com>, Seth House <shouse@saltstack.com> :maturity: mature :depends: python-mysqldb :platform: all To enable this returner, the minion will need the python client for mysql installed and the following ...
saltstack/salt
salt/returners/mysql.py
get_load
python
def get_load(jid): ''' Return the load data that marks a specified jid ''' with _get_serv(ret=None, commit=True) as cur: sql = '''SELECT `load` FROM `jids` WHERE `jid` = %s;''' cur.execute(sql, (jid,)) data = cur.fetchone() if data: return salt.utils.json.loa...
Return the load data that marks a specified jid
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mysql.py#L354-L365
null
# -*- coding: utf-8 -*- ''' Return data to a mysql server :maintainer: Dave Boucha <dave@saltstack.com>, Seth House <shouse@saltstack.com> :maturity: mature :depends: python-mysqldb :platform: all To enable this returner, the minion will need the python client for mysql installed and the following ...
saltstack/salt
salt/returners/mysql.py
get_jid
python
def get_jid(jid): ''' Return the information returned when the specified job id was executed ''' with _get_serv(ret=None, commit=True) as cur: sql = '''SELECT id, full_ret FROM `salt_returns` WHERE `jid` = %s''' cur.execute(sql, (jid,)) data = cur.fetchall() ...
Return the information returned when the specified job id was executed
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mysql.py#L368-L383
null
# -*- coding: utf-8 -*- ''' Return data to a mysql server :maintainer: Dave Boucha <dave@saltstack.com>, Seth House <shouse@saltstack.com> :maturity: mature :depends: python-mysqldb :platform: all To enable this returner, the minion will need the python client for mysql installed and the following ...
saltstack/salt
salt/returners/mysql.py
get_fun
python
def get_fun(fun): ''' Return a dict of the last function called for all minions ''' with _get_serv(ret=None, commit=True) as cur: sql = '''SELECT s.id,s.jid, s.full_ret FROM `salt_returns` s JOIN ( SELECT MAX(`jid`) as jid from `salt_returns` ...
Return a dict of the last function called for all minions
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mysql.py#L386-L407
null
# -*- coding: utf-8 -*- ''' Return data to a mysql server :maintainer: Dave Boucha <dave@saltstack.com>, Seth House <shouse@saltstack.com> :maturity: mature :depends: python-mysqldb :platform: all To enable this returner, the minion will need the python client for mysql installed and the following ...
saltstack/salt
salt/returners/mysql.py
get_jids_filter
python
def get_jids_filter(count, filter_find_job=True): ''' Return a list of all job ids :param int count: show not more than the count of most recent jobs :param bool filter_find_jobs: filter out 'saltutil.find_job' jobs ''' with _get_serv(ret=None, commit=True) as cur: sql = '''SELECT * FRO...
Return a list of all job ids :param int count: show not more than the count of most recent jobs :param bool filter_find_jobs: filter out 'saltutil.find_job' jobs
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mysql.py#L429-L452
[ "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 -*- ''' Return data to a mysql server :maintainer: Dave Boucha <dave@saltstack.com>, Seth House <shouse@saltstack.com> :maturity: mature :depends: python-mysqldb :platform: all To enable this returner, the minion will need the python client for mysql installed and the following ...
saltstack/salt
salt/returners/mysql.py
get_minions
python
def get_minions(): ''' Return a list of minions ''' with _get_serv(ret=None, commit=True) as cur: sql = '''SELECT DISTINCT id FROM `salt_returns`''' cur.execute(sql) data = cur.fetchall() ret = [] for minion in data: ret.append(minion...
Return a list of minions
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mysql.py#L455-L469
null
# -*- coding: utf-8 -*- ''' Return data to a mysql server :maintainer: Dave Boucha <dave@saltstack.com>, Seth House <shouse@saltstack.com> :maturity: mature :depends: python-mysqldb :platform: all To enable this returner, the minion will need the python client for mysql installed and the following ...
saltstack/salt
salt/returners/mysql.py
_purge_jobs
python
def _purge_jobs(timestamp): ''' Purge records from the returner tables. :param job_age_in_seconds: Purge jobs older than this :return: ''' with _get_serv() as cur: try: sql = 'delete from `jids` where jid in (select distinct jid from salt_returns where alter_time < %s)' ...
Purge records from the returner tables. :param job_age_in_seconds: Purge jobs older than this :return:
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mysql.py#L479-L513
null
# -*- coding: utf-8 -*- ''' Return data to a mysql server :maintainer: Dave Boucha <dave@saltstack.com>, Seth House <shouse@saltstack.com> :maturity: mature :depends: python-mysqldb :platform: all To enable this returner, the minion will need the python client for mysql installed and the following ...
saltstack/salt
salt/returners/mysql.py
_archive_jobs
python
def _archive_jobs(timestamp): ''' Copy rows to a set of backup tables, then purge rows. :param timestamp: Archive rows older than this timestamp :return: ''' source_tables = ['jids', 'salt_returns', 'salt_events'] with _get_serv() as cur: ta...
Copy rows to a set of backup tables, then purge rows. :param timestamp: Archive rows older than this timestamp :return:
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mysql.py#L516-L570
null
# -*- coding: utf-8 -*- ''' Return data to a mysql server :maintainer: Dave Boucha <dave@saltstack.com>, Seth House <shouse@saltstack.com> :maturity: mature :depends: python-mysqldb :platform: all To enable this returner, the minion will need the python client for mysql installed and the following ...
saltstack/salt
salt/returners/mysql.py
clean_old_jobs
python
def clean_old_jobs(): ''' Called in the master's event loop every loop_interval. Archives and/or deletes the events and job details from the database. :return: ''' if __opts__.get('keep_jobs', False) and int(__opts__.get('keep_jobs', 0)) > 0: try: with _get_serv() as cur: ...
Called in the master's event loop every loop_interval. Archives and/or deletes the events and job details from the database. :return:
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/mysql.py#L573-L594
null
# -*- coding: utf-8 -*- ''' Return data to a mysql server :maintainer: Dave Boucha <dave@saltstack.com>, Seth House <shouse@saltstack.com> :maturity: mature :depends: python-mysqldb :platform: all To enable this returner, the minion will need the python client for mysql installed and the following ...
saltstack/salt
salt/returners/syslog_return.py
_verify_options
python
def _verify_options(options): ''' Verify options and log warnings Returns True if all options can be verified, otherwise False ''' # sanity check all vals used for bitwise operations later bitwise_args = [('level', options['level']), ('facility', options['facility']) ...
Verify options and log warnings Returns True if all options can be verified, otherwise False
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/syslog_return.py#L135-L166
null
# -*- coding: utf-8 -*- ''' Return data to the host operating system's syslog facility To use the syslog returner, append '--return syslog' to the salt command. .. code-block:: bash salt '*' test.ping --return syslog The following fields can be set in the minion conf file:: syslog.level (optional, Default:...
saltstack/salt
salt/returners/syslog_return.py
returner
python
def returner(ret): ''' Return data to the local syslog ''' _options = _get_options(ret) if not _verify_options(_options): return # Get values from syslog module level = getattr(syslog, _options['level']) facility = getattr(syslog, _options['facility']) # parse for syslog ...
Return data to the local syslog
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/syslog_return.py#L175-L204
[ "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 the host operating system's syslog facility To use the syslog returner, append '--return syslog' to the salt command. .. code-block:: bash salt '*' test.ping --return syslog The following fields can be set in the minion conf file:: syslog.level (optional, Default:...
saltstack/salt
salt/utils/parsers.py
OptionParser.error
python
def error(self, msg): ''' error(msg : string) Print a usage message incorporating 'msg' to stderr and exit. This keeps option parsing exit status uniform for all parsing errors. ''' self.print_usage(sys.stderr) self.exit(salt.defaults.exitcodes.EX_USAGE, '{0}: er...
error(msg : string) Print a usage message incorporating 'msg' to stderr and exit. This keeps option parsing exit status uniform for all parsing errors.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/parsers.py#L279-L287
null
class OptionParser(optparse.OptionParser, object): VERSION = version.__saltstack_version__.formatted_version usage = '%prog [options]' epilog = ('You can find additional help about %prog issuing "man %prog" ' 'or on http://docs.saltstack.com') description = None # Private attributes...
saltstack/salt
salt/utils/parsers.py
DaemonMixIn.check_running
python
def check_running(self): ''' Check if a pid file exists and if it is associated with a running process. ''' if self.check_pidfile(): pid = self.get_pidfile() if not salt.utils.platform.is_windows(): if self.check_pidfile() and self.is_daem...
Check if a pid file exists and if it is associated with a running process.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/parsers.py#L1045-L1060
[ "def check_pidfile(self):\n '''\n Report whether a pidfile exists\n '''\n from salt.utils.process import check_pidfile\n return check_pidfile(self.config['pidfile'])\n" ]
class DaemonMixIn(six.with_metaclass(MixInMeta, object)): _mixin_prio_ = 30 def _mixin_setup(self): self.add_option( '-d', '--daemon', default=False, action='store_true', help='Run the {0} as a daemon.'.format(self.get_prog_name()) ) self....
saltstack/salt
salt/utils/parsers.py
SaltSupportOptionParser.find_existing_configs
python
def find_existing_configs(self, default): ''' Find configuration files on the system. :return: ''' configs = [] for cfg in [default, self._config_filename_, 'minion', 'proxy', 'cloud', 'spm']: if not cfg: continue config_path = self...
Find configuration files on the system. :return:
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/parsers.py#L1950-L1966
null
class SaltSupportOptionParser(six.with_metaclass(OptionParserMeta, OptionParser, ConfigDirMixIn, MergeConfigMixIn, LogLevelMixIn, TimeoutMixIn)): default_timeout = 5 description = 'Salt Support is a program to collect all support data: logs, system configuration ...
saltstack/salt
salt/utils/parsers.py
SaltSupportOptionParser.setup_config
python
def setup_config(self, cfg=None): ''' Open suitable config file. :return: ''' _opts, _args = optparse.OptionParser.parse_args(self) configs = self.find_existing_configs(_opts.support_unit) if configs and cfg not in configs: cfg = configs[0] re...
Open suitable config file. :return:
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/parsers.py#L1968-L1978
[ "def master_config(path, env_var='SALT_MASTER_CONFIG', defaults=None, exit_on_config_errors=False):\n '''\n Reads in the master configuration file and sets up default options\n\n This is useful for running the actual master daemon. For running\n Master-side client interfaces that need the master opts se...
class SaltSupportOptionParser(six.with_metaclass(OptionParserMeta, OptionParser, ConfigDirMixIn, MergeConfigMixIn, LogLevelMixIn, TimeoutMixIn)): default_timeout = 5 description = 'Salt Support is a program to collect all support data: logs, system configuration ...
saltstack/salt
salt/states/ethtool.py
coalesce
python
def coalesce(name, **kwargs): ''' Manage coalescing settings of network device name Interface name to apply coalescing settings .. code-block:: yaml eth0: ethtool.coalesce: - name: eth0 - adaptive_rx: on - adaptive_tx: on - rx_...
Manage coalescing settings of network device name Interface name to apply coalescing settings .. code-block:: yaml eth0: ethtool.coalesce: - name: eth0 - adaptive_rx: on - adaptive_tx: on - rx_usecs: 24 - rx_frame: 0 ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/ethtool.py#L51-L144
null
# -*- coding: utf-8 -*- ''' Configuration of network device .. versionadded:: 2016.11.0 :codeauthor: Krzysztof Pawlowski <msciciel@msciciel.eu> :maturity: new :depends: python-ethtool :platform: linux .. code-block:: yaml eth0: ethtool.coalesce: - name: eth0 - rx_usecs: ...
saltstack/salt
salt/states/esxdatacenter.py
datacenter_configured
python
def datacenter_configured(name): ''' Makes sure a datacenter exists. If the state is run by an ``esxdatacenter`` minion, the name of the datacenter is retrieved from the proxy details, otherwise the datacenter has the same name as the state. Supported proxies: esxdatacenter name: ...
Makes sure a datacenter exists. If the state is run by an ``esxdatacenter`` minion, the name of the datacenter is retrieved from the proxy details, otherwise the datacenter has the same name as the state. Supported proxies: esxdatacenter name: Datacenter name. Ignored if the proxytype is ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/esxdatacenter.py#L72-L126
null
# -*- coding: utf-8 -*- ''' Salt states to create and manage VMware vSphere datacenters (datacenters). :codeauthor: :email:`Alexandru Bleotu <alexandru.bleotu@morganstaley.com>` Dependencies ============ - pyVmomi Python Module States ====== datacenter_configured --------------------- Makes sure a datacenter exis...
saltstack/salt
salt/modules/napalm_formula.py
_container_path
python
def _container_path(model, key=None, container=None, delim=DEFAULT_TARGET_DELIM): ''' Generate all the possible paths within an OpenConfig-like object. This function returns a generator. ''' if not key: key = '' if not container...
Generate all the possible paths within an OpenConfig-like object. This function returns a generator.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_formula.py#L42-L68
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "def _container_path(model,\n key=None,\n container=None,\n delim=DEFAULT_TARGET_DELIM):\n '''\n Generate all the possible paths within an OpenConfig-like object.\n This function returns a ...
# -*- coding: utf-8 -*- ''' NAPALM Formula helpers ====================== .. versionadded:: 2019.2.0 This is an Execution Module providing helpers for various NAPALM formulas, e.g., napalm-interfaces-formula, napalm-bgp-formula, napalm-ntp-formula etc., meant to provide various helper functions to make the templates ...
saltstack/salt
salt/modules/napalm_formula.py
setval
python
def setval(key, val, dict_=None, delim=DEFAULT_TARGET_DELIM): ''' Set a value under the dictionary hierarchy identified under the key. The target 'foo/bar/baz' returns the dictionary hierarchy {'foo': {'bar': {'baz': {}}}}. .. note:: Currently this doesn't work with integers, i.e. ...
Set a value under the dictionary hierarchy identified under the key. The target 'foo/bar/baz' returns the dictionary hierarchy {'foo': {'bar': {'baz': {}}}}. .. note:: Currently this doesn't work with integers, i.e. cannot build lists dynamically. CLI Example: .. code-block:: bas...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_formula.py#L107-L133
null
# -*- coding: utf-8 -*- ''' NAPALM Formula helpers ====================== .. versionadded:: 2019.2.0 This is an Execution Module providing helpers for various NAPALM formulas, e.g., napalm-interfaces-formula, napalm-bgp-formula, napalm-ntp-formula etc., meant to provide various helper functions to make the templates ...
saltstack/salt
salt/modules/napalm_formula.py
traverse
python
def traverse(data, key, default=None, delimiter=DEFAULT_TARGET_DELIM): ''' Traverse a dict or list using a colon-delimited (or otherwise delimited, using the ``delimiter`` param) target string. The target ``foo:bar:0`` will return ``data['foo']['bar'][0]`` if this value exists, and will otherwise re...
Traverse a dict or list using a colon-delimited (or otherwise delimited, using the ``delimiter`` param) target string. The target ``foo:bar:0`` will return ``data['foo']['bar'][0]`` if this value exists, and will otherwise return the dict in the default argument. Function will automatically determine th...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_formula.py#L136-L153
null
# -*- coding: utf-8 -*- ''' NAPALM Formula helpers ====================== .. versionadded:: 2019.2.0 This is an Execution Module providing helpers for various NAPALM formulas, e.g., napalm-interfaces-formula, napalm-bgp-formula, napalm-ntp-formula etc., meant to provide various helper functions to make the templates ...
saltstack/salt
salt/modules/napalm_formula.py
dictupdate
python
def dictupdate(dest, upd, recursive_update=True, merge_lists=False): ''' Recursive version of the default dict.update Merges upd recursively into dest If recursive_update=False, will use the classic dict.update, or fall back on a manual merge (helpful for non-dict types like ``FunctionWrapper``). ...
Recursive version of the default dict.update Merges upd recursively into dest If recursive_update=False, will use the classic dict.update, or fall back on a manual merge (helpful for non-dict types like ``FunctionWrapper``). If ``merge_lists=True``, will aggregate list object types instead of replace...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_formula.py#L156-L170
[ "def update(dest, upd, recursive_update=True, merge_lists=False):\n '''\n Recursive version of the default dict.update\n\n Merges upd recursively into dest\n\n If recursive_update=False, will use the classic dict.update, or fall back\n on a manual merge (helpful for non-dict types like FunctionWrappe...
# -*- coding: utf-8 -*- ''' NAPALM Formula helpers ====================== .. versionadded:: 2019.2.0 This is an Execution Module providing helpers for various NAPALM formulas, e.g., napalm-interfaces-formula, napalm-bgp-formula, napalm-ntp-formula etc., meant to provide various helper functions to make the templates ...
saltstack/salt
salt/modules/napalm_formula.py
defaults
python
def defaults(model, defaults_, delim='//', flipped_merge=False): ''' Apply the defaults to a Python dictionary having the structure as described in the OpenConfig standards. model The OpenConfig model to apply the defaults to. defaults The dic...
Apply the defaults to a Python dictionary having the structure as described in the OpenConfig standards. model The OpenConfig model to apply the defaults to. defaults The dictionary of defaults. This argument must equally be structured with respect to the OpenConfig standards. ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_formula.py#L173-L234
[ "def update(dest, upd, recursive_update=True, merge_lists=False):\n '''\n Recursive version of the default dict.update\n\n Merges upd recursively into dest\n\n If recursive_update=False, will use the classic dict.update, or fall back\n on a manual merge (helpful for non-dict types like FunctionWrappe...
# -*- coding: utf-8 -*- ''' NAPALM Formula helpers ====================== .. versionadded:: 2019.2.0 This is an Execution Module providing helpers for various NAPALM formulas, e.g., napalm-interfaces-formula, napalm-bgp-formula, napalm-ntp-formula etc., meant to provide various helper functions to make the templates ...
saltstack/salt
salt/modules/napalm_formula.py
render_field
python
def render_field(dictionary, field, prepend=None, append=None, quotes=False, **opts): ''' Render a field found under the ``field`` level of the hierarchy in the ``dictionary`` object. This is useful to render a field in...
Render a field found under the ``field`` level of the hierarchy in the ``dictionary`` object. This is useful to render a field in a Jinja template without worrying that the hierarchy might not exist. For example if we do the following in Jinja: ``{{ interfaces.interface.Ethernet5.config.description }}``...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_formula.py#L237-L314
[ "def traverse(data, key, default=None, delimiter=DEFAULT_TARGET_DELIM):\n '''\n Traverse a dict or list using a colon-delimited (or otherwise delimited,\n using the ``delimiter`` param) target string. The target ``foo:bar:0`` will\n return ``data['foo']['bar'][0]`` if this value exists, and will otherwi...
# -*- coding: utf-8 -*- ''' NAPALM Formula helpers ====================== .. versionadded:: 2019.2.0 This is an Execution Module providing helpers for various NAPALM formulas, e.g., napalm-interfaces-formula, napalm-bgp-formula, napalm-ntp-formula etc., meant to provide various helper functions to make the templates ...
saltstack/salt
salt/modules/napalm_formula.py
render_fields
python
def render_fields(dictionary, *fields, **opts): ''' This function works similarly to :mod:`render_field <salt.modules.napalm_formula.render_field>` but for a list of fields from the same dictionary, rendering, indenting and distributing them on separate lines. ...
This function works similarly to :mod:`render_field <salt.modules.napalm_formula.render_field>` but for a list of fields from the same dictionary, rendering, indenting and distributing them on separate lines. dictionary The dictionary to traverse. fields A list of field names or pa...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/napalm_formula.py#L317-L367
[ "def render_field(dictionary,\n field,\n prepend=None,\n append=None,\n quotes=False,\n **opts):\n '''\n Render a field found under the ``field`` level of the hierarchy in the\n ``dictionary`` object.\n This is useful to ren...
# -*- coding: utf-8 -*- ''' NAPALM Formula helpers ====================== .. versionadded:: 2019.2.0 This is an Execution Module providing helpers for various NAPALM formulas, e.g., napalm-interfaces-formula, napalm-bgp-formula, napalm-ntp-formula etc., meant to provide various helper functions to make the templates ...
saltstack/salt
salt/states/win_servermanager.py
installed
python
def installed(name, features=None, recurse=False, restart=False, source=None, exclude=None): ''' Install the windows feature. To install a single feature, use the ``name`` parameter. To install multiple features, use the ``features`` para...
Install the windows feature. To install a single feature, use the ``name`` parameter. To install multiple features, use the ``features`` parameter. .. note:: Some features require reboot after un/installation. If so, until the server is restarted other features can not be installed! Args: ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_servermanager.py#L25-L189
null
# -*- coding: utf-8 -*- ''' Manage Windows features via the ServerManager powershell module. Can install and remove roles/features. :maintainer: Shane Lee <slee@saltstack.com> :platform: Windows Server 2008R2 or greater :depends: win_servermanager.install :depends: win_servermanager.remove ''' from...
saltstack/salt
salt/states/win_servermanager.py
removed
python
def removed(name, features=None, remove_payload=False, restart=False): ''' Remove the windows feature To remove a single feature, use the ``name`` parameter. To remove multiple features, use the ``features`` parameter. Args: name (str): Short name of the feature (the right column in...
Remove the windows feature To remove a single feature, use the ``name`` parameter. To remove multiple features, use the ``features`` parameter. Args: name (str): Short name of the feature (the right column in win_servermanager.list_available). This can be a single feature or a ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_servermanager.py#L192-L320
null
# -*- coding: utf-8 -*- ''' Manage Windows features via the ServerManager powershell module. Can install and remove roles/features. :maintainer: Shane Lee <slee@saltstack.com> :platform: Windows Server 2008R2 or greater :depends: win_servermanager.install :depends: win_servermanager.remove ''' from...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
_check_cors_origin
python
def _check_cors_origin(origin, allowed_origins): ''' Check if an origin match cors allowed origins ''' if isinstance(allowed_origins, list): if origin in allowed_origins: return origin elif allowed_origins == '*': return allowed_origins elif allowed_origins == origin:...
Check if an origin match cors allowed origins
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L1750-L1761
null
# encoding: utf-8 ''' A non-blocking REST API for Salt ================================ .. py:currentmodule:: salt.netapi.rest_tornado.saltnado :depends: - tornado Python module :configuration: All authentication is done through Salt's :ref:`external auth <acl-eauth>` system which requires additional configura...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
EventListener.clean_by_request
python
def clean_by_request(self, request): ''' Remove all futures that were waiting for request `request` since it is done waiting ''' if request not in self.request_map: return for tag, matcher, future in self.request_map[request]: # timeout the future ...
Remove all futures that were waiting for request `request` since it is done waiting
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L302-L316
[ "def _timeout_future(self, tag, matcher, future):\n '''\n Timeout a specific future\n '''\n if (tag, matcher) not in self.tag_map:\n return\n if not future.done():\n future.set_exception(TimeoutException())\n self.tag_map[(tag, matcher)].remove(future)\n if not self.tag_map[(t...
class EventListener(object): ''' Class responsible for listening to the salt master event bus and updating futures. This is the core of what makes this asynchronous, this allows us to do non-blocking work in the main processes and "wait" for an event to happen ''' def __init__(self, mod_opts, o...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
EventListener.get_event
python
def get_event(self, request, tag='', matcher=prefix_matcher.__func__, callback=None, timeout=None ): ''' Get an event (asynchronous of course) return a future that will get it later ''' ...
Get an event (asynchronous of course) return a future that will get it later
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L330-L360
null
class EventListener(object): ''' Class responsible for listening to the salt master event bus and updating futures. This is the core of what makes this asynchronous, this allows us to do non-blocking work in the main processes and "wait" for an event to happen ''' def __init__(self, mod_opts, o...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
EventListener._timeout_future
python
def _timeout_future(self, tag, matcher, future): ''' Timeout a specific future ''' if (tag, matcher) not in self.tag_map: return if not future.done(): future.set_exception(TimeoutException()) self.tag_map[(tag, matcher)].remove(future) ...
Timeout a specific future
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L362-L372
null
class EventListener(object): ''' Class responsible for listening to the salt master event bus and updating futures. This is the core of what makes this asynchronous, this allows us to do non-blocking work in the main processes and "wait" for an event to happen ''' def __init__(self, mod_opts, o...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
EventListener._handle_event_socket_recv
python
def _handle_event_socket_recv(self, raw): ''' Callback for events on the event sub socket ''' mtag, data = self.event.unpack(raw, self.event.serial) # see if we have any futures that need this info: for (tag, matcher), futures in six.iteritems(self.tag_map): ...
Callback for events on the event sub socket
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L374-L398
null
class EventListener(object): ''' Class responsible for listening to the salt master event bus and updating futures. This is the core of what makes this asynchronous, this allows us to do non-blocking work in the main processes and "wait" for an event to happen ''' def __init__(self, mod_opts, o...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
BaseSaltAPIHandler._verify_client
python
def _verify_client(self, low): ''' Verify that the client is in fact one we have ''' if 'client' not in low or low.get('client') not in self.saltclients: self.set_status(400) self.write("400 Invalid Client: Client not found in salt clients") self.finis...
Verify that the client is in fact one we have
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L407-L416
null
class BaseSaltAPIHandler(tornado.web.RequestHandler): # pylint: disable=W0223 ct_out_map = ( ('application/json', _json_dumps), ('application/x-yaml', salt.utils.yaml.safe_dump), ) def initialize(self): ''' Initialize the handler before requests are called ''' ...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
BaseSaltAPIHandler.initialize
python
def initialize(self): ''' Initialize the handler before requests are called ''' if not hasattr(self.application, 'event_listener'): log.debug('init a listener') self.application.event_listener = EventListener( self.application.mod_opts, ...
Initialize the handler before requests are called
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L418-L440
[ "def get_local_client(\n c_path=os.path.join(syspaths.CONFIG_DIR, 'master'),\n mopts=None,\n skip_perm_errors=False,\n io_loop=None,\n auto_reconnect=False):\n '''\n .. versionadded:: 2014.7.0\n\n Read in the config and return the correct LocalClient object based on\n ...
class BaseSaltAPIHandler(tornado.web.RequestHandler): # pylint: disable=W0223 ct_out_map = ( ('application/json', _json_dumps), ('application/x-yaml', salt.utils.yaml.safe_dump), ) def _verify_client(self, low): ''' Verify that the client is in fact one we have ''' ...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
BaseSaltAPIHandler.token
python
def token(self): ''' The token used for the request ''' # find the token (cookie or headers) if AUTH_TOKEN_HEADER in self.request.headers: return self.request.headers[AUTH_TOKEN_HEADER] else: return self.get_cookie(AUTH_COOKIE_NAME)
The token used for the request
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L443-L451
null
class BaseSaltAPIHandler(tornado.web.RequestHandler): # pylint: disable=W0223 ct_out_map = ( ('application/json', _json_dumps), ('application/x-yaml', salt.utils.yaml.safe_dump), ) def _verify_client(self, low): ''' Verify that the client is in fact one we have ''' ...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
BaseSaltAPIHandler._verify_auth
python
def _verify_auth(self): ''' Boolean whether the request is auth'd ''' return self.token and bool(self.application.auth.get_tok(self.token))
Boolean whether the request is auth'd
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L453-L458
null
class BaseSaltAPIHandler(tornado.web.RequestHandler): # pylint: disable=W0223 ct_out_map = ( ('application/json', _json_dumps), ('application/x-yaml', salt.utils.yaml.safe_dump), ) def _verify_client(self, low): ''' Verify that the client is in fact one we have ''' ...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
BaseSaltAPIHandler.prepare
python
def prepare(self): ''' Run before get/posts etc. Pre-flight checks: - verify that we can speak back to them (compatible accept header) ''' # Find an acceptable content-type accept_header = self.request.headers.get('Accept', '*/*') # Ignore any parameter, inclu...
Run before get/posts etc. Pre-flight checks: - verify that we can speak back to them (compatible accept header)
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L460-L490
[ "def _get_lowstate(self):\n '''\n Format the incoming data into a lowstate object\n '''\n if not self.request.body:\n return\n data = self.deserialize(self.request.body)\n self.request_payload = copy(data)\n\n if data and 'arg' in data and not isinstance(data['arg'], list):\n data...
class BaseSaltAPIHandler(tornado.web.RequestHandler): # pylint: disable=W0223 ct_out_map = ( ('application/json', _json_dumps), ('application/x-yaml', salt.utils.yaml.safe_dump), ) def _verify_client(self, low): ''' Verify that the client is in fact one we have ''' ...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
BaseSaltAPIHandler.serialize
python
def serialize(self, data): ''' Serlialize the output based on the Accept header ''' self.set_header('Content-Type', self.content_type) return self.dumper(data)
Serlialize the output based on the Accept header
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L514-L520
null
class BaseSaltAPIHandler(tornado.web.RequestHandler): # pylint: disable=W0223 ct_out_map = ( ('application/json', _json_dumps), ('application/x-yaml', salt.utils.yaml.safe_dump), ) def _verify_client(self, low): ''' Verify that the client is in fact one we have ''' ...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
BaseSaltAPIHandler._form_loader
python
def _form_loader(self, _): ''' function to get the data from the urlencoded forms ignore the data passed in and just get the args from wherever they are ''' data = {} for key in self.request.arguments: val = self.get_arguments(key) if len(val) == 1...
function to get the data from the urlencoded forms ignore the data passed in and just get the args from wherever they are
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L522-L534
null
class BaseSaltAPIHandler(tornado.web.RequestHandler): # pylint: disable=W0223 ct_out_map = ( ('application/json', _json_dumps), ('application/x-yaml', salt.utils.yaml.safe_dump), ) def _verify_client(self, low): ''' Verify that the client is in fact one we have ''' ...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
BaseSaltAPIHandler.deserialize
python
def deserialize(self, data): ''' Deserialize the data based on request content type headers ''' ct_in_map = { 'application/x-www-form-urlencoded': self._form_loader, 'application/json': salt.utils.json.loads, 'application/x-yaml': salt.utils.yaml.safe_...
Deserialize the data based on request content type headers
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L536-L556
null
class BaseSaltAPIHandler(tornado.web.RequestHandler): # pylint: disable=W0223 ct_out_map = ( ('application/json', _json_dumps), ('application/x-yaml', salt.utils.yaml.safe_dump), ) def _verify_client(self, low): ''' Verify that the client is in fact one we have ''' ...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
BaseSaltAPIHandler._get_lowstate
python
def _get_lowstate(self): ''' Format the incoming data into a lowstate object ''' if not self.request.body: return data = self.deserialize(self.request.body) self.request_payload = copy(data) if data and 'arg' in data and not isinstance(data['arg'], li...
Format the incoming data into a lowstate object
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L558-L575
[ "def deserialize(self, data):\n '''\n Deserialize the data based on request content type headers\n '''\n ct_in_map = {\n 'application/x-www-form-urlencoded': self._form_loader,\n 'application/json': salt.utils.json.loads,\n 'application/x-yaml': salt.utils.yaml.safe_load,\n '...
class BaseSaltAPIHandler(tornado.web.RequestHandler): # pylint: disable=W0223 ct_out_map = ( ('application/json', _json_dumps), ('application/x-yaml', salt.utils.yaml.safe_dump), ) def _verify_client(self, low): ''' Verify that the client is in fact one we have ''' ...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
BaseSaltAPIHandler.set_default_headers
python
def set_default_headers(self): ''' Set default CORS headers ''' mod_opts = self.application.mod_opts if mod_opts.get('cors_origin'): origin = self.request.headers.get('Origin') allowed_origin = _check_cors_origin(origin, mod_opts['cors_origin']) ...
Set default CORS headers
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L577-L589
[ "def _check_cors_origin(origin, allowed_origins):\n '''\n Check if an origin match cors allowed origins\n '''\n if isinstance(allowed_origins, list):\n if origin in allowed_origins:\n return origin\n elif allowed_origins == '*':\n return allowed_origins\n elif allowed_orig...
class BaseSaltAPIHandler(tornado.web.RequestHandler): # pylint: disable=W0223 ct_out_map = ( ('application/json', _json_dumps), ('application/x-yaml', salt.utils.yaml.safe_dump), ) def _verify_client(self, low): ''' Verify that the client is in fact one we have ''' ...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
BaseSaltAPIHandler.options
python
def options(self, *args, **kwargs): ''' Return CORS headers for preflight requests ''' # Allow X-Auth-Token in requests request_headers = self.request.headers.get('Access-Control-Request-Headers') allowed_headers = request_headers.split(',') # Filter allowed head...
Return CORS headers for preflight requests
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L591-L611
null
class BaseSaltAPIHandler(tornado.web.RequestHandler): # pylint: disable=W0223 ct_out_map = ( ('application/json', _json_dumps), ('application/x-yaml', salt.utils.yaml.safe_dump), ) def _verify_client(self, low): ''' Verify that the client is in fact one we have ''' ...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
SaltAuthHandler.get
python
def get(self): ''' All logins are done over post, this is a parked endpoint .. http:get:: /login :status 401: |401| :status 406: |406| **Example request:** .. code-block:: bash curl -i localhost:8000/login .. code-block:: text ...
All logins are done over post, this is a parked endpoint .. http:get:: /login :status 401: |401| :status 406: |406| **Example request:** .. code-block:: bash curl -i localhost:8000/login .. code-block:: text GET /login HTTP/1.1 ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L618-L655
[ "def serialize(self, data):\n '''\n Serlialize the output based on the Accept header\n '''\n self.set_header('Content-Type', self.content_type)\n\n return self.dumper(data)\n" ]
class SaltAuthHandler(BaseSaltAPIHandler): # pylint: disable=W0223 ''' Handler for login requests ''' # TODO: make asynchronous? Underlying library isn't... and we ARE making disk calls :( def post(self): ''' :ref:`Authenticate <rest_tornado-auth>` against Salt's eauth system ...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
SaltAuthHandler.post
python
def post(self): ''' :ref:`Authenticate <rest_tornado-auth>` against Salt's eauth system .. http:post:: /login :reqheader X-Auth-Token: |req_token| :reqheader Accept: |req_accept| :reqheader Content-Type: |req_ct| :form eauth: the eauth backend c...
:ref:`Authenticate <rest_tornado-auth>` against Salt's eauth system .. http:post:: /login :reqheader X-Auth-Token: |req_token| :reqheader Accept: |req_accept| :reqheader Content-Type: |req_ct| :form eauth: the eauth backend configured for the user :...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L658-L788
[ "def serialize(self, data):\n '''\n Serlialize the output based on the Accept header\n '''\n self.set_header('Content-Type', self.content_type)\n\n return self.dumper(data)\n" ]
class SaltAuthHandler(BaseSaltAPIHandler): # pylint: disable=W0223 ''' Handler for login requests ''' def get(self): ''' All logins are done over post, this is a parked endpoint .. http:get:: /login :status 401: |401| :status 406: |406| **Examp...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
SaltAPIHandler.get
python
def get(self): ''' An endpoint to determine salt-api capabilities .. http:get:: / :reqheader Accept: |req_accept| :status 200: |200| :status 401: |401| :status 406: |406| **Example request:** .. code-block:: bash c...
An endpoint to determine salt-api capabilities .. http:get:: / :reqheader Accept: |req_accept| :status 200: |200| :status 401: |401| :status 406: |406| **Example request:** .. code-block:: bash curl -i localhost:8000 .. c...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L795-L831
[ "def serialize(self, data):\n '''\n Serlialize the output based on the Accept header\n '''\n self.set_header('Content-Type', self.content_type)\n\n return self.dumper(data)\n" ]
class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223 ''' Main API handler for base "/" ''' @tornado.web.asynchronous def post(self): ''' Send one or more Salt commands (lowstates) in the request body .. http:post:: / :reqheader X-Auth-Token: |req...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
SaltAPIHandler.disbatch
python
def disbatch(self): ''' Disbatch all lowstates to the appropriate clients ''' ret = [] # check clients before going, we want to throw 400 if one is bad for low in self.lowstate: if not self._verify_client(low): return # Make sure ...
Disbatch all lowstates to the appropriate clients
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L912-L946
[ "def _verify_client(self, low):\n '''\n Verify that the client is in fact one we have\n '''\n if 'client' not in low or low.get('client') not in self.saltclients:\n self.set_status(400)\n self.write(\"400 Invalid Client: Client not found in salt clients\")\n self.finish()\n r...
class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223 ''' Main API handler for base "/" ''' def get(self): ''' An endpoint to determine salt-api capabilities .. http:get:: / :reqheader Accept: |req_accept| :status 200: |200| :st...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
SaltAPIHandler._disbatch_local
python
def _disbatch_local(self, chunk): ''' Dispatch local client commands ''' # Generate jid and find all minions before triggering a job to subscribe all returns from minions full_return = chunk.pop('full_return', False) chunk['jid'] = salt.utils.jid.gen_jid(self.application....
Dispatch local client commands
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L949-L1070
null
class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223 ''' Main API handler for base "/" ''' def get(self): ''' An endpoint to determine salt-api capabilities .. http:get:: / :reqheader Accept: |req_accept| :status 200: |200| :st...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
SaltAPIHandler.job_not_running
python
def job_not_running(self, jid, tgt, tgt_type, minions, is_finished): ''' Return a future which will complete once jid (passed in) is no longer running on tgt ''' ping_pub_data = yield self.saltclients['local'](tgt, 'saltutil...
Return a future which will complete once jid (passed in) is no longer running on tgt
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L1073-L1111
[ "def tagify(suffix='', prefix='', base=SALT):\n '''\n convenience function to build a namespaced event tag string\n from joining with the TABPART character the base, prefix and suffix\n\n If string prefix is a valid key in TAGS Then use the value of key prefix\n Else use prefix string\n\n If suffi...
class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223 ''' Main API handler for base "/" ''' def get(self): ''' An endpoint to determine salt-api capabilities .. http:get:: / :reqheader Accept: |req_accept| :status 200: |200| :st...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
SaltAPIHandler._disbatch_local_async
python
def _disbatch_local_async(self, chunk): ''' Disbatch local client_async commands ''' f_call = self._format_call_run_job_async(chunk) # fire a job off pub_data = yield self.saltclients['local_async'](*f_call.get('args', ()), **f_call.get('kwargs', {})) raise torna...
Disbatch local client_async commands
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L1114-L1122
null
class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223 ''' Main API handler for base "/" ''' def get(self): ''' An endpoint to determine salt-api capabilities .. http:get:: / :reqheader Accept: |req_accept| :status 200: |200| :st...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
SaltAPIHandler._disbatch_runner
python
def _disbatch_runner(self, chunk): ''' Disbatch runner client commands ''' full_return = chunk.pop('full_return', False) pub_data = self.saltclients['runner'](chunk) tag = pub_data['tag'] + '/ret' try: event = yield self.application.event_listener.get_...
Disbatch runner client commands
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L1125-L1139
null
class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223 ''' Main API handler for base "/" ''' def get(self): ''' An endpoint to determine salt-api capabilities .. http:get:: / :reqheader Accept: |req_accept| :status 200: |200| :st...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
SaltAPIHandler._disbatch_runner_async
python
def _disbatch_runner_async(self, chunk): ''' Disbatch runner client_async commands ''' pub_data = self.saltclients['runner'](chunk) raise tornado.gen.Return(pub_data)
Disbatch runner client_async commands
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L1142-L1147
null
class SaltAPIHandler(BaseSaltAPIHandler): # pylint: disable=W0223 ''' Main API handler for base "/" ''' def get(self): ''' An endpoint to determine salt-api capabilities .. http:get:: / :reqheader Accept: |req_accept| :status 200: |200| :st...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
MinionSaltAPIHandler.get
python
def get(self, mid=None): # pylint: disable=W0221 ''' A convenience URL for getting lists of minions or getting minion details .. http:get:: /minions/(mid) :reqheader X-Auth-Token: |req_token| :reqheader Accept: |req_accept| :status 200: |200| ...
A convenience URL for getting lists of minions or getting minion details .. http:get:: /minions/(mid) :reqheader X-Auth-Token: |req_token| :reqheader Accept: |req_accept| :status 200: |200| :status 401: |401| :status 406: |406| **Ex...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L1165-L1214
[ "def _verify_auth(self):\n '''\n Boolean whether the request is auth'd\n '''\n\n return self.token and bool(self.application.auth.get_tok(self.token))\n" ]
class MinionSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223 ''' A convenience endpoint for minion related functions ''' @tornado.web.asynchronous @tornado.web.asynchronous def post(self): ''' Start an execution command and immediately return the job id .. http...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
MinionSaltAPIHandler.post
python
def post(self): ''' Start an execution command and immediately return the job id .. http:post:: /minions :reqheader X-Auth-Token: |req_token| :reqheader Accept: |req_accept| :reqheader Content-Type: |req_ct| :resheader Content-Type: |res_ct| ...
Start an execution command and immediately return the job id .. http:post:: /minions :reqheader X-Auth-Token: |req_token| :reqheader Accept: |req_accept| :reqheader Content-Type: |req_ct| :resheader Content-Type: |res_ct| :status 200: |200| ...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L1217-L1286
[ "def _verify_auth(self):\n '''\n Boolean whether the request is auth'd\n '''\n\n return self.token and bool(self.application.auth.get_tok(self.token))\n" ]
class MinionSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223 ''' A convenience endpoint for minion related functions ''' @tornado.web.asynchronous def get(self, mid=None): # pylint: disable=W0221 ''' A convenience URL for getting lists of minions or getting minion de...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
JobsSaltAPIHandler.get
python
def get(self, jid=None): # pylint: disable=W0221 ''' A convenience URL for getting lists of previously run jobs or getting the return from a single job .. http:get:: /jobs/(jid) List jobs or show a single job from the job cache. :status 200: |200| ...
A convenience URL for getting lists of previously run jobs or getting the return from a single job .. http:get:: /jobs/(jid) List jobs or show a single job from the job cache. :status 200: |200| :status 401: |401| :status 406: |406| **Example r...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L1294-L1392
[ "def _verify_auth(self):\n '''\n Boolean whether the request is auth'd\n '''\n\n return self.token and bool(self.application.auth.get_tok(self.token))\n" ]
class JobsSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223 ''' A convenience endpoint for job cache data ''' @tornado.web.asynchronous
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
EventsSaltAPIHandler.get
python
def get(self): r''' An HTTP stream of the Salt master event bus This stream is formatted per the Server Sent Events (SSE) spec. Each event is formatted as JSON. .. http:get:: /events :status 200: |200| :status 401: |401| :status 406: |406| ...
r''' An HTTP stream of the Salt master event bus This stream is formatted per the Server Sent Events (SSE) spec. Each event is formatted as JSON. .. http:get:: /events :status 200: |200| :status 401: |401| :status 406: |406| **Example reque...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L1471-L1584
[ "def _json_dumps(obj, **kwargs):\n '''\n Invoke salt.utils.json.dumps using the alternate json module loaded using\n salt.utils.json.import_json(). This ensures that we properly encode any\n strings in the object before we perform the serialization.\n '''\n return salt.utils.json.dumps(obj, _json_...
class EventsSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223 ''' Expose the Salt event bus The event bus on the Salt master exposes a large variety of things, notably when executions are started on the master and also when minions ultimately return their results. This URL provides a real-ti...
saltstack/salt
salt/netapi/rest_tornado/saltnado.py
WebhookSaltAPIHandler.post
python
def post(self, tag_suffix=None): # pylint: disable=W0221 ''' Fire an event in Salt with a custom event tag and data .. http:post:: /hook :status 200: |200| :status 401: |401| :status 406: |406| :status 413: request body is too large **E...
Fire an event in Salt with a custom event tag and data .. http:post:: /hook :status 200: |200| :status 401: |401| :status 406: |406| :status 413: request body is too large **Example request:** .. code-block:: bash curl -sS localhos...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/saltnado.py#L1628-L1747
[ "def get_event(\n node, sock_dir=None, transport='zeromq',\n opts=None, listen=True, io_loop=None, keep_loop=False, raise_errors=False):\n '''\n Return an event object suitable for the named transport\n\n :param IOLoop io_loop: Pass in an io_loop if you want asynchronous\n ...
class WebhookSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223 ''' A generic web hook entry point that fires an event on Salt's event bus External services can POST data to this URL to trigger an event in Salt. For example, Amazon SNS, Jenkins-CI or Travis-CI, or GitHub web hooks. .. note::...
saltstack/salt
salt/beacons/proxy_example.py
beacon
python
def beacon(config): ''' Called several times each second https://docs.saltstack.com/en/latest/topics/beacons/#the-beacon-function .. code-block:: yaml beacons: proxy_example: - endpoint: beacon ''' # Important!!! # Although this toy example makes an HTTP call ...
Called several times each second https://docs.saltstack.com/en/latest/topics/beacons/#the-beacon-function .. code-block:: yaml beacons: proxy_example: - endpoint: beacon
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/beacons/proxy_example.py#L46-L71
null
# -*- coding: utf-8 -*- ''' Example beacon to use with salt-proxy .. code-block:: yaml beacons: proxy_example: endpoint: beacon ''' # Import Python libs from __future__ import absolute_import, unicode_literals import logging # Import salt libs import salt.utils.http from salt.ext.six.moves import ...
saltstack/salt
salt/states/pdbedit.py
absent
python
def absent(name): ''' Ensure user account is absent name : string username ''' ret = {'name': name, 'changes': {}, 'result': True, 'comment': ''} # remove if needed if name in __salt__['pdbedit.list'](False): res = __salt__['pdbedit.delete']...
Ensure user account is absent name : string username
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/pdbedit.py#L53-L75
null
# -*- coding: utf-8 -*- ''' Manage accounts in Samba's passdb using pdbedit :maintainer: Jorge Schrauwen <sjorge@blackdot.be> :maturity: new :depends: pdbedit :platform: posix .. versionadded:: 2017.7.0 .. code-block:: yaml wash: pdbedit.absent kaylee: pdbedit.managed: ...
saltstack/salt
salt/states/pdbedit.py
managed
python
def managed(name, **kwargs): ''' Manage user account login : string login name password : string password password_hashed : boolean set if password is a nt hash instead of plain text domain : string users domain profile : string profile path scrip...
Manage user account login : string login name password : string password password_hashed : boolean set if password is a nt hash instead of plain text domain : string users domain profile : string profile path script : string logon script drive...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/pdbedit.py#L78-L146
null
# -*- coding: utf-8 -*- ''' Manage accounts in Samba's passdb using pdbedit :maintainer: Jorge Schrauwen <sjorge@blackdot.be> :maturity: new :depends: pdbedit :platform: posix .. versionadded:: 2017.7.0 .. code-block:: yaml wash: pdbedit.absent kaylee: pdbedit.managed: ...
saltstack/salt
salt/modules/salt_proxy.py
_write_proxy_conf
python
def _write_proxy_conf(proxyfile): ''' write to file ''' msg = 'Invalid value for proxy file provided!, Supplied value = {0}' \ .format(proxyfile) log.trace('Salt Proxy Module: write proxy conf') if proxyfile: log.debug('Writing proxy conf file') with salt.utils.files.fo...
write to file
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/salt_proxy.py#L24-L41
null
# -*- coding: utf-8 -*- ''' Salt proxy module .. versionadded:: 2015.8.3 Module to deploy and manage salt-proxy processes on a minion. ''' # Import Python libs from __future__ import absolute_import, unicode_literals, print_function import os import logging # Import Salt libs import salt.utils.files ...
saltstack/salt
salt/modules/salt_proxy.py
_proxy_conf_file
python
def _proxy_conf_file(proxyfile, test): ''' Check if proxy conf exists and update ''' changes_old = [] changes_new = [] success = True if not os.path.exists(proxyfile): try: if not test: changes_new.append(_write_proxy_conf(proxyfile)) msg =...
Check if proxy conf exists and update
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/salt_proxy.py#L44-L70
[ "def _write_proxy_conf(proxyfile):\n '''\n write to file\n '''\n msg = 'Invalid value for proxy file provided!, Supplied value = {0}' \\\n .format(proxyfile)\n\n log.trace('Salt Proxy Module: write proxy conf')\n\n if proxyfile:\n log.debug('Writing proxy conf file')\n with sa...
# -*- coding: utf-8 -*- ''' Salt proxy module .. versionadded:: 2015.8.3 Module to deploy and manage salt-proxy processes on a minion. ''' # Import Python libs from __future__ import absolute_import, unicode_literals, print_function import os import logging # Import Salt libs import salt.utils.files ...
saltstack/salt
salt/modules/salt_proxy.py
_is_proxy_running
python
def _is_proxy_running(proxyname): ''' Check if proxy for this name is running ''' cmd = ('ps ax | grep "salt-proxy --proxyid={0}" | grep -v grep' .format(salt.ext.six.moves.shlex_quote(proxyname))) cmdout = __salt__['cmd.run_all']( cmd, timeout=5, python_shell=True...
Check if proxy for this name is running
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/salt_proxy.py#L73-L86
null
# -*- coding: utf-8 -*- ''' Salt proxy module .. versionadded:: 2015.8.3 Module to deploy and manage salt-proxy processes on a minion. ''' # Import Python libs from __future__ import absolute_import, unicode_literals, print_function import os import logging # Import Salt libs import salt.utils.files ...
saltstack/salt
salt/modules/salt_proxy.py
_proxy_process
python
def _proxy_process(proxyname, test): ''' Check and execute proxy process ''' changes_old = [] changes_new = [] if not _is_proxy_running(proxyname): if not test: __salt__['cmd.run_all']( 'salt-proxy --proxyid={0} -l info -d'.format(salt.ext.six.moves.shlex_quot...
Check and execute proxy process
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/salt_proxy.py#L89-L108
[ "def _is_proxy_running(proxyname):\n '''\n Check if proxy for this name is running\n '''\n cmd = ('ps ax | grep \"salt-proxy --proxyid={0}\" | grep -v grep'\n .format(salt.ext.six.moves.shlex_quote(proxyname)))\n cmdout = __salt__['cmd.run_all'](\n cmd,\n timeout=5,\n p...
# -*- coding: utf-8 -*- ''' Salt proxy module .. versionadded:: 2015.8.3 Module to deploy and manage salt-proxy processes on a minion. ''' # Import Python libs from __future__ import absolute_import, unicode_literals, print_function import os import logging # Import Salt libs import salt.utils.files ...
saltstack/salt
salt/modules/salt_proxy.py
configure_proxy
python
def configure_proxy(proxyname, start=True): ''' Create the salt proxy file and start the proxy process if required Parameters: proxyname: Name to be used for this proxy (should match entries in pillar) start: Boolean indicating if the process should be started ...
Create the salt proxy file and start the proxy process if required Parameters: proxyname: Name to be used for this proxy (should match entries in pillar) start: Boolean indicating if the process should be started default = True CLI Example: .. code-...
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/salt_proxy.py#L111-L156
[ "def _proxy_conf_file(proxyfile, test):\n '''\n Check if proxy conf exists and update\n '''\n changes_old = []\n changes_new = []\n success = True\n if not os.path.exists(proxyfile):\n try:\n if not test:\n changes_new.append(_write_proxy_conf(proxyfile))\n ...
# -*- coding: utf-8 -*- ''' Salt proxy module .. versionadded:: 2015.8.3 Module to deploy and manage salt-proxy processes on a minion. ''' # Import Python libs from __future__ import absolute_import, unicode_literals, print_function import os import logging # Import Salt libs import salt.utils.files ...
saltstack/salt
salt/netapi/rest_tornado/event_processor.py
SaltInfo.publish_minions
python
def publish_minions(self): ''' Publishes minions as a list of dicts. ''' log.debug('in publish minions') minions = {} log.debug('starting loop') for minion, minion_info in six.iteritems(self.minions): log.debug(minion) # log.debug(minion_i...
Publishes minions as a list of dicts.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/event_processor.py#L32-L50
[ "def iteritems(d, **kw):\n return d.iteritems(**kw)\n", "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 unico...
class SaltInfo(object): ''' Class to handle processing and publishing of "real time" Salt upates. ''' def __init__(self, handler): ''' handler is expected to be the server side end of a websocket connection. ''' self.handler = handler # These represent ...
saltstack/salt
salt/netapi/rest_tornado/event_processor.py
SaltInfo.publish
python
def publish(self, key, data): ''' Publishes the data to the event stream. ''' publish_data = {key: data} pub = salt.utils.json.dumps(publish_data) + str('\n\n') # future lint: disable=blacklisted-function self.handler.write_message(pub)
Publishes the data to the event stream.
train
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/netapi/rest_tornado/event_processor.py#L52-L58
[ "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...
class SaltInfo(object): ''' Class to handle processing and publishing of "real time" Salt upates. ''' def __init__(self, handler): ''' handler is expected to be the server side end of a websocket connection. ''' self.handler = handler # These represent ...