partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
string_format
Return the formatted outputter string, removing the ANSI escape sequences.
salt/output/__init__.py
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): ''' Return the formatted outputter string, removing the ANSI escape sequences. ''' raw_output = try_printout(data, out, opts, **kwargs) ansi_escape = re.compile(r'\x1b[^m]*m') return ansi_escape.sub('', raw_output)
[ "Return", "the", "formatted", "outputter", "string", "removing", "the", "ANSI", "escape", "sequences", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L208-L214
[ "def", "string_format", "(", "data", ",", "out", ",", "opts", "=", "None", ",", "*", "*", "kwargs", ")", ":", "raw_output", "=", "try_printout", "(", "data", ",", "out", ",", "opts", ",", "*", "*", "kwargs", ")", "ansi_escape", "=", "re", ".", "com...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
html_format
Return the formatted string as HTML.
salt/output/__init__.py
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): ''' Return the formatted string as HTML. ''' ansi_escaped_string = string_format(data, out, opts, **kwargs) return ansi_escaped_string.replace(' ', '&nbsp;').replace('\n', '<br />')
[ "Return", "the", "formatted", "string", "as", "HTML", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L217-L222
[ "def", "html_format", "(", "data", ",", "out", ",", "opts", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ansi_escaped_string", "=", "string_format", "(", "data", ",", "out", ",", "opts", ",", "*", "*", "kwargs", ")", "return", "ansi_escaped_string", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
strip_esc_sequence
Replace ESC (ASCII 27/Oct 33) to prevent unsafe strings from writing their own terminal manipulation commands
salt/output/__init__.py
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): ''' Replace ESC (ASCII 27/Oct 33) to prevent unsafe strings from writing their own terminal manipulation commands ''' if isinstance(txt, six.string_types): try: return txt.replace('\033', '?') except UnicodeDecodeError: return txt....
[ "Replace", "ESC", "(", "ASCII", "27", "/", "Oct", "33", ")", "to", "prevent", "unsafe", "strings", "from", "writing", "their", "own", "terminal", "manipulation", "commands" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/output/__init__.py#L225-L236
[ "def", "strip_esc_sequence", "(", "txt", ")", ":", "if", "isinstance", "(", "txt", ",", "six", ".", "string_types", ")", ":", "try", ":", "return", "txt", ".", "replace", "(", "'\\033'", ",", "'?'", ")", "except", "UnicodeDecodeError", ":", "return", "tx...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_tree
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']
salt/utils/dns.py
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): ''' Split out a domain in its parents Leverages tldextract to take the TLDs from publicsuffix.org or makes a valiant approximation of that :param domain: dc2.ams2.example.com :param tld: Include TLD in list :return: [ 'dc2.ams2.example.com', 'ams2.example.com'...
[ "Split", "out", "a", "domain", "in", "its", "parents" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L134-L166
[ "def", "_tree", "(", "domain", ",", "tld", "=", "False", ")", ":", "domain", "=", "domain", ".", "rstrip", "(", "'.'", ")", "assert", "'.'", "in", "domain", ",", "'Provide a decent domain'", "if", "not", "tld", ":", "if", "HAS_TLDEXTRACT", ":", "tld", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_data2rec
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'}
salt/utils/dns.py
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): ''' schema = OrderedDict({ 'prio': int, 'weight': int, 'port': to_port, 'name': str, }) rec_data = '10 20 25 myawesome.nl' res = {'prio': 10, 'weight': 20, 'port': 25 'name': 'myawesome.nl'} ''' try: rec_fields = rec_d...
[ "schema", "=", "OrderedDict", "(", "{", "prio", ":", "int", "weight", ":", "int", "port", ":", "to_port", "name", ":", "str", "}", ")", "rec_data", "=", "10", "20", "25", "myawesome", ".", "nl" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L195-L228
[ "def", "_data2rec", "(", "schema", ",", "rec_data", ")", ":", "try", ":", "rec_fields", "=", "rec_data", ".", "split", "(", "' '", ")", "# spaces in digest fields are allowed", "assert", "len", "(", "rec_fields", ")", ">=", "len", "(", "schema", ")", "if", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_lookup_dig
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
salt/utils/dns.py
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): ''' 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", ":...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L271-L319
[ "def", "_lookup_dig", "(", "name", ",", "rdtype", ",", "timeout", "=", "None", ",", "servers", "=", "None", ",", "secure", "=", "None", ")", ":", "cmd", "=", "'dig {0} -t {1} '", ".", "format", "(", "DIG_OPTIONS", ",", "rdtype", ")", "if", "servers", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_lookup_drill
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
salt/utils/dns.py
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): ''' Use drill to lookup addresses :param name: Name of record to search :param rdtype: DNS record type :param timeout: command return timeout :param servers: [] of servers to use :return: [] of records or False if erro...
[ "Use", "drill", "to", "lookup", "addresses", ":", "param", "name", ":", "Name", "of", "record", "to", "search", ":", "param", "rdtype", ":", "DNS", "record", "type", ":", "param", "timeout", ":", "command", "return", "timeout", ":", "param", "servers", "...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L322-L375
[ "def", "_lookup_drill", "(", "name", ",", "rdtype", ",", "timeout", "=", "None", ",", "servers", "=", "None", ",", "secure", "=", "None", ")", ":", "cmd", "=", "'drill '", "if", "secure", ":", "cmd", "+=", "'-D -o ad '", "cmd", "+=", "'{0} {1} '", ".",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_lookup_gai
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
salt/utils/dns.py
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): ''' Use Python's socket interface to lookup addresses :param name: Name of record to search :param rdtype: A or AAAA :param timeout: ignored :return: [] of addresses or False if error ''' try: sock_t = { 'A': socket.AF_I...
[ "Use", "Python", "s", "socket", "interface", "to", "lookup", "addresses", ":", "param", "name", ":", "Name", "of", "record", "to", "search", ":", "param", "rdtype", ":", "A", "or", "AAAA", ":", "param", "timeout", ":", "ignored", ":", "return", ":", "[...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L378-L401
[ "def", "_lookup_gai", "(", "name", ",", "rdtype", ",", "timeout", "=", "None", ")", ":", "try", ":", "sock_t", "=", "{", "'A'", ":", "socket", ".", "AF_INET", ",", "'AAAA'", ":", "socket", ".", "AF_INET6", "}", "[", "rdtype", "]", "except", "KeyError...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_lookup_host
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
salt/utils/dns.py
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): ''' Use host to lookup addresses :param name: Name of record to search :param server: Server to query :param rdtype: DNS record type :param timeout: server response wait :return: [] of records or False if error ''' cmd = 'hos...
[ "Use", "host", "to", "lookup", "addresses", ":", "param", "name", ":", "Name", "of", "record", "to", "search", ":", "param", "server", ":", "Server", "to", "query", ":", "param", "rdtype", ":", "DNS", "record", "type", ":", "param", "timeout", ":", "se...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L404-L443
[ "def", "_lookup_host", "(", "name", ",", "rdtype", ",", "timeout", "=", "None", ",", "server", "=", "None", ")", ":", "cmd", "=", "'host -t {0} '", ".", "format", "(", "rdtype", ")", "if", "timeout", ":", "cmd", "+=", "'-W {0} '", ".", "format", "(", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_lookup_dnspython
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
salt/utils/dns.py
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): ''' Use dnspython to lookup addresses :param name: Name of record to search :param rdtype: DNS record type :param timeout: query timeout :param server: [] of server(s) to try in order :return: [] of records or Fals...
[ "Use", "dnspython", "to", "lookup", "addresses", ":", "param", "name", ":", "Name", "of", "record", "to", "search", ":", "param", "rdtype", ":", "DNS", "record", "type", ":", "param", "timeout", ":", "query", "timeout", ":", "param", "server", ":", "[]",...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L446-L474
[ "def", "_lookup_dnspython", "(", "name", ",", "rdtype", ",", "timeout", "=", "None", ",", "servers", "=", "None", ",", "secure", "=", "None", ")", ":", "resolver", "=", "dns", ".", "resolver", ".", "Resolver", "(", ")", "if", "timeout", "is", "not", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_lookup_nslookup
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
salt/utils/dns.py
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): ''' 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", ...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L477-L543
[ "def", "_lookup_nslookup", "(", "name", ",", "rdtype", ",", "timeout", "=", "None", ",", "server", "=", "None", ")", ":", "cmd", "=", "'nslookup -query={0} {1}'", ".", "format", "(", "rdtype", ",", "name", ")", "if", "timeout", "is", "not", "None", ":", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
lookup
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...
salt/utils/dns.py
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 ): ''' Lookup DNS records and return their data :param name: name to lookup :param rdtype: DNS record type :param method: gai (getaddrinfo()), dnspython, dig, d...
[ "Lookup", "DNS", "records", "and", "return", "their", "data" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L546-L654
[ "def", "lookup", "(", "name", ",", "rdtype", ",", "method", "=", "None", ",", "servers", "=", "None", ",", "timeout", "=", "None", ",", "walk", "=", "False", ",", "walk_tld", "=", "False", ",", "secure", "=", "None", ")", ":", "# opts = __opts__.get('d...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
query
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)...
salt/utils/dns.py
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 ): ''' Query DNS for information. Where `lookup()` returns record data, `query()` tries to interpret the data and return it's results :param name: name to lookup ...
[ "Query", "DNS", "for", "information", ".", "Where", "lookup", "()", "returns", "record", "data", "query", "()", "tries", "to", "interpret", "the", "data", "and", "return", "it", "s", "results" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L657-L723
[ "def", "query", "(", "name", ",", "rdtype", ",", "method", "=", "None", ",", "servers", "=", "None", ",", "timeout", "=", "None", ",", "walk", "=", "False", ",", "walk_tld", "=", "False", ",", "secure", "=", "None", ")", ":", "rdtype", "=", "rdtype...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
host
Return a list of addresses for name ip6: Return IPv6 addresses ip4: Return IPv4 addresses the rest is passed on to lookup()
salt/utils/dns.py
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): ''' Return a list of addresses for name ip6: Return IPv6 addresses ip4: Return IPv4 addresses the rest is passed on to lookup() ''' res = {} if ip6: ip6 = lookup(name, 'AAAA', **kwargs) if ip6: re...
[ "Return", "a", "list", "of", "addresses", "for", "name" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L726-L747
[ "def", "host", "(", "name", ",", "ip4", "=", "True", ",", "ip6", "=", "True", ",", "*", "*", "kwargs", ")", ":", "res", "=", "{", "}", "if", "ip6", ":", "ip6", "=", "lookup", "(", "name", ",", "'AAAA'", ",", "*", "*", "kwargs", ")", "if", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
caa_rec
Validate and parse DNS record data for a CAA record :param rdata: DNS record data :return: dict w/fields
salt/utils/dns.py
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): ''' Validate and parse DNS record data for a CAA record :param rdata: DNS record data :return: dict w/fields ''' rschema = OrderedDict(( ('flags', lambda flag: ['critical'] if int(flag) > 0 else []), ('tag', RFC.CAA_TAGS), ('value', lambda val: val.st...
[ "Validate", "and", "parse", "DNS", "record", "data", "for", "a", "CAA", "record", ":", "param", "rdata", ":", "DNS", "record", "data", ":", "return", ":", "dict", "w", "/", "fields" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L774-L799
[ "def", "caa_rec", "(", "rdatas", ")", ":", "rschema", "=", "OrderedDict", "(", "(", "(", "'flags'", ",", "lambda", "flag", ":", "[", "'critical'", "]", "if", "int", "(", "flag", ")", ">", "0", "else", "[", "]", ")", ",", "(", "'tag'", ",", "RFC",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
ptr_name
Return PTR name of given IP :param rdata: IP address :return: PTR record name
salt/utils/dns.py
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): ''' Return PTR name of given IP :param rdata: IP address :return: PTR record name ''' try: return ipaddress.ip_address(rdata).reverse_pointer except ValueError: log.error( 'Unable to generate PTR record; %s is not a valid IP address', ...
[ "Return", "PTR", "name", "of", "given", "IP", ":", "param", "rdata", ":", "IP", "address", ":", "return", ":", "PTR", "record", "name" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L825-L838
[ "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'", ",", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
soa_rec
Validate and parse DNS record data for SOA record(s) :param rdata: DNS record data :return: dict w/fields
salt/utils/dns.py
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): ''' Validate and parse DNS record data for SOA record(s) :param rdata: DNS record data :return: dict w/fields ''' rschema = OrderedDict(( ('mname', str), ('rname', str), ('serial', int), ('refresh', int), ('retry', int), ('expir...
[ "Validate", "and", "parse", "DNS", "record", "data", "for", "SOA", "record", "(", "s", ")", ":", "param", "rdata", ":", "DNS", "record", "data", ":", "return", ":", "dict", "w", "/", "fields" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L841-L856
[ "def", "soa_rec", "(", "rdata", ")", ":", "rschema", "=", "OrderedDict", "(", "(", "(", "'mname'", ",", "str", ")", ",", "(", "'rname'", ",", "str", ")", ",", "(", "'serial'", ",", "int", ")", ",", "(", "'refresh'", ",", "int", ")", ",", "(", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
spf_rec
Validate and parse DNS record data for SPF record(s) :param rdata: DNS record data :return: dict w/fields
salt/utils/dns.py
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): ''' Validate and parse DNS record data for SPF record(s) :param rdata: DNS record data :return: dict w/fields ''' spf_fields = rdata.split(' ') if not spf_fields.pop(0).startswith('v=spf'): raise ValueError('Not an SPF record') res = OrderedDict() mods = ...
[ "Validate", "and", "parse", "DNS", "record", "data", "for", "SPF", "record", "(", "s", ")", ":", "param", "rdata", ":", "DNS", "record", "data", ":", "return", ":", "dict", "w", "/", "fields" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L859-L911
[ "def", "spf_rec", "(", "rdata", ")", ":", "spf_fields", "=", "rdata", ".", "split", "(", "' '", ")", "if", "not", "spf_fields", ".", "pop", "(", "0", ")", ".", "startswith", "(", "'v=spf'", ")", ":", "raise", "ValueError", "(", "'Not an SPF record'", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
srv_data
Generate SRV record data :param target: :param port: :param prio: :param weight: :return:
salt/utils/dns.py
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): ''' Generate SRV record data :param target: :param port: :param prio: :param weight: :return: ''' return _rec2data(prio, weight, port, target)
[ "Generate", "SRV", "record", "data", ":", "param", "target", ":", ":", "param", "port", ":", ":", "param", "prio", ":", ":", "param", "weight", ":", ":", "return", ":" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L914-L923
[ "def", "srv_data", "(", "target", ",", "port", ",", "prio", "=", "10", ",", "weight", "=", "10", ")", ":", "return", "_rec2data", "(", "prio", ",", "weight", ",", "port", ",", "target", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
srv_name
Generate SRV record name :param svc: ldap, 389 etc :param proto: tcp, udp, sctp etc. :param domain: name to append :return:
salt/utils/dns.py
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): ''' Generate SRV record name :param svc: ldap, 389 etc :param proto: tcp, udp, sctp etc. :param domain: name to append :return: ''' proto = RFC.validate(proto, RFC.SRV_PROTO) if isinstance(svc, int) or svc.isdigit(): svc = _to_port...
[ "Generate", "SRV", "record", "name", ":", "param", "svc", ":", "ldap", "389", "etc", ":", "param", "proto", ":", "tcp", "udp", "sctp", "etc", ".", ":", "param", "domain", ":", "name", "to", "append", ":", "return", ":" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L926-L940
[ "def", "srv_name", "(", "svc", ",", "proto", "=", "'tcp'", ",", "domain", "=", "None", ")", ":", "proto", "=", "RFC", ".", "validate", "(", "proto", ",", "RFC", ".", "SRV_PROTO", ")", "if", "isinstance", "(", "svc", ",", "int", ")", "or", "svc", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
srv_rec
Validate and parse DNS record data for SRV record(s) :param rdata: DNS record data :return: dict w/fields
salt/utils/dns.py
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): ''' Validate and parse DNS record data for SRV record(s) :param rdata: DNS record data :return: dict w/fields ''' rschema = OrderedDict(( ('prio', int), ('weight', int), ('port', _to_port), ('name', str), )) return _data2rec_group(rsch...
[ "Validate", "and", "parse", "DNS", "record", "data", "for", "SRV", "record", "(", "s", ")", ":", "param", "rdata", ":", "DNS", "record", "data", ":", "return", ":", "dict", "w", "/", "fields" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L943-L955
[ "def", "srv_rec", "(", "rdatas", ")", ":", "rschema", "=", "OrderedDict", "(", "(", "(", "'prio'", ",", "int", ")", ",", "(", "'weight'", ",", "int", ")", ",", "(", "'port'", ",", "_to_port", ")", ",", "(", "'name'", ",", "str", ")", ",", ")", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
sshfp_data
Generate an SSHFP record :param key_t: rsa/dsa/ecdsa/ed25519 :param hash_t: sha1/sha256 :param pub: the SSH public key
salt/utils/dns.py
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): ''' Generate an SSHFP record :param key_t: rsa/dsa/ecdsa/ed25519 :param hash_t: sha1/sha256 :param pub: the SSH public key ''' key_t = RFC.validate(key_t, RFC.SSHFP_ALGO, 'in') hash_t = RFC.validate(hash_t, RFC.SSHFP_HASH) hasher = hashlib.new(has...
[ "Generate", "an", "SSHFP", "record", ":", "param", "key_t", ":", "rsa", "/", "dsa", "/", "ecdsa", "/", "ed25519", ":", "param", "hash_t", ":", "sha1", "/", "sha256", ":", "param", "pub", ":", "the", "SSH", "public", "key" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L958-L974
[ "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...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
sshfp_rec
Validate and parse DNS record data for TLSA record(s) :param rdata: DNS record data :return: dict w/fields
salt/utils/dns.py
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): ''' Validate and parse DNS record data for TLSA record(s) :param rdata: DNS record data :return: dict w/fields ''' rschema = OrderedDict(( ('algorithm', RFC.SSHFP_ALGO), ('fp_hash', RFC.SSHFP_HASH), ('fingerprint', lambda val: val.lower()) # resolve...
[ "Validate", "and", "parse", "DNS", "record", "data", "for", "TLSA", "record", "(", "s", ")", ":", "param", "rdata", ":", "DNS", "record", "data", ":", "return", ":", "dict", "w", "/", "fields" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L977-L989
[ "def", "sshfp_rec", "(", "rdata", ")", ":", "rschema", "=", "OrderedDict", "(", "(", "(", "'algorithm'", ",", "RFC", ".", "SSHFP_ALGO", ")", ",", "(", "'fp_hash'", ",", "RFC", ".", "SSHFP_HASH", ")", ",", "(", "'fingerprint'", ",", "lambda", "val", ":"...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
tlsa_data
Generate a TLSA rec :param pub: Pub key in PEM format :param usage: :param selector: :param matching: :return: TLSA data portion
salt/utils/dns.py
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): ''' Generate a TLSA rec :param pub: Pub key in PEM format :param usage: :param selector: :param matching: :return: TLSA data portion ''' usage = RFC.validate(usage, RFC.TLSA_USAGE) selector = RFC.validate(selector, RFC.TLSA_SELECT) ...
[ "Generate", "a", "TLSA", "rec", ":", "param", "pub", ":", "Pub", "key", "in", "PEM", "format", ":", "param", "usage", ":", ":", "param", "selector", ":", ":", "param", "matching", ":", ":", "return", ":", "TLSA", "data", "portion" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L992-L1015
[ "def", "tlsa_data", "(", "pub", ",", "usage", ",", "selector", ",", "matching", ")", ":", "usage", "=", "RFC", ".", "validate", "(", "usage", ",", "RFC", ".", "TLSA_USAGE", ")", "selector", "=", "RFC", ".", "validate", "(", "selector", ",", "RFC", "....
e8541fd6e744ab0df786c0f76102e41631f45d46
train
tlsa_rec
Validate and parse DNS record data for TLSA record(s) :param rdata: DNS record data :return: dict w/fields
salt/utils/dns.py
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): ''' Validate and parse DNS record data for TLSA record(s) :param rdata: DNS record data :return: dict w/fields ''' rschema = OrderedDict(( ('usage', RFC.TLSA_USAGE), ('selector', RFC.TLSA_SELECT), ('matching', RFC.TLSA_MATCHING), ('pub', str) ...
[ "Validate", "and", "parse", "DNS", "record", "data", "for", "TLSA", "record", "(", "s", ")", ":", "param", "rdata", ":", "DNS", "record", "data", ":", "return", ":", "dict", "w", "/", "fields" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L1018-L1031
[ "def", "tlsa_rec", "(", "rdata", ")", ":", "rschema", "=", "OrderedDict", "(", "(", "(", "'usage'", ",", "RFC", ".", "TLSA_USAGE", ")", ",", "(", "'selector'", ",", "RFC", ".", "TLSA_SELECT", ")", ",", "(", "'matching'", ",", "RFC", ".", "TLSA_MATCHING...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
service
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...
salt/utils/dns.py
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 ): ''' Find an SRV service in a domain or it's parents :param svc: service to find (ldap, 389, etc) :param proto: protocol the service talks (tcp, udp, etc) :param domain: domain to start search in :param wal...
[ "Find", "an", "SRV", "service", "in", "a", "domain", "or", "it", "s", "parents", ":", "param", "svc", ":", "service", "to", "find", "(", "ldap", "389", "etc", ")", ":", "param", "proto", ":", "protocol", "the", "service", "talks", "(", "tcp", "udp", ...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L1034-L1061
[ "def", "service", "(", "svc", ",", "proto", "=", "'tcp'", ",", "domain", "=", "None", ",", "walk", "=", "False", ",", "secure", "=", "None", ")", ":", "qres", "=", "query", "(", "srv_name", "(", "svc", ",", "proto", ",", "domain", ")", ",", "'SRV...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
services
Parse through system-known services :return: { 'svc': [ { 'port': port 'proto': proto, 'desc': comment }, ], }
salt/utils/dns.py
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'): ''' Parse through system-known services :return: { 'svc': [ { 'port': port 'proto': proto, 'desc': comment }, ], } ''' res = {} with salt.utils.files.fopen(services_file, 'r') as svc_d...
[ "Parse", "through", "system", "-", "known", "services", ":", "return", ":", "{", "svc", ":", "[", "{", "port", ":", "port", "proto", ":", "proto", "desc", ":", "comment", "}", "]", "}" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L1064-L1125
[ "def", "services", "(", "services_file", "=", "'/etc/services'", ")", ":", "res", "=", "{", "}", "with", "salt", ".", "utils", ".", "files", ".", "fopen", "(", "services_file", ",", "'r'", ")", "as", "svc_defs", ":", "for", "svc_def", "in", "svc_defs", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
parse_resolv
Parse a resolver configuration file (traditionally /etc/resolv.conf)
salt/utils/dns.py
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'): ''' Parse a resolver configuration file (traditionally /etc/resolv.conf) ''' nameservers = [] ip4_nameservers = [] ip6_nameservers = [] search = [] sortlist = [] domain = '' options = [] try: with salt.utils.files.fopen(src)...
[ "Parse", "a", "resolver", "configuration", "file", "(", "traditionally", "/", "etc", "/", "resolv", ".", "conf", ")" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/dns.py#L1128-L1224
[ "def", "parse_resolv", "(", "src", "=", "'/etc/resolv.conf'", ")", ":", "nameservers", "=", "[", "]", "ip4_nameservers", "=", "[", "]", "ip6_nameservers", "=", "[", "]", "search", "=", "[", "]", "sortlist", "=", "[", "]", "domain", "=", "''", "options", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_returner_options
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...
salt/returners/__init__.py
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): ''' Get the returner options from salt. :param str virtualname: The returner virtualname (as returned by __virtual__() :param ret: result of the...
[ "Get", "the", "returner", "options", "from", "salt", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/__init__.py#L16-L107
[ "def", "get_returner_options", "(", "virtualname", "=", "None", ",", "ret", "=", "None", ",", "attrs", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ret_config", "=", "_fetch_ret_config", "(", "ret", ")", "attrs", "=", "attrs", "or", "{", "}", "prof...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_fetch_option
Fetch a given option value from the config. @see :func:`get_returner_options`
salt/returners/__init__.py
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): """ 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...
[ "Fetch", "a", "given", "option", "value", "from", "the", "config", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/__init__.py#L123-L166
[ "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",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_options_browser
Iterator generating all duples ```option name -> value``` @see :func:`get_returner_options`
salt/returners/__init__.py
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): """ 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...
[ "Iterator", "generating", "all", "duples", "option", "name", "-", ">", "value" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/__init__.py#L169-L193
[ "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...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_fetch_profile_opts
Fetches profile specific options if applicable @see :func:`get_returner_options` :return: a options dict
salt/returners/__init__.py
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 ): """ Fetches profile specific options if applicable @see :func:`get_returner_options` :return: a options dict """ if (not profile_attr) or (profile_attr not...
[ "Fetches", "profile", "specific", "options", "if", "applicable" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/returners/__init__.py#L196-L235
[ "def", "_fetch_profile_opts", "(", "cfg", ",", "virtualname", ",", "__salt__", ",", "_options", ",", "profile_attr", ",", "profile_attrs", ")", ":", "if", "(", "not", "profile_attr", ")", "or", "(", "profile_attr", "not", "in", "_options", ")", ":", "return"...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
enabled
Ensure the RabbitMQ plugin is enabled. name The name of the plugin runas The user to run the rabbitmq-plugin command as
salt/states/rabbitmq_plugin.py
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): ''' Ensure the RabbitMQ plugin is enabled. name The name of the plugin runas The user to run the rabbitmq-plugin command as ''' ret = {'name': name, 'result': True, 'comment': '', 'changes': {}} try: plugin_enabled = __salt__['rabbitm...
[ "Ensure", "the", "RabbitMQ", "plugin", "is", "enabled", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/rabbitmq_plugin.py#L35-L73
[ "def", "enabled", "(", "name", ",", "runas", "=", "None", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'result'", ":", "True", ",", "'comment'", ":", "''", ",", "'changes'", ":", "{", "}", "}", "try", ":", "plugin_enabled", "=", "__salt_...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_revs_equal
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.
salt/states/git.py
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): ''' Shorthand helper function for comparing SHA1s. If rev_type == 'sha1' then the comparison will be done using str.startwith() to allow short SHA1s to compare successfully. NOTE: This means that rev2 must be the short rev. ''' if (rev1 is None and rev...
[ "Shorthand", "helper", "function", "for", "comparing", "SHA1s", ".", "If", "rev_type", "==", "sha1", "then", "the", "comparison", "will", "be", "done", "using", "str", ".", "startwith", "()", "to", "allow", "short", "SHA1s", "to", "compare", "successfully", ...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L47-L63
[ "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", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_get_branch_opts
DRY helper to build list of opts for git.branch, for the purposes of setting upstream tracking branch
salt/states/git.py
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): ''' DRY helper to build list of opts for git.branch, for the purposes of setting upstream tracking branch ''' if branch is not None and branch not in all_local_branches: # We ...
[ "DRY", "helper", "to", "build", "list", "of", "opts", "for", "git", ".", "branch", "for", "the", "purposes", "of", "setting", "upstream", "tracking", "branch" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L87-L110
[ "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...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_get_local_rev_and_branch
Return the local revision for before/after comparisons
salt/states/git.py
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): ''' Return the local revision for before/after comparisons ''' log.info('Checking local revision for %s', target) try: local_rev = __salt__['git.revision']( target, user=user, pas...
[ "Return", "the", "local", "revision", "for", "before", "/", "after", "comparisons" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L113-L141
[ "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...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
present
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...
salt/states/git.py
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_encoding=None): ''' Ensure that a repository exists in the given directory .. warning...
[ "Ensure", "that", "a", "repository", "exists", "in", "the", "given", "directory" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L2063-L2235
[ "def", "present", "(", "name", ",", "force", "=", "False", ",", "bare", "=", "True", ",", "template", "=", "None", ",", "separate_git_dir", "=", "None", ",", "shared", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "output_...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
detached
.. 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...
salt/states/git.py
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=True, hard_reset=False, submodules=False, identity=None, ...
[ "..", "versionadded", "::", "2016", ".", "3", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L2238-L2761
[ "def", "detached", "(", "name", ",", "rev", ",", "target", "=", "None", ",", "remote", "=", "'origin'", ",", "user", "=", "None", ",", "password", "=", "None", ",", "force_clone", "=", "False", ",", "force_checkout", "=", "False", ",", "fetch_remote", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
cloned
.. 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...
salt/states/git.py
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_encoding=None): ''' .. versionadded:: 2018.3.3,2019.2.0 Ensure that a repository has been clon...
[ "..", "versionadded", "::", "2018", ".", "3", ".", "3", "2019", ".", "2", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L2764-L2957
[ "def", "cloned", "(", "name", ",", "target", "=", "None", ",", "branch", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "identity", "=", "None", ",", "https_user", "=", "None", ",", "https_pass", "=", "None", ",", "output_e...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
config_unset
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...
salt/states/git.py
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): r''' .. versionadded:: 2015.8.0 Ensure that the named config key is not present name ...
[ "r", "..", "versionadded", "::", "2015", ".", "8", ".", "0" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L2960-L3217
[ "def", "config_unset", "(", "name", ",", "value_regex", "=", "None", ",", "repo", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "output_encoding", "=", "None", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
config_set
.. 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...
salt/states/git.py
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): ''' .. versionadded:: 2014.7.0 .. versionchanged:: 2015.8.0 Renamed from ``gi...
[ "..", "versionadded", "::", "2014", ".", "7", ".", "0", "..", "versionchanged", "::", "2015", ".", "8", ".", "0", "Renamed", "from", "git", ".", "config", "to", "git", ".", "config_set", ".", "For", "earlier", "versions", "use", "git", ".", "config", ...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L3220-L3438
[ "def", "config_set", "(", "name", ",", "value", "=", "None", ",", "multivar", "=", "None", ",", "repo", "=", "None", ",", "user", "=", "None", ",", "password", "=", "None", ",", "output_encoding", "=", "None", ",", "*", "*", "kwargs", ")", ":", "re...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
mod_run_check
Execute the onlyif and unless logic. Return a result dict if: * onlyif failed (onlyif != 0) * unless succeeded (unless == 0) Otherwise, returns ``True``
salt/states/git.py
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): ''' Execute the onlyif and unless logic. Return a result dict if: * onlyif failed (onlyif != 0) * unless succeeded (unless == 0) Otherwise, returns ``True`` ''' cmd_kwargs = copy.deepcopy(cmd_kwargs) cmd_kwargs.update({ 'use_vt': F...
[ "Execute", "the", "onlyif", "and", "unless", "logic", ".", "Return", "a", "result", "dict", "if", ":" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/git.py#L3441-L3512
[ "def", "mod_run_check", "(", "cmd_kwargs", ",", "onlyif", ",", "unless", ")", ":", "cmd_kwargs", "=", "copy", ".", "deepcopy", "(", "cmd_kwargs", ")", "cmd_kwargs", ".", "update", "(", "{", "'use_vt'", ":", "False", ",", "'bg'", ":", "False", ",", "'igno...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
push_note
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...
salt/modules/pushbullet.py
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): ''' Pushing a text note. :param device: Pushbullet target device :param title: Note title :param body: Note body :return: Boolean if message was sent successfully. CLI Example: .. code-block:: bash salt "...
[ "Pushing", "a", "text", "note", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/pushbullet.py#L65-L84
[ "def", "push_note", "(", "device", "=", "None", ",", "title", "=", "None", ",", "body", "=", "None", ")", ":", "spb", "=", "_SaltPushbullet", "(", "device", ")", "res", "=", "spb", ".", "push_note", "(", "title", ",", "body", ")", "return", "res" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
verify_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...
salt/modules/travisci.py
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): ''' Verify the webhook signature from travisci signature The signature header from the webhook header body The full payload body from the webhook post .. note:: The body needs to be the urlencoded version of the body. CLI Example: .. ...
[ "Verify", "the", "webhook", "signature", "from", "travisci" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/travisci.py#L42-L77
[ "def", "verify_webhook", "(", "signature", ",", "body", ")", ":", "# get public key setup", "public_key", "=", "__utils__", "[", "'http.query'", "]", "(", "'https://api.travis-ci.org/config'", ")", "[", "'config'", "]", "[", "'notifications'", "]", "[", "'webhook'",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
managed
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.
salt/states/network.py
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): ''' Ensure that the named interface is configured properly. name The name of the interface to manage type Type of interface and configuration. enabled Designates the state of this interface. kwargs The IP parame...
[ "Ensure", "that", "the", "named", "interface", "is", "configured", "properly", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/network.py#L359-L551
[ "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...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
routes
Manage network interface static routes. name Interface name to apply the route to. kwargs Named routes
salt/states/network.py
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): ''' Manage network interface static routes. name Interface name to apply the route to. kwargs Named routes ''' ret = { 'name': name, 'changes': {}, 'result': True, 'comment': 'Interface {0} routes are up to date.'.form...
[ "Manage", "network", "interface", "static", "routes", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/network.py#L554-L614
[ "def", "routes", "(", "name", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "True", ",", "'comment'", ":", "'Interface {0} routes are up to date.'", ".", "format", "(", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
system
Ensure that global network settings are configured properly. name Custom name to represent this configuration change. kwargs The global parameters for the system.
salt/states/network.py
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): ''' Ensure that global network settings are configured properly. name Custom name to represent this configuration change. kwargs The global parameters for the system. ''' ret = { 'name': name, 'changes': {}, 'result': True, ...
[ "Ensure", "that", "global", "network", "settings", "are", "configured", "properly", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/network.py#L617-L678
[ "def", "system", "(", "name", ",", "*", "*", "kwargs", ")", ":", "ret", "=", "{", "'name'", ":", "name", ",", "'changes'", ":", "{", "}", ",", "'result'", ":", "True", ",", "'comment'", ":", "'Global network settings are up to date.'", ",", "}", "apply_n...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
present
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...
salt/states/zabbix_mediatype.py
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): ''' Creates new mediatype. NOTE: This function accepts all standard mediatype properties: keyword argument names differ depending on your zabbix version, see: https://www.zabbix.com/documentation/3.0/manual/api/reference/host/object#host_inventory :param ...
[ "Creates", "new", "mediatype", ".", "NOTE", ":", "This", "function", "accepts", "all", "standard", "mediatype", "properties", ":", "keyword", "argument", "names", "differ", "depending", "on", "your", "zabbix", "version", "see", ":", "https", ":", "//", "www", ...
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zabbix_mediatype.py#L23-L319
[ "def", "present", "(", "name", ",", "mediatype", ",", "*", "*", "kwargs", ")", ":", "connection_args", "=", "{", "}", "if", "'_connection_user'", "in", "kwargs", ":", "connection_args", "[", "'_connection_user'", "]", "=", "kwargs", "[", "'_connection_user'", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
absent
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...
salt/states/zabbix_mediatype.py
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): ''' Ensures that the mediatype does not exist, eventually deletes the mediatype. :param name: name of the mediatype :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring) :param _connection_password: Optional - zabbix ...
[ "Ensures", "that", "the", "mediatype", "does", "not", "exist", "eventually", "deletes", "the", "mediatype", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/zabbix_mediatype.py#L322-L386
[ "def", "absent", "(", "name", ",", "*", "*", "kwargs", ")", ":", "connection_args", "=", "{", "}", "if", "'_connection_user'", "in", "kwargs", ":", "connection_args", "[", "'_connection_user'", "]", "=", "kwargs", "[", "'_connection_user'", "]", "if", "'_con...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
sanitize_host
Sanitize host string. https://tools.ietf.org/html/rfc1123#section-2.1
salt/utils/network.py
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): ''' Sanitize host string. https://tools.ietf.org/html/rfc1123#section-2.1 ''' RFC952_characters = ascii_letters + digits + ".-" return "".join([c for c in host[0:255] if c in RFC952_characters])
[ "Sanitize", "host", "string", ".", "https", ":", "//", "tools", ".", "ietf", ".", "org", "/", "html", "/", "rfc1123#section", "-", "2", ".", "1" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L58-L64
[ "def", "sanitize_host", "(", "host", ")", ":", "RFC952_characters", "=", "ascii_letters", "+", "digits", "+", "\".-\"", "return", "\"\"", ".", "join", "(", "[", "c", "for", "c", "in", "host", "[", "0", ":", "255", "]", "if", "c", "in", "RFC952_characte...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
isportopen
Return status of a port
salt/utils/network.py
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): ''' Return status of a port ''' if not 1 <= int(port) <= 65535: return False sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) out = sock.connect_ex((sanitize_host(host), int(port))) return out
[ "Return", "status", "of", "a", "port" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L67-L78
[ "def", "isportopen", "(", "host", ",", "port", ")", ":", "if", "not", "1", "<=", "int", "(", "port", ")", "<=", "65535", ":", "return", "False", "sock", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
host_to_ips
Returns a list of IP addresses of a given hostname or None if not found.
salt/utils/network.py
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): ''' Returns a list of IP addresses of a given hostname or None if not found. ''' ips = [] try: for family, socktype, proto, canonname, sockaddr in socket.getaddrinfo( host, 0, socket.AF_UNSPEC, socket.SOCK_STREAM): if family == socket.AF_INE...
[ "Returns", "a", "list", "of", "IP", "addresses", "of", "a", "given", "hostname", "or", "None", "if", "not", "found", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L81-L98
[ "def", "host_to_ips", "(", "host", ")", ":", "ips", "=", "[", "]", "try", ":", "for", "family", ",", "socktype", ",", "proto", ",", "canonname", ",", "sockaddr", "in", "socket", ".", "getaddrinfo", "(", "host", ",", "0", ",", "socket", ".", "AF_UNSPE...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_generate_minion_id
Get list of possible host names and convention names. :return:
salt/utils/network.py
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(): ''' Get list of possible host names and convention names. :return: ''' # There are three types of hostnames: # 1. Network names. How host is accessed from the network. # 2. Host aliases. They might be not available in all the network or only locally (/etc/hosts) ...
[ "Get", "list", "of", "possible", "host", "names", "and", "convention", "names", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L101-L170
[ "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...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
generate_minion_id
Return only first element of the hostname from all possible list. :return:
salt/utils/network.py
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(): ''' Return only first element of the hostname from all possible list. :return: ''' try: ret = salt.utils.stringutils.to_unicode(_generate_minion_id().first()) except TypeError: ret = None return ret or 'localhost'
[ "Return", "only", "first", "element", "of", "the", "hostname", "from", "all", "possible", "list", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L173-L183
[ "def", "generate_minion_id", "(", ")", ":", "try", ":", "ret", "=", "salt", ".", "utils", ".", "stringutils", ".", "to_unicode", "(", "_generate_minion_id", "(", ")", ".", "first", "(", ")", ")", "except", "TypeError", ":", "ret", "=", "None", "return", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_socket
Return a socket object for the addr IP-version agnostic
salt/utils/network.py
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): ''' Return a socket object for the addr IP-version agnostic ''' version = ipaddress.ip_address(addr).version if version == 4: family = socket.AF_INET elif version == 6: family = socket.AF_INET6 return socket.socket(...
[ "Return", "a", "socket", "object", "for", "the", "addr", "IP", "-", "version", "agnostic" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L186-L197
[ "def", "get_socket", "(", "addr", ",", "type", "=", "socket", ".", "SOCK_STREAM", ",", "proto", "=", "0", ")", ":", "version", "=", "ipaddress", ".", "ip_address", "(", "addr", ")", ".", "version", "if", "version", "==", "4", ":", "family", "=", "soc...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_fqhostname
Returns the fully qualified hostname
salt/utils/network.py
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(): ''' Returns the fully qualified hostname ''' # try getaddrinfo() fqdn = None try: addrinfo = socket.getaddrinfo( socket.gethostname(), 0, socket.AF_UNSPEC, socket.SOCK_STREAM, socket.SOL_TCP, socket.AI_CANONNAME ) for info in ...
[ "Returns", "the", "fully", "qualified", "hostname" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L200-L224
[ "def", "get_fqhostname", "(", ")", ":", "# try getaddrinfo()", "fqdn", "=", "None", "try", ":", "addrinfo", "=", "socket", ".", "getaddrinfo", "(", "socket", ".", "gethostname", "(", ")", ",", "0", ",", "socket", ".", "AF_UNSPEC", ",", "socket", ".", "SO...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
ip_to_host
Returns the hostname of a given IP
salt/utils/network.py
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): ''' Returns the hostname of a given IP ''' try: hostname, aliaslist, ipaddrlist = socket.gethostbyaddr(ip) except Exception as exc: log.debug('salt.utils.network.ip_to_host(%r) failed: %s', ip, exc) hostname = None return hostname
[ "Returns", "the", "hostname", "of", "a", "given", "IP" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L227-L236
[ "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)...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
is_reachable_host
Returns a bool telling if the entity name is a reachable host (IPv4/IPv6/FQDN/etc). :param hostname: :return:
salt/utils/network.py
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): ''' Returns a bool telling if the entity name is a reachable host (IPv4/IPv6/FQDN/etc). :param hostname: :return: ''' try: assert type(socket.getaddrinfo(entity_name, 0, 0, 0, 0)) == list ret = True except socket.gaierror: ret = Fal...
[ "Returns", "a", "bool", "telling", "if", "the", "entity", "name", "is", "a", "reachable", "host", "(", "IPv4", "/", "IPv6", "/", "FQDN", "/", "etc", ")", ".", ":", "param", "hostname", ":", ":", "return", ":" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L241-L253
[ "def", "is_reachable_host", "(", "entity_name", ")", ":", "try", ":", "assert", "type", "(", "socket", ".", "getaddrinfo", "(", "entity_name", ",", "0", ",", "0", ",", "0", ",", "0", ")", ")", "==", "list", "ret", "=", "True", "except", "socket", "."...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
is_ip_filter
Returns a bool telling if the passed IP is a valid IPv4 or IPv6 address.
salt/utils/network.py
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): ''' Returns a bool telling if the passed IP is a valid IPv4 or IPv6 address. ''' return is_ipv4_filter(ip, options=options) or is_ipv6_filter(ip, options=options)
[ "Returns", "a", "bool", "telling", "if", "the", "passed", "IP", "is", "a", "valid", "IPv4", "or", "IPv6", "address", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L311-L315
[ "def", "is_ip_filter", "(", "ip", ",", "options", "=", "None", ")", ":", "return", "is_ipv4_filter", "(", "ip", ",", "options", "=", "options", ")", "or", "is_ipv6_filter", "(", "ip", ",", "options", "=", "options", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
is_ipv4_filter
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.
salt/utils/network.py
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): ''' Returns a bool telling if the value passed to it was a valid IPv4 address. ip The IP address. net: False Consider IP addresses followed by netmask. options CSV of options regarding the nature of the IP address. E.g.: loopback, mult...
[ "Returns", "a", "bool", "telling", "if", "the", "value", "passed", "to", "it", "was", "a", "valid", "IPv4", "address", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L414-L428
[ "def", "is_ipv4_filter", "(", "ip", ",", "options", "=", "None", ")", ":", "_is_ipv4", "=", "_is_ipv", "(", "ip", ",", "4", ",", "options", "=", "options", ")", "return", "isinstance", "(", "_is_ipv4", ",", "six", ".", "string_types", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
is_ipv6_filter
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.
salt/utils/network.py
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): ''' Returns a bool telling if the value passed to it was a valid IPv6 address. ip The IP address. net: False Consider IP addresses followed by netmask. options CSV of options regarding the nature of the IP address. E.g.: loopback, mult...
[ "Returns", "a", "bool", "telling", "if", "the", "value", "passed", "to", "it", "was", "a", "valid", "IPv6", "address", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L432-L446
[ "def", "is_ipv6_filter", "(", "ip", ",", "options", "=", "None", ")", ":", "_is_ipv6", "=", "_is_ipv", "(", "ip", ",", "6", ",", "options", "=", "options", ")", "return", "isinstance", "(", "_is_ipv6", ",", "six", ".", "string_types", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46
train
ipaddr
Filters and returns only valid IP objects.
salt/utils/network.py
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): ''' Filters and returns only valid IP objects. ''' ipv4_obj = ipv4(value, options=options) ipv6_obj = ipv6(value, options=options) if ipv4_obj is None or ipv6_obj is None: # an IP address can be either IPv4 either IPv6 # therefofe if the value pas...
[ "Filters", "and", "returns", "only", "valid", "IP", "objects", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L484-L496
[ "def", "ipaddr", "(", "value", ",", "options", "=", "None", ")", ":", "ipv4_obj", "=", "ipv4", "(", "value", ",", "options", "=", "options", ")", "ipv6_obj", "=", "ipv6", "(", "value", ",", "options", "=", "options", ")", "if", "ipv4_obj", "is", "Non...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
ip_host
Returns the interfaces IP address, e.g.: 192.168.0.1/28.
salt/utils/network.py
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): ''' Returns the interfaces IP address, e.g.: 192.168.0.1/28. ''' ipaddr_filter_out = _filter_ipaddr(value, options=options, version=version) if not ipaddr_filter_out: return if not isinstance(value, (list, tuple, types.GeneratorType)): ...
[ "Returns", "the", "interfaces", "IP", "address", "e", ".", "g", ".", ":", "192", ".", "168", ".", "0", ".", "1", "/", "28", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L516-L525
[ "def", "ip_host", "(", "value", ",", "options", "=", "None", ",", "version", "=", "None", ")", ":", "ipaddr_filter_out", "=", "_filter_ipaddr", "(", "value", ",", "options", "=", "options", ",", "version", "=", "version", ")", "if", "not", "ipaddr_filter_o...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
network_hosts
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.
salt/utils/network.py
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): ''' Return the list of hosts within a network. .. note:: When running this command with a large IPv6 network, the command will take a long time to gather all of the hosts. ''' ipaddr_filter_out = _filter_ipaddr(value, options=op...
[ "Return", "the", "list", "of", "hosts", "within", "a", "network", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L536-L553
[ "def", "network_hosts", "(", "value", ",", "options", "=", "None", ",", "version", "=", "None", ")", ":", "ipaddr_filter_out", "=", "_filter_ipaddr", "(", "value", ",", "options", "=", "options", ",", "version", "=", "version", ")", "if", "not", "ipaddr_fi...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
network_size
Get the size of a network.
salt/utils/network.py
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): ''' Get the size of a network. ''' ipaddr_filter_out = _filter_ipaddr(value, options=options, version=version) if not ipaddr_filter_out: return if not isinstance(value, (list, tuple, types.GeneratorType)): return _network_size(...
[ "Get", "the", "size", "of", "a", "network", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L561-L573
[ "def", "network_size", "(", "value", ",", "options", "=", "None", ",", "version", "=", "None", ")", ":", "ipaddr_filter_out", "=", "_filter_ipaddr", "(", "value", ",", "options", "=", "options", ",", "version", "=", "version", ")", "if", "not", "ipaddr_fil...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
natural_ipv4_netmask
Returns the "natural" mask of an IPv4 address
salt/utils/network.py
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'): ''' 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...
[ "Returns", "the", "natural", "mask", "of", "an", "IPv4", "address" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L576-L592
[ "def", "natural_ipv4_netmask", "(", "ip", ",", "fmt", "=", "'prefixlen'", ")", ":", "bits", "=", "_ipv4_to_bits", "(", "ip", ")", "if", "bits", ".", "startswith", "(", "'11'", ")", ":", "mask", "=", "'24'", "elif", "bits", ".", "startswith", "(", "'1'"...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
cidr_to_ipv4_netmask
Returns an IPv4 netmask
salt/utils/network.py
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): ''' 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...
[ "Returns", "an", "IPv4", "netmask" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L606-L627
[ "def", "cidr_to_ipv4_netmask", "(", "cidr_bits", ")", ":", "try", ":", "cidr_bits", "=", "int", "(", "cidr_bits", ")", "if", "not", "1", "<=", "cidr_bits", "<=", "32", ":", "return", "''", "except", "ValueError", ":", "return", "''", "netmask", "=", "''"...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_number_of_set_bits
Returns the number of bits that are set in a 32bit int
salt/utils/network.py
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): ''' 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 ...
[ "Returns", "the", "number", "of", "bits", "that", "are", "set", "in", "a", "32bit", "int" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L640-L650
[ "def", "_number_of_set_bits", "(", "x", ")", ":", "# Taken from http://stackoverflow.com/a/4912729. Many thanks!", "x", "-=", "(", "x", ">>", "1", ")", "&", "0x55555555", "x", "=", "(", "(", "x", ">>", "2", ")", "&", "0x33333333", ")", "+", "(", "x", "&", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_interfaces_ifconfig
Uses ifconfig to return a dictionary of interfaces with various information about each (up/down state, ip address, netmask, and hwaddr)
salt/utils/network.py
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): ''' 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:]...
[ "Uses", "ifconfig", "to", "return", "a", "dictionary", "of", "interfaces", "with", "various", "information", "about", "each", "(", "up", "/", "down", "state", "ip", "address", "netmask", "and", "hwaddr", ")" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L748-L841
[ "def", "_interfaces_ifconfig", "(", "out", ")", ":", "ret", "=", "dict", "(", ")", "piface", "=", "re", ".", "compile", "(", "r'^([^\\s:]+)'", ")", "pmac", "=", "re", ".", "compile", "(", "'.*?(?:HWaddr|ether|address:|lladdr) ([0-9a-fA-F:]+)'", ")", "if", "sal...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
linux_interfaces
Obtain interface information for *NIX/BSD variants
salt/utils/network.py
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(): ''' 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...
[ "Obtain", "interface", "information", "for", "*", "NIX", "/", "BSD", "variants" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L844-L874
[ "def", "linux_interfaces", "(", ")", ":", "ifaces", "=", "dict", "(", ")", "ip_path", "=", "salt", ".", "utils", ".", "path", ".", "which", "(", "'ip'", ")", "ifconfig_path", "=", "None", "if", "ip_path", "else", "salt", ".", "utils", ".", "path", "....
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_netbsd_interfaces_ifconfig
Uses ifconfig to return a dictionary of interfaces with various information about each (up/down state, ip address, netmask, and hwaddr)
salt/utils/network.py
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): ''' 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...
[ "Uses", "ifconfig", "to", "return", "a", "dictionary", "of", "interfaces", "with", "various", "information", "about", "each", "(", "up", "/", "down", "state", "ip", "address", "netmask", "and", "hwaddr", ")" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L877-L934
[ "def", "_netbsd_interfaces_ifconfig", "(", "out", ")", ":", "ret", "=", "dict", "(", ")", "piface", "=", "re", ".", "compile", "(", "r'^([^\\s:]+)'", ")", "pmac", "=", "re", ".", "compile", "(", "'.*?address: ([0-9a-f:]+)'", ")", "pip", "=", "re", ".", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
netbsd_interfaces
Obtain interface information for NetBSD >= 8 where the ifconfig output diverged from other BSD variants (Netmask is now part of the address)
salt/utils/network.py
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(): ''' 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'): ...
[ "Obtain", "interface", "information", "for", "NetBSD", ">", "=", "8", "where", "the", "ifconfig", "output", "diverged", "from", "other", "BSD", "variants", "(", "Netmask", "is", "now", "part", "of", "the", "address", ")" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L937-L953
[ "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", "(...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_interfaces_ipconfig
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.
salt/utils/network.py
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): ''' 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...
[ "Returns", "a", "dictionary", "of", "interfaces", "with", "various", "information", "about", "each", "(", "up", "/", "down", "state", "ip", "address", "netmask", "and", "hwaddr", ")" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L956-L1002
[ "def", "_interfaces_ipconfig", "(", "out", ")", ":", "ifaces", "=", "dict", "(", ")", "iface", "=", "None", "adapter_iface_regex", "=", "re", ".", "compile", "(", "r'adapter (\\S.+):$'", ")", "for", "line", "in", "out", ".", "splitlines", "(", ")", ":", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
win_interfaces
Obtain interface information for Windows systems
salt/utils/network.py
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(): ''' 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: ...
[ "Obtain", "interface", "information", "for", "Windows", "systems" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1005-L1048
[ "def", "win_interfaces", "(", ")", ":", "with", "salt", ".", "utils", ".", "winapi", ".", "Com", "(", ")", ":", "c", "=", "wmi", ".", "WMI", "(", ")", "ifaces", "=", "{", "}", "for", "iface", "in", "c", ".", "Win32_NetworkAdapterConfiguration", "(", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
interfaces
Return a dictionary of information about all the interfaces on the minion
salt/utils/network.py
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(): ''' 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()
[ "Return", "a", "dictionary", "of", "information", "about", "all", "the", "interfaces", "on", "the", "minion" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1051-L1060
[ "def", "interfaces", "(", ")", ":", "if", "salt", ".", "utils", ".", "platform", ".", "is_windows", "(", ")", ":", "return", "win_interfaces", "(", ")", "elif", "salt", ".", "utils", ".", "platform", ".", "is_netbsd", "(", ")", ":", "return", "netbsd_i...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_net_start
Return the address of the network
salt/utils/network.py
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): ''' Return the address of the network ''' net = ipaddress.ip_network('{0}/{1}'.format(ipaddr, netmask), strict=False) return six.text_type(net.network_address)
[ "Return", "the", "address", "of", "the", "network" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1063-L1068
[ "def", "get_net_start", "(", "ipaddr", ",", "netmask", ")", ":", "net", "=", "ipaddress", ".", "ip_network", "(", "'{0}/{1}'", ".", "format", "(", "ipaddr", ",", "netmask", ")", ",", "strict", "=", "False", ")", "return", "six", ".", "text_type", "(", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
get_net_size
Turns an IPv4 netmask into it's corresponding prefix length (255.255.255.0 -> 24 as in 192.168.1.10/24).
salt/utils/network.py
def get_net_size(mask): ''' Turns an IPv4 netmask into it's corresponding prefix length (255.255.255.0 -> 24 as in 192.168.1.10/24). ''' binary_str = '' for octet in mask.split('.'): binary_str += bin(int(octet))[2:].zfill(8) return len(binary_str.rstrip('0'))
def get_net_size(mask): ''' Turns an IPv4 netmask into it's corresponding prefix length (255.255.255.0 -> 24 as in 192.168.1.10/24). ''' binary_str = '' for octet in mask.split('.'): binary_str += bin(int(octet))[2:].zfill(8) return len(binary_str.rstrip('0'))
[ "Turns", "an", "IPv4", "netmask", "into", "it", "s", "corresponding", "prefix", "length", "(", "255", ".", "255", ".", "255", ".", "0", "-", ">", "24", "as", "in", "192", ".", "168", ".", "1", ".", "10", "/", "24", ")", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1071-L1079
[ "def", "get_net_size", "(", "mask", ")", ":", "binary_str", "=", "''", "for", "octet", "in", "mask", ".", "split", "(", "'.'", ")", ":", "binary_str", "+=", "bin", "(", "int", "(", "octet", ")", ")", "[", "2", ":", "]", ".", "zfill", "(", "8", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
calc_net
Takes IP (CIDR notation supported) and optionally netmask and returns the network in CIDR-notation. (The IP can be any IP inside the subnet)
salt/utils/network.py
def calc_net(ipaddr, netmask=None): ''' Takes IP (CIDR notation supported) and optionally netmask and returns the network in CIDR-notation. (The IP can be any IP inside the subnet) ''' if netmask is not None: ipaddr = '{0}/{1}'.format(ipaddr, netmask) return six.text_type(ipaddress....
def calc_net(ipaddr, netmask=None): ''' Takes IP (CIDR notation supported) and optionally netmask and returns the network in CIDR-notation. (The IP can be any IP inside the subnet) ''' if netmask is not None: ipaddr = '{0}/{1}'.format(ipaddr, netmask) return six.text_type(ipaddress....
[ "Takes", "IP", "(", "CIDR", "notation", "supported", ")", "and", "optionally", "netmask", "and", "returns", "the", "network", "in", "CIDR", "-", "notation", ".", "(", "The", "IP", "can", "be", "any", "IP", "inside", "the", "subnet", ")" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1082-L1091
[ "def", "calc_net", "(", "ipaddr", ",", "netmask", "=", "None", ")", ":", "if", "netmask", "is", "not", "None", ":", "ipaddr", "=", "'{0}/{1}'", ".", "format", "(", "ipaddr", ",", "netmask", ")", "return", "six", ".", "text_type", "(", "ipaddress", ".",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_ipv4_to_bits
Accepts an IPv4 dotted quad and returns a string representing its binary counterpart
salt/utils/network.py
def _ipv4_to_bits(ipaddr): ''' Accepts an IPv4 dotted quad and returns a string representing its binary counterpart ''' return ''.join([bin(int(x))[2:].rjust(8, '0') for x in ipaddr.split('.')])
def _ipv4_to_bits(ipaddr): ''' Accepts an IPv4 dotted quad and returns a string representing its binary counterpart ''' return ''.join([bin(int(x))[2:].rjust(8, '0') for x in ipaddr.split('.')])
[ "Accepts", "an", "IPv4", "dotted", "quad", "and", "returns", "a", "string", "representing", "its", "binary", "counterpart" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1094-L1099
[ "def", "_ipv4_to_bits", "(", "ipaddr", ")", ":", "return", "''", ".", "join", "(", "[", "bin", "(", "int", "(", "x", ")", ")", "[", "2", ":", "]", ".", "rjust", "(", "8", ",", "'0'", ")", "for", "x", "in", "ipaddr", ".", "split", "(", "'.'", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_get_iface_info
If `iface` is available, return interface info and no error, otherwise return no info and log and return an error
salt/utils/network.py
def _get_iface_info(iface): ''' If `iface` is available, return interface info and no error, otherwise return no info and log and return an error ''' iface_info = interfaces() if iface in iface_info.keys(): return iface_info, False else: error_msg = ('Interface "{0}" not in ...
def _get_iface_info(iface): ''' If `iface` is available, return interface info and no error, otherwise return no info and log and return an error ''' iface_info = interfaces() if iface in iface_info.keys(): return iface_info, False else: error_msg = ('Interface "{0}" not in ...
[ "If", "iface", "is", "available", "return", "interface", "info", "and", "no", "error", "otherwise", "return", "no", "info", "and", "log", "and", "return", "an", "error" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1102-L1115
[ "def", "_get_iface_info", "(", "iface", ")", ":", "iface_info", "=", "interfaces", "(", ")", "if", "iface", "in", "iface_info", ".", "keys", "(", ")", ":", "return", "iface_info", ",", "False", "else", ":", "error_msg", "=", "(", "'Interface \"{0}\" not in a...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_hw_addr_aix
Return the hardware address (a.k.a. MAC address) for a given interface on AIX MAC address not available in through interfaces
salt/utils/network.py
def _hw_addr_aix(iface): ''' Return the hardware address (a.k.a. MAC address) for a given interface on AIX MAC address not available in through interfaces ''' cmd = subprocess.Popen( 'entstat -d {0} | grep \'Hardware Address\''.format(iface), shell=True, stdout=subprocess.PIP...
def _hw_addr_aix(iface): ''' Return the hardware address (a.k.a. MAC address) for a given interface on AIX MAC address not available in through interfaces ''' cmd = subprocess.Popen( 'entstat -d {0} | grep \'Hardware Address\''.format(iface), shell=True, stdout=subprocess.PIP...
[ "Return", "the", "hardware", "address", "(", "a", ".", "k", ".", "a", ".", "MAC", "address", ")", "for", "a", "given", "interface", "on", "AIX", "MAC", "address", "not", "available", "in", "through", "interfaces" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1118-L1137
[ "def", "_hw_addr_aix", "(", "iface", ")", ":", "cmd", "=", "subprocess", ".", "Popen", "(", "'entstat -d {0} | grep \\'Hardware Address\\''", ".", "format", "(", "iface", ")", ",", "shell", "=", "True", ",", "stdout", "=", "subprocess", ".", "PIPE", ",", "st...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
hw_addr
Return the hardware address (a.k.a. MAC address) for a given interface .. versionchanged:: 2016.11.4 Added support for AIX
salt/utils/network.py
def hw_addr(iface): ''' Return the hardware address (a.k.a. MAC address) for a given interface .. versionchanged:: 2016.11.4 Added support for AIX ''' if salt.utils.platform.is_aix(): return _hw_addr_aix iface_info, error = _get_iface_info(iface) if error is False: ...
def hw_addr(iface): ''' Return the hardware address (a.k.a. MAC address) for a given interface .. versionchanged:: 2016.11.4 Added support for AIX ''' if salt.utils.platform.is_aix(): return _hw_addr_aix iface_info, error = _get_iface_info(iface) if error is False: ...
[ "Return", "the", "hardware", "address", "(", "a", ".", "k", ".", "a", ".", "MAC", "address", ")", "for", "a", "given", "interface" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1140-L1156
[ "def", "hw_addr", "(", "iface", ")", ":", "if", "salt", ".", "utils", ".", "platform", ".", "is_aix", "(", ")", ":", "return", "_hw_addr_aix", "iface_info", ",", "error", "=", "_get_iface_info", "(", "iface", ")", "if", "error", "is", "False", ":", "re...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
interface
Return the details of `iface` or an error if it does not exist
salt/utils/network.py
def interface(iface): ''' Return the details of `iface` or an error if it does not exist ''' iface_info, error = _get_iface_info(iface) if error is False: return iface_info.get(iface, {}).get('inet', '') else: return error
def interface(iface): ''' Return the details of `iface` or an error if it does not exist ''' iface_info, error = _get_iface_info(iface) if error is False: return iface_info.get(iface, {}).get('inet', '') else: return error
[ "Return", "the", "details", "of", "iface", "or", "an", "error", "if", "it", "does", "not", "exist" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1159-L1168
[ "def", "interface", "(", "iface", ")", ":", "iface_info", ",", "error", "=", "_get_iface_info", "(", "iface", ")", "if", "error", "is", "False", ":", "return", "iface_info", ".", "get", "(", "iface", ",", "{", "}", ")", ".", "get", "(", "'inet'", ","...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
interface_ip
Return `iface` IPv4 addr or an error if `iface` does not exist
salt/utils/network.py
def interface_ip(iface): ''' Return `iface` IPv4 addr or an error if `iface` does not exist ''' iface_info, error = _get_iface_info(iface) if error is False: inet = iface_info.get(iface, {}).get('inet', None) return inet[0].get('address', '') if inet else '' else: return...
def interface_ip(iface): ''' Return `iface` IPv4 addr or an error if `iface` does not exist ''' iface_info, error = _get_iface_info(iface) if error is False: inet = iface_info.get(iface, {}).get('inet', None) return inet[0].get('address', '') if inet else '' else: return...
[ "Return", "iface", "IPv4", "addr", "or", "an", "error", "if", "iface", "does", "not", "exist" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1171-L1181
[ "def", "interface_ip", "(", "iface", ")", ":", "iface_info", ",", "error", "=", "_get_iface_info", "(", "iface", ")", "if", "error", "is", "False", ":", "inet", "=", "iface_info", ".", "get", "(", "iface", ",", "{", "}", ")", ".", "get", "(", "'inet'...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_subnets
Returns a list of subnets to which the host belongs
salt/utils/network.py
def _subnets(proto='inet', interfaces_=None): ''' Returns a list of subnets to which the host belongs ''' if interfaces_ is None: ifaces = interfaces() elif isinstance(interfaces_, list): ifaces = {} for key, value in six.iteritems(interfaces()): if key in interfa...
def _subnets(proto='inet', interfaces_=None): ''' Returns a list of subnets to which the host belongs ''' if interfaces_ is None: ifaces = interfaces() elif isinstance(interfaces_, list): ifaces = {} for key, value in six.iteritems(interfaces()): if key in interfa...
[ "Returns", "a", "list", "of", "subnets", "to", "which", "the", "host", "belongs" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1184-L1221
[ "def", "_subnets", "(", "proto", "=", "'inet'", ",", "interfaces_", "=", "None", ")", ":", "if", "interfaces_", "is", "None", ":", "ifaces", "=", "interfaces", "(", ")", "elif", "isinstance", "(", "interfaces_", ",", "list", ")", ":", "ifaces", "=", "{...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
in_subnet
Returns True if host or (any of) addrs is within specified subnet, otherwise False
salt/utils/network.py
def in_subnet(cidr, addr=None): ''' Returns True if host or (any of) addrs is within specified subnet, otherwise False ''' try: cidr = ipaddress.ip_network(cidr) except ValueError: log.error('Invalid CIDR \'%s\'', cidr) return False if addr is None: addr = ip_add...
def in_subnet(cidr, addr=None): ''' Returns True if host or (any of) addrs is within specified subnet, otherwise False ''' try: cidr = ipaddress.ip_network(cidr) except ValueError: log.error('Invalid CIDR \'%s\'', cidr) return False if addr is None: addr = ip_add...
[ "Returns", "True", "if", "host", "or", "(", "any", "of", ")", "addrs", "is", "within", "specified", "subnet", "otherwise", "False" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1238-L1254
[ "def", "in_subnet", "(", "cidr", ",", "addr", "=", "None", ")", ":", "try", ":", "cidr", "=", "ipaddress", ".", "ip_network", "(", "cidr", ")", "except", "ValueError", ":", "log", ".", "error", "(", "'Invalid CIDR \\'%s\\''", ",", "cidr", ")", "return", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_ip_addrs
Return the full list of IP adresses matching the criteria proto = inet|inet6
salt/utils/network.py
def _ip_addrs(interface=None, include_loopback=False, interface_data=None, proto='inet'): ''' Return the full list of IP adresses matching the criteria proto = inet|inet6 ''' ret = set() ifaces = interface_data \ if isinstance(interface_data, dict) \ else interfaces() if in...
def _ip_addrs(interface=None, include_loopback=False, interface_data=None, proto='inet'): ''' Return the full list of IP adresses matching the criteria proto = inet|inet6 ''' ret = set() ifaces = interface_data \ if isinstance(interface_data, dict) \ else interfaces() if in...
[ "Return", "the", "full", "list", "of", "IP", "adresses", "matching", "the", "criteria" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1257-L1283
[ "def", "_ip_addrs", "(", "interface", "=", "None", ",", "include_loopback", "=", "False", ",", "interface_data", "=", "None", ",", "proto", "=", "'inet'", ")", ":", "ret", "=", "set", "(", ")", "ifaces", "=", "interface_data", "if", "isinstance", "(", "i...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
hex2ip
Convert a hex string to an ip, if a failure occurs the original hex is returned. If 'invert=True' assume that ip from /proc/net/<proto>
salt/utils/network.py
def hex2ip(hex_ip, invert=False): ''' Convert a hex string to an ip, if a failure occurs the original hex is returned. If 'invert=True' assume that ip from /proc/net/<proto> ''' if len(hex_ip) == 32: # ipv6 ip = [] for i in range(0, 32, 8): ip_part = hex_ip[i:i + 8] ...
def hex2ip(hex_ip, invert=False): ''' Convert a hex string to an ip, if a failure occurs the original hex is returned. If 'invert=True' assume that ip from /proc/net/<proto> ''' if len(hex_ip) == 32: # ipv6 ip = [] for i in range(0, 32, 8): ip_part = hex_ip[i:i + 8] ...
[ "Convert", "a", "hex", "string", "to", "an", "ip", "if", "a", "failure", "occurs", "the", "original", "hex", "is", "returned", ".", "If", "invert", "=", "True", "assume", "that", "ip", "from", "/", "proc", "/", "net", "/", "<proto", ">" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1304-L1340
[ "def", "hex2ip", "(", "hex_ip", ",", "invert", "=", "False", ")", ":", "if", "len", "(", "hex_ip", ")", "==", "32", ":", "# ipv6", "ip", "=", "[", "]", "for", "i", "in", "range", "(", "0", ",", "32", ",", "8", ")", ":", "ip_part", "=", "hex_i...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
mac2eui64
Convert a MAC address to a EUI64 identifier or, with prefix provided, a full IPv6 address
salt/utils/network.py
def mac2eui64(mac, prefix=None): ''' Convert a MAC address to a EUI64 identifier or, with prefix provided, a full IPv6 address ''' # http://tools.ietf.org/html/rfc4291#section-2.5.1 eui64 = re.sub(r'[.:-]', '', mac).lower() eui64 = eui64[0:6] + 'fffe' + eui64[6:] eui64 = hex(int(eui64[0:...
def mac2eui64(mac, prefix=None): ''' Convert a MAC address to a EUI64 identifier or, with prefix provided, a full IPv6 address ''' # http://tools.ietf.org/html/rfc4291#section-2.5.1 eui64 = re.sub(r'[.:-]', '', mac).lower() eui64 = eui64[0:6] + 'fffe' + eui64[6:] eui64 = hex(int(eui64[0:...
[ "Convert", "a", "MAC", "address", "to", "a", "EUI64", "identifier", "or", "with", "prefix", "provided", "a", "full", "IPv6", "address" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1343-L1361
[ "def", "mac2eui64", "(", "mac", ",", "prefix", "=", "None", ")", ":", "# http://tools.ietf.org/html/rfc4291#section-2.5.1", "eui64", "=", "re", ".", "sub", "(", "r'[.:-]'", ",", "''", ",", "mac", ")", ".", "lower", "(", ")", "eui64", "=", "eui64", "[", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
active_tcp
Return a dict describing all active tcp connections as quickly as possible
salt/utils/network.py
def active_tcp(): ''' Return a dict describing all active tcp connections as quickly as possible ''' ret = {} for statf in ['/proc/net/tcp', '/proc/net/tcp6']: if os.path.isfile(statf): with salt.utils.files.fopen(statf, 'rb') as fp_: for line in fp_: ...
def active_tcp(): ''' Return a dict describing all active tcp connections as quickly as possible ''' ret = {} for statf in ['/proc/net/tcp', '/proc/net/tcp6']: if os.path.isfile(statf): with salt.utils.files.fopen(statf, 'rb') as fp_: for line in fp_: ...
[ "Return", "a", "dict", "describing", "all", "active", "tcp", "connections", "as", "quickly", "as", "possible" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1364-L1381
[ "def", "active_tcp", "(", ")", ":", "ret", "=", "{", "}", "for", "statf", "in", "[", "'/proc/net/tcp'", ",", "'/proc/net/tcp6'", "]", ":", "if", "os", ".", "path", ".", "isfile", "(", "statf", ")", ":", "with", "salt", ".", "utils", ".", "files", "...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_remotes_on
Return a set of ip addrs active tcp connections
salt/utils/network.py
def _remotes_on(port, which_end): ''' Return a set of ip addrs active tcp connections ''' port = int(port) ret = _netlink_tool_remote_on(port, which_end) if ret is not None: return ret ret = set() proc_available = False for statf in ['/proc/net/tcp', '/proc/net/tcp6']: ...
def _remotes_on(port, which_end): ''' Return a set of ip addrs active tcp connections ''' port = int(port) ret = _netlink_tool_remote_on(port, which_end) if ret is not None: return ret ret = set() proc_available = False for statf in ['/proc/net/tcp', '/proc/net/tcp6']: ...
[ "Return", "a", "set", "of", "ip", "addrs", "active", "tcp", "connections" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1400-L1441
[ "def", "_remotes_on", "(", "port", ",", "which_end", ")", ":", "port", "=", "int", "(", "port", ")", "ret", "=", "_netlink_tool_remote_on", "(", "port", ",", "which_end", ")", "if", "ret", "is", "not", "None", ":", "return", "ret", "ret", "=", "set", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_parse_tcp_line
Parse a single line from the contents of /proc/net/tcp or /proc/net/tcp6
salt/utils/network.py
def _parse_tcp_line(line): ''' Parse a single line from the contents of /proc/net/tcp or /proc/net/tcp6 ''' ret = {} comps = line.strip().split() sl = comps[0].rstrip(':') ret[sl] = {} l_addr, l_port = comps[1].split(':') r_addr, r_port = comps[2].split(':') ret[sl]['local_addr']...
def _parse_tcp_line(line): ''' Parse a single line from the contents of /proc/net/tcp or /proc/net/tcp6 ''' ret = {} comps = line.strip().split() sl = comps[0].rstrip(':') ret[sl] = {} l_addr, l_port = comps[1].split(':') r_addr, r_port = comps[2].split(':') ret[sl]['local_addr']...
[ "Parse", "a", "single", "line", "from", "the", "contents", "of", "/", "proc", "/", "net", "/", "tcp", "or", "/", "proc", "/", "net", "/", "tcp6" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1444-L1459
[ "def", "_parse_tcp_line", "(", "line", ")", ":", "ret", "=", "{", "}", "comps", "=", "line", ".", "strip", "(", ")", ".", "split", "(", ")", "sl", "=", "comps", "[", "0", "]", ".", "rstrip", "(", "':'", ")", "ret", "[", "sl", "]", "=", "{", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_netlink_tool_remote_on
Returns set of ipv4 host addresses of remote established connections on local or remote tcp port. Parses output of shell 'ss' to get connections [root@salt-master ~]# ss -ant State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 511 ...
salt/utils/network.py
def _netlink_tool_remote_on(port, which_end): ''' Returns set of ipv4 host addresses of remote established connections on local or remote tcp port. Parses output of shell 'ss' to get connections [root@salt-master ~]# ss -ant State Recv-Q Send-Q Local Address:Port ...
def _netlink_tool_remote_on(port, which_end): ''' Returns set of ipv4 host addresses of remote established connections on local or remote tcp port. Parses output of shell 'ss' to get connections [root@salt-master ~]# ss -ant State Recv-Q Send-Q Local Address:Port ...
[ "Returns", "set", "of", "ipv4", "host", "addresses", "of", "remote", "established", "connections", "on", "local", "or", "remote", "tcp", "port", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1462-L1504
[ "def", "_netlink_tool_remote_on", "(", "port", ",", "which_end", ")", ":", "remotes", "=", "set", "(", ")", "valid", "=", "False", "try", ":", "data", "=", "subprocess", ".", "check_output", "(", "[", "'ss'", ",", "'-ant'", "]", ")", "# pylint: disable=min...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_netbsd_remotes_on
Returns set of ipv4 host addresses of remote established connections on local tcp port port. Parses output of shell 'sockstat' (NetBSD) to get connections $ sudo sockstat -4 -n USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDRESS root python2.7 1456 29 tcp *.4505...
salt/utils/network.py
def _netbsd_remotes_on(port, which_end): ''' Returns set of ipv4 host addresses of remote established connections on local tcp port port. Parses output of shell 'sockstat' (NetBSD) to get connections $ sudo sockstat -4 -n USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDR...
def _netbsd_remotes_on(port, which_end): ''' Returns set of ipv4 host addresses of remote established connections on local tcp port port. Parses output of shell 'sockstat' (NetBSD) to get connections $ sudo sockstat -4 -n USER COMMAND PID FD PROTO LOCAL ADDRESS FOREIGN ADDR...
[ "Returns", "set", "of", "ipv4", "host", "addresses", "of", "remote", "established", "connections", "on", "local", "tcp", "port", "port", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1605-L1661
[ "def", "_netbsd_remotes_on", "(", "port", ",", "which_end", ")", ":", "port", "=", "int", "(", "port", ")", "remotes", "=", "set", "(", ")", "try", ":", "cmd", "=", "salt", ".", "utils", ".", "args", ".", "shlex_split", "(", "'sockstat -4 -c -n -p {0}'",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_openbsd_remotes_on
OpenBSD specific helper function. Returns set of ipv4 host addresses of remote established connections on local or remote tcp port. Parses output of shell 'netstat' to get connections $ netstat -nf inet Active Internet connections Proto Recv-Q Send-Q Local Address Foreign Address ...
salt/utils/network.py
def _openbsd_remotes_on(port, which_end): ''' OpenBSD specific helper function. Returns set of ipv4 host addresses of remote established connections on local or remote tcp port. Parses output of shell 'netstat' to get connections $ netstat -nf inet Active Internet connections Proto R...
def _openbsd_remotes_on(port, which_end): ''' OpenBSD specific helper function. Returns set of ipv4 host addresses of remote established connections on local or remote tcp port. Parses output of shell 'netstat' to get connections $ netstat -nf inet Active Internet connections Proto R...
[ "OpenBSD", "specific", "helper", "function", ".", "Returns", "set", "of", "ipv4", "host", "addresses", "of", "remote", "established", "connections", "on", "local", "or", "remote", "tcp", "port", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1664-L1698
[ "def", "_openbsd_remotes_on", "(", "port", ",", "which_end", ")", ":", "remotes", "=", "set", "(", ")", "try", ":", "data", "=", "subprocess", ".", "check_output", "(", "[", "'netstat'", ",", "'-nf'", ",", "'inet'", "]", ")", "# pylint: disable=minimum-pytho...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_windows_remotes_on
r''' Windows specific helper function. Returns set of ipv4 host addresses of remote established connections on local or remote tcp port. Parses output of shell 'netstat' to get connections C:\>netstat -n Active Connections Proto Local Address Foreign Address State ...
salt/utils/network.py
def _windows_remotes_on(port, which_end): r''' Windows specific helper function. Returns set of ipv4 host addresses of remote established connections on local or remote tcp port. Parses output of shell 'netstat' to get connections C:\>netstat -n Active Connections Proto Local Add...
def _windows_remotes_on(port, which_end): r''' Windows specific helper function. Returns set of ipv4 host addresses of remote established connections on local or remote tcp port. Parses output of shell 'netstat' to get connections C:\>netstat -n Active Connections Proto Local Add...
[ "r", "Windows", "specific", "helper", "function", ".", "Returns", "set", "of", "ipv4", "host", "addresses", "of", "remote", "established", "connections", "on", "local", "or", "remote", "tcp", "port", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1701-L1736
[ "def", "_windows_remotes_on", "(", "port", ",", "which_end", ")", ":", "remotes", "=", "set", "(", ")", "try", ":", "data", "=", "subprocess", ".", "check_output", "(", "[", "'netstat'", ",", "'-n'", "]", ")", "# pylint: disable=minimum-python-version", "excep...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
_linux_remotes_on
Linux specific helper function. Returns set of ip host addresses of remote established connections on local tcp port port. Parses output of shell 'lsof' to get connections $ sudo lsof -iTCP:4505 -n COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME Python 9971 root 35...
salt/utils/network.py
def _linux_remotes_on(port, which_end): ''' Linux specific helper function. Returns set of ip host addresses of remote established connections on local tcp port port. Parses output of shell 'lsof' to get connections $ sudo lsof -iTCP:4505 -n COMMAND PID USER FD TYPE D...
def _linux_remotes_on(port, which_end): ''' Linux specific helper function. Returns set of ip host addresses of remote established connections on local tcp port port. Parses output of shell 'lsof' to get connections $ sudo lsof -iTCP:4505 -n COMMAND PID USER FD TYPE D...
[ "Linux", "specific", "helper", "function", ".", "Returns", "set", "of", "ip", "host", "addresses", "of", "remote", "established", "connections", "on", "local", "tcp", "port", "port", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1739-L1793
[ "def", "_linux_remotes_on", "(", "port", ",", "which_end", ")", ":", "remotes", "=", "set", "(", ")", "try", ":", "data", "=", "subprocess", ".", "check_output", "(", "[", "'lsof'", ",", "'-iTCP:{0:d}'", ".", "format", "(", "port", ")", ",", "'-n'", ",...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
gen_mac
Generates a MAC address with the defined OUI prefix. Common prefixes: - ``00:16:3E`` -- Xen - ``00:18:51`` -- OpenVZ - ``00:50:56`` -- VMware (manually generated) - ``52:54:00`` -- QEMU/KVM - ``AC:DE:48`` -- PRIVATE References: - http://standards.ieee.org/develop/regauth/oui/ou...
salt/utils/network.py
def gen_mac(prefix='AC:DE:48'): ''' Generates a MAC address with the defined OUI prefix. Common prefixes: - ``00:16:3E`` -- Xen - ``00:18:51`` -- OpenVZ - ``00:50:56`` -- VMware (manually generated) - ``52:54:00`` -- QEMU/KVM - ``AC:DE:48`` -- PRIVATE References: - http...
def gen_mac(prefix='AC:DE:48'): ''' Generates a MAC address with the defined OUI prefix. Common prefixes: - ``00:16:3E`` -- Xen - ``00:18:51`` -- OpenVZ - ``00:50:56`` -- VMware (manually generated) - ``52:54:00`` -- QEMU/KVM - ``AC:DE:48`` -- PRIVATE References: - http...
[ "Generates", "a", "MAC", "address", "with", "the", "defined", "OUI", "prefix", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1847-L1868
[ "def", "gen_mac", "(", "prefix", "=", "'AC:DE:48'", ")", ":", "return", "'{0}:{1:02X}:{2:02X}:{3:02X}'", ".", "format", "(", "prefix", ",", "random", ".", "randint", "(", "0", ",", "0xff", ")", ",", "random", ".", "randint", "(", "0", ",", "0xff", ")", ...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
mac_str_to_bytes
Convert a MAC address string into bytes. Works with or without separators: b1 = mac_str_to_bytes('08:00:27:13:69:77') b2 = mac_str_to_bytes('080027136977') assert b1 == b2 assert isinstance(b1, bytes)
salt/utils/network.py
def mac_str_to_bytes(mac_str): ''' Convert a MAC address string into bytes. Works with or without separators: b1 = mac_str_to_bytes('08:00:27:13:69:77') b2 = mac_str_to_bytes('080027136977') assert b1 == b2 assert isinstance(b1, bytes) ''' if len(mac_str) == 12: pass elif le...
def mac_str_to_bytes(mac_str): ''' Convert a MAC address string into bytes. Works with or without separators: b1 = mac_str_to_bytes('08:00:27:13:69:77') b2 = mac_str_to_bytes('080027136977') assert b1 == b2 assert isinstance(b1, bytes) ''' if len(mac_str) == 12: pass elif le...
[ "Convert", "a", "MAC", "address", "string", "into", "bytes", ".", "Works", "with", "or", "without", "separators", ":" ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1872-L1889
[ "def", "mac_str_to_bytes", "(", "mac_str", ")", ":", "if", "len", "(", "mac_str", ")", "==", "12", ":", "pass", "elif", "len", "(", "mac_str", ")", "==", "17", ":", "sep", "=", "mac_str", "[", "2", "]", "mac_str", "=", "mac_str", ".", "replace", "(...
e8541fd6e744ab0df786c0f76102e41631f45d46
train
connection_check
Provides a convenient alias for the dns_check filter.
salt/utils/network.py
def connection_check(addr, port=80, safe=False, ipv6=None): ''' Provides a convenient alias for the dns_check filter. ''' return dns_check(addr, port, safe, ipv6)
def connection_check(addr, port=80, safe=False, ipv6=None): ''' Provides a convenient alias for the dns_check filter. ''' return dns_check(addr, port, safe, ipv6)
[ "Provides", "a", "convenient", "alias", "for", "the", "dns_check", "filter", "." ]
saltstack/salt
python
https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1904-L1908
[ "def", "connection_check", "(", "addr", ",", "port", "=", "80", ",", "safe", "=", "False", ",", "ipv6", "=", "None", ")", ":", "return", "dns_check", "(", "addr", ",", "port", ",", "safe", ",", "ipv6", ")" ]
e8541fd6e744ab0df786c0f76102e41631f45d46