repo
stringclasses
85 values
path
stringlengths
8
121
func_name
stringlengths
1
82
original_string
stringlengths
112
65.5k
language
stringclasses
1 value
code
stringlengths
112
65.5k
code_tokens
listlengths
20
4.09k
docstring
stringlengths
3
46.3k
docstring_tokens
listlengths
1
564
sha
stringclasses
85 values
url
stringlengths
93
218
partition
stringclasses
1 value
saltstack/salt
salt/modules/boto_elasticache.py
exists
def exists(name, region=None, key=None, keyid=None, profile=None): ''' Check to see if a cache cluster exists. CLI example:: salt myminion boto_elasticache.exists myelasticache ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: conn.describe_cache_...
python
def exists(name, region=None, key=None, keyid=None, profile=None): ''' Check to see if a cache cluster exists. CLI example:: salt myminion boto_elasticache.exists myelasticache ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: conn.describe_cache_...
[ "def", "exists", "(", "name", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ",", "keyid", "="...
Check to see if a cache cluster exists. CLI example:: salt myminion boto_elasticache.exists myelasticache
[ "Check", "to", "see", "if", "a", "cache", "cluster", "exists", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L87-L102
train
saltstack/salt
salt/modules/boto_elasticache.py
group_exists
def group_exists(name, region=None, key=None, keyid=None, profile=None): ''' Check to see if a replication group exists. CLI example:: salt myminion boto_elasticache.group_exists myelasticache ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: conn...
python
def group_exists(name, region=None, key=None, keyid=None, profile=None): ''' Check to see if a replication group exists. CLI example:: salt myminion boto_elasticache.group_exists myelasticache ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: conn...
[ "def", "group_exists", "(", "name", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ",", "keyid",...
Check to see if a replication group exists. CLI example:: salt myminion boto_elasticache.group_exists myelasticache
[ "Check", "to", "see", "if", "a", "replication", "group", "exists", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L105-L120
train
saltstack/salt
salt/modules/boto_elasticache.py
create_replication_group
def create_replication_group(name, primary_cluster_id, replication_group_description, wait=None, region=None, key=None, keyid=None, profile=None): ''' Create replication group. CLI example:: salt myminion boto_elasticache.create_replication...
python
def create_replication_group(name, primary_cluster_id, replication_group_description, wait=None, region=None, key=None, keyid=None, profile=None): ''' Create replication group. CLI example:: salt myminion boto_elasticache.create_replication...
[ "def", "create_replication_group", "(", "name", ",", "primary_cluster_id", ",", "replication_group_description", ",", "wait", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", ...
Create replication group. CLI example:: salt myminion boto_elasticache.create_replication_group myelasticache myprimarycluster description
[ "Create", "replication", "group", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L123-L154
train
saltstack/salt
salt/modules/boto_elasticache.py
describe_replication_group
def describe_replication_group(name, region=None, key=None, keyid=None, profile=None, parameter=None): ''' Get replication group information. CLI example:: salt myminion boto_elasticache.describe_replication_group mygroup ''' conn = _get_conn(region=region, k...
python
def describe_replication_group(name, region=None, key=None, keyid=None, profile=None, parameter=None): ''' Get replication group information. CLI example:: salt myminion boto_elasticache.describe_replication_group mygroup ''' conn = _get_conn(region=region, k...
[ "def", "describe_replication_group", "(", "name", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ",", "parameter", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "regio...
Get replication group information. CLI example:: salt myminion boto_elasticache.describe_replication_group mygroup
[ "Get", "replication", "group", "information", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L181-L241
train
saltstack/salt
salt/modules/boto_elasticache.py
get_config
def get_config(name, region=None, key=None, keyid=None, profile=None): ''' Get the configuration for a cache cluster. CLI example:: salt myminion boto_elasticache.get_config myelasticache ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) if not conn: r...
python
def get_config(name, region=None, key=None, keyid=None, profile=None): ''' Get the configuration for a cache cluster. CLI example:: salt myminion boto_elasticache.get_config myelasticache ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) if not conn: r...
[ "def", "get_config", "(", "name", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ",", "keyid", ...
Get the configuration for a cache cluster. CLI example:: salt myminion boto_elasticache.get_config myelasticache
[ "Get", "the", "configuration", "for", "a", "cache", "cluster", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L244-L307
train
saltstack/salt
salt/modules/boto_elasticache.py
get_node_host
def get_node_host(name, region=None, key=None, keyid=None, profile=None): ''' Get hostname from cache node CLI example:: salt myminion boto_elasticache.get_node_host myelasticache ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) if not conn: return No...
python
def get_node_host(name, region=None, key=None, keyid=None, profile=None): ''' Get hostname from cache node CLI example:: salt myminion boto_elasticache.get_node_host myelasticache ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) if not conn: return No...
[ "def", "get_node_host", "(", "name", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ",", "keyid"...
Get hostname from cache node CLI example:: salt myminion boto_elasticache.get_node_host myelasticache
[ "Get", "hostname", "from", "cache", "node" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L310-L333
train
saltstack/salt
salt/modules/boto_elasticache.py
get_group_host
def get_group_host(name, region=None, key=None, keyid=None, profile=None): ''' Get hostname from replication cache group CLI example:: salt myminion boto_elasticache.get_group_host myelasticachegroup ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) if not con...
python
def get_group_host(name, region=None, key=None, keyid=None, profile=None): ''' Get hostname from replication cache group CLI example:: salt myminion boto_elasticache.get_group_host myelasticachegroup ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) if not con...
[ "def", "get_group_host", "(", "name", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ",", "keyid...
Get hostname from replication cache group CLI example:: salt myminion boto_elasticache.get_group_host myelasticachegroup
[ "Get", "hostname", "from", "replication", "cache", "group" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L336-L359
train
saltstack/salt
salt/modules/boto_elasticache.py
get_all_cache_subnet_groups
def get_all_cache_subnet_groups(name=None, region=None, key=None, keyid=None, profile=None): ''' Return a list of all cache subnet groups with details CLI example:: salt myminion boto_elasticache.get_all_subnet_groups region=us-east-1 ''' conn = _get_conn(re...
python
def get_all_cache_subnet_groups(name=None, region=None, key=None, keyid=None, profile=None): ''' Return a list of all cache subnet groups with details CLI example:: salt myminion boto_elasticache.get_all_subnet_groups region=us-east-1 ''' conn = _get_conn(re...
[ "def", "get_all_cache_subnet_groups", "(", "name", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", ...
Return a list of all cache subnet groups with details CLI example:: salt myminion boto_elasticache.get_all_subnet_groups region=us-east-1
[ "Return", "a", "list", "of", "all", "cache", "subnet", "groups", "with", "details" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L362-L387
train
saltstack/salt
salt/modules/boto_elasticache.py
list_cache_subnet_groups
def list_cache_subnet_groups(name=None, region=None, key=None, keyid=None, profile=None): ''' Return a list of all cache subnet group names CLI example:: salt myminion boto_elasticache.list_subnet_groups region=us-east-1 ''' return [g['CacheSubnetGroupName'] fo...
python
def list_cache_subnet_groups(name=None, region=None, key=None, keyid=None, profile=None): ''' Return a list of all cache subnet group names CLI example:: salt myminion boto_elasticache.list_subnet_groups region=us-east-1 ''' return [g['CacheSubnetGroupName'] fo...
[ "def", "list_cache_subnet_groups", "(", "name", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "return", "[", "g", "[", "'CacheSubnetGroupName'", "]", "for", "g", "in"...
Return a list of all cache subnet group names CLI example:: salt myminion boto_elasticache.list_subnet_groups region=us-east-1
[ "Return", "a", "list", "of", "all", "cache", "subnet", "group", "names" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L390-L400
train
saltstack/salt
salt/modules/boto_elasticache.py
subnet_group_exists
def subnet_group_exists(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Check to see if an ElastiCache subnet group exists. CLI example:: salt myminion boto_elasticache.subnet_group_exists my-param-group \ region=us-east-1 ''' conn = _get_conn(region=...
python
def subnet_group_exists(name, tags=None, region=None, key=None, keyid=None, profile=None): ''' Check to see if an ElastiCache subnet group exists. CLI example:: salt myminion boto_elasticache.subnet_group_exists my-param-group \ region=us-east-1 ''' conn = _get_conn(region=...
[ "def", "subnet_group_exists", "(", "name", ",", "tags", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", ...
Check to see if an ElastiCache subnet group exists. CLI example:: salt myminion boto_elasticache.subnet_group_exists my-param-group \ region=us-east-1
[ "Check", "to", "see", "if", "an", "ElastiCache", "subnet", "group", "exists", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L403-L424
train
saltstack/salt
salt/modules/boto_elasticache.py
create_subnet_group
def create_subnet_group(name, description, subnet_ids=None, subnet_names=None, tags=None, region=None, key=None, keyid=None, profile=None): ''' Create an ElastiCache subnet group CLI example to create an ElastiCache subnet group:: salt myminion boto_elasticache.create_subne...
python
def create_subnet_group(name, description, subnet_ids=None, subnet_names=None, tags=None, region=None, key=None, keyid=None, profile=None): ''' Create an ElastiCache subnet group CLI example to create an ElastiCache subnet group:: salt myminion boto_elasticache.create_subne...
[ "def", "create_subnet_group", "(", "name", ",", "description", ",", "subnet_ids", "=", "None", ",", "subnet_names", "=", "None", ",", "tags", "=", "None", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "...
Create an ElastiCache subnet group CLI example to create an ElastiCache subnet group:: salt myminion boto_elasticache.create_subnet_group my-subnet-group \ "group description" subnet_ids='[subnet-12345678, subnet-87654321]' \ region=us-east-1
[ "Create", "an", "ElastiCache", "subnet", "group" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L427-L468
train
saltstack/salt
salt/modules/boto_elasticache.py
get_cache_subnet_group
def get_cache_subnet_group(name, region=None, key=None, keyid=None, profile=None): ''' Get information about a cache subnet group. CLI example:: salt myminion boto_elasticache.get_cache_subnet_group mycache_subnet_group ''' conn = _get_conn(region=region, key=key...
python
def get_cache_subnet_group(name, region=None, key=None, keyid=None, profile=None): ''' Get information about a cache subnet group. CLI example:: salt myminion boto_elasticache.get_cache_subnet_group mycache_subnet_group ''' conn = _get_conn(region=region, key=key...
[ "def", "get_cache_subnet_group", "(", "name", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ",", ...
Get information about a cache subnet group. CLI example:: salt myminion boto_elasticache.get_cache_subnet_group mycache_subnet_group
[ "Get", "information", "about", "a", "cache", "subnet", "group", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L471-L513
train
saltstack/salt
salt/modules/boto_elasticache.py
delete_subnet_group
def delete_subnet_group(name, region=None, key=None, keyid=None, profile=None): ''' Delete an ElastiCache subnet group. CLI example:: salt myminion boto_elasticache.delete_subnet_group my-subnet-group \ region=us-east-1 ''' conn = _get_conn(region=region, key=key, keyid=key...
python
def delete_subnet_group(name, region=None, key=None, keyid=None, profile=None): ''' Delete an ElastiCache subnet group. CLI example:: salt myminion boto_elasticache.delete_subnet_group my-subnet-group \ region=us-east-1 ''' conn = _get_conn(region=region, key=key, keyid=key...
[ "def", "delete_subnet_group", "(", "name", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ",", "...
Delete an ElastiCache subnet group. CLI example:: salt myminion boto_elasticache.delete_subnet_group my-subnet-group \ region=us-east-1
[ "Delete", "an", "ElastiCache", "subnet", "group", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L516-L537
train
saltstack/salt
salt/modules/boto_elasticache.py
create
def create(name, num_cache_nodes=None, engine=None, cache_node_type=None, replication_group_id=None, engine_version=None, cache_parameter_group_name=None, cache_subnet_group_name=None, cache_security_group_names=None, security_group_ids=None, snapshot_arns=None, preferred_ava...
python
def create(name, num_cache_nodes=None, engine=None, cache_node_type=None, replication_group_id=None, engine_version=None, cache_parameter_group_name=None, cache_subnet_group_name=None, cache_security_group_names=None, security_group_ids=None, snapshot_arns=None, preferred_ava...
[ "def", "create", "(", "name", ",", "num_cache_nodes", "=", "None", ",", "engine", "=", "None", ",", "cache_node_type", "=", "None", ",", "replication_group_id", "=", "None", ",", "engine_version", "=", "None", ",", "cache_parameter_group_name", "=", "None", ",...
Create a cache cluster. CLI example:: salt myminion boto_elasticache.create myelasticache 1 redis cache.t1.micro cache_security_group_names='["myelasticachesg"]'
[ "Create", "a", "cache", "cluster", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L540-L581
train
saltstack/salt
salt/modules/boto_elasticache.py
delete
def delete(name, wait=False, region=None, key=None, keyid=None, profile=None): ''' Delete a cache cluster. CLI example:: salt myminion boto_elasticache.delete myelasticache ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: conn.delete_cache_cluste...
python
def delete(name, wait=False, region=None, key=None, keyid=None, profile=None): ''' Delete a cache cluster. CLI example:: salt myminion boto_elasticache.delete myelasticache ''' conn = _get_conn(region=region, key=key, keyid=keyid, profile=profile) try: conn.delete_cache_cluste...
[ "def", "delete", "(", "name", ",", "wait", "=", "False", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=...
Delete a cache cluster. CLI example:: salt myminion boto_elasticache.delete myelasticache
[ "Delete", "a", "cache", "cluster", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L584-L612
train
saltstack/salt
salt/modules/boto_elasticache.py
create_cache_security_group
def create_cache_security_group(name, description, region=None, key=None, keyid=None, profile=None): ''' Create a cache security group. CLI example:: salt myminion boto_elasticache.create_cache_security_group myelasticachesg 'My Cache Security Group' ''' con...
python
def create_cache_security_group(name, description, region=None, key=None, keyid=None, profile=None): ''' Create a cache security group. CLI example:: salt myminion boto_elasticache.create_cache_security_group myelasticachesg 'My Cache Security Group' ''' con...
[ "def", "create_cache_security_group", "(", "name", ",", "description", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "...
Create a cache security group. CLI example:: salt myminion boto_elasticache.create_cache_security_group myelasticachesg 'My Cache Security Group'
[ "Create", "a", "cache", "security", "group", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L615-L633
train
saltstack/salt
salt/modules/boto_elasticache.py
delete_cache_security_group
def delete_cache_security_group(name, region=None, key=None, keyid=None, profile=None): ''' Delete a cache security group. CLI example:: salt myminion boto_elasticache.delete_cache_security_group myelasticachesg 'My Cache Security Group' ''' conn = _get_conn...
python
def delete_cache_security_group(name, region=None, key=None, keyid=None, profile=None): ''' Delete a cache security group. CLI example:: salt myminion boto_elasticache.delete_cache_security_group myelasticachesg 'My Cache Security Group' ''' conn = _get_conn...
[ "def", "delete_cache_security_group", "(", "name", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", "_get_conn", "(", "region", "=", "region", ",", "key", "=", "key", ...
Delete a cache security group. CLI example:: salt myminion boto_elasticache.delete_cache_security_group myelasticachesg 'My Cache Security Group'
[ "Delete", "a", "cache", "security", "group", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L636-L654
train
saltstack/salt
salt/modules/boto_elasticache.py
authorize_cache_security_group_ingress
def authorize_cache_security_group_ingress(name, ec2_security_group_name, ec2_security_group_owner_id, region=None, key=None, keyid=None, profile=None): ''' Authorize network ingress ...
python
def authorize_cache_security_group_ingress(name, ec2_security_group_name, ec2_security_group_owner_id, region=None, key=None, keyid=None, profile=None): ''' Authorize network ingress ...
[ "def", "authorize_cache_security_group_ingress", "(", "name", ",", "ec2_security_group_name", ",", "ec2_security_group_owner_id", ",", "region", "=", "None", ",", "key", "=", "None", ",", "keyid", "=", "None", ",", "profile", "=", "None", ")", ":", "conn", "=", ...
Authorize network ingress from an ec2 security group to a cache security group. CLI example:: salt myminion boto_elasticache.authorize_cache_security_group_ingress myelasticachesg myec2sg 879879
[ "Authorize", "network", "ingress", "from", "an", "ec2", "security", "group", "to", "a", "cache", "security", "group", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/boto_elasticache.py#L657-L689
train
saltstack/salt
salt/output/__init__.py
try_printout
def try_printout(data, out, opts, **kwargs): ''' Safely get the string to print out, try the configured outputter, then fall back to nested and then to raw ''' try: printout = get_printout(out, opts)(data, **kwargs) if printout is not None: return printout.rstrip() ex...
python
def try_printout(data, out, opts, **kwargs): ''' Safely get the string to print out, try the configured outputter, then fall back to nested and then to raw ''' try: printout = get_printout(out, opts)(data, **kwargs) if printout is not None: return printout.rstrip() ex...
[ "def", "try_printout", "(", "data", ",", "out", ",", "opts", ",", "*", "*", "kwargs", ")", ":", "try", ":", "printout", "=", "get_printout", "(", "out", ",", "opts", ")", "(", "data", ",", "*", "*", "kwargs", ")", "if", "printout", "is", "not", "...
Safely get the string to print out, try the configured outputter, then fall back to nested and then to raw
[ "Safely", "get", "the", "string", "to", "print", "out", "try", "the", "configured", "outputter", "then", "fall", "back", "to", "nested", "and", "then", "to", "raw" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L37-L56
train
saltstack/salt
salt/output/__init__.py
get_progress
def get_progress(opts, out, progress): ''' Get the progress bar from the given outputter ''' return salt.loader.raw_mod(opts, out, 'rawmodule', mod='output')['{0}.progress_iter'.format(out)](progress)
python
def get_progress(opts, out, progress): ''' Get the progress bar from the given outputter ''' return salt.loader.raw_mod(opts, out, 'rawmodule', mod='output')['{0}.progress_iter'.format(out)](progress)
[ "def", "get_progress", "(", "opts", ",", "out", ",", "progress", ")", ":", "return", "salt", ".", "loader", ".", "raw_mod", "(", "opts", ",", "out", ",", "'rawmodule'", ",", "mod", "=", "'output'", ")", "[", "'{0}.progress_iter'", ".", "format", "(", "...
Get the progress bar from the given outputter
[ "Get", "the", "progress", "bar", "from", "the", "given", "outputter" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L59-L66
train
saltstack/salt
salt/output/__init__.py
update_progress
def update_progress(opts, progress, progress_iter, out): ''' Update the progress iterator for the given outputter ''' # Look up the outputter try: progress_outputter = salt.loader.outputters(opts)[out] except KeyError: # Outputter is not loaded log.warning('Progress outputter no...
python
def update_progress(opts, progress, progress_iter, out): ''' Update the progress iterator for the given outputter ''' # Look up the outputter try: progress_outputter = salt.loader.outputters(opts)[out] except KeyError: # Outputter is not loaded log.warning('Progress outputter no...
[ "def", "update_progress", "(", "opts", ",", "progress", ",", "progress_iter", ",", "out", ")", ":", "# Look up the outputter", "try", ":", "progress_outputter", "=", "salt", ".", "loader", ".", "outputters", "(", "opts", ")", "[", "out", "]", "except", "KeyE...
Update the progress iterator for the given outputter
[ "Update", "the", "progress", "iterator", "for", "the", "given", "outputter" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L69-L79
train
saltstack/salt
salt/output/__init__.py
display_output
def display_output(data, out=None, opts=None, **kwargs): ''' Print the passed data using the desired output ''' if opts is None: opts = {} display_data = try_printout(data, out, opts, **kwargs) output_filename = opts.get('output_file', None) log.trace('data = %s', data) try: ...
python
def display_output(data, out=None, opts=None, **kwargs): ''' Print the passed data using the desired output ''' if opts is None: opts = {} display_data = try_printout(data, out, opts, **kwargs) output_filename = opts.get('output_file', None) log.trace('data = %s', data) try: ...
[ "def", "display_output", "(", "data", ",", "out", "=", "None", ",", "opts", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "opts", "is", "None", ":", "opts", "=", "{", "}", "display_data", "=", "try_printout", "(", "data", ",", "out", ",", ...
Print the passed data using the desired output
[ "Print", "the", "passed", "data", "using", "the", "desired", "output" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L90-L132
train
saltstack/salt
salt/output/__init__.py
get_printout
def get_printout(out, opts=None, **kwargs): ''' Return a printer function ''' if opts is None: opts = {} if 'output' in opts and opts['output'] != 'highstate': # new --out option, but don't choke when using --out=highstate at CLI # See Issue #29796 for more information. ...
python
def get_printout(out, opts=None, **kwargs): ''' Return a printer function ''' if opts is None: opts = {} if 'output' in opts and opts['output'] != 'highstate': # new --out option, but don't choke when using --out=highstate at CLI # See Issue #29796 for more information. ...
[ "def", "get_printout", "(", "out", ",", "opts", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "opts", "is", "None", ":", "opts", "=", "{", "}", "if", "'output'", "in", "opts", "and", "opts", "[", "'output'", "]", "!=", "'highstate'", ":", ...
Return a printer function
[ "Return", "a", "printer", "function" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L135-L198
train
saltstack/salt
salt/output/__init__.py
out_format
def out_format(data, out, opts=None, **kwargs): ''' Return the formatted outputter string for the passed data ''' return try_printout(data, out, opts, **kwargs)
python
def out_format(data, out, opts=None, **kwargs): ''' Return the formatted outputter string for the passed data ''' return try_printout(data, out, opts, **kwargs)
[ "def", "out_format", "(", "data", ",", "out", ",", "opts", "=", "None", ",", "*", "*", "kwargs", ")", ":", "return", "try_printout", "(", "data", ",", "out", ",", "opts", ",", "*", "*", "kwargs", ")" ]
Return the formatted outputter string for the passed data
[ "Return", "the", "formatted", "outputter", "string", "for", "the", "passed", "data" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L201-L205
train
saltstack/salt
salt/output/__init__.py
string_format
def string_format(data, out, opts=None, **kwargs): ''' Return the formatted outputter string, removing the ANSI escape sequences. ''' raw_output = try_printout(data, out, opts, **kwargs) ansi_escape = re.compile(r'\x1b[^m]*m') return ansi_escape.sub('', raw_output)
python
def string_format(data, out, opts=None, **kwargs): ''' Return the formatted outputter string, removing the ANSI escape sequences. ''' raw_output = try_printout(data, out, opts, **kwargs) ansi_escape = re.compile(r'\x1b[^m]*m') return ansi_escape.sub('', raw_output)
[ "def", "string_format", "(", "data", ",", "out", ",", "opts", "=", "None", ",", "*", "*", "kwargs", ")", ":", "raw_output", "=", "try_printout", "(", "data", ",", "out", ",", "opts", ",", "*", "*", "kwargs", ")", "ansi_escape", "=", "re", ".", "com...
Return the formatted outputter string, removing the ANSI escape sequences.
[ "Return", "the", "formatted", "outputter", "string", "removing", "the", "ANSI", "escape", "sequences", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L208-L214
train
saltstack/salt
salt/output/__init__.py
html_format
def html_format(data, out, opts=None, **kwargs): ''' Return the formatted string as HTML. ''' ansi_escaped_string = string_format(data, out, opts, **kwargs) return ansi_escaped_string.replace(' ', '&nbsp;').replace('\n', '<br />')
python
def html_format(data, out, opts=None, **kwargs): ''' Return the formatted string as HTML. ''' ansi_escaped_string = string_format(data, out, opts, **kwargs) return ansi_escaped_string.replace(' ', '&nbsp;').replace('\n', '<br />')
[ "def", "html_format", "(", "data", ",", "out", ",", "opts", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ansi_escaped_string", "=", "string_format", "(", "data", ",", "out", ",", "opts", ",", "*", "*", "kwargs", ")", "return", "ansi_escaped_string", ...
Return the formatted string as HTML.
[ "Return", "the", "formatted", "string", "as", "HTML", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L217-L222
train
saltstack/salt
salt/output/__init__.py
strip_esc_sequence
def strip_esc_sequence(txt): ''' Replace ESC (ASCII 27/Oct 33) to prevent unsafe strings from writing their own terminal manipulation commands ''' if isinstance(txt, six.string_types): try: return txt.replace('\033', '?') except UnicodeDecodeError: return txt....
python
def strip_esc_sequence(txt): ''' Replace ESC (ASCII 27/Oct 33) to prevent unsafe strings from writing their own terminal manipulation commands ''' if isinstance(txt, six.string_types): try: return txt.replace('\033', '?') except UnicodeDecodeError: return txt....
[ "def", "strip_esc_sequence", "(", "txt", ")", ":", "if", "isinstance", "(", "txt", ",", "six", ".", "string_types", ")", ":", "try", ":", "return", "txt", ".", "replace", "(", "'\\033'", ",", "'?'", ")", "except", "UnicodeDecodeError", ":", "return", "tx...
Replace ESC (ASCII 27/Oct 33) to prevent unsafe strings from writing their own terminal manipulation commands
[ "Replace", "ESC", "(", "ASCII", "27", "/", "Oct", "33", ")", "to", "prevent", "unsafe", "strings", "from", "writing", "their", "own", "terminal", "manipulation", "commands" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L225-L236
train
saltstack/salt
salt/utils/dns.py
_tree
def _tree(domain, tld=False): ''' Split out a domain in its parents Leverages tldextract to take the TLDs from publicsuffix.org or makes a valiant approximation of that :param domain: dc2.ams2.example.com :param tld: Include TLD in list :return: [ 'dc2.ams2.example.com', 'ams2.example.com'...
python
def _tree(domain, tld=False): ''' Split out a domain in its parents Leverages tldextract to take the TLDs from publicsuffix.org or makes a valiant approximation of that :param domain: dc2.ams2.example.com :param tld: Include TLD in list :return: [ 'dc2.ams2.example.com', 'ams2.example.com'...
[ "def", "_tree", "(", "domain", ",", "tld", "=", "False", ")", ":", "domain", "=", "domain", ".", "rstrip", "(", "'.'", ")", "assert", "'.'", "in", "domain", ",", "'Provide a decent domain'", "if", "not", "tld", ":", "if", "HAS_TLDEXTRACT", ":", "tld", ...
Split out a domain in its parents Leverages tldextract to take the TLDs from publicsuffix.org or makes a valiant approximation of that :param domain: dc2.ams2.example.com :param tld: Include TLD in list :return: [ 'dc2.ams2.example.com', 'ams2.example.com', 'example.com']
[ "Split", "out", "a", "domain", "in", "its", "parents" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L134-L166
train
saltstack/salt
salt/utils/dns.py
_data2rec
def _data2rec(schema, rec_data): ''' schema = OrderedDict({ 'prio': int, 'weight': int, 'port': to_port, 'name': str, }) rec_data = '10 20 25 myawesome.nl' res = {'prio': 10, 'weight': 20, 'port': 25 'name': 'myawesome.nl'} ''' try: rec_fields = rec_d...
python
def _data2rec(schema, rec_data): ''' schema = OrderedDict({ 'prio': int, 'weight': int, 'port': to_port, 'name': str, }) rec_data = '10 20 25 myawesome.nl' res = {'prio': 10, 'weight': 20, 'port': 25 'name': 'myawesome.nl'} ''' try: rec_fields = rec_d...
[ "def", "_data2rec", "(", "schema", ",", "rec_data", ")", ":", "try", ":", "rec_fields", "=", "rec_data", ".", "split", "(", "' '", ")", "# spaces in digest fields are allowed", "assert", "len", "(", "rec_fields", ")", ">=", "len", "(", "schema", ")", "if", ...
schema = OrderedDict({ 'prio': int, 'weight': int, 'port': to_port, 'name': str, }) rec_data = '10 20 25 myawesome.nl' res = {'prio': 10, 'weight': 20, 'port': 25 'name': 'myawesome.nl'}
[ "schema", "=", "OrderedDict", "(", "{", "prio", ":", "int", "weight", ":", "int", "port", ":", "to_port", "name", ":", "str", "}", ")", "rec_data", "=", "10", "20", "25", "myawesome", ".", "nl" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L195-L228
train
saltstack/salt
salt/utils/dns.py
_lookup_dig
def _lookup_dig(name, rdtype, timeout=None, servers=None, secure=None): ''' Use dig to lookup addresses :param name: Name of record to search :param rdtype: DNS record type :param timeout: server response timeout :param servers: [] of servers to use :return: [] of records or False if error ...
python
def _lookup_dig(name, rdtype, timeout=None, servers=None, secure=None): ''' Use dig to lookup addresses :param name: Name of record to search :param rdtype: DNS record type :param timeout: server response timeout :param servers: [] of servers to use :return: [] of records or False if error ...
[ "def", "_lookup_dig", "(", "name", ",", "rdtype", ",", "timeout", "=", "None", ",", "servers", "=", "None", ",", "secure", "=", "None", ")", ":", "cmd", "=", "'dig {0} -t {1} '", ".", "format", "(", "DIG_OPTIONS", ",", "rdtype", ")", "if", "servers", "...
Use dig to lookup addresses :param name: Name of record to search :param rdtype: DNS record type :param timeout: server response timeout :param servers: [] of servers to use :return: [] of records or False if error
[ "Use", "dig", "to", "lookup", "addresses", ":", "param", "name", ":", "Name", "of", "record", "to", "search", ":", "param", "rdtype", ":", "DNS", "record", "type", ":", "param", "timeout", ":", "server", "response", "timeout", ":", "param", "servers", ":...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L271-L319
train
saltstack/salt
salt/utils/dns.py
_lookup_drill
def _lookup_drill(name, rdtype, timeout=None, servers=None, secure=None): ''' Use drill to lookup addresses :param name: Name of record to search :param rdtype: DNS record type :param timeout: command return timeout :param servers: [] of servers to use :return: [] of records or False if erro...
python
def _lookup_drill(name, rdtype, timeout=None, servers=None, secure=None): ''' Use drill to lookup addresses :param name: Name of record to search :param rdtype: DNS record type :param timeout: command return timeout :param servers: [] of servers to use :return: [] of records or False if erro...
[ "def", "_lookup_drill", "(", "name", ",", "rdtype", ",", "timeout", "=", "None", ",", "servers", "=", "None", ",", "secure", "=", "None", ")", ":", "cmd", "=", "'drill '", "if", "secure", ":", "cmd", "+=", "'-D -o ad '", "cmd", "+=", "'{0} {1} '", ".",...
Use drill to lookup addresses :param name: Name of record to search :param rdtype: DNS record type :param timeout: command return timeout :param servers: [] of servers to use :return: [] of records or False if error
[ "Use", "drill", "to", "lookup", "addresses", ":", "param", "name", ":", "Name", "of", "record", "to", "search", ":", "param", "rdtype", ":", "DNS", "record", "type", ":", "param", "timeout", ":", "command", "return", "timeout", ":", "param", "servers", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L322-L375
train
saltstack/salt
salt/utils/dns.py
_lookup_gai
def _lookup_gai(name, rdtype, timeout=None): ''' Use Python's socket interface to lookup addresses :param name: Name of record to search :param rdtype: A or AAAA :param timeout: ignored :return: [] of addresses or False if error ''' try: sock_t = { 'A': socket.AF_I...
python
def _lookup_gai(name, rdtype, timeout=None): ''' Use Python's socket interface to lookup addresses :param name: Name of record to search :param rdtype: A or AAAA :param timeout: ignored :return: [] of addresses or False if error ''' try: sock_t = { 'A': socket.AF_I...
[ "def", "_lookup_gai", "(", "name", ",", "rdtype", ",", "timeout", "=", "None", ")", ":", "try", ":", "sock_t", "=", "{", "'A'", ":", "socket", ".", "AF_INET", ",", "'AAAA'", ":", "socket", ".", "AF_INET6", "}", "[", "rdtype", "]", "except", "KeyError...
Use Python's socket interface to lookup addresses :param name: Name of record to search :param rdtype: A or AAAA :param timeout: ignored :return: [] of addresses or False if error
[ "Use", "Python", "s", "socket", "interface", "to", "lookup", "addresses", ":", "param", "name", ":", "Name", "of", "record", "to", "search", ":", "param", "rdtype", ":", "A", "or", "AAAA", ":", "param", "timeout", ":", "ignored", ":", "return", ":", "[...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L378-L401
train
saltstack/salt
salt/utils/dns.py
_lookup_host
def _lookup_host(name, rdtype, timeout=None, server=None): ''' Use host to lookup addresses :param name: Name of record to search :param server: Server to query :param rdtype: DNS record type :param timeout: server response wait :return: [] of records or False if error ''' cmd = 'hos...
python
def _lookup_host(name, rdtype, timeout=None, server=None): ''' Use host to lookup addresses :param name: Name of record to search :param server: Server to query :param rdtype: DNS record type :param timeout: server response wait :return: [] of records or False if error ''' cmd = 'hos...
[ "def", "_lookup_host", "(", "name", ",", "rdtype", ",", "timeout", "=", "None", ",", "server", "=", "None", ")", ":", "cmd", "=", "'host -t {0} '", ".", "format", "(", "rdtype", ")", "if", "timeout", ":", "cmd", "+=", "'-W {0} '", ".", "format", "(", ...
Use host to lookup addresses :param name: Name of record to search :param server: Server to query :param rdtype: DNS record type :param timeout: server response wait :return: [] of records or False if error
[ "Use", "host", "to", "lookup", "addresses", ":", "param", "name", ":", "Name", "of", "record", "to", "search", ":", "param", "server", ":", "Server", "to", "query", ":", "param", "rdtype", ":", "DNS", "record", "type", ":", "param", "timeout", ":", "se...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L404-L443
train
saltstack/salt
salt/utils/dns.py
_lookup_dnspython
def _lookup_dnspython(name, rdtype, timeout=None, servers=None, secure=None): ''' Use dnspython to lookup addresses :param name: Name of record to search :param rdtype: DNS record type :param timeout: query timeout :param server: [] of server(s) to try in order :return: [] of records or Fals...
python
def _lookup_dnspython(name, rdtype, timeout=None, servers=None, secure=None): ''' Use dnspython to lookup addresses :param name: Name of record to search :param rdtype: DNS record type :param timeout: query timeout :param server: [] of server(s) to try in order :return: [] of records or Fals...
[ "def", "_lookup_dnspython", "(", "name", ",", "rdtype", ",", "timeout", "=", "None", ",", "servers", "=", "None", ",", "secure", "=", "None", ")", ":", "resolver", "=", "dns", ".", "resolver", ".", "Resolver", "(", ")", "if", "timeout", "is", "not", ...
Use dnspython to lookup addresses :param name: Name of record to search :param rdtype: DNS record type :param timeout: query timeout :param server: [] of server(s) to try in order :return: [] of records or False if error
[ "Use", "dnspython", "to", "lookup", "addresses", ":", "param", "name", ":", "Name", "of", "record", "to", "search", ":", "param", "rdtype", ":", "DNS", "record", "type", ":", "param", "timeout", ":", "query", "timeout", ":", "param", "server", ":", "[]",...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L446-L474
train
saltstack/salt
salt/utils/dns.py
_lookup_nslookup
def _lookup_nslookup(name, rdtype, timeout=None, server=None): ''' Use nslookup to lookup addresses :param name: Name of record to search :param rdtype: DNS record type :param timeout: server response timeout :param server: server to query :return: [] of records or False if error ''' ...
python
def _lookup_nslookup(name, rdtype, timeout=None, server=None): ''' Use nslookup to lookup addresses :param name: Name of record to search :param rdtype: DNS record type :param timeout: server response timeout :param server: server to query :return: [] of records or False if error ''' ...
[ "def", "_lookup_nslookup", "(", "name", ",", "rdtype", ",", "timeout", "=", "None", ",", "server", "=", "None", ")", ":", "cmd", "=", "'nslookup -query={0} {1}'", ".", "format", "(", "rdtype", ",", "name", ")", "if", "timeout", "is", "not", "None", ":", ...
Use nslookup to lookup addresses :param name: Name of record to search :param rdtype: DNS record type :param timeout: server response timeout :param server: server to query :return: [] of records or False if error
[ "Use", "nslookup", "to", "lookup", "addresses", ":", "param", "name", ":", "Name", "of", "record", "to", "search", ":", "param", "rdtype", ":", "DNS", "record", "type", ":", "param", "timeout", ":", "server", "response", "timeout", ":", "param", "server", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L477-L543
train
saltstack/salt
salt/utils/dns.py
lookup
def lookup( name, rdtype, method=None, servers=None, timeout=None, walk=False, walk_tld=False, secure=None ): ''' Lookup DNS records and return their data :param name: name to lookup :param rdtype: DNS record type :param method: gai (getaddrinfo()), dnspython, dig, d...
python
def lookup( name, rdtype, method=None, servers=None, timeout=None, walk=False, walk_tld=False, secure=None ): ''' Lookup DNS records and return their data :param name: name to lookup :param rdtype: DNS record type :param method: gai (getaddrinfo()), dnspython, dig, d...
[ "def", "lookup", "(", "name", ",", "rdtype", ",", "method", "=", "None", ",", "servers", "=", "None", ",", "timeout", "=", "None", ",", "walk", "=", "False", ",", "walk_tld", "=", "False", ",", "secure", "=", "None", ")", ":", "# opts = __opts__.get('d...
Lookup DNS records and return their data :param name: name to lookup :param rdtype: DNS record type :param method: gai (getaddrinfo()), dnspython, dig, drill, host, nslookup or auto (default) :param servers: (list of) server(s) to try in-order :param timeout: query timeout or a valiant approximatio...
[ "Lookup", "DNS", "records", "and", "return", "their", "data" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L546-L654
train
saltstack/salt
salt/utils/dns.py
query
def query( name, rdtype, method=None, servers=None, timeout=None, walk=False, walk_tld=False, secure=None ): ''' Query DNS for information. Where `lookup()` returns record data, `query()` tries to interpret the data and return it's results :param name: name to lookup ...
python
def query( name, rdtype, method=None, servers=None, timeout=None, walk=False, walk_tld=False, secure=None ): ''' Query DNS for information. Where `lookup()` returns record data, `query()` tries to interpret the data and return it's results :param name: name to lookup ...
[ "def", "query", "(", "name", ",", "rdtype", ",", "method", "=", "None", ",", "servers", "=", "None", ",", "timeout", "=", "None", ",", "walk", "=", "False", ",", "walk_tld", "=", "False", ",", "secure", "=", "None", ")", ":", "rdtype", "=", "rdtype...
Query DNS for information. Where `lookup()` returns record data, `query()` tries to interpret the data and return it's results :param name: name to lookup :param rdtype: DNS record type :param method: gai (getaddrinfo()), pydns, dig, drill, host, nslookup or auto (default) :param servers: (list of)...
[ "Query", "DNS", "for", "information", ".", "Where", "lookup", "()", "returns", "record", "data", "query", "()", "tries", "to", "interpret", "the", "data", "and", "return", "it", "s", "results" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L657-L723
train
saltstack/salt
salt/utils/dns.py
host
def host(name, ip4=True, ip6=True, **kwargs): ''' Return a list of addresses for name ip6: Return IPv6 addresses ip4: Return IPv4 addresses the rest is passed on to lookup() ''' res = {} if ip6: ip6 = lookup(name, 'AAAA', **kwargs) if ip6: re...
python
def host(name, ip4=True, ip6=True, **kwargs): ''' Return a list of addresses for name ip6: Return IPv6 addresses ip4: Return IPv4 addresses the rest is passed on to lookup() ''' res = {} if ip6: ip6 = lookup(name, 'AAAA', **kwargs) if ip6: re...
[ "def", "host", "(", "name", ",", "ip4", "=", "True", ",", "ip6", "=", "True", ",", "*", "*", "kwargs", ")", ":", "res", "=", "{", "}", "if", "ip6", ":", "ip6", "=", "lookup", "(", "name", ",", "'AAAA'", ",", "*", "*", "kwargs", ")", "if", "...
Return a list of addresses for name ip6: Return IPv6 addresses ip4: Return IPv4 addresses the rest is passed on to lookup()
[ "Return", "a", "list", "of", "addresses", "for", "name" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L726-L747
train
saltstack/salt
salt/utils/dns.py
caa_rec
def caa_rec(rdatas): ''' Validate and parse DNS record data for a CAA record :param rdata: DNS record data :return: dict w/fields ''' rschema = OrderedDict(( ('flags', lambda flag: ['critical'] if int(flag) > 0 else []), ('tag', RFC.CAA_TAGS), ('value', lambda val: val.st...
python
def caa_rec(rdatas): ''' Validate and parse DNS record data for a CAA record :param rdata: DNS record data :return: dict w/fields ''' rschema = OrderedDict(( ('flags', lambda flag: ['critical'] if int(flag) > 0 else []), ('tag', RFC.CAA_TAGS), ('value', lambda val: val.st...
[ "def", "caa_rec", "(", "rdatas", ")", ":", "rschema", "=", "OrderedDict", "(", "(", "(", "'flags'", ",", "lambda", "flag", ":", "[", "'critical'", "]", "if", "int", "(", "flag", ")", ">", "0", "else", "[", "]", ")", ",", "(", "'tag'", ",", "RFC",...
Validate and parse DNS record data for a CAA record :param rdata: DNS record data :return: dict w/fields
[ "Validate", "and", "parse", "DNS", "record", "data", "for", "a", "CAA", "record", ":", "param", "rdata", ":", "DNS", "record", "data", ":", "return", ":", "dict", "w", "/", "fields" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L774-L799
train
saltstack/salt
salt/utils/dns.py
ptr_name
def ptr_name(rdata): ''' Return PTR name of given IP :param rdata: IP address :return: PTR record name ''' try: return ipaddress.ip_address(rdata).reverse_pointer except ValueError: log.error( 'Unable to generate PTR record; %s is not a valid IP address', ...
python
def ptr_name(rdata): ''' Return PTR name of given IP :param rdata: IP address :return: PTR record name ''' try: return ipaddress.ip_address(rdata).reverse_pointer except ValueError: log.error( 'Unable to generate PTR record; %s is not a valid IP address', ...
[ "def", "ptr_name", "(", "rdata", ")", ":", "try", ":", "return", "ipaddress", ".", "ip_address", "(", "rdata", ")", ".", "reverse_pointer", "except", "ValueError", ":", "log", ".", "error", "(", "'Unable to generate PTR record; %s is not a valid IP address'", ",", ...
Return PTR name of given IP :param rdata: IP address :return: PTR record name
[ "Return", "PTR", "name", "of", "given", "IP", ":", "param", "rdata", ":", "IP", "address", ":", "return", ":", "PTR", "record", "name" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L825-L838
train
saltstack/salt
salt/utils/dns.py
soa_rec
def soa_rec(rdata): ''' Validate and parse DNS record data for SOA record(s) :param rdata: DNS record data :return: dict w/fields ''' rschema = OrderedDict(( ('mname', str), ('rname', str), ('serial', int), ('refresh', int), ('retry', int), ('expir...
python
def soa_rec(rdata): ''' Validate and parse DNS record data for SOA record(s) :param rdata: DNS record data :return: dict w/fields ''' rschema = OrderedDict(( ('mname', str), ('rname', str), ('serial', int), ('refresh', int), ('retry', int), ('expir...
[ "def", "soa_rec", "(", "rdata", ")", ":", "rschema", "=", "OrderedDict", "(", "(", "(", "'mname'", ",", "str", ")", ",", "(", "'rname'", ",", "str", ")", ",", "(", "'serial'", ",", "int", ")", ",", "(", "'refresh'", ",", "int", ")", ",", "(", "...
Validate and parse DNS record data for SOA record(s) :param rdata: DNS record data :return: dict w/fields
[ "Validate", "and", "parse", "DNS", "record", "data", "for", "SOA", "record", "(", "s", ")", ":", "param", "rdata", ":", "DNS", "record", "data", ":", "return", ":", "dict", "w", "/", "fields" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L841-L856
train
saltstack/salt
salt/utils/dns.py
spf_rec
def spf_rec(rdata): ''' Validate and parse DNS record data for SPF record(s) :param rdata: DNS record data :return: dict w/fields ''' spf_fields = rdata.split(' ') if not spf_fields.pop(0).startswith('v=spf'): raise ValueError('Not an SPF record') res = OrderedDict() mods = ...
python
def spf_rec(rdata): ''' Validate and parse DNS record data for SPF record(s) :param rdata: DNS record data :return: dict w/fields ''' spf_fields = rdata.split(' ') if not spf_fields.pop(0).startswith('v=spf'): raise ValueError('Not an SPF record') res = OrderedDict() mods = ...
[ "def", "spf_rec", "(", "rdata", ")", ":", "spf_fields", "=", "rdata", ".", "split", "(", "' '", ")", "if", "not", "spf_fields", ".", "pop", "(", "0", ")", ".", "startswith", "(", "'v=spf'", ")", ":", "raise", "ValueError", "(", "'Not an SPF record'", "...
Validate and parse DNS record data for SPF record(s) :param rdata: DNS record data :return: dict w/fields
[ "Validate", "and", "parse", "DNS", "record", "data", "for", "SPF", "record", "(", "s", ")", ":", "param", "rdata", ":", "DNS", "record", "data", ":", "return", ":", "dict", "w", "/", "fields" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L859-L911
train
saltstack/salt
salt/utils/dns.py
srv_data
def srv_data(target, port, prio=10, weight=10): ''' Generate SRV record data :param target: :param port: :param prio: :param weight: :return: ''' return _rec2data(prio, weight, port, target)
python
def srv_data(target, port, prio=10, weight=10): ''' Generate SRV record data :param target: :param port: :param prio: :param weight: :return: ''' return _rec2data(prio, weight, port, target)
[ "def", "srv_data", "(", "target", ",", "port", ",", "prio", "=", "10", ",", "weight", "=", "10", ")", ":", "return", "_rec2data", "(", "prio", ",", "weight", ",", "port", ",", "target", ")" ]
Generate SRV record data :param target: :param port: :param prio: :param weight: :return:
[ "Generate", "SRV", "record", "data", ":", "param", "target", ":", ":", "param", "port", ":", ":", "param", "prio", ":", ":", "param", "weight", ":", ":", "return", ":" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L914-L923
train
saltstack/salt
salt/utils/dns.py
srv_name
def srv_name(svc, proto='tcp', domain=None): ''' Generate SRV record name :param svc: ldap, 389 etc :param proto: tcp, udp, sctp etc. :param domain: name to append :return: ''' proto = RFC.validate(proto, RFC.SRV_PROTO) if isinstance(svc, int) or svc.isdigit(): svc = _to_port...
python
def srv_name(svc, proto='tcp', domain=None): ''' Generate SRV record name :param svc: ldap, 389 etc :param proto: tcp, udp, sctp etc. :param domain: name to append :return: ''' proto = RFC.validate(proto, RFC.SRV_PROTO) if isinstance(svc, int) or svc.isdigit(): svc = _to_port...
[ "def", "srv_name", "(", "svc", ",", "proto", "=", "'tcp'", ",", "domain", "=", "None", ")", ":", "proto", "=", "RFC", ".", "validate", "(", "proto", ",", "RFC", ".", "SRV_PROTO", ")", "if", "isinstance", "(", "svc", ",", "int", ")", "or", "svc", ...
Generate SRV record name :param svc: ldap, 389 etc :param proto: tcp, udp, sctp etc. :param domain: name to append :return:
[ "Generate", "SRV", "record", "name", ":", "param", "svc", ":", "ldap", "389", "etc", ":", "param", "proto", ":", "tcp", "udp", "sctp", "etc", ".", ":", "param", "domain", ":", "name", "to", "append", ":", "return", ":" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L926-L940
train
saltstack/salt
salt/utils/dns.py
srv_rec
def srv_rec(rdatas): ''' Validate and parse DNS record data for SRV record(s) :param rdata: DNS record data :return: dict w/fields ''' rschema = OrderedDict(( ('prio', int), ('weight', int), ('port', _to_port), ('name', str), )) return _data2rec_group(rsch...
python
def srv_rec(rdatas): ''' Validate and parse DNS record data for SRV record(s) :param rdata: DNS record data :return: dict w/fields ''' rschema = OrderedDict(( ('prio', int), ('weight', int), ('port', _to_port), ('name', str), )) return _data2rec_group(rsch...
[ "def", "srv_rec", "(", "rdatas", ")", ":", "rschema", "=", "OrderedDict", "(", "(", "(", "'prio'", ",", "int", ")", ",", "(", "'weight'", ",", "int", ")", ",", "(", "'port'", ",", "_to_port", ")", ",", "(", "'name'", ",", "str", ")", ",", ")", ...
Validate and parse DNS record data for SRV record(s) :param rdata: DNS record data :return: dict w/fields
[ "Validate", "and", "parse", "DNS", "record", "data", "for", "SRV", "record", "(", "s", ")", ":", "param", "rdata", ":", "DNS", "record", "data", ":", "return", ":", "dict", "w", "/", "fields" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L943-L955
train
saltstack/salt
salt/utils/dns.py
sshfp_data
def sshfp_data(key_t, hash_t, pub): ''' Generate an SSHFP record :param key_t: rsa/dsa/ecdsa/ed25519 :param hash_t: sha1/sha256 :param pub: the SSH public key ''' key_t = RFC.validate(key_t, RFC.SSHFP_ALGO, 'in') hash_t = RFC.validate(hash_t, RFC.SSHFP_HASH) hasher = hashlib.new(has...
python
def sshfp_data(key_t, hash_t, pub): ''' Generate an SSHFP record :param key_t: rsa/dsa/ecdsa/ed25519 :param hash_t: sha1/sha256 :param pub: the SSH public key ''' key_t = RFC.validate(key_t, RFC.SSHFP_ALGO, 'in') hash_t = RFC.validate(hash_t, RFC.SSHFP_HASH) hasher = hashlib.new(has...
[ "def", "sshfp_data", "(", "key_t", ",", "hash_t", ",", "pub", ")", ":", "key_t", "=", "RFC", ".", "validate", "(", "key_t", ",", "RFC", ".", "SSHFP_ALGO", ",", "'in'", ")", "hash_t", "=", "RFC", ".", "validate", "(", "hash_t", ",", "RFC", ".", "SSH...
Generate an SSHFP record :param key_t: rsa/dsa/ecdsa/ed25519 :param hash_t: sha1/sha256 :param pub: the SSH public key
[ "Generate", "an", "SSHFP", "record", ":", "param", "key_t", ":", "rsa", "/", "dsa", "/", "ecdsa", "/", "ed25519", ":", "param", "hash_t", ":", "sha1", "/", "sha256", ":", "param", "pub", ":", "the", "SSH", "public", "key" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L958-L974
train
saltstack/salt
salt/utils/dns.py
sshfp_rec
def sshfp_rec(rdata): ''' Validate and parse DNS record data for TLSA record(s) :param rdata: DNS record data :return: dict w/fields ''' rschema = OrderedDict(( ('algorithm', RFC.SSHFP_ALGO), ('fp_hash', RFC.SSHFP_HASH), ('fingerprint', lambda val: val.lower()) # resolve...
python
def sshfp_rec(rdata): ''' Validate and parse DNS record data for TLSA record(s) :param rdata: DNS record data :return: dict w/fields ''' rschema = OrderedDict(( ('algorithm', RFC.SSHFP_ALGO), ('fp_hash', RFC.SSHFP_HASH), ('fingerprint', lambda val: val.lower()) # resolve...
[ "def", "sshfp_rec", "(", "rdata", ")", ":", "rschema", "=", "OrderedDict", "(", "(", "(", "'algorithm'", ",", "RFC", ".", "SSHFP_ALGO", ")", ",", "(", "'fp_hash'", ",", "RFC", ".", "SSHFP_HASH", ")", ",", "(", "'fingerprint'", ",", "lambda", "val", ":"...
Validate and parse DNS record data for TLSA record(s) :param rdata: DNS record data :return: dict w/fields
[ "Validate", "and", "parse", "DNS", "record", "data", "for", "TLSA", "record", "(", "s", ")", ":", "param", "rdata", ":", "DNS", "record", "data", ":", "return", ":", "dict", "w", "/", "fields" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L977-L989
train
saltstack/salt
salt/utils/dns.py
tlsa_data
def tlsa_data(pub, usage, selector, matching): ''' Generate a TLSA rec :param pub: Pub key in PEM format :param usage: :param selector: :param matching: :return: TLSA data portion ''' usage = RFC.validate(usage, RFC.TLSA_USAGE) selector = RFC.validate(selector, RFC.TLSA_SELECT) ...
python
def tlsa_data(pub, usage, selector, matching): ''' Generate a TLSA rec :param pub: Pub key in PEM format :param usage: :param selector: :param matching: :return: TLSA data portion ''' usage = RFC.validate(usage, RFC.TLSA_USAGE) selector = RFC.validate(selector, RFC.TLSA_SELECT) ...
[ "def", "tlsa_data", "(", "pub", ",", "usage", ",", "selector", ",", "matching", ")", ":", "usage", "=", "RFC", ".", "validate", "(", "usage", ",", "RFC", ".", "TLSA_USAGE", ")", "selector", "=", "RFC", ".", "validate", "(", "selector", ",", "RFC", "....
Generate a TLSA rec :param pub: Pub key in PEM format :param usage: :param selector: :param matching: :return: TLSA data portion
[ "Generate", "a", "TLSA", "rec", ":", "param", "pub", ":", "Pub", "key", "in", "PEM", "format", ":", "param", "usage", ":", ":", "param", "selector", ":", ":", "param", "matching", ":", ":", "return", ":", "TLSA", "data", "portion" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L992-L1015
train
saltstack/salt
salt/utils/dns.py
tlsa_rec
def tlsa_rec(rdata): ''' Validate and parse DNS record data for TLSA record(s) :param rdata: DNS record data :return: dict w/fields ''' rschema = OrderedDict(( ('usage', RFC.TLSA_USAGE), ('selector', RFC.TLSA_SELECT), ('matching', RFC.TLSA_MATCHING), ('pub', str) ...
python
def tlsa_rec(rdata): ''' Validate and parse DNS record data for TLSA record(s) :param rdata: DNS record data :return: dict w/fields ''' rschema = OrderedDict(( ('usage', RFC.TLSA_USAGE), ('selector', RFC.TLSA_SELECT), ('matching', RFC.TLSA_MATCHING), ('pub', str) ...
[ "def", "tlsa_rec", "(", "rdata", ")", ":", "rschema", "=", "OrderedDict", "(", "(", "(", "'usage'", ",", "RFC", ".", "TLSA_USAGE", ")", ",", "(", "'selector'", ",", "RFC", ".", "TLSA_SELECT", ")", ",", "(", "'matching'", ",", "RFC", ".", "TLSA_MATCHING...
Validate and parse DNS record data for TLSA record(s) :param rdata: DNS record data :return: dict w/fields
[ "Validate", "and", "parse", "DNS", "record", "data", "for", "TLSA", "record", "(", "s", ")", ":", "param", "rdata", ":", "DNS", "record", "data", ":", "return", ":", "dict", "w", "/", "fields" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L1018-L1031
train
saltstack/salt
salt/utils/dns.py
service
def service( svc, proto='tcp', domain=None, walk=False, secure=None ): ''' Find an SRV service in a domain or it's parents :param svc: service to find (ldap, 389, etc) :param proto: protocol the service talks (tcp, udp, etc) :param domain: domain to start search in :param wal...
python
def service( svc, proto='tcp', domain=None, walk=False, secure=None ): ''' Find an SRV service in a domain or it's parents :param svc: service to find (ldap, 389, etc) :param proto: protocol the service talks (tcp, udp, etc) :param domain: domain to start search in :param wal...
[ "def", "service", "(", "svc", ",", "proto", "=", "'tcp'", ",", "domain", "=", "None", ",", "walk", "=", "False", ",", "secure", "=", "None", ")", ":", "qres", "=", "query", "(", "srv_name", "(", "svc", ",", "proto", ",", "domain", ")", ",", "'SRV...
Find an SRV service in a domain or it's parents :param svc: service to find (ldap, 389, etc) :param proto: protocol the service talks (tcp, udp, etc) :param domain: domain to start search in :param walk: walk the parents if domain doesn't provide the service :param secure: only return DNSSEC-validat...
[ "Find", "an", "SRV", "service", "in", "a", "domain", "or", "it", "s", "parents", ":", "param", "svc", ":", "service", "to", "find", "(", "ldap", "389", "etc", ")", ":", "param", "proto", ":", "protocol", "the", "service", "talks", "(", "tcp", "udp", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L1034-L1061
train
saltstack/salt
salt/utils/dns.py
services
def services(services_file='/etc/services'): ''' Parse through system-known services :return: { 'svc': [ { 'port': port 'proto': proto, 'desc': comment }, ], } ''' res = {} with salt.utils.files.fopen(services_file, 'r') as svc_d...
python
def services(services_file='/etc/services'): ''' Parse through system-known services :return: { 'svc': [ { 'port': port 'proto': proto, 'desc': comment }, ], } ''' res = {} with salt.utils.files.fopen(services_file, 'r') as svc_d...
[ "def", "services", "(", "services_file", "=", "'/etc/services'", ")", ":", "res", "=", "{", "}", "with", "salt", ".", "utils", ".", "files", ".", "fopen", "(", "services_file", ",", "'r'", ")", "as", "svc_defs", ":", "for", "svc_def", "in", "svc_defs", ...
Parse through system-known services :return: { 'svc': [ { 'port': port 'proto': proto, 'desc': comment }, ], }
[ "Parse", "through", "system", "-", "known", "services", ":", "return", ":", "{", "svc", ":", "[", "{", "port", ":", "port", "proto", ":", "proto", "desc", ":", "comment", "}", "]", "}" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L1064-L1125
train
saltstack/salt
salt/utils/dns.py
parse_resolv
def parse_resolv(src='/etc/resolv.conf'): ''' Parse a resolver configuration file (traditionally /etc/resolv.conf) ''' nameservers = [] ip4_nameservers = [] ip6_nameservers = [] search = [] sortlist = [] domain = '' options = [] try: with salt.utils.files.fopen(src)...
python
def parse_resolv(src='/etc/resolv.conf'): ''' Parse a resolver configuration file (traditionally /etc/resolv.conf) ''' nameservers = [] ip4_nameservers = [] ip6_nameservers = [] search = [] sortlist = [] domain = '' options = [] try: with salt.utils.files.fopen(src)...
[ "def", "parse_resolv", "(", "src", "=", "'/etc/resolv.conf'", ")", ":", "nameservers", "=", "[", "]", "ip4_nameservers", "=", "[", "]", "ip6_nameservers", "=", "[", "]", "search", "=", "[", "]", "sortlist", "=", "[", "]", "domain", "=", "''", "options", ...
Parse a resolver configuration file (traditionally /etc/resolv.conf)
[ "Parse", "a", "resolver", "configuration", "file", "(", "traditionally", "/", "etc", "/", "resolv", ".", "conf", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L1128-L1224
train
saltstack/salt
salt/returners/__init__.py
get_returner_options
def get_returner_options(virtualname=None, ret=None, attrs=None, **kwargs): ''' Get the returner options from salt. :param str virtualname: The returner virtualname (as returned by __virtual__() :param ret: result of the...
python
def get_returner_options(virtualname=None, ret=None, attrs=None, **kwargs): ''' Get the returner options from salt. :param str virtualname: The returner virtualname (as returned by __virtual__() :param ret: result of the...
[ "def", "get_returner_options", "(", "virtualname", "=", "None", ",", "ret", "=", "None", ",", "attrs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ret_config", "=", "_fetch_ret_config", "(", "ret", ")", "attrs", "=", "attrs", "or", "{", "}", "prof...
Get the returner options from salt. :param str virtualname: The returner virtualname (as returned by __virtual__() :param ret: result of the module that ran. dict-like object May contain a `ret_config` key pointing to a string If a `ret_config` is specified, config options are read fro...
[ "Get", "the", "returner", "options", "from", "salt", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/__init__.py#L16-L107
train
saltstack/salt
salt/returners/__init__.py
_fetch_option
def _fetch_option(cfg, ret_config, virtualname, attr_name): """ Fetch a given option value from the config. @see :func:`get_returner_options` """ # c_cfg is a dictionary returned from config.option for # any options configured for this returner. if isinstance(cfg, dict): c_cfg = cfg...
python
def _fetch_option(cfg, ret_config, virtualname, attr_name): """ Fetch a given option value from the config. @see :func:`get_returner_options` """ # c_cfg is a dictionary returned from config.option for # any options configured for this returner. if isinstance(cfg, dict): c_cfg = cfg...
[ "def", "_fetch_option", "(", "cfg", ",", "ret_config", ",", "virtualname", ",", "attr_name", ")", ":", "# c_cfg is a dictionary returned from config.option for", "# any options configured for this returner.", "if", "isinstance", "(", "cfg", ",", "dict", ")", ":", "c_cfg",...
Fetch a given option value from the config. @see :func:`get_returner_options`
[ "Fetch", "a", "given", "option", "value", "from", "the", "config", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/__init__.py#L123-L166
train
saltstack/salt
salt/returners/__init__.py
_options_browser
def _options_browser(cfg, ret_config, defaults, virtualname, options): """ Iterator generating all duples ```option name -> value``` @see :func:`get_returner_options` """ for option in options: # default place for the option in the config value = _fetch_option(cfg, ret_config, vir...
python
def _options_browser(cfg, ret_config, defaults, virtualname, options): """ Iterator generating all duples ```option name -> value``` @see :func:`get_returner_options` """ for option in options: # default place for the option in the config value = _fetch_option(cfg, ret_config, vir...
[ "def", "_options_browser", "(", "cfg", ",", "ret_config", ",", "defaults", ",", "virtualname", ",", "options", ")", ":", "for", "option", "in", "options", ":", "# default place for the option in the config", "value", "=", "_fetch_option", "(", "cfg", ",", "ret_con...
Iterator generating all duples ```option name -> value``` @see :func:`get_returner_options`
[ "Iterator", "generating", "all", "duples", "option", "name", "-", ">", "value" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/__init__.py#L169-L193
train
saltstack/salt
salt/returners/__init__.py
_fetch_profile_opts
def _fetch_profile_opts( cfg, virtualname, __salt__, _options, profile_attr, profile_attrs ): """ Fetches profile specific options if applicable @see :func:`get_returner_options` :return: a options dict """ if (not profile_attr) or (profile_attr not...
python
def _fetch_profile_opts( cfg, virtualname, __salt__, _options, profile_attr, profile_attrs ): """ Fetches profile specific options if applicable @see :func:`get_returner_options` :return: a options dict """ if (not profile_attr) or (profile_attr not...
[ "def", "_fetch_profile_opts", "(", "cfg", ",", "virtualname", ",", "__salt__", ",", "_options", ",", "profile_attr", ",", "profile_attrs", ")", ":", "if", "(", "not", "profile_attr", ")", "or", "(", "profile_attr", "not", "in", "_options", ")", ":", "return"...
Fetches profile specific options if applicable @see :func:`get_returner_options` :return: a options dict
[ "Fetches", "profile", "specific", "options", "if", "applicable" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/__init__.py#L196-L235
train
saltstack/salt
salt/states/rabbitmq_plugin.py
enabled
def enabled(name, runas=None): ''' Ensure the RabbitMQ plugin is enabled. name The name of the plugin runas The user to run the rabbitmq-plugin command as ''' ret = {'name': name, 'result': True, 'comment': '', 'changes': {}} try: plugin_enabled = __salt__['rabbitm...
python
def enabled(name, runas=None): ''' Ensure the RabbitMQ plugin is enabled. name The name of the plugin runas The user to run the rabbitmq-plugin command as ''' ret = {'name': name, 'result': True, 'comment': '', 'changes': {}} try: plugin_enabled = __salt__['rabbitm...
[ "def", "enabled", "(", "name", ",", "runas", "=", "None", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'result'", ":", "True", ",", "'comment'", ":", "''", ",", "'changes'", ":", "{", "}", "}", "try", ":", "plugin_enabled", "=", "__salt_...
Ensure the RabbitMQ plugin is enabled. name The name of the plugin runas The user to run the rabbitmq-plugin command as
[ "Ensure", "the", "RabbitMQ", "plugin", "is", "enabled", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/rabbitmq_plugin.py#L35-L73
train
saltstack/salt
salt/states/git.py
_revs_equal
def _revs_equal(rev1, rev2, rev_type): ''' Shorthand helper function for comparing SHA1s. If rev_type == 'sha1' then the comparison will be done using str.startwith() to allow short SHA1s to compare successfully. NOTE: This means that rev2 must be the short rev. ''' if (rev1 is None and rev...
python
def _revs_equal(rev1, rev2, rev_type): ''' Shorthand helper function for comparing SHA1s. If rev_type == 'sha1' then the comparison will be done using str.startwith() to allow short SHA1s to compare successfully. NOTE: This means that rev2 must be the short rev. ''' if (rev1 is None and rev...
[ "def", "_revs_equal", "(", "rev1", ",", "rev2", ",", "rev_type", ")", ":", "if", "(", "rev1", "is", "None", "and", "rev2", "is", "not", "None", ")", "or", "(", "rev2", "is", "None", "and", "rev1", "is", "not", "None", ")", ":", "return", "False", ...
Shorthand helper function for comparing SHA1s. If rev_type == 'sha1' then the comparison will be done using str.startwith() to allow short SHA1s to compare successfully. NOTE: This means that rev2 must be the short rev.
[ "Shorthand", "helper", "function", "for", "comparing", "SHA1s", ".", "If", "rev_type", "==", "sha1", "then", "the", "comparison", "will", "be", "done", "using", "str", ".", "startwith", "()", "to", "allow", "short", "SHA1s", "to", "compare", "successfully", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L47-L63
train
saltstack/salt
salt/states/git.py
_get_branch_opts
def _get_branch_opts(branch, local_branch, all_local_branches, desired_upstream, git_ver=None): ''' DRY helper to build list of opts for git.branch, for the purposes of setting upstream tracking branch ''' if branch is not None and branch not in all_local_branches: # We ...
python
def _get_branch_opts(branch, local_branch, all_local_branches, desired_upstream, git_ver=None): ''' DRY helper to build list of opts for git.branch, for the purposes of setting upstream tracking branch ''' if branch is not None and branch not in all_local_branches: # We ...
[ "def", "_get_branch_opts", "(", "branch", ",", "local_branch", ",", "all_local_branches", ",", "desired_upstream", ",", "git_ver", "=", "None", ")", ":", "if", "branch", "is", "not", "None", "and", "branch", "not", "in", "all_local_branches", ":", "# We won't be...
DRY helper to build list of opts for git.branch, for the purposes of setting upstream tracking branch
[ "DRY", "helper", "to", "build", "list", "of", "opts", "for", "git", ".", "branch", "for", "the", "purposes", "of", "setting", "upstream", "tracking", "branch" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L87-L110
train
saltstack/salt
salt/states/git.py
_get_local_rev_and_branch
def _get_local_rev_and_branch(target, user, password, output_encoding=None): ''' Return the local revision for before/after comparisons ''' log.info('Checking local revision for %s', target) try: local_rev = __salt__['git.revision']( target, user=user, pas...
python
def _get_local_rev_and_branch(target, user, password, output_encoding=None): ''' Return the local revision for before/after comparisons ''' log.info('Checking local revision for %s', target) try: local_rev = __salt__['git.revision']( target, user=user, pas...
[ "def", "_get_local_rev_and_branch", "(", "target", ",", "user", ",", "password", ",", "output_encoding", "=", "None", ")", ":", "log", ".", "info", "(", "'Checking local revision for %s'", ",", "target", ")", "try", ":", "local_rev", "=", "__salt__", "[", "'gi...
Return the local revision for before/after comparisons
[ "Return", "the", "local", "revision", "for", "before", "/", "after", "comparisons" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L113-L141
train
saltstack/salt
salt/states/git.py
present
def present(name, force=False, bare=True, template=None, separate_git_dir=None, shared=None, user=None, password=None, output_encoding=None): ''' Ensure that a repository exists in the given directory .. warning...
python
def present(name, force=False, bare=True, template=None, separate_git_dir=None, shared=None, user=None, password=None, output_encoding=None): ''' Ensure that a repository exists in the given directory .. warning...
[ "def", "present", "(", "name", ",", "force", "=", "False", ",", "bare", "=", "True", ",", "template", "=", "None", ",", "separate_git_dir", "=", "None", ",", "shared", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "output_...
Ensure that a repository exists in the given directory .. warning:: If the minion has Git 2.5 or later installed, ``name`` points to a worktree_, and ``force`` is set to ``True``, then the worktree will be deleted. This has been corrected in Salt 2015.8.0. name Path to the dire...
[ "Ensure", "that", "a", "repository", "exists", "in", "the", "given", "directory" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L2063-L2235
train
saltstack/salt
salt/states/git.py
detached
def detached(name, rev, target=None, remote='origin', user=None, password=None, force_clone=False, force_checkout=False, fetch_remote=True, hard_reset=False, submodules=False, identity=None, ...
python
def detached(name, rev, target=None, remote='origin', user=None, password=None, force_clone=False, force_checkout=False, fetch_remote=True, hard_reset=False, submodules=False, identity=None, ...
[ "def", "detached", "(", "name", ",", "rev", ",", "target", "=", "None", ",", "remote", "=", "'origin'", ",", "user", "=", "None", ",", "password", "=", "None", ",", "force_clone", "=", "False", ",", "force_checkout", "=", "False", ",", "fetch_remote", ...
.. versionadded:: 2016.3.0 Make sure a repository is cloned to the given target directory and is a detached HEAD checkout of the commit ID resolved from ``rev``. name Address of the remote repository. rev The branch, tag, or commit ID to checkout after clone. If a branch or ta...
[ "..", "versionadded", "::", "2016", ".", "3", ".", "0" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L2238-L2761
train
saltstack/salt
salt/states/git.py
cloned
def cloned(name, target=None, branch=None, user=None, password=None, identity=None, https_user=None, https_pass=None, output_encoding=None): ''' .. versionadded:: 2018.3.3,2019.2.0 Ensure that a repository has been clon...
python
def cloned(name, target=None, branch=None, user=None, password=None, identity=None, https_user=None, https_pass=None, output_encoding=None): ''' .. versionadded:: 2018.3.3,2019.2.0 Ensure that a repository has been clon...
[ "def", "cloned", "(", "name", ",", "target", "=", "None", ",", "branch", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "identity", "=", "None", ",", "https_user", "=", "None", ",", "https_pass", "=", "None", ",", "output_e...
.. versionadded:: 2018.3.3,2019.2.0 Ensure that a repository has been cloned to the specified target directory. If not, clone that repository. No fetches will be performed once cloned. name Address of the remote repository target Name of the target directory where repository should be...
[ "..", "versionadded", "::", "2018", ".", "3", ".", "3", "2019", ".", "2", ".", "0" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L2764-L2957
train
saltstack/salt
salt/states/git.py
config_unset
def config_unset(name, value_regex=None, repo=None, user=None, password=None, output_encoding=None, **kwargs): r''' .. versionadded:: 2015.8.0 Ensure that the named config key is not present name ...
python
def config_unset(name, value_regex=None, repo=None, user=None, password=None, output_encoding=None, **kwargs): r''' .. versionadded:: 2015.8.0 Ensure that the named config key is not present name ...
[ "def", "config_unset", "(", "name", ",", "value_regex", "=", "None", ",", "repo", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "output_encoding", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ...
r''' .. versionadded:: 2015.8.0 Ensure that the named config key is not present name The name of the configuration key to unset. This value can be a regex, but the regex must match the entire key name. For example, ``foo\.`` would not match all keys in the ``foo`` section, it would...
[ "r", "..", "versionadded", "::", "2015", ".", "8", ".", "0" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L2960-L3217
train
saltstack/salt
salt/states/git.py
config_set
def config_set(name, value=None, multivar=None, repo=None, user=None, password=None, output_encoding=None, **kwargs): ''' .. versionadded:: 2014.7.0 .. versionchanged:: 2015.8.0 Renamed from ``gi...
python
def config_set(name, value=None, multivar=None, repo=None, user=None, password=None, output_encoding=None, **kwargs): ''' .. versionadded:: 2014.7.0 .. versionchanged:: 2015.8.0 Renamed from ``gi...
[ "def", "config_set", "(", "name", ",", "value", "=", "None", ",", "multivar", "=", "None", ",", "repo", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "output_encoding", "=", "None", ",", "*", "*", "kwargs", ")", ":", "re...
.. versionadded:: 2014.7.0 .. versionchanged:: 2015.8.0 Renamed from ``git.config`` to ``git.config_set``. For earlier versions, use ``git.config``. Ensure that a config value is set to the desired value(s) name Name of the git config value to set value Set a single va...
[ "..", "versionadded", "::", "2014", ".", "7", ".", "0", "..", "versionchanged", "::", "2015", ".", "8", ".", "0", "Renamed", "from", "git", ".", "config", "to", "git", ".", "config_set", ".", "For", "earlier", "versions", "use", "git", ".", "config", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L3220-L3438
train
saltstack/salt
salt/states/git.py
mod_run_check
def mod_run_check(cmd_kwargs, onlyif, unless): ''' Execute the onlyif and unless logic. Return a result dict if: * onlyif failed (onlyif != 0) * unless succeeded (unless == 0) Otherwise, returns ``True`` ''' cmd_kwargs = copy.deepcopy(cmd_kwargs) cmd_kwargs.update({ 'use_vt': F...
python
def mod_run_check(cmd_kwargs, onlyif, unless): ''' Execute the onlyif and unless logic. Return a result dict if: * onlyif failed (onlyif != 0) * unless succeeded (unless == 0) Otherwise, returns ``True`` ''' cmd_kwargs = copy.deepcopy(cmd_kwargs) cmd_kwargs.update({ 'use_vt': F...
[ "def", "mod_run_check", "(", "cmd_kwargs", ",", "onlyif", ",", "unless", ")", ":", "cmd_kwargs", "=", "copy", ".", "deepcopy", "(", "cmd_kwargs", ")", "cmd_kwargs", ".", "update", "(", "{", "'use_vt'", ":", "False", ",", "'bg'", ":", "False", ",", "'igno...
Execute the onlyif and unless logic. Return a result dict if: * onlyif failed (onlyif != 0) * unless succeeded (unless == 0) Otherwise, returns ``True``
[ "Execute", "the", "onlyif", "and", "unless", "logic", ".", "Return", "a", "result", "dict", "if", ":" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L3441-L3512
train
saltstack/salt
salt/modules/pushbullet.py
push_note
def push_note(device=None, title=None, body=None): ''' Pushing a text note. :param device: Pushbullet target device :param title: Note title :param body: Note body :return: Boolean if message was sent successfully. CLI Example: .. code-block:: bash salt "...
python
def push_note(device=None, title=None, body=None): ''' Pushing a text note. :param device: Pushbullet target device :param title: Note title :param body: Note body :return: Boolean if message was sent successfully. CLI Example: .. code-block:: bash salt "...
[ "def", "push_note", "(", "device", "=", "None", ",", "title", "=", "None", ",", "body", "=", "None", ")", ":", "spb", "=", "_SaltPushbullet", "(", "device", ")", "res", "=", "spb", ".", "push_note", "(", "title", ",", "body", ")", "return", "res" ]
Pushing a text note. :param device: Pushbullet target device :param title: Note title :param body: Note body :return: Boolean if message was sent successfully. CLI Example: .. code-block:: bash salt "*" pushbullet.push_note device="Chrome" title="Example title" b...
[ "Pushing", "a", "text", "note", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pushbullet.py#L65-L84
train
saltstack/salt
salt/modules/travisci.py
verify_webhook
def verify_webhook(signature, body): ''' Verify the webhook signature from travisci signature The signature header from the webhook header body The full payload body from the webhook post .. note:: The body needs to be the urlencoded version of the body. CLI Example: .. ...
python
def verify_webhook(signature, body): ''' Verify the webhook signature from travisci signature The signature header from the webhook header body The full payload body from the webhook post .. note:: The body needs to be the urlencoded version of the body. CLI Example: .. ...
[ "def", "verify_webhook", "(", "signature", ",", "body", ")", ":", "# get public key setup", "public_key", "=", "__utils__", "[", "'http.query'", "]", "(", "'https://api.travis-ci.org/config'", ")", "[", "'config'", "]", "[", "'notifications'", "]", "[", "'webhook'",...
Verify the webhook signature from travisci signature The signature header from the webhook header body The full payload body from the webhook post .. note:: The body needs to be the urlencoded version of the body. CLI Example: .. code-block:: bash salt '*' travisci.veri...
[ "Verify", "the", "webhook", "signature", "from", "travisci" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/travisci.py#L42-L77
train
saltstack/salt
salt/states/network.py
managed
def managed(name, type, enabled=True, **kwargs): ''' Ensure that the named interface is configured properly. name The name of the interface to manage type Type of interface and configuration. enabled Designates the state of this interface. kwargs The IP parame...
python
def managed(name, type, enabled=True, **kwargs): ''' Ensure that the named interface is configured properly. name The name of the interface to manage type Type of interface and configuration. enabled Designates the state of this interface. kwargs The IP parame...
[ "def", "managed", "(", "name", ",", "type", ",", "enabled", "=", "True", ",", "*", "*", "kwargs", ")", ":", "# For this function we are purposefully overwriting a bif", "# to enhance the user experience. This does not look like", "# it will cause a problem. Just giving a heads up...
Ensure that the named interface is configured properly. name The name of the interface to manage type Type of interface and configuration. enabled Designates the state of this interface. kwargs The IP parameters for this interface.
[ "Ensure", "that", "the", "named", "interface", "is", "configured", "properly", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/network.py#L359-L551
train
saltstack/salt
salt/states/network.py
routes
def routes(name, **kwargs): ''' Manage network interface static routes. name Interface name to apply the route to. kwargs Named routes ''' ret = { 'name': name, 'changes': {}, 'result': True, 'comment': 'Interface {0} routes are up to date.'.form...
python
def routes(name, **kwargs): ''' Manage network interface static routes. name Interface name to apply the route to. kwargs Named routes ''' ret = { 'name': name, 'changes': {}, 'result': True, 'comment': 'Interface {0} routes are up to date.'.form...
[ "def", "routes", "(", "name", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "True", ",", "'comment'", ":", "'Interface {0} routes are up to date.'", ".", "format", "(", ...
Manage network interface static routes. name Interface name to apply the route to. kwargs Named routes
[ "Manage", "network", "interface", "static", "routes", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/network.py#L554-L614
train
saltstack/salt
salt/states/network.py
system
def system(name, **kwargs): ''' Ensure that global network settings are configured properly. name Custom name to represent this configuration change. kwargs The global parameters for the system. ''' ret = { 'name': name, 'changes': {}, 'result': True, ...
python
def system(name, **kwargs): ''' Ensure that global network settings are configured properly. name Custom name to represent this configuration change. kwargs The global parameters for the system. ''' ret = { 'name': name, 'changes': {}, 'result': True, ...
[ "def", "system", "(", "name", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "True", ",", "'comment'", ":", "'Global network settings are up to date.'", ",", "}", "apply_n...
Ensure that global network settings are configured properly. name Custom name to represent this configuration change. kwargs The global parameters for the system.
[ "Ensure", "that", "global", "network", "settings", "are", "configured", "properly", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/network.py#L617-L678
train
saltstack/salt
salt/states/zabbix_mediatype.py
present
def present(name, mediatype, **kwargs): ''' Creates new mediatype. NOTE: This function accepts all standard mediatype properties: keyword argument names differ depending on your zabbix version, see: https://www.zabbix.com/documentation/3.0/manual/api/reference/host/object#host_inventory :param ...
python
def present(name, mediatype, **kwargs): ''' Creates new mediatype. NOTE: This function accepts all standard mediatype properties: keyword argument names differ depending on your zabbix version, see: https://www.zabbix.com/documentation/3.0/manual/api/reference/host/object#host_inventory :param ...
[ "def", "present", "(", "name", ",", "mediatype", ",", "*", "*", "kwargs", ")", ":", "connection_args", "=", "{", "}", "if", "'_connection_user'", "in", "kwargs", ":", "connection_args", "[", "'_connection_user'", "]", "=", "kwargs", "[", "'_connection_user'", ...
Creates new mediatype. NOTE: This function accepts all standard mediatype properties: keyword argument names differ depending on your zabbix version, see: https://www.zabbix.com/documentation/3.0/manual/api/reference/host/object#host_inventory :param name: name of the mediatype :param _connection_u...
[ "Creates", "new", "mediatype", ".", "NOTE", ":", "This", "function", "accepts", "all", "standard", "mediatype", "properties", ":", "keyword", "argument", "names", "differ", "depending", "on", "your", "zabbix", "version", "see", ":", "https", ":", "//", "www", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zabbix_mediatype.py#L23-L319
train
saltstack/salt
salt/states/zabbix_mediatype.py
absent
def absent(name, **kwargs): ''' Ensures that the mediatype does not exist, eventually deletes the mediatype. :param name: name of the mediatype :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring) :param _connection_password: Optional - zabbix ...
python
def absent(name, **kwargs): ''' Ensures that the mediatype does not exist, eventually deletes the mediatype. :param name: name of the mediatype :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring) :param _connection_password: Optional - zabbix ...
[ "def", "absent", "(", "name", ",", "*", "*", "kwargs", ")", ":", "connection_args", "=", "{", "}", "if", "'_connection_user'", "in", "kwargs", ":", "connection_args", "[", "'_connection_user'", "]", "=", "kwargs", "[", "'_connection_user'", "]", "if", "'_con...
Ensures that the mediatype does not exist, eventually deletes the mediatype. :param name: name of the mediatype :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring) :param _connection_password: Optional - zabbix password (can also be set in opts or pil...
[ "Ensures", "that", "the", "mediatype", "does", "not", "exist", "eventually", "deletes", "the", "mediatype", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zabbix_mediatype.py#L322-L386
train
saltstack/salt
salt/utils/network.py
sanitize_host
def sanitize_host(host): ''' Sanitize host string. https://tools.ietf.org/html/rfc1123#section-2.1 ''' RFC952_characters = ascii_letters + digits + ".-" return "".join([c for c in host[0:255] if c in RFC952_characters])
python
def sanitize_host(host): ''' Sanitize host string. https://tools.ietf.org/html/rfc1123#section-2.1 ''' RFC952_characters = ascii_letters + digits + ".-" return "".join([c for c in host[0:255] if c in RFC952_characters])
[ "def", "sanitize_host", "(", "host", ")", ":", "RFC952_characters", "=", "ascii_letters", "+", "digits", "+", "\".-\"", "return", "\"\"", ".", "join", "(", "[", "c", "for", "c", "in", "host", "[", "0", ":", "255", "]", "if", "c", "in", "RFC952_characte...
Sanitize host string. https://tools.ietf.org/html/rfc1123#section-2.1
[ "Sanitize", "host", "string", ".", "https", ":", "//", "tools", ".", "ietf", ".", "org", "/", "html", "/", "rfc1123#section", "-", "2", ".", "1" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L58-L64
train
saltstack/salt
salt/utils/network.py
isportopen
def isportopen(host, port): ''' Return status of a port ''' if not 1 <= int(port) <= 65535: return False sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) out = sock.connect_ex((sanitize_host(host), int(port))) return out
python
def isportopen(host, port): ''' Return status of a port ''' if not 1 <= int(port) <= 65535: return False sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) out = sock.connect_ex((sanitize_host(host), int(port))) return out
[ "def", "isportopen", "(", "host", ",", "port", ")", ":", "if", "not", "1", "<=", "int", "(", "port", ")", "<=", "65535", ":", "return", "False", "sock", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ...
Return status of a port
[ "Return", "status", "of", "a", "port" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L67-L78
train
saltstack/salt
salt/utils/network.py
host_to_ips
def host_to_ips(host): ''' Returns a list of IP addresses of a given hostname or None if not found. ''' ips = [] try: for family, socktype, proto, canonname, sockaddr in socket.getaddrinfo( host, 0, socket.AF_UNSPEC, socket.SOCK_STREAM): if family == socket.AF_INE...
python
def host_to_ips(host): ''' Returns a list of IP addresses of a given hostname or None if not found. ''' ips = [] try: for family, socktype, proto, canonname, sockaddr in socket.getaddrinfo( host, 0, socket.AF_UNSPEC, socket.SOCK_STREAM): if family == socket.AF_INE...
[ "def", "host_to_ips", "(", "host", ")", ":", "ips", "=", "[", "]", "try", ":", "for", "family", ",", "socktype", ",", "proto", ",", "canonname", ",", "sockaddr", "in", "socket", ".", "getaddrinfo", "(", "host", ",", "0", ",", "socket", ".", "AF_UNSPE...
Returns a list of IP addresses of a given hostname or None if not found.
[ "Returns", "a", "list", "of", "IP", "addresses", "of", "a", "given", "hostname", "or", "None", "if", "not", "found", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L81-L98
train
saltstack/salt
salt/utils/network.py
_generate_minion_id
def _generate_minion_id(): ''' Get list of possible host names and convention names. :return: ''' # There are three types of hostnames: # 1. Network names. How host is accessed from the network. # 2. Host aliases. They might be not available in all the network or only locally (/etc/hosts) ...
python
def _generate_minion_id(): ''' Get list of possible host names and convention names. :return: ''' # There are three types of hostnames: # 1. Network names. How host is accessed from the network. # 2. Host aliases. They might be not available in all the network or only locally (/etc/hosts) ...
[ "def", "_generate_minion_id", "(", ")", ":", "# There are three types of hostnames:", "# 1. Network names. How host is accessed from the network.", "# 2. Host aliases. They might be not available in all the network or only locally (/etc/hosts)", "# 3. Convention names, an internal nodename.", "cla...
Get list of possible host names and convention names. :return:
[ "Get", "list", "of", "possible", "host", "names", "and", "convention", "names", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L101-L170
train
saltstack/salt
salt/utils/network.py
generate_minion_id
def generate_minion_id(): ''' Return only first element of the hostname from all possible list. :return: ''' try: ret = salt.utils.stringutils.to_unicode(_generate_minion_id().first()) except TypeError: ret = None return ret or 'localhost'
python
def generate_minion_id(): ''' Return only first element of the hostname from all possible list. :return: ''' try: ret = salt.utils.stringutils.to_unicode(_generate_minion_id().first()) except TypeError: ret = None return ret or 'localhost'
[ "def", "generate_minion_id", "(", ")", ":", "try", ":", "ret", "=", "salt", ".", "utils", ".", "stringutils", ".", "to_unicode", "(", "_generate_minion_id", "(", ")", ".", "first", "(", ")", ")", "except", "TypeError", ":", "ret", "=", "None", "return", ...
Return only first element of the hostname from all possible list. :return:
[ "Return", "only", "first", "element", "of", "the", "hostname", "from", "all", "possible", "list", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L173-L183
train
saltstack/salt
salt/utils/network.py
get_socket
def get_socket(addr, type=socket.SOCK_STREAM, proto=0): ''' Return a socket object for the addr IP-version agnostic ''' version = ipaddress.ip_address(addr).version if version == 4: family = socket.AF_INET elif version == 6: family = socket.AF_INET6 return socket.socket(...
python
def get_socket(addr, type=socket.SOCK_STREAM, proto=0): ''' Return a socket object for the addr IP-version agnostic ''' version = ipaddress.ip_address(addr).version if version == 4: family = socket.AF_INET elif version == 6: family = socket.AF_INET6 return socket.socket(...
[ "def", "get_socket", "(", "addr", ",", "type", "=", "socket", ".", "SOCK_STREAM", ",", "proto", "=", "0", ")", ":", "version", "=", "ipaddress", ".", "ip_address", "(", "addr", ")", ".", "version", "if", "version", "==", "4", ":", "family", "=", "soc...
Return a socket object for the addr IP-version agnostic
[ "Return", "a", "socket", "object", "for", "the", "addr", "IP", "-", "version", "agnostic" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L186-L197
train
saltstack/salt
salt/utils/network.py
get_fqhostname
def get_fqhostname(): ''' Returns the fully qualified hostname ''' # try getaddrinfo() fqdn = None try: addrinfo = socket.getaddrinfo( socket.gethostname(), 0, socket.AF_UNSPEC, socket.SOCK_STREAM, socket.SOL_TCP, socket.AI_CANONNAME ) for info in ...
python
def get_fqhostname(): ''' Returns the fully qualified hostname ''' # try getaddrinfo() fqdn = None try: addrinfo = socket.getaddrinfo( socket.gethostname(), 0, socket.AF_UNSPEC, socket.SOCK_STREAM, socket.SOL_TCP, socket.AI_CANONNAME ) for info in ...
[ "def", "get_fqhostname", "(", ")", ":", "# try getaddrinfo()", "fqdn", "=", "None", "try", ":", "addrinfo", "=", "socket", ".", "getaddrinfo", "(", "socket", ".", "gethostname", "(", ")", ",", "0", ",", "socket", ".", "AF_UNSPEC", ",", "socket", ".", "SO...
Returns the fully qualified hostname
[ "Returns", "the", "fully", "qualified", "hostname" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L200-L224
train
saltstack/salt
salt/utils/network.py
ip_to_host
def ip_to_host(ip): ''' Returns the hostname of a given IP ''' try: hostname, aliaslist, ipaddrlist = socket.gethostbyaddr(ip) except Exception as exc: log.debug('salt.utils.network.ip_to_host(%r) failed: %s', ip, exc) hostname = None return hostname
python
def ip_to_host(ip): ''' Returns the hostname of a given IP ''' try: hostname, aliaslist, ipaddrlist = socket.gethostbyaddr(ip) except Exception as exc: log.debug('salt.utils.network.ip_to_host(%r) failed: %s', ip, exc) hostname = None return hostname
[ "def", "ip_to_host", "(", "ip", ")", ":", "try", ":", "hostname", ",", "aliaslist", ",", "ipaddrlist", "=", "socket", ".", "gethostbyaddr", "(", "ip", ")", "except", "Exception", "as", "exc", ":", "log", ".", "debug", "(", "'salt.utils.network.ip_to_host(%r)...
Returns the hostname of a given IP
[ "Returns", "the", "hostname", "of", "a", "given", "IP" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L227-L236
train
saltstack/salt
salt/utils/network.py
is_reachable_host
def is_reachable_host(entity_name): ''' Returns a bool telling if the entity name is a reachable host (IPv4/IPv6/FQDN/etc). :param hostname: :return: ''' try: assert type(socket.getaddrinfo(entity_name, 0, 0, 0, 0)) == list ret = True except socket.gaierror: ret = Fal...
python
def is_reachable_host(entity_name): ''' Returns a bool telling if the entity name is a reachable host (IPv4/IPv6/FQDN/etc). :param hostname: :return: ''' try: assert type(socket.getaddrinfo(entity_name, 0, 0, 0, 0)) == list ret = True except socket.gaierror: ret = Fal...
[ "def", "is_reachable_host", "(", "entity_name", ")", ":", "try", ":", "assert", "type", "(", "socket", ".", "getaddrinfo", "(", "entity_name", ",", "0", ",", "0", ",", "0", ",", "0", ")", ")", "==", "list", "ret", "=", "True", "except", "socket", "."...
Returns a bool telling if the entity name is a reachable host (IPv4/IPv6/FQDN/etc). :param hostname: :return:
[ "Returns", "a", "bool", "telling", "if", "the", "entity", "name", "is", "a", "reachable", "host", "(", "IPv4", "/", "IPv6", "/", "FQDN", "/", "etc", ")", ".", ":", "param", "hostname", ":", ":", "return", ":" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L241-L253
train
saltstack/salt
salt/utils/network.py
is_ip_filter
def is_ip_filter(ip, options=None): ''' Returns a bool telling if the passed IP is a valid IPv4 or IPv6 address. ''' return is_ipv4_filter(ip, options=options) or is_ipv6_filter(ip, options=options)
python
def is_ip_filter(ip, options=None): ''' Returns a bool telling if the passed IP is a valid IPv4 or IPv6 address. ''' return is_ipv4_filter(ip, options=options) or is_ipv6_filter(ip, options=options)
[ "def", "is_ip_filter", "(", "ip", ",", "options", "=", "None", ")", ":", "return", "is_ipv4_filter", "(", "ip", ",", "options", "=", "options", ")", "or", "is_ipv6_filter", "(", "ip", ",", "options", "=", "options", ")" ]
Returns a bool telling if the passed IP is a valid IPv4 or IPv6 address.
[ "Returns", "a", "bool", "telling", "if", "the", "passed", "IP", "is", "a", "valid", "IPv4", "or", "IPv6", "address", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L311-L315
train
saltstack/salt
salt/utils/network.py
is_ipv4_filter
def is_ipv4_filter(ip, options=None): ''' Returns a bool telling if the value passed to it was a valid IPv4 address. ip The IP address. net: False Consider IP addresses followed by netmask. options CSV of options regarding the nature of the IP address. E.g.: loopback, mult...
python
def is_ipv4_filter(ip, options=None): ''' Returns a bool telling if the value passed to it was a valid IPv4 address. ip The IP address. net: False Consider IP addresses followed by netmask. options CSV of options regarding the nature of the IP address. E.g.: loopback, mult...
[ "def", "is_ipv4_filter", "(", "ip", ",", "options", "=", "None", ")", ":", "_is_ipv4", "=", "_is_ipv", "(", "ip", ",", "4", ",", "options", "=", "options", ")", "return", "isinstance", "(", "_is_ipv4", ",", "six", ".", "string_types", ")" ]
Returns a bool telling if the value passed to it was a valid IPv4 address. ip The IP address. net: False Consider IP addresses followed by netmask. options CSV of options regarding the nature of the IP address. E.g.: loopback, multicast, private etc.
[ "Returns", "a", "bool", "telling", "if", "the", "value", "passed", "to", "it", "was", "a", "valid", "IPv4", "address", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L414-L428
train
saltstack/salt
salt/utils/network.py
is_ipv6_filter
def is_ipv6_filter(ip, options=None): ''' Returns a bool telling if the value passed to it was a valid IPv6 address. ip The IP address. net: False Consider IP addresses followed by netmask. options CSV of options regarding the nature of the IP address. E.g.: loopback, mult...
python
def is_ipv6_filter(ip, options=None): ''' Returns a bool telling if the value passed to it was a valid IPv6 address. ip The IP address. net: False Consider IP addresses followed by netmask. options CSV of options regarding the nature of the IP address. E.g.: loopback, mult...
[ "def", "is_ipv6_filter", "(", "ip", ",", "options", "=", "None", ")", ":", "_is_ipv6", "=", "_is_ipv", "(", "ip", ",", "6", ",", "options", "=", "options", ")", "return", "isinstance", "(", "_is_ipv6", ",", "six", ".", "string_types", ")" ]
Returns a bool telling if the value passed to it was a valid IPv6 address. ip The IP address. net: False Consider IP addresses followed by netmask. options CSV of options regarding the nature of the IP address. E.g.: loopback, multicast, private etc.
[ "Returns", "a", "bool", "telling", "if", "the", "value", "passed", "to", "it", "was", "a", "valid", "IPv6", "address", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L432-L446
train
saltstack/salt
salt/utils/network.py
ipaddr
def ipaddr(value, options=None): ''' Filters and returns only valid IP objects. ''' ipv4_obj = ipv4(value, options=options) ipv6_obj = ipv6(value, options=options) if ipv4_obj is None or ipv6_obj is None: # an IP address can be either IPv4 either IPv6 # therefofe if the value pas...
python
def ipaddr(value, options=None): ''' Filters and returns only valid IP objects. ''' ipv4_obj = ipv4(value, options=options) ipv6_obj = ipv6(value, options=options) if ipv4_obj is None or ipv6_obj is None: # an IP address can be either IPv4 either IPv6 # therefofe if the value pas...
[ "def", "ipaddr", "(", "value", ",", "options", "=", "None", ")", ":", "ipv4_obj", "=", "ipv4", "(", "value", ",", "options", "=", "options", ")", "ipv6_obj", "=", "ipv6", "(", "value", ",", "options", "=", "options", ")", "if", "ipv4_obj", "is", "Non...
Filters and returns only valid IP objects.
[ "Filters", "and", "returns", "only", "valid", "IP", "objects", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L484-L496
train
saltstack/salt
salt/utils/network.py
ip_host
def ip_host(value, options=None, version=None): ''' Returns the interfaces IP address, e.g.: 192.168.0.1/28. ''' ipaddr_filter_out = _filter_ipaddr(value, options=options, version=version) if not ipaddr_filter_out: return if not isinstance(value, (list, tuple, types.GeneratorType)): ...
python
def ip_host(value, options=None, version=None): ''' Returns the interfaces IP address, e.g.: 192.168.0.1/28. ''' ipaddr_filter_out = _filter_ipaddr(value, options=options, version=version) if not ipaddr_filter_out: return if not isinstance(value, (list, tuple, types.GeneratorType)): ...
[ "def", "ip_host", "(", "value", ",", "options", "=", "None", ",", "version", "=", "None", ")", ":", "ipaddr_filter_out", "=", "_filter_ipaddr", "(", "value", ",", "options", "=", "options", ",", "version", "=", "version", ")", "if", "not", "ipaddr_filter_o...
Returns the interfaces IP address, e.g.: 192.168.0.1/28.
[ "Returns", "the", "interfaces", "IP", "address", "e", ".", "g", ".", ":", "192", ".", "168", ".", "0", ".", "1", "/", "28", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L516-L525
train
saltstack/salt
salt/utils/network.py
network_hosts
def network_hosts(value, options=None, version=None): ''' Return the list of hosts within a network. .. note:: When running this command with a large IPv6 network, the command will take a long time to gather all of the hosts. ''' ipaddr_filter_out = _filter_ipaddr(value, options=op...
python
def network_hosts(value, options=None, version=None): ''' Return the list of hosts within a network. .. note:: When running this command with a large IPv6 network, the command will take a long time to gather all of the hosts. ''' ipaddr_filter_out = _filter_ipaddr(value, options=op...
[ "def", "network_hosts", "(", "value", ",", "options", "=", "None", ",", "version", "=", "None", ")", ":", "ipaddr_filter_out", "=", "_filter_ipaddr", "(", "value", ",", "options", "=", "options", ",", "version", "=", "version", ")", "if", "not", "ipaddr_fi...
Return the list of hosts within a network. .. note:: When running this command with a large IPv6 network, the command will take a long time to gather all of the hosts.
[ "Return", "the", "list", "of", "hosts", "within", "a", "network", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L536-L553
train
saltstack/salt
salt/utils/network.py
network_size
def network_size(value, options=None, version=None): ''' Get the size of a network. ''' ipaddr_filter_out = _filter_ipaddr(value, options=options, version=version) if not ipaddr_filter_out: return if not isinstance(value, (list, tuple, types.GeneratorType)): return _network_size(...
python
def network_size(value, options=None, version=None): ''' Get the size of a network. ''' ipaddr_filter_out = _filter_ipaddr(value, options=options, version=version) if not ipaddr_filter_out: return if not isinstance(value, (list, tuple, types.GeneratorType)): return _network_size(...
[ "def", "network_size", "(", "value", ",", "options", "=", "None", ",", "version", "=", "None", ")", ":", "ipaddr_filter_out", "=", "_filter_ipaddr", "(", "value", ",", "options", "=", "options", ",", "version", "=", "version", ")", "if", "not", "ipaddr_fil...
Get the size of a network.
[ "Get", "the", "size", "of", "a", "network", "." ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L561-L573
train
saltstack/salt
salt/utils/network.py
natural_ipv4_netmask
def natural_ipv4_netmask(ip, fmt='prefixlen'): ''' Returns the "natural" mask of an IPv4 address ''' bits = _ipv4_to_bits(ip) if bits.startswith('11'): mask = '24' elif bits.startswith('1'): mask = '16' else: mask = '8' if fmt == 'netmask': return cidr_t...
python
def natural_ipv4_netmask(ip, fmt='prefixlen'): ''' Returns the "natural" mask of an IPv4 address ''' bits = _ipv4_to_bits(ip) if bits.startswith('11'): mask = '24' elif bits.startswith('1'): mask = '16' else: mask = '8' if fmt == 'netmask': return cidr_t...
[ "def", "natural_ipv4_netmask", "(", "ip", ",", "fmt", "=", "'prefixlen'", ")", ":", "bits", "=", "_ipv4_to_bits", "(", "ip", ")", "if", "bits", ".", "startswith", "(", "'11'", ")", ":", "mask", "=", "'24'", "elif", "bits", ".", "startswith", "(", "'1'"...
Returns the "natural" mask of an IPv4 address
[ "Returns", "the", "natural", "mask", "of", "an", "IPv4", "address" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L576-L592
train
saltstack/salt
salt/utils/network.py
cidr_to_ipv4_netmask
def cidr_to_ipv4_netmask(cidr_bits): ''' Returns an IPv4 netmask ''' try: cidr_bits = int(cidr_bits) if not 1 <= cidr_bits <= 32: return '' except ValueError: return '' netmask = '' for idx in range(4): if idx: netmask += '.' i...
python
def cidr_to_ipv4_netmask(cidr_bits): ''' Returns an IPv4 netmask ''' try: cidr_bits = int(cidr_bits) if not 1 <= cidr_bits <= 32: return '' except ValueError: return '' netmask = '' for idx in range(4): if idx: netmask += '.' i...
[ "def", "cidr_to_ipv4_netmask", "(", "cidr_bits", ")", ":", "try", ":", "cidr_bits", "=", "int", "(", "cidr_bits", ")", "if", "not", "1", "<=", "cidr_bits", "<=", "32", ":", "return", "''", "except", "ValueError", ":", "return", "''", "netmask", "=", "''"...
Returns an IPv4 netmask
[ "Returns", "an", "IPv4", "netmask" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L606-L627
train
saltstack/salt
salt/utils/network.py
_number_of_set_bits
def _number_of_set_bits(x): ''' Returns the number of bits that are set in a 32bit int ''' # Taken from http://stackoverflow.com/a/4912729. Many thanks! x -= (x >> 1) & 0x55555555 x = ((x >> 2) & 0x33333333) + (x & 0x33333333) x = ((x >> 4) + x) & 0x0f0f0f0f x += x >> 8 x += x >> 16 ...
python
def _number_of_set_bits(x): ''' Returns the number of bits that are set in a 32bit int ''' # Taken from http://stackoverflow.com/a/4912729. Many thanks! x -= (x >> 1) & 0x55555555 x = ((x >> 2) & 0x33333333) + (x & 0x33333333) x = ((x >> 4) + x) & 0x0f0f0f0f x += x >> 8 x += x >> 16 ...
[ "def", "_number_of_set_bits", "(", "x", ")", ":", "# Taken from http://stackoverflow.com/a/4912729. Many thanks!", "x", "-=", "(", "x", ">>", "1", ")", "&", "0x55555555", "x", "=", "(", "(", "x", ">>", "2", ")", "&", "0x33333333", ")", "+", "(", "x", "&", ...
Returns the number of bits that are set in a 32bit int
[ "Returns", "the", "number", "of", "bits", "that", "are", "set", "in", "a", "32bit", "int" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L640-L650
train
saltstack/salt
salt/utils/network.py
_interfaces_ifconfig
def _interfaces_ifconfig(out): ''' Uses ifconfig to return a dictionary of interfaces with various information about each (up/down state, ip address, netmask, and hwaddr) ''' ret = dict() piface = re.compile(r'^([^\s:]+)') pmac = re.compile('.*?(?:HWaddr|ether|address:|lladdr) ([0-9a-fA-F:]...
python
def _interfaces_ifconfig(out): ''' Uses ifconfig to return a dictionary of interfaces with various information about each (up/down state, ip address, netmask, and hwaddr) ''' ret = dict() piface = re.compile(r'^([^\s:]+)') pmac = re.compile('.*?(?:HWaddr|ether|address:|lladdr) ([0-9a-fA-F:]...
[ "def", "_interfaces_ifconfig", "(", "out", ")", ":", "ret", "=", "dict", "(", ")", "piface", "=", "re", ".", "compile", "(", "r'^([^\\s:]+)'", ")", "pmac", "=", "re", ".", "compile", "(", "'.*?(?:HWaddr|ether|address:|lladdr) ([0-9a-fA-F:]+)'", ")", "if", "sal...
Uses ifconfig to return a dictionary of interfaces with various information about each (up/down state, ip address, netmask, and hwaddr)
[ "Uses", "ifconfig", "to", "return", "a", "dictionary", "of", "interfaces", "with", "various", "information", "about", "each", "(", "up", "/", "down", "state", "ip", "address", "netmask", "and", "hwaddr", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L748-L841
train
saltstack/salt
salt/utils/network.py
linux_interfaces
def linux_interfaces(): ''' Obtain interface information for *NIX/BSD variants ''' ifaces = dict() ip_path = salt.utils.path.which('ip') ifconfig_path = None if ip_path else salt.utils.path.which('ifconfig') if ip_path: cmd1 = subprocess.Popen( '{0} link show'.format(ip_p...
python
def linux_interfaces(): ''' Obtain interface information for *NIX/BSD variants ''' ifaces = dict() ip_path = salt.utils.path.which('ip') ifconfig_path = None if ip_path else salt.utils.path.which('ifconfig') if ip_path: cmd1 = subprocess.Popen( '{0} link show'.format(ip_p...
[ "def", "linux_interfaces", "(", ")", ":", "ifaces", "=", "dict", "(", ")", "ip_path", "=", "salt", ".", "utils", ".", "path", ".", "which", "(", "'ip'", ")", "ifconfig_path", "=", "None", "if", "ip_path", "else", "salt", ".", "utils", ".", "path", "....
Obtain interface information for *NIX/BSD variants
[ "Obtain", "interface", "information", "for", "*", "NIX", "/", "BSD", "variants" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L844-L874
train
saltstack/salt
salt/utils/network.py
_netbsd_interfaces_ifconfig
def _netbsd_interfaces_ifconfig(out): ''' Uses ifconfig to return a dictionary of interfaces with various information about each (up/down state, ip address, netmask, and hwaddr) ''' ret = dict() piface = re.compile(r'^([^\s:]+)') pmac = re.compile('.*?address: ([0-9a-f:]+)') pip = re.c...
python
def _netbsd_interfaces_ifconfig(out): ''' Uses ifconfig to return a dictionary of interfaces with various information about each (up/down state, ip address, netmask, and hwaddr) ''' ret = dict() piface = re.compile(r'^([^\s:]+)') pmac = re.compile('.*?address: ([0-9a-f:]+)') pip = re.c...
[ "def", "_netbsd_interfaces_ifconfig", "(", "out", ")", ":", "ret", "=", "dict", "(", ")", "piface", "=", "re", ".", "compile", "(", "r'^([^\\s:]+)'", ")", "pmac", "=", "re", ".", "compile", "(", "'.*?address: ([0-9a-f:]+)'", ")", "pip", "=", "re", ".", "...
Uses ifconfig to return a dictionary of interfaces with various information about each (up/down state, ip address, netmask, and hwaddr)
[ "Uses", "ifconfig", "to", "return", "a", "dictionary", "of", "interfaces", "with", "various", "information", "about", "each", "(", "up", "/", "down", "state", "ip", "address", "netmask", "and", "hwaddr", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L877-L934
train
saltstack/salt
salt/utils/network.py
netbsd_interfaces
def netbsd_interfaces(): ''' Obtain interface information for NetBSD >= 8 where the ifconfig output diverged from other BSD variants (Netmask is now part of the address) ''' # NetBSD versions prior to 8.0 can still use linux_interfaces() if LooseVersion(os.uname()[2]) < LooseVersion('8.0'): ...
python
def netbsd_interfaces(): ''' Obtain interface information for NetBSD >= 8 where the ifconfig output diverged from other BSD variants (Netmask is now part of the address) ''' # NetBSD versions prior to 8.0 can still use linux_interfaces() if LooseVersion(os.uname()[2]) < LooseVersion('8.0'): ...
[ "def", "netbsd_interfaces", "(", ")", ":", "# NetBSD versions prior to 8.0 can still use linux_interfaces()", "if", "LooseVersion", "(", "os", ".", "uname", "(", ")", "[", "2", "]", ")", "<", "LooseVersion", "(", "'8.0'", ")", ":", "return", "linux_interfaces", "(...
Obtain interface information for NetBSD >= 8 where the ifconfig output diverged from other BSD variants (Netmask is now part of the address)
[ "Obtain", "interface", "information", "for", "NetBSD", ">", "=", "8", "where", "the", "ifconfig", "output", "diverged", "from", "other", "BSD", "variants", "(", "Netmask", "is", "now", "part", "of", "the", "address", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L937-L953
train
saltstack/salt
salt/utils/network.py
_interfaces_ipconfig
def _interfaces_ipconfig(out): ''' Returns a dictionary of interfaces with various information about each (up/down state, ip address, netmask, and hwaddr) NOTE: This is not used by any function and may be able to be removed in the future. ''' ifaces = dict() iface = None adapter_ifa...
python
def _interfaces_ipconfig(out): ''' Returns a dictionary of interfaces with various information about each (up/down state, ip address, netmask, and hwaddr) NOTE: This is not used by any function and may be able to be removed in the future. ''' ifaces = dict() iface = None adapter_ifa...
[ "def", "_interfaces_ipconfig", "(", "out", ")", ":", "ifaces", "=", "dict", "(", ")", "iface", "=", "None", "adapter_iface_regex", "=", "re", ".", "compile", "(", "r'adapter (\\S.+):$'", ")", "for", "line", "in", "out", ".", "splitlines", "(", ")", ":", ...
Returns a dictionary of interfaces with various information about each (up/down state, ip address, netmask, and hwaddr) NOTE: This is not used by any function and may be able to be removed in the future.
[ "Returns", "a", "dictionary", "of", "interfaces", "with", "various", "information", "about", "each", "(", "up", "/", "down", "state", "ip", "address", "netmask", "and", "hwaddr", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L956-L1002
train
saltstack/salt
salt/utils/network.py
win_interfaces
def win_interfaces(): ''' Obtain interface information for Windows systems ''' with salt.utils.winapi.Com(): c = wmi.WMI() ifaces = {} for iface in c.Win32_NetworkAdapterConfiguration(IPEnabled=1): ifaces[iface.Description] = dict() if iface.MACAddress: ...
python
def win_interfaces(): ''' Obtain interface information for Windows systems ''' with salt.utils.winapi.Com(): c = wmi.WMI() ifaces = {} for iface in c.Win32_NetworkAdapterConfiguration(IPEnabled=1): ifaces[iface.Description] = dict() if iface.MACAddress: ...
[ "def", "win_interfaces", "(", ")", ":", "with", "salt", ".", "utils", ".", "winapi", ".", "Com", "(", ")", ":", "c", "=", "wmi", ".", "WMI", "(", ")", "ifaces", "=", "{", "}", "for", "iface", "in", "c", ".", "Win32_NetworkAdapterConfiguration", "(", ...
Obtain interface information for Windows systems
[ "Obtain", "interface", "information", "for", "Windows", "systems" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1005-L1048
train
saltstack/salt
salt/utils/network.py
interfaces
def interfaces(): ''' Return a dictionary of information about all the interfaces on the minion ''' if salt.utils.platform.is_windows(): return win_interfaces() elif salt.utils.platform.is_netbsd(): return netbsd_interfaces() else: return linux_interfaces()
python
def interfaces(): ''' Return a dictionary of information about all the interfaces on the minion ''' if salt.utils.platform.is_windows(): return win_interfaces() elif salt.utils.platform.is_netbsd(): return netbsd_interfaces() else: return linux_interfaces()
[ "def", "interfaces", "(", ")", ":", "if", "salt", ".", "utils", ".", "platform", ".", "is_windows", "(", ")", ":", "return", "win_interfaces", "(", ")", "elif", "salt", ".", "utils", ".", "platform", ".", "is_netbsd", "(", ")", ":", "return", "netbsd_i...
Return a dictionary of information about all the interfaces on the minion
[ "Return", "a", "dictionary", "of", "information", "about", "all", "the", "interfaces", "on", "the", "minion" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1051-L1060
train
saltstack/salt
salt/utils/network.py
get_net_start
def get_net_start(ipaddr, netmask): ''' Return the address of the network ''' net = ipaddress.ip_network('{0}/{1}'.format(ipaddr, netmask), strict=False) return six.text_type(net.network_address)
python
def get_net_start(ipaddr, netmask): ''' Return the address of the network ''' net = ipaddress.ip_network('{0}/{1}'.format(ipaddr, netmask), strict=False) return six.text_type(net.network_address)
[ "def", "get_net_start", "(", "ipaddr", ",", "netmask", ")", ":", "net", "=", "ipaddress", ".", "ip_network", "(", "'{0}/{1}'", ".", "format", "(", "ipaddr", ",", "netmask", ")", ",", "strict", "=", "False", ")", "return", "six", ".", "text_type", "(", ...
Return the address of the network
[ "Return", "the", "address", "of", "the", "network" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1063-L1068
train