repo stringclasses 85
values | path stringlengths 8 121 | func_name stringlengths 1 82 | original_string stringlengths 112 65.5k | language stringclasses 1
value | code stringlengths 112 65.5k | code_tokens listlengths 20 4.09k | docstring stringlengths 3 46.3k | docstring_tokens listlengths 1 564 | sha stringclasses 85
values | url stringlengths 93 218 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
saltstack/salt | salt/utils/network.py | get_net_size | 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')) | python | 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",
")",
":",
"binary_str",
"=",
"''",
"for",
"octet",
"in",
"mask",
".",
"split",
"(",
"'.'",
")",
":",
"binary_str",
"+=",
"bin",
"(",
"int",
"(",
"octet",
")",
")",
"[",
"2",
":",
"]",
".",
"zfill",
"(",
"8",
... | Turns an IPv4 netmask into it's corresponding prefix length
(255.255.255.0 -> 24 as in 192.168.1.10/24). | [
"Turns",
"an",
"IPv4",
"netmask",
"into",
"it",
"s",
"corresponding",
"prefix",
"length",
"(",
"255",
".",
"255",
".",
"255",
".",
"0",
"-",
">",
"24",
"as",
"in",
"192",
".",
"168",
".",
"1",
".",
"10",
"/",
"24",
")",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1071-L1079 | train |
saltstack/salt | salt/utils/network.py | calc_net | 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.... | python | 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",
")",
":",
"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) | [
"Takes",
"IP",
"(",
"CIDR",
"notation",
"supported",
")",
"and",
"optionally",
"netmask",
"and",
"returns",
"the",
"network",
"in",
"CIDR",
"-",
"notation",
".",
"(",
"The",
"IP",
"can",
"be",
"any",
"IP",
"inside",
"the",
"subnet",
")"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1082-L1091 | train |
saltstack/salt | salt/utils/network.py | _ipv4_to_bits | 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('.')]) | python | 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",
")",
":",
"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 | [
"Accepts",
"an",
"IPv4",
"dotted",
"quad",
"and",
"returns",
"a",
"string",
"representing",
"its",
"binary",
"counterpart"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1094-L1099 | train |
saltstack/salt | salt/utils/network.py | _get_iface_info | 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 ... | python | 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",
")",
":",
"iface_info",
"=",
"interfaces",
"(",
")",
"if",
"iface",
"in",
"iface_info",
".",
"keys",
"(",
")",
":",
"return",
"iface_info",
",",
"False",
"else",
":",
"error_msg",
"=",
"(",
"'Interface \"{0}\" not in a... | If `iface` is available, return interface info and no error, otherwise
return no info and log and return an error | [
"If",
"iface",
"is",
"available",
"return",
"interface",
"info",
"and",
"no",
"error",
"otherwise",
"return",
"no",
"info",
"and",
"log",
"and",
"return",
"an",
"error"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1102-L1115 | train |
saltstack/salt | salt/utils/network.py | _hw_addr_aix | 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... | python | 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",
")",
":",
"cmd",
"=",
"subprocess",
".",
"Popen",
"(",
"'entstat -d {0} | grep \\'Hardware Address\\''",
".",
"format",
"(",
"iface",
")",
",",
"shell",
"=",
"True",
",",
"stdout",
"=",
"subprocess",
".",
"PIPE",
",",
"st... | Return the hardware address (a.k.a. MAC address) for a given interface on AIX
MAC address not available in through interfaces | [
"Return",
"the",
"hardware",
"address",
"(",
"a",
".",
"k",
".",
"a",
".",
"MAC",
"address",
")",
"for",
"a",
"given",
"interface",
"on",
"AIX",
"MAC",
"address",
"not",
"available",
"in",
"through",
"interfaces"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1118-L1137 | train |
saltstack/salt | salt/utils/network.py | hw_addr | 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:
... | python | 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",
")",
":",
"if",
"salt",
".",
"utils",
".",
"platform",
".",
"is_aix",
"(",
")",
":",
"return",
"_hw_addr_aix",
"iface_info",
",",
"error",
"=",
"_get_iface_info",
"(",
"iface",
")",
"if",
"error",
"is",
"False",
":",
"re... | Return the hardware address (a.k.a. MAC address) for a given interface
.. versionchanged:: 2016.11.4
Added support for AIX | [
"Return",
"the",
"hardware",
"address",
"(",
"a",
".",
"k",
".",
"a",
".",
"MAC",
"address",
")",
"for",
"a",
"given",
"interface"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1140-L1156 | train |
saltstack/salt | salt/utils/network.py | interface | 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 | python | 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",
")",
":",
"iface_info",
",",
"error",
"=",
"_get_iface_info",
"(",
"iface",
")",
"if",
"error",
"is",
"False",
":",
"return",
"iface_info",
".",
"get",
"(",
"iface",
",",
"{",
"}",
")",
".",
"get",
"(",
"'inet'",
","... | Return the details of `iface` or an error if it does not exist | [
"Return",
"the",
"details",
"of",
"iface",
"or",
"an",
"error",
"if",
"it",
"does",
"not",
"exist"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1159-L1168 | train |
saltstack/salt | salt/utils/network.py | interface_ip | 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... | python | 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",
")",
":",
"iface_info",
",",
"error",
"=",
"_get_iface_info",
"(",
"iface",
")",
"if",
"error",
"is",
"False",
":",
"inet",
"=",
"iface_info",
".",
"get",
"(",
"iface",
",",
"{",
"}",
")",
".",
"get",
"(",
"'inet'... | Return `iface` IPv4 addr or an error if `iface` does not exist | [
"Return",
"iface",
"IPv4",
"addr",
"or",
"an",
"error",
"if",
"iface",
"does",
"not",
"exist"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1171-L1181 | train |
saltstack/salt | salt/utils/network.py | _subnets | 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... | python | 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",
")",
":",
"if",
"interfaces_",
"is",
"None",
":",
"ifaces",
"=",
"interfaces",
"(",
")",
"elif",
"isinstance",
"(",
"interfaces_",
",",
"list",
")",
":",
"ifaces",
"=",
"{... | Returns a list of subnets to which the host belongs | [
"Returns",
"a",
"list",
"of",
"subnets",
"to",
"which",
"the",
"host",
"belongs"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1184-L1221 | train |
saltstack/salt | salt/utils/network.py | in_subnet | 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... | python | 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",
")",
":",
"try",
":",
"cidr",
"=",
"ipaddress",
".",
"ip_network",
"(",
"cidr",
")",
"except",
"ValueError",
":",
"log",
".",
"error",
"(",
"'Invalid CIDR \\'%s\\''",
",",
"cidr",
")",
"return",
... | Returns True if host or (any of) addrs is within specified subnet, otherwise False | [
"Returns",
"True",
"if",
"host",
"or",
"(",
"any",
"of",
")",
"addrs",
"is",
"within",
"specified",
"subnet",
"otherwise",
"False"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1238-L1254 | train |
saltstack/salt | salt/utils/network.py | _ip_addrs | 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... | python | 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'",
")",
":",
"ret",
"=",
"set",
"(",
")",
"ifaces",
"=",
"interface_data",
"if",
"isinstance",
"(",
"i... | Return the full list of IP adresses matching the criteria
proto = inet|inet6 | [
"Return",
"the",
"full",
"list",
"of",
"IP",
"adresses",
"matching",
"the",
"criteria"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1257-L1283 | train |
saltstack/salt | salt/utils/network.py | hex2ip | 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]
... | python | 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",
")",
":",
"if",
"len",
"(",
"hex_ip",
")",
"==",
"32",
":",
"# ipv6",
"ip",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"32",
",",
"8",
")",
":",
"ip_part",
"=",
"hex_i... | 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> | [
"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",
">"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1304-L1340 | train |
saltstack/salt | salt/utils/network.py | mac2eui64 | 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:... | python | 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",
")",
":",
"# http://tools.ietf.org/html/rfc4291#section-2.5.1",
"eui64",
"=",
"re",
".",
"sub",
"(",
"r'[.:-]'",
",",
"''",
",",
"mac",
")",
".",
"lower",
"(",
")",
"eui64",
"=",
"eui64",
"[",
"... | Convert a MAC address to a EUI64 identifier
or, with prefix provided, a full IPv6 address | [
"Convert",
"a",
"MAC",
"address",
"to",
"a",
"EUI64",
"identifier",
"or",
"with",
"prefix",
"provided",
"a",
"full",
"IPv6",
"address"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1343-L1361 | train |
saltstack/salt | salt/utils/network.py | active_tcp | 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_:
... | python | 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",
"(",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"statf",
"in",
"[",
"'/proc/net/tcp'",
",",
"'/proc/net/tcp6'",
"]",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"statf",
")",
":",
"with",
"salt",
".",
"utils",
".",
"files",
"... | Return a dict describing all active tcp connections as quickly as possible | [
"Return",
"a",
"dict",
"describing",
"all",
"active",
"tcp",
"connections",
"as",
"quickly",
"as",
"possible"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1364-L1381 | train |
saltstack/salt | salt/utils/network.py | _remotes_on | 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']:
... | python | 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",
")",
":",
"port",
"=",
"int",
"(",
"port",
")",
"ret",
"=",
"_netlink_tool_remote_on",
"(",
"port",
",",
"which_end",
")",
"if",
"ret",
"is",
"not",
"None",
":",
"return",
"ret",
"ret",
"=",
"set",
... | Return a set of ip addrs active tcp connections | [
"Return",
"a",
"set",
"of",
"ip",
"addrs",
"active",
"tcp",
"connections"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1400-L1441 | train |
saltstack/salt | salt/utils/network.py | _parse_tcp_line | 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']... | python | 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",
")",
":",
"ret",
"=",
"{",
"}",
"comps",
"=",
"line",
".",
"strip",
"(",
")",
".",
"split",
"(",
")",
"sl",
"=",
"comps",
"[",
"0",
"]",
".",
"rstrip",
"(",
"':'",
")",
"ret",
"[",
"sl",
"]",
"=",
"{",
... | Parse a single line from the contents of /proc/net/tcp or /proc/net/tcp6 | [
"Parse",
"a",
"single",
"line",
"from",
"the",
"contents",
"of",
"/",
"proc",
"/",
"net",
"/",
"tcp",
"or",
"/",
"proc",
"/",
"net",
"/",
"tcp6"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1444-L1459 | train |
saltstack/salt | salt/utils/network.py | _netlink_tool_remote_on | 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 ... | python | 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",
")",
":",
"remotes",
"=",
"set",
"(",
")",
"valid",
"=",
"False",
"try",
":",
"data",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'ss'",
",",
"'-ant'",
"]",
")",
"# pylint: disable=min... | 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 ... | [
"Returns",
"set",
"of",
"ipv4",
"host",
"addresses",
"of",
"remote",
"established",
"connections",
"on",
"local",
"or",
"remote",
"tcp",
"port",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1462-L1504 | train |
saltstack/salt | salt/utils/network.py | _netbsd_remotes_on | 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... | python | 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",
")",
":",
"port",
"=",
"int",
"(",
"port",
")",
"remotes",
"=",
"set",
"(",
")",
"try",
":",
"cmd",
"=",
"salt",
".",
"utils",
".",
"args",
".",
"shlex_split",
"(",
"'sockstat -4 -c -n -p {0}'",... | 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... | [
"Returns",
"set",
"of",
"ipv4",
"host",
"addresses",
"of",
"remote",
"established",
"connections",
"on",
"local",
"tcp",
"port",
"port",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1605-L1661 | train |
saltstack/salt | salt/utils/network.py | _openbsd_remotes_on | 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... | python | 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",
")",
":",
"remotes",
"=",
"set",
"(",
")",
"try",
":",
"data",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'netstat'",
",",
"'-nf'",
",",
"'inet'",
"]",
")",
"# pylint: disable=minimum-pytho... | 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 ... | [
"OpenBSD",
"specific",
"helper",
"function",
".",
"Returns",
"set",
"of",
"ipv4",
"host",
"addresses",
"of",
"remote",
"established",
"connections",
"on",
"local",
"or",
"remote",
"tcp",
"port",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1664-L1698 | train |
saltstack/salt | salt/utils/network.py | _windows_remotes_on | 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... | python | 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",
")",
":",
"remotes",
"=",
"set",
"(",
")",
"try",
":",
"data",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'netstat'",
",",
"'-n'",
"]",
")",
"# pylint: disable=minimum-python-version",
"excep... | 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
... | [
"r",
"Windows",
"specific",
"helper",
"function",
".",
"Returns",
"set",
"of",
"ipv4",
"host",
"addresses",
"of",
"remote",
"established",
"connections",
"on",
"local",
"or",
"remote",
"tcp",
"port",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1701-L1736 | train |
saltstack/salt | salt/utils/network.py | _linux_remotes_on | 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... | python | 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",
")",
":",
"remotes",
"=",
"set",
"(",
")",
"try",
":",
"data",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'lsof'",
",",
"'-iTCP:{0:d}'",
".",
"format",
"(",
"port",
")",
",",
"'-n'",
",... | 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... | [
"Linux",
"specific",
"helper",
"function",
".",
"Returns",
"set",
"of",
"ip",
"host",
"addresses",
"of",
"remote",
"established",
"connections",
"on",
"local",
"tcp",
"port",
"port",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1739-L1793 | train |
saltstack/salt | salt/utils/network.py | gen_mac | 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... | python | 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'",
")",
":",
"return",
"'{0}:{1:02X}:{2:02X}:{3:02X}'",
".",
"format",
"(",
"prefix",
",",
"random",
".",
"randint",
"(",
"0",
",",
"0xff",
")",
",",
"random",
".",
"randint",
"(",
"0",
",",
"0xff",
")",
... | 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... | [
"Generates",
"a",
"MAC",
"address",
"with",
"the",
"defined",
"OUI",
"prefix",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1847-L1868 | train |
saltstack/salt | salt/utils/network.py | mac_str_to_bytes | 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... | python | 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",
")",
":",
"if",
"len",
"(",
"mac_str",
")",
"==",
"12",
":",
"pass",
"elif",
"len",
"(",
"mac_str",
")",
"==",
"17",
":",
"sep",
"=",
"mac_str",
"[",
"2",
"]",
"mac_str",
"=",
"mac_str",
".",
"replace",
"(... | 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) | [
"Convert",
"a",
"MAC",
"address",
"string",
"into",
"bytes",
".",
"Works",
"with",
"or",
"without",
"separators",
":"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1872-L1889 | train |
saltstack/salt | salt/utils/network.py | connection_check | 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) | python | 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",
")",
":",
"return",
"dns_check",
"(",
"addr",
",",
"port",
",",
"safe",
",",
"ipv6",
")"
] | Provides a convenient alias for the dns_check filter. | [
"Provides",
"a",
"convenient",
"alias",
"for",
"the",
"dns_check",
"filter",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1904-L1908 | train |
saltstack/salt | salt/utils/network.py | dns_check | def dns_check(addr, port=80, safe=False, ipv6=None, attempt_connect=True):
'''
Return the ip resolved by dns, but do not exit on failure, only raise an
exception. Obeys system preference for IPv4/6 address resolution - this
can be overridden by the ipv6 flag.
Tries to connect to the address before c... | python | def dns_check(addr, port=80, safe=False, ipv6=None, attempt_connect=True):
'''
Return the ip resolved by dns, but do not exit on failure, only raise an
exception. Obeys system preference for IPv4/6 address resolution - this
can be overridden by the ipv6 flag.
Tries to connect to the address before c... | [
"def",
"dns_check",
"(",
"addr",
",",
"port",
"=",
"80",
",",
"safe",
"=",
"False",
",",
"ipv6",
"=",
"None",
",",
"attempt_connect",
"=",
"True",
")",
":",
"error",
"=",
"False",
"lookup",
"=",
"addr",
"seen_ipv6",
"=",
"False",
"family",
"=",
"sock... | Return the ip resolved by dns, but do not exit on failure, only raise an
exception. Obeys system preference for IPv4/6 address resolution - this
can be overridden by the ipv6 flag.
Tries to connect to the address before considering it useful. If no address
can be reached, the first one resolved is used ... | [
"Return",
"the",
"ip",
"resolved",
"by",
"dns",
"but",
"do",
"not",
"exit",
"on",
"failure",
"only",
"raise",
"an",
"exception",
".",
"Obeys",
"system",
"preference",
"for",
"IPv4",
"/",
"6",
"address",
"resolution",
"-",
"this",
"can",
"be",
"overridden",... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1912-L2002 | train |
saltstack/salt | salt/utils/network.py | parse_host_port | def parse_host_port(host_port):
"""
Takes a string argument specifying host or host:port.
Returns a (hostname, port) or (ip_address, port) tuple. If no port is given,
the second (port) element of the returned tuple will be None.
host:port argument, for example, is accepted in the forms of:
-... | python | def parse_host_port(host_port):
"""
Takes a string argument specifying host or host:port.
Returns a (hostname, port) or (ip_address, port) tuple. If no port is given,
the second (port) element of the returned tuple will be None.
host:port argument, for example, is accepted in the forms of:
-... | [
"def",
"parse_host_port",
"(",
"host_port",
")",
":",
"host",
",",
"port",
"=",
"None",
",",
"None",
"# default",
"_s_",
"=",
"host_port",
"[",
":",
"]",
"if",
"_s_",
"[",
"0",
"]",
"==",
"\"[\"",
":",
"if",
"\"]\"",
"in",
"host_port",
":",
"host",
... | Takes a string argument specifying host or host:port.
Returns a (hostname, port) or (ip_address, port) tuple. If no port is given,
the second (port) element of the returned tuple will be None.
host:port argument, for example, is accepted in the forms of:
- hostname
- hostname:1234
- host... | [
"Takes",
"a",
"string",
"argument",
"specifying",
"host",
"or",
"host",
":",
"port",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L2005-L2054 | train |
saltstack/salt | salt/utils/network.py | is_fqdn | def is_fqdn(hostname):
"""
Verify if hostname conforms to be a FQDN.
:param hostname: text string with the name of the host
:return: bool, True if hostname is correct FQDN, False otherwise
"""
compliant = re.compile(r"(?!-)[A-Z\d\-\_]{1,63}(?<!-)$", re.IGNORECASE)
return "." in hostname an... | python | def is_fqdn(hostname):
"""
Verify if hostname conforms to be a FQDN.
:param hostname: text string with the name of the host
:return: bool, True if hostname is correct FQDN, False otherwise
"""
compliant = re.compile(r"(?!-)[A-Z\d\-\_]{1,63}(?<!-)$", re.IGNORECASE)
return "." in hostname an... | [
"def",
"is_fqdn",
"(",
"hostname",
")",
":",
"compliant",
"=",
"re",
".",
"compile",
"(",
"r\"(?!-)[A-Z\\d\\-\\_]{1,63}(?<!-)$\"",
",",
"re",
".",
"IGNORECASE",
")",
"return",
"\".\"",
"in",
"hostname",
"and",
"len",
"(",
"hostname",
")",
"<",
"0xff",
"and",... | Verify if hostname conforms to be a FQDN.
:param hostname: text string with the name of the host
:return: bool, True if hostname is correct FQDN, False otherwise | [
"Verify",
"if",
"hostname",
"conforms",
"to",
"be",
"a",
"FQDN",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L2057-L2066 | train |
saltstack/salt | salt/modules/mount.py | _active_mounts | def _active_mounts(ret):
'''
List active mounts on Linux systems
'''
_list = _list_mounts()
filename = '/proc/self/mounts'
if not os.access(filename, os.R_OK):
msg = 'File not readable {0}'
raise CommandExecutionError(msg.format(filename))
with salt.utils.files.fopen(filenam... | python | def _active_mounts(ret):
'''
List active mounts on Linux systems
'''
_list = _list_mounts()
filename = '/proc/self/mounts'
if not os.access(filename, os.R_OK):
msg = 'File not readable {0}'
raise CommandExecutionError(msg.format(filename))
with salt.utils.files.fopen(filenam... | [
"def",
"_active_mounts",
"(",
"ret",
")",
":",
"_list",
"=",
"_list_mounts",
"(",
")",
"filename",
"=",
"'/proc/self/mounts'",
"if",
"not",
"os",
".",
"access",
"(",
"filename",
",",
"os",
".",
"R_OK",
")",
":",
"msg",
"=",
"'File not readable {0}'",
"rais... | List active mounts on Linux systems | [
"List",
"active",
"mounts",
"on",
"Linux",
"systems"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L102-L119 | train |
saltstack/salt | salt/modules/mount.py | _active_mounts_aix | def _active_mounts_aix(ret):
'''
List active mounts on AIX systems
'''
for line in __salt__['cmd.run_stdout']('mount -p').split('\n'):
comps = re.sub(r"\s+", " ", line).split()
if comps:
if comps[0] == 'node' or comps[0] == '--------':
continue
com... | python | def _active_mounts_aix(ret):
'''
List active mounts on AIX systems
'''
for line in __salt__['cmd.run_stdout']('mount -p').split('\n'):
comps = re.sub(r"\s+", " ", line).split()
if comps:
if comps[0] == 'node' or comps[0] == '--------':
continue
com... | [
"def",
"_active_mounts_aix",
"(",
"ret",
")",
":",
"for",
"line",
"in",
"__salt__",
"[",
"'cmd.run_stdout'",
"]",
"(",
"'mount -p'",
")",
".",
"split",
"(",
"'\\n'",
")",
":",
"comps",
"=",
"re",
".",
"sub",
"(",
"r\"\\s+\"",
",",
"\" \"",
",",
"line",... | List active mounts on AIX systems | [
"List",
"active",
"mounts",
"on",
"AIX",
"systems"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L122-L152 | train |
saltstack/salt | salt/modules/mount.py | _active_mounts_freebsd | def _active_mounts_freebsd(ret):
'''
List active mounts on FreeBSD systems
'''
for line in __salt__['cmd.run_stdout']('mount -p').split('\n'):
comps = re.sub(r"\s+", " ", line).split()
ret[comps[1]] = {'device': comps[0],
'fstype': comps[2],
... | python | def _active_mounts_freebsd(ret):
'''
List active mounts on FreeBSD systems
'''
for line in __salt__['cmd.run_stdout']('mount -p').split('\n'):
comps = re.sub(r"\s+", " ", line).split()
ret[comps[1]] = {'device': comps[0],
'fstype': comps[2],
... | [
"def",
"_active_mounts_freebsd",
"(",
"ret",
")",
":",
"for",
"line",
"in",
"__salt__",
"[",
"'cmd.run_stdout'",
"]",
"(",
"'mount -p'",
")",
".",
"split",
"(",
"'\\n'",
")",
":",
"comps",
"=",
"re",
".",
"sub",
"(",
"r\"\\s+\"",
",",
"\" \"",
",",
"li... | List active mounts on FreeBSD systems | [
"List",
"active",
"mounts",
"on",
"FreeBSD",
"systems"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L155-L164 | train |
saltstack/salt | salt/modules/mount.py | _active_mounts_openbsd | def _active_mounts_openbsd(ret):
'''
List active mounts on OpenBSD systems
'''
for line in __salt__['cmd.run_stdout']('mount -v').split('\n'):
comps = re.sub(r"\s+", " ", line).split()
parens = re.findall(r'\((.*?)\)', line, re.DOTALL)
if len(parens) > 1:
nod = __salt... | python | def _active_mounts_openbsd(ret):
'''
List active mounts on OpenBSD systems
'''
for line in __salt__['cmd.run_stdout']('mount -v').split('\n'):
comps = re.sub(r"\s+", " ", line).split()
parens = re.findall(r'\((.*?)\)', line, re.DOTALL)
if len(parens) > 1:
nod = __salt... | [
"def",
"_active_mounts_openbsd",
"(",
"ret",
")",
":",
"for",
"line",
"in",
"__salt__",
"[",
"'cmd.run_stdout'",
"]",
"(",
"'mount -v'",
")",
".",
"split",
"(",
"'\\n'",
")",
":",
"comps",
"=",
"re",
".",
"sub",
"(",
"r\"\\s+\"",
",",
"\" \"",
",",
"li... | List active mounts on OpenBSD systems | [
"List",
"active",
"mounts",
"on",
"OpenBSD",
"systems"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L179-L199 | train |
saltstack/salt | salt/modules/mount.py | _active_mounts_darwin | def _active_mounts_darwin(ret):
'''
List active mounts on Mac OS systems
'''
for line in __salt__['cmd.run_stdout']('mount').split('\n'):
comps = re.sub(r"\s+", " ", line).split()
parens = re.findall(r'\((.*?)\)', line, re.DOTALL)[0].split(", ")
ret[comps[2]] = {'device': comps[0... | python | def _active_mounts_darwin(ret):
'''
List active mounts on Mac OS systems
'''
for line in __salt__['cmd.run_stdout']('mount').split('\n'):
comps = re.sub(r"\s+", " ", line).split()
parens = re.findall(r'\((.*?)\)', line, re.DOTALL)[0].split(", ")
ret[comps[2]] = {'device': comps[0... | [
"def",
"_active_mounts_darwin",
"(",
"ret",
")",
":",
"for",
"line",
"in",
"__salt__",
"[",
"'cmd.run_stdout'",
"]",
"(",
"'mount'",
")",
".",
"split",
"(",
"'\\n'",
")",
":",
"comps",
"=",
"re",
".",
"sub",
"(",
"r\"\\s+\"",
",",
"\" \"",
",",
"line",... | List active mounts on Mac OS systems | [
"List",
"active",
"mounts",
"on",
"Mac",
"OS",
"systems"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L202-L212 | train |
saltstack/salt | salt/modules/mount.py | _resolve_user_group_names | def _resolve_user_group_names(opts):
'''
Resolve user and group names in related opts
'''
name_id_opts = {'uid': 'user.info',
'gid': 'group.info'}
for ind, opt in enumerate(opts):
if opt.split('=')[0] in name_id_opts:
_givenid = opt.split('=')[1]
_... | python | def _resolve_user_group_names(opts):
'''
Resolve user and group names in related opts
'''
name_id_opts = {'uid': 'user.info',
'gid': 'group.info'}
for ind, opt in enumerate(opts):
if opt.split('=')[0] in name_id_opts:
_givenid = opt.split('=')[1]
_... | [
"def",
"_resolve_user_group_names",
"(",
"opts",
")",
":",
"name_id_opts",
"=",
"{",
"'uid'",
":",
"'user.info'",
",",
"'gid'",
":",
"'group.info'",
"}",
"for",
"ind",
",",
"opt",
"in",
"enumerate",
"(",
"opts",
")",
":",
"if",
"opt",
".",
"split",
"(",
... | Resolve user and group names in related opts | [
"Resolve",
"user",
"and",
"group",
"names",
"in",
"related",
"opts"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L215-L232 | train |
saltstack/salt | salt/modules/mount.py | active | def active(extended=False):
'''
List the active mounts.
CLI Example:
.. code-block:: bash
salt '*' mount.active
'''
ret = {}
if __grains__['os'] == 'FreeBSD':
_active_mounts_freebsd(ret)
elif 'AIX' in __grains__['kernel']:
_active_mounts_aix(ret)
elif __gra... | python | def active(extended=False):
'''
List the active mounts.
CLI Example:
.. code-block:: bash
salt '*' mount.active
'''
ret = {}
if __grains__['os'] == 'FreeBSD':
_active_mounts_freebsd(ret)
elif 'AIX' in __grains__['kernel']:
_active_mounts_aix(ret)
elif __gra... | [
"def",
"active",
"(",
"extended",
"=",
"False",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"__grains__",
"[",
"'os'",
"]",
"==",
"'FreeBSD'",
":",
"_active_mounts_freebsd",
"(",
"ret",
")",
"elif",
"'AIX'",
"in",
"__grains__",
"[",
"'kernel'",
"]",
":",
"_a... | List the active mounts.
CLI Example:
.. code-block:: bash
salt '*' mount.active | [
"List",
"the",
"active",
"mounts",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L235-L264 | train |
saltstack/salt | salt/modules/mount.py | fstab | def fstab(config='/etc/fstab'):
'''
.. versionchanged:: 2016.3.2
List the contents of the fstab
CLI Example:
.. code-block:: bash
salt '*' mount.fstab
'''
ret = {}
if not os.path.isfile(config):
return ret
with salt.utils.files.fopen(config) as ifile:
for ... | python | def fstab(config='/etc/fstab'):
'''
.. versionchanged:: 2016.3.2
List the contents of the fstab
CLI Example:
.. code-block:: bash
salt '*' mount.fstab
'''
ret = {}
if not os.path.isfile(config):
return ret
with salt.utils.files.fopen(config) as ifile:
for ... | [
"def",
"fstab",
"(",
"config",
"=",
"'/etc/fstab'",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"config",
")",
":",
"return",
"ret",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"config",
... | .. versionchanged:: 2016.3.2
List the contents of the fstab
CLI Example:
.. code-block:: bash
salt '*' mount.fstab | [
"..",
"versionchanged",
"::",
"2016",
".",
"3",
".",
"2"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L577-L617 | train |
saltstack/salt | salt/modules/mount.py | rm_fstab | def rm_fstab(name, device, config='/etc/fstab'):
'''
.. versionchanged:: 2016.3.2
Remove the mount point from the fstab
CLI Example:
.. code-block:: bash
salt '*' mount.rm_fstab /mnt/foo /dev/sdg
'''
modified = False
if __grains__['kernel'] == 'SunOS':
criteria = _vf... | python | def rm_fstab(name, device, config='/etc/fstab'):
'''
.. versionchanged:: 2016.3.2
Remove the mount point from the fstab
CLI Example:
.. code-block:: bash
salt '*' mount.rm_fstab /mnt/foo /dev/sdg
'''
modified = False
if __grains__['kernel'] == 'SunOS':
criteria = _vf... | [
"def",
"rm_fstab",
"(",
"name",
",",
"device",
",",
"config",
"=",
"'/etc/fstab'",
")",
":",
"modified",
"=",
"False",
"if",
"__grains__",
"[",
"'kernel'",
"]",
"==",
"'SunOS'",
":",
"criteria",
"=",
"_vfstab_entry",
"(",
"name",
"=",
"name",
",",
"devic... | .. versionchanged:: 2016.3.2
Remove the mount point from the fstab
CLI Example:
.. code-block:: bash
salt '*' mount.rm_fstab /mnt/foo /dev/sdg | [
"..",
"versionchanged",
"::",
"2016",
".",
"3",
".",
"2"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L636-L685 | train |
saltstack/salt | salt/modules/mount.py | set_fstab | def set_fstab(
name,
device,
fstype,
opts='defaults',
dump=0,
pass_num=0,
config='/etc/fstab',
test=False,
match_on='auto',
**kwargs):
'''
Verify that this mount is represented in the fstab, change the mount
to match the data pa... | python | def set_fstab(
name,
device,
fstype,
opts='defaults',
dump=0,
pass_num=0,
config='/etc/fstab',
test=False,
match_on='auto',
**kwargs):
'''
Verify that this mount is represented in the fstab, change the mount
to match the data pa... | [
"def",
"set_fstab",
"(",
"name",
",",
"device",
",",
"fstype",
",",
"opts",
"=",
"'defaults'",
",",
"dump",
"=",
"0",
",",
"pass_num",
"=",
"0",
",",
"config",
"=",
"'/etc/fstab'",
",",
"test",
"=",
"False",
",",
"match_on",
"=",
"'auto'",
",",
"*",
... | Verify that this mount is represented in the fstab, change the mount
to match the data passed, or add the mount if it is not present.
CLI Example:
.. code-block:: bash
salt '*' mount.set_fstab /mnt/foo /dev/sdz1 ext4 | [
"Verify",
"that",
"this",
"mount",
"is",
"represented",
"in",
"the",
"fstab",
"change",
"the",
"mount",
"to",
"match",
"the",
"data",
"passed",
"or",
"add",
"the",
"mount",
"if",
"it",
"is",
"not",
"present",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L704-L826 | train |
saltstack/salt | salt/modules/mount.py | rm_automaster | def rm_automaster(name, device, config='/etc/auto_salt'):
'''
Remove the mount point from the auto_master
CLI Example:
.. code-block:: bash
salt '*' mount.rm_automaster /mnt/foo /dev/sdg
'''
contents = automaster(config)
if name not in contents:
return True
# The entry... | python | def rm_automaster(name, device, config='/etc/auto_salt'):
'''
Remove the mount point from the auto_master
CLI Example:
.. code-block:: bash
salt '*' mount.rm_automaster /mnt/foo /dev/sdg
'''
contents = automaster(config)
if name not in contents:
return True
# The entry... | [
"def",
"rm_automaster",
"(",
"name",
",",
"device",
",",
"config",
"=",
"'/etc/auto_salt'",
")",
":",
"contents",
"=",
"automaster",
"(",
"config",
")",
"if",
"name",
"not",
"in",
"contents",
":",
"return",
"True",
"# The entry is present, get rid of it",
"lines... | Remove the mount point from the auto_master
CLI Example:
.. code-block:: bash
salt '*' mount.rm_automaster /mnt/foo /dev/sdg | [
"Remove",
"the",
"mount",
"point",
"from",
"the",
"auto_master"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L958-L1016 | train |
saltstack/salt | salt/modules/mount.py | set_automaster | def set_automaster(
name,
device,
fstype,
opts='',
config='/etc/auto_salt',
test=False,
**kwargs):
'''
Verify that this mount is represented in the auto_salt, change the mount
to match the data passed, or add the mount if it is not present.
CLI Ex... | python | def set_automaster(
name,
device,
fstype,
opts='',
config='/etc/auto_salt',
test=False,
**kwargs):
'''
Verify that this mount is represented in the auto_salt, change the mount
to match the data passed, or add the mount if it is not present.
CLI Ex... | [
"def",
"set_automaster",
"(",
"name",
",",
"device",
",",
"fstype",
",",
"opts",
"=",
"''",
",",
"config",
"=",
"'/etc/auto_salt'",
",",
"test",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# Fix the opts type if it is a list",
"if",
"isinstance",
"(",
... | Verify that this mount is represented in the auto_salt, change the mount
to match the data passed, or add the mount if it is not present.
CLI Example:
.. code-block:: bash
salt '*' mount.set_automaster /mnt/foo /dev/sdz1 ext4 | [
"Verify",
"that",
"this",
"mount",
"is",
"represented",
"in",
"the",
"auto_salt",
"change",
"the",
"mount",
"to",
"match",
"the",
"data",
"passed",
"or",
"add",
"the",
"mount",
"if",
"it",
"is",
"not",
"present",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1019-L1136 | train |
saltstack/salt | salt/modules/mount.py | automaster | def automaster(config='/etc/auto_salt'):
'''
List the contents of the auto master
CLI Example:
.. code-block:: bash
salt '*' mount.automaster
'''
ret = {}
if not os.path.isfile(config):
return ret
with salt.utils.files.fopen(config) as ifile:
for line in ifile:... | python | def automaster(config='/etc/auto_salt'):
'''
List the contents of the auto master
CLI Example:
.. code-block:: bash
salt '*' mount.automaster
'''
ret = {}
if not os.path.isfile(config):
return ret
with salt.utils.files.fopen(config) as ifile:
for line in ifile:... | [
"def",
"automaster",
"(",
"config",
"=",
"'/etc/auto_salt'",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"config",
")",
":",
"return",
"ret",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"co... | List the contents of the auto master
CLI Example:
.. code-block:: bash
salt '*' mount.automaster | [
"List",
"the",
"contents",
"of",
"the",
"auto",
"master"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1139-L1174 | train |
saltstack/salt | salt/modules/mount.py | mount | def mount(name, device, mkmnt=False, fstype='', opts='defaults', user=None, util='mount'):
'''
Mount a device
CLI Example:
.. code-block:: bash
salt '*' mount.mount /mnt/foo /dev/sdz1 True
'''
if util != 'mount':
# This functionality used to live in img.mount_image
if ... | python | def mount(name, device, mkmnt=False, fstype='', opts='defaults', user=None, util='mount'):
'''
Mount a device
CLI Example:
.. code-block:: bash
salt '*' mount.mount /mnt/foo /dev/sdz1 True
'''
if util != 'mount':
# This functionality used to live in img.mount_image
if ... | [
"def",
"mount",
"(",
"name",
",",
"device",
",",
"mkmnt",
"=",
"False",
",",
"fstype",
"=",
"''",
",",
"opts",
"=",
"'defaults'",
",",
"user",
"=",
"None",
",",
"util",
"=",
"'mount'",
")",
":",
"if",
"util",
"!=",
"'mount'",
":",
"# This functionali... | Mount a device
CLI Example:
.. code-block:: bash
salt '*' mount.mount /mnt/foo /dev/sdz1 True | [
"Mount",
"a",
"device"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1177-L1230 | train |
saltstack/salt | salt/modules/mount.py | remount | def remount(name, device, mkmnt=False, fstype='', opts='defaults', user=None):
'''
Attempt to remount a device, if the device is not already mounted, mount
is called
CLI Example:
.. code-block:: bash
salt '*' mount.remount /mnt/foo /dev/sdz1 True
'''
force_mount = False
if __g... | python | def remount(name, device, mkmnt=False, fstype='', opts='defaults', user=None):
'''
Attempt to remount a device, if the device is not already mounted, mount
is called
CLI Example:
.. code-block:: bash
salt '*' mount.remount /mnt/foo /dev/sdz1 True
'''
force_mount = False
if __g... | [
"def",
"remount",
"(",
"name",
",",
"device",
",",
"mkmnt",
"=",
"False",
",",
"fstype",
"=",
"''",
",",
"opts",
"=",
"'defaults'",
",",
"user",
"=",
"None",
")",
":",
"force_mount",
"=",
"False",
"if",
"__grains__",
"[",
"'os'",
"]",
"in",
"[",
"'... | Attempt to remount a device, if the device is not already mounted, mount
is called
CLI Example:
.. code-block:: bash
salt '*' mount.remount /mnt/foo /dev/sdz1 True | [
"Attempt",
"to",
"remount",
"a",
"device",
"if",
"the",
"device",
"is",
"not",
"already",
"mounted",
"mount",
"is",
"called"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1233-L1288 | train |
saltstack/salt | salt/modules/mount.py | umount | def umount(name, device=None, user=None, util='mount'):
'''
Attempt to unmount a device by specifying the directory it is mounted on
CLI Example:
.. code-block:: bash
salt '*' mount.umount /mnt/foo
.. versionadded:: 2015.5.0
.. code-block:: bash
salt '*' mount.umount /mnt/fo... | python | def umount(name, device=None, user=None, util='mount'):
'''
Attempt to unmount a device by specifying the directory it is mounted on
CLI Example:
.. code-block:: bash
salt '*' mount.umount /mnt/foo
.. versionadded:: 2015.5.0
.. code-block:: bash
salt '*' mount.umount /mnt/fo... | [
"def",
"umount",
"(",
"name",
",",
"device",
"=",
"None",
",",
"user",
"=",
"None",
",",
"util",
"=",
"'mount'",
")",
":",
"if",
"util",
"!=",
"'mount'",
":",
"# This functionality used to live in img.umount_image",
"if",
"'qemu_nbd.clear'",
"in",
"__salt__",
... | Attempt to unmount a device by specifying the directory it is mounted on
CLI Example:
.. code-block:: bash
salt '*' mount.umount /mnt/foo
.. versionadded:: 2015.5.0
.. code-block:: bash
salt '*' mount.umount /mnt/foo /dev/xvdc1 | [
"Attempt",
"to",
"unmount",
"a",
"device",
"by",
"specifying",
"the",
"directory",
"it",
"is",
"mounted",
"on"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1291-L1324 | train |
saltstack/salt | salt/modules/mount.py | is_fuse_exec | def is_fuse_exec(cmd):
'''
Returns true if the command passed is a fuse mountable application.
CLI Example:
.. code-block:: bash
salt '*' mount.is_fuse_exec sshfs
'''
cmd_path = salt.utils.path.which(cmd)
# No point in running ldd on a command that doesn't exist
if not cmd_pa... | python | def is_fuse_exec(cmd):
'''
Returns true if the command passed is a fuse mountable application.
CLI Example:
.. code-block:: bash
salt '*' mount.is_fuse_exec sshfs
'''
cmd_path = salt.utils.path.which(cmd)
# No point in running ldd on a command that doesn't exist
if not cmd_pa... | [
"def",
"is_fuse_exec",
"(",
"cmd",
")",
":",
"cmd_path",
"=",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"cmd",
")",
"# No point in running ldd on a command that doesn't exist",
"if",
"not",
"cmd_path",
":",
"return",
"False",
"elif",
"not",
"salt",
... | Returns true if the command passed is a fuse mountable application.
CLI Example:
.. code-block:: bash
salt '*' mount.is_fuse_exec sshfs | [
"Returns",
"true",
"if",
"the",
"command",
"passed",
"is",
"a",
"fuse",
"mountable",
"application",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1327-L1346 | train |
saltstack/salt | salt/modules/mount.py | swaps | def swaps():
'''
Return a dict containing information on active swap
.. versionchanged:: 2016.3.2
CLI Example:
.. code-block:: bash
salt '*' mount.swaps
'''
ret = {}
if __grains__['kernel'] == 'SunOS':
for line in __salt__['cmd.run_stdout']('swap -l').splitlines():
... | python | def swaps():
'''
Return a dict containing information on active swap
.. versionchanged:: 2016.3.2
CLI Example:
.. code-block:: bash
salt '*' mount.swaps
'''
ret = {}
if __grains__['kernel'] == 'SunOS':
for line in __salt__['cmd.run_stdout']('swap -l').splitlines():
... | [
"def",
"swaps",
"(",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"__grains__",
"[",
"'kernel'",
"]",
"==",
"'SunOS'",
":",
"for",
"line",
"in",
"__salt__",
"[",
"'cmd.run_stdout'",
"]",
"(",
"'swap -l'",
")",
".",
"splitlines",
"(",
")",
":",
"if",
"line",... | Return a dict containing information on active swap
.. versionchanged:: 2016.3.2
CLI Example:
.. code-block:: bash
salt '*' mount.swaps | [
"Return",
"a",
"dict",
"containing",
"information",
"on",
"active",
"swap"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1349-L1405 | train |
saltstack/salt | salt/modules/mount.py | swapon | def swapon(name, priority=None):
'''
Activate a swap disk
.. versionchanged:: 2016.3.2
CLI Example:
.. code-block:: bash
salt '*' mount.swapon /root/swapfile
'''
ret = {}
on_ = swaps()
if name in on_:
ret['stats'] = on_[name]
ret['new'] = False
ret... | python | def swapon(name, priority=None):
'''
Activate a swap disk
.. versionchanged:: 2016.3.2
CLI Example:
.. code-block:: bash
salt '*' mount.swapon /root/swapfile
'''
ret = {}
on_ = swaps()
if name in on_:
ret['stats'] = on_[name]
ret['new'] = False
ret... | [
"def",
"swapon",
"(",
"name",
",",
"priority",
"=",
"None",
")",
":",
"ret",
"=",
"{",
"}",
"on_",
"=",
"swaps",
"(",
")",
"if",
"name",
"in",
"on_",
":",
"ret",
"[",
"'stats'",
"]",
"=",
"on_",
"[",
"name",
"]",
"ret",
"[",
"'new'",
"]",
"="... | Activate a swap disk
.. versionchanged:: 2016.3.2
CLI Example:
.. code-block:: bash
salt '*' mount.swapon /root/swapfile | [
"Activate",
"a",
"swap",
"disk"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1408-L1444 | train |
saltstack/salt | salt/modules/mount.py | swapoff | def swapoff(name):
'''
Deactivate a named swap mount
.. versionchanged:: 2016.3.2
CLI Example:
.. code-block:: bash
salt '*' mount.swapoff /root/swapfile
'''
on_ = swaps()
if name in on_:
if __grains__['kernel'] == 'SunOS':
if __grains__['virtual'] != 'zon... | python | def swapoff(name):
'''
Deactivate a named swap mount
.. versionchanged:: 2016.3.2
CLI Example:
.. code-block:: bash
salt '*' mount.swapoff /root/swapfile
'''
on_ = swaps()
if name in on_:
if __grains__['kernel'] == 'SunOS':
if __grains__['virtual'] != 'zon... | [
"def",
"swapoff",
"(",
"name",
")",
":",
"on_",
"=",
"swaps",
"(",
")",
"if",
"name",
"in",
"on_",
":",
"if",
"__grains__",
"[",
"'kernel'",
"]",
"==",
"'SunOS'",
":",
"if",
"__grains__",
"[",
"'virtual'",
"]",
"!=",
"'zone'",
":",
"__salt__",
"[",
... | Deactivate a named swap mount
.. versionchanged:: 2016.3.2
CLI Example:
.. code-block:: bash
salt '*' mount.swapoff /root/swapfile | [
"Deactivate",
"a",
"named",
"swap",
"mount"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1447-L1475 | train |
saltstack/salt | salt/modules/mount.py | read_mount_cache | def read_mount_cache(name):
'''
.. versionadded:: 2018.3.0
Provide information if the path is mounted
CLI Example:
.. code-block:: bash
salt '*' mount.read_mount_cache /mnt/share
'''
cache = salt.utils.mount.read_cache(__opts__)
if cache:
if 'mounts' in cache and cach... | python | def read_mount_cache(name):
'''
.. versionadded:: 2018.3.0
Provide information if the path is mounted
CLI Example:
.. code-block:: bash
salt '*' mount.read_mount_cache /mnt/share
'''
cache = salt.utils.mount.read_cache(__opts__)
if cache:
if 'mounts' in cache and cach... | [
"def",
"read_mount_cache",
"(",
"name",
")",
":",
"cache",
"=",
"salt",
".",
"utils",
".",
"mount",
".",
"read_cache",
"(",
"__opts__",
")",
"if",
"cache",
":",
"if",
"'mounts'",
"in",
"cache",
"and",
"cache",
"[",
"'mounts'",
"]",
":",
"if",
"name",
... | .. versionadded:: 2018.3.0
Provide information if the path is mounted
CLI Example:
.. code-block:: bash
salt '*' mount.read_mount_cache /mnt/share | [
"..",
"versionadded",
"::",
"2018",
".",
"3",
".",
"0"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1497-L1514 | train |
saltstack/salt | salt/modules/mount.py | write_mount_cache | def write_mount_cache(real_name,
device,
mkmnt,
fstype,
mount_opts):
'''
.. versionadded:: 2018.3.0
Provide information if the path is mounted
:param real_name: The real name of the mount point where the device... | python | def write_mount_cache(real_name,
device,
mkmnt,
fstype,
mount_opts):
'''
.. versionadded:: 2018.3.0
Provide information if the path is mounted
:param real_name: The real name of the mount point where the device... | [
"def",
"write_mount_cache",
"(",
"real_name",
",",
"device",
",",
"mkmnt",
",",
"fstype",
",",
"mount_opts",
")",
":",
"cache",
"=",
"salt",
".",
"utils",
".",
"mount",
".",
"read_cache",
"(",
"__opts__",
")",
"if",
"not",
"cache",
":",
"cache",
"=",
"... | .. versionadded:: 2018.3.0
Provide information if the path is mounted
:param real_name: The real name of the mount point where the device is mounted.
:param device: The device that is being mounted.
:param mkmnt: Whether or not the mount point should be created.
:param fstype: ... | [
"..",
"versionadded",
"::",
"2018",
".",
"3",
".",
"0"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1517-L1558 | train |
saltstack/salt | salt/modules/mount.py | delete_mount_cache | def delete_mount_cache(real_name):
'''
.. versionadded:: 2018.3.0
Provide information if the path is mounted
CLI Example:
.. code-block:: bash
salt '*' mount.delete_mount_cache /mnt/share
'''
cache = salt.utils.mount.read_cache(__opts__)
if cache:
if 'mounts' in cach... | python | def delete_mount_cache(real_name):
'''
.. versionadded:: 2018.3.0
Provide information if the path is mounted
CLI Example:
.. code-block:: bash
salt '*' mount.delete_mount_cache /mnt/share
'''
cache = salt.utils.mount.read_cache(__opts__)
if cache:
if 'mounts' in cach... | [
"def",
"delete_mount_cache",
"(",
"real_name",
")",
":",
"cache",
"=",
"salt",
".",
"utils",
".",
"mount",
".",
"read_cache",
"(",
"__opts__",
")",
"if",
"cache",
":",
"if",
"'mounts'",
"in",
"cache",
":",
"if",
"real_name",
"in",
"cache",
"[",
"'mounts'... | .. versionadded:: 2018.3.0
Provide information if the path is mounted
CLI Example:
.. code-block:: bash
salt '*' mount.delete_mount_cache /mnt/share | [
"..",
"versionadded",
"::",
"2018",
".",
"3",
".",
"0"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1561-L1582 | train |
saltstack/salt | salt/modules/mount.py | _filesystems | def _filesystems(config='/etc/filesystems', leading_key=True):
'''
Return the contents of the filesystems in an OrderedDict
config
File containing filesystem infomation
leading_key
True return dictionary keyed by 'name' and value as dictionary with other keys, values (name excluded)... | python | def _filesystems(config='/etc/filesystems', leading_key=True):
'''
Return the contents of the filesystems in an OrderedDict
config
File containing filesystem infomation
leading_key
True return dictionary keyed by 'name' and value as dictionary with other keys, values (name excluded)... | [
"def",
"_filesystems",
"(",
"config",
"=",
"'/etc/filesystems'",
",",
"leading_key",
"=",
"True",
")",
":",
"ret",
"=",
"OrderedDict",
"(",
")",
"lines",
"=",
"[",
"]",
"parsing_block",
"=",
"False",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
... | Return the contents of the filesystems in an OrderedDict
config
File containing filesystem infomation
leading_key
True return dictionary keyed by 'name' and value as dictionary with other keys, values (name excluded)
OrderedDict({ '/dir' : OrderedDict({'dev': '/dev/hd8', ...... | [
"Return",
"the",
"contents",
"of",
"the",
"filesystems",
"in",
"an",
"OrderedDict"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1585-L1639 | train |
saltstack/salt | salt/modules/mount.py | filesystems | def filesystems(config='/etc/filesystems'):
'''
.. versionadded:: 2018.3.3
List the contents of the filesystems
CLI Example:
.. code-block:: bash
salt '*' mount.filesystems
'''
ret = {}
if 'AIX' not in __grains__['kernel']:
return ret
ret_dict = _filesystems(conf... | python | def filesystems(config='/etc/filesystems'):
'''
.. versionadded:: 2018.3.3
List the contents of the filesystems
CLI Example:
.. code-block:: bash
salt '*' mount.filesystems
'''
ret = {}
if 'AIX' not in __grains__['kernel']:
return ret
ret_dict = _filesystems(conf... | [
"def",
"filesystems",
"(",
"config",
"=",
"'/etc/filesystems'",
")",
":",
"ret",
"=",
"{",
"}",
"if",
"'AIX'",
"not",
"in",
"__grains__",
"[",
"'kernel'",
"]",
":",
"return",
"ret",
"ret_dict",
"=",
"_filesystems",
"(",
"config",
")",
"if",
"ret_dict",
"... | .. versionadded:: 2018.3.3
List the contents of the filesystems
CLI Example:
.. code-block:: bash
salt '*' mount.filesystems | [
"..",
"versionadded",
"::",
"2018",
".",
"3",
".",
"3"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1642-L1663 | train |
saltstack/salt | salt/modules/mount.py | set_filesystems | def set_filesystems(
name,
device,
vfstype,
opts='-',
mount='true',
config='/etc/filesystems',
test=False,
match_on='auto',
**kwargs):
'''
.. versionadded:: 2018.3.3
Verify that this mount is represented in the filesystems, change the ... | python | def set_filesystems(
name,
device,
vfstype,
opts='-',
mount='true',
config='/etc/filesystems',
test=False,
match_on='auto',
**kwargs):
'''
.. versionadded:: 2018.3.3
Verify that this mount is represented in the filesystems, change the ... | [
"def",
"set_filesystems",
"(",
"name",
",",
"device",
",",
"vfstype",
",",
"opts",
"=",
"'-'",
",",
"mount",
"=",
"'true'",
",",
"config",
"=",
"'/etc/filesystems'",
",",
"test",
"=",
"False",
",",
"match_on",
"=",
"'auto'",
",",
"*",
"*",
"kwargs",
")... | .. versionadded:: 2018.3.3
Verify that this mount is represented in the filesystems, change the mount
to match the data passed, or add the mount if it is not present on AIX
Provide information if the path is mounted
:param name: The name of the mount point where the device is mounted.
... | [
"..",
"versionadded",
"::",
"2018",
".",
"3",
".",
"3"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1666-L1810 | train |
saltstack/salt | salt/modules/mount.py | rm_filesystems | def rm_filesystems(name, device, config='/etc/filesystems'):
'''
.. versionadded:: 2018.3.3
Remove the mount point from the filesystems
CLI Example:
.. code-block:: bash
salt '*' mount.rm_filesystems /mnt/foo /dev/sdg
'''
modified = False
view_lines = []
if 'AIX' not in ... | python | def rm_filesystems(name, device, config='/etc/filesystems'):
'''
.. versionadded:: 2018.3.3
Remove the mount point from the filesystems
CLI Example:
.. code-block:: bash
salt '*' mount.rm_filesystems /mnt/foo /dev/sdg
'''
modified = False
view_lines = []
if 'AIX' not in ... | [
"def",
"rm_filesystems",
"(",
"name",
",",
"device",
",",
"config",
"=",
"'/etc/filesystems'",
")",
":",
"modified",
"=",
"False",
"view_lines",
"=",
"[",
"]",
"if",
"'AIX'",
"not",
"in",
"__grains__",
"[",
"'kernel'",
"]",
":",
"return",
"modified",
"crit... | .. versionadded:: 2018.3.3
Remove the mount point from the filesystems
CLI Example:
.. code-block:: bash
salt '*' mount.rm_filesystems /mnt/foo /dev/sdg | [
"..",
"versionadded",
"::",
"2018",
".",
"3",
".",
"3"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1813-L1857 | train |
saltstack/salt | salt/modules/mount.py | _fstab_entry.pick | def pick(self, keys):
'''
Returns an instance with just those keys
'''
subset = dict([(key, self.criteria[key]) for key in keys])
return self.__class__(**subset) | python | def pick(self, keys):
'''
Returns an instance with just those keys
'''
subset = dict([(key, self.criteria[key]) for key in keys])
return self.__class__(**subset) | [
"def",
"pick",
"(",
"self",
",",
"keys",
")",
":",
"subset",
"=",
"dict",
"(",
"[",
"(",
"key",
",",
"self",
".",
"criteria",
"[",
"key",
"]",
")",
"for",
"key",
"in",
"keys",
"]",
")",
"return",
"self",
".",
"__class__",
"(",
"*",
"*",
"subset... | Returns an instance with just those keys | [
"Returns",
"an",
"instance",
"with",
"just",
"those",
"keys"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L323-L328 | train |
saltstack/salt | salt/modules/mount.py | _fstab_entry.match | def match(self, line):
'''
Compare potentially partial criteria against line
'''
entry = self.dict_from_line(line)
for key, value in six.iteritems(self.criteria):
if entry[key] != value:
return False
return True | python | def match(self, line):
'''
Compare potentially partial criteria against line
'''
entry = self.dict_from_line(line)
for key, value in six.iteritems(self.criteria):
if entry[key] != value:
return False
return True | [
"def",
"match",
"(",
"self",
",",
"line",
")",
":",
"entry",
"=",
"self",
".",
"dict_from_line",
"(",
"line",
")",
"for",
"key",
",",
"value",
"in",
"six",
".",
"iteritems",
"(",
"self",
".",
"criteria",
")",
":",
"if",
"entry",
"[",
"key",
"]",
... | Compare potentially partial criteria against line | [
"Compare",
"potentially",
"partial",
"criteria",
"against",
"line"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L345-L353 | train |
saltstack/salt | salt/modules/mount.py | _FileSystemsEntry.match | def match(self, fsys_view):
'''
Compare potentially partial criteria against built filesystems entry dictionary
'''
evalue_dict = fsys_view[1]
for key, value in six.viewitems(self.criteria):
if key in evalue_dict:
if evalue_dict[key] != value:
... | python | def match(self, fsys_view):
'''
Compare potentially partial criteria against built filesystems entry dictionary
'''
evalue_dict = fsys_view[1]
for key, value in six.viewitems(self.criteria):
if key in evalue_dict:
if evalue_dict[key] != value:
... | [
"def",
"match",
"(",
"self",
",",
"fsys_view",
")",
":",
"evalue_dict",
"=",
"fsys_view",
"[",
"1",
"]",
"for",
"key",
",",
"value",
"in",
"six",
".",
"viewitems",
"(",
"self",
".",
"criteria",
")",
":",
"if",
"key",
"in",
"evalue_dict",
":",
"if",
... | Compare potentially partial criteria against built filesystems entry dictionary | [
"Compare",
"potentially",
"partial",
"criteria",
"against",
"built",
"filesystems",
"entry",
"dictionary"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L557-L568 | train |
saltstack/salt | salt/utils/napalm.py | virtual | def virtual(opts, virtualname, filename):
'''
Returns the __virtual__.
'''
if ((HAS_NAPALM and NAPALM_MAJOR >= 2) or HAS_NAPALM_BASE) and (is_proxy(opts) or is_minion(opts)):
return virtualname
else:
return (
False,
(
'"{vname}"" {filename} can... | python | def virtual(opts, virtualname, filename):
'''
Returns the __virtual__.
'''
if ((HAS_NAPALM and NAPALM_MAJOR >= 2) or HAS_NAPALM_BASE) and (is_proxy(opts) or is_minion(opts)):
return virtualname
else:
return (
False,
(
'"{vname}"" {filename} can... | [
"def",
"virtual",
"(",
"opts",
",",
"virtualname",
",",
"filename",
")",
":",
"if",
"(",
"(",
"HAS_NAPALM",
"and",
"NAPALM_MAJOR",
">=",
"2",
")",
"or",
"HAS_NAPALM_BASE",
")",
"and",
"(",
"is_proxy",
"(",
"opts",
")",
"or",
"is_minion",
"(",
"opts",
"... | Returns the __virtual__. | [
"Returns",
"the",
"__virtual__",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/napalm.py#L94-L110 | train |
saltstack/salt | salt/utils/napalm.py | call | def call(napalm_device, method, *args, **kwargs):
'''
Calls arbitrary methods from the network driver instance.
Please check the readthedocs_ page for the updated list of getters.
.. _readthedocs: http://napalm.readthedocs.org/en/latest/support/index.html#getters-support-matrix
method
Spec... | python | def call(napalm_device, method, *args, **kwargs):
'''
Calls arbitrary methods from the network driver instance.
Please check the readthedocs_ page for the updated list of getters.
.. _readthedocs: http://napalm.readthedocs.org/en/latest/support/index.html#getters-support-matrix
method
Spec... | [
"def",
"call",
"(",
"napalm_device",
",",
"method",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"result",
"=",
"False",
"out",
"=",
"None",
"opts",
"=",
"napalm_device",
".",
"get",
"(",
"'__opts__'",
",",
"{",
"}",
")",
"retry",
"=",
"kwa... | Calls arbitrary methods from the network driver instance.
Please check the readthedocs_ page for the updated list of getters.
.. _readthedocs: http://napalm.readthedocs.org/en/latest/support/index.html#getters-support-matrix
method
Specifies the name of the method to be called.
*args
... | [
"Calls",
"arbitrary",
"methods",
"from",
"the",
"network",
"driver",
"instance",
".",
"Please",
"check",
"the",
"readthedocs_",
"page",
"for",
"the",
"updated",
"list",
"of",
"getters",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/napalm.py#L113-L258 | train |
saltstack/salt | salt/utils/napalm.py | get_device_opts | def get_device_opts(opts, salt_obj=None):
'''
Returns the options of the napalm device.
:pram: opts
:return: the network device opts
'''
network_device = {}
# by default, look in the proxy config details
device_dict = opts.get('proxy', {}) if is_proxy(opts) else opts.get('napalm', {})
... | python | def get_device_opts(opts, salt_obj=None):
'''
Returns the options of the napalm device.
:pram: opts
:return: the network device opts
'''
network_device = {}
# by default, look in the proxy config details
device_dict = opts.get('proxy', {}) if is_proxy(opts) else opts.get('napalm', {})
... | [
"def",
"get_device_opts",
"(",
"opts",
",",
"salt_obj",
"=",
"None",
")",
":",
"network_device",
"=",
"{",
"}",
"# by default, look in the proxy config details",
"device_dict",
"=",
"opts",
".",
"get",
"(",
"'proxy'",
",",
"{",
"}",
")",
"if",
"is_proxy",
"(",... | Returns the options of the napalm device.
:pram: opts
:return: the network device opts | [
"Returns",
"the",
"options",
"of",
"the",
"napalm",
"device",
".",
":",
"pram",
":",
"opts",
":",
"return",
":",
"the",
"network",
"device",
"opts"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/napalm.py#L261-L301 | train |
saltstack/salt | salt/utils/napalm.py | get_device | def get_device(opts, salt_obj=None):
'''
Initialise the connection with the network device through NAPALM.
:param: opts
:return: the network device object
'''
log.debug('Setting up NAPALM connection')
network_device = get_device_opts(opts, salt_obj=salt_obj)
provider_lib = napalm_base
... | python | def get_device(opts, salt_obj=None):
'''
Initialise the connection with the network device through NAPALM.
:param: opts
:return: the network device object
'''
log.debug('Setting up NAPALM connection')
network_device = get_device_opts(opts, salt_obj=salt_obj)
provider_lib = napalm_base
... | [
"def",
"get_device",
"(",
"opts",
",",
"salt_obj",
"=",
"None",
")",
":",
"log",
".",
"debug",
"(",
"'Setting up NAPALM connection'",
")",
"network_device",
"=",
"get_device_opts",
"(",
"opts",
",",
"salt_obj",
"=",
"salt_obj",
")",
"provider_lib",
"=",
"napal... | Initialise the connection with the network device through NAPALM.
:param: opts
:return: the network device object | [
"Initialise",
"the",
"connection",
"with",
"the",
"network",
"device",
"through",
"NAPALM",
".",
":",
"param",
":",
"opts",
":",
"return",
":",
"the",
"network",
"device",
"object"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/napalm.py#L304-L355 | train |
saltstack/salt | salt/utils/napalm.py | proxy_napalm_wrap | def proxy_napalm_wrap(func):
'''
This decorator is used to make the execution module functions
available outside a proxy minion, or when running inside a proxy
minion. If we are running in a proxy, retrieve the connection details
from the __proxy__ injected variable. If we are not, then
use the... | python | def proxy_napalm_wrap(func):
'''
This decorator is used to make the execution module functions
available outside a proxy minion, or when running inside a proxy
minion. If we are running in a proxy, retrieve the connection details
from the __proxy__ injected variable. If we are not, then
use the... | [
"def",
"proxy_napalm_wrap",
"(",
"func",
")",
":",
"@",
"wraps",
"(",
"func",
")",
"def",
"func_wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"wrapped_global_namespace",
"=",
"func",
".",
"__globals__",
"# get __opts__ and __proxy__ from func_gl... | This decorator is used to make the execution module functions
available outside a proxy minion, or when running inside a proxy
minion. If we are running in a proxy, retrieve the connection details
from the __proxy__ injected variable. If we are not, then
use the connection information from the opts.
... | [
"This",
"decorator",
"is",
"used",
"to",
"make",
"the",
"execution",
"module",
"functions",
"available",
"outside",
"a",
"proxy",
"minion",
"or",
"when",
"running",
"inside",
"a",
"proxy",
"minion",
".",
"If",
"we",
"are",
"running",
"in",
"a",
"proxy",
"r... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/napalm.py#L358-L486 | train |
saltstack/salt | salt/utils/napalm.py | loaded_ret | def loaded_ret(ret, loaded, test, debug, compliance_report=False, opts=None):
'''
Return the final state output.
ret
The initial state output structure.
loaded
The loaded dictionary.
'''
# Always get the comment
changes = {}
ret['comment'] = loaded['comment']
if 'diff... | python | def loaded_ret(ret, loaded, test, debug, compliance_report=False, opts=None):
'''
Return the final state output.
ret
The initial state output structure.
loaded
The loaded dictionary.
'''
# Always get the comment
changes = {}
ret['comment'] = loaded['comment']
if 'diff... | [
"def",
"loaded_ret",
"(",
"ret",
",",
"loaded",
",",
"test",
",",
"debug",
",",
"compliance_report",
"=",
"False",
",",
"opts",
"=",
"None",
")",
":",
"# Always get the comment",
"changes",
"=",
"{",
"}",
"ret",
"[",
"'comment'",
"]",
"=",
"loaded",
"[",... | Return the final state output.
ret
The initial state output structure.
loaded
The loaded dictionary. | [
"Return",
"the",
"final",
"state",
"output",
".",
"ret",
"The",
"initial",
"state",
"output",
"structure",
".",
"loaded",
"The",
"loaded",
"dictionary",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/napalm.py#L502-L553 | train |
saltstack/salt | salt/engines/webhook.py | start | def start(address=None, port=5000, ssl_crt=None, ssl_key=None):
'''
Api to listen for webhooks to send to the reactor.
Implement the webhook behavior in an engine.
:py:class:`rest_cherrypy Webhook docs <salt.netapi.rest_cherrypy.app.Webhook>`
Unlike the rest_cherrypy Webhook, this is only an unaut... | python | def start(address=None, port=5000, ssl_crt=None, ssl_key=None):
'''
Api to listen for webhooks to send to the reactor.
Implement the webhook behavior in an engine.
:py:class:`rest_cherrypy Webhook docs <salt.netapi.rest_cherrypy.app.Webhook>`
Unlike the rest_cherrypy Webhook, this is only an unaut... | [
"def",
"start",
"(",
"address",
"=",
"None",
",",
"port",
"=",
"5000",
",",
"ssl_crt",
"=",
"None",
",",
"ssl_key",
"=",
"None",
")",
":",
"if",
"__opts__",
".",
"get",
"(",
"'__role'",
")",
"==",
"'master'",
":",
"fire_master",
"=",
"salt",
".",
"... | Api to listen for webhooks to send to the reactor.
Implement the webhook behavior in an engine.
:py:class:`rest_cherrypy Webhook docs <salt.netapi.rest_cherrypy.app.Webhook>`
Unlike the rest_cherrypy Webhook, this is only an unauthenticated webhook
endpoint. If an authenticated webhook endpoint is ne... | [
"Api",
"to",
"listen",
"for",
"webhooks",
"to",
"send",
"to",
"the",
"reactor",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/webhook.py#L17-L88 | train |
saltstack/salt | salt/states/win_wua.py | installed | def installed(name, updates=None):
'''
Ensure Microsoft Updates are installed. Updates will be downloaded if
needed.
Args:
name (str):
The identifier of a single update to install.
updates (list):
A list of identifiers for updates to be installed. Overrides
... | python | def installed(name, updates=None):
'''
Ensure Microsoft Updates are installed. Updates will be downloaded if
needed.
Args:
name (str):
The identifier of a single update to install.
updates (list):
A list of identifiers for updates to be installed. Overrides
... | [
"def",
"installed",
"(",
"name",
",",
"updates",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"updates",
",",
"six",
".",
"string_types",
")",
":",
"updates",
"=",
"[",
"updates",
"]",
"if",
"not",
"updates",
":",
"updates",
"=",
"name",
"ret",
"=... | Ensure Microsoft Updates are installed. Updates will be downloaded if
needed.
Args:
name (str):
The identifier of a single update to install.
updates (list):
A list of identifiers for updates to be installed. Overrides
``name``. Default is None.
.. not... | [
"Ensure",
"Microsoft",
"Updates",
"are",
"installed",
".",
"Updates",
"will",
"be",
"downloaded",
"if",
"needed",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_wua.py#L80-L211 | train |
saltstack/salt | salt/states/win_wua.py | removed | def removed(name, updates=None):
'''
Ensure Microsoft Updates are uninstalled.
Args:
name (str):
The identifier of a single update to uninstall.
updates (list):
A list of identifiers for updates to be removed. Overrides ``name``.
Default is None.
.... | python | def removed(name, updates=None):
'''
Ensure Microsoft Updates are uninstalled.
Args:
name (str):
The identifier of a single update to uninstall.
updates (list):
A list of identifiers for updates to be removed. Overrides ``name``.
Default is None.
.... | [
"def",
"removed",
"(",
"name",
",",
"updates",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"updates",
",",
"six",
".",
"string_types",
")",
":",
"updates",
"=",
"[",
"updates",
"]",
"if",
"not",
"updates",
":",
"updates",
"=",
"name",
"ret",
"=",... | Ensure Microsoft Updates are uninstalled.
Args:
name (str):
The identifier of a single update to uninstall.
updates (list):
A list of identifiers for updates to be removed. Overrides ``name``.
Default is None.
.. note:: Identifiers can be the GUID, the KB ... | [
"Ensure",
"Microsoft",
"Updates",
"are",
"uninstalled",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_wua.py#L214-L335 | train |
saltstack/salt | salt/states/win_wua.py | uptodate | def uptodate(name,
software=True,
drivers=False,
skip_hidden=False,
skip_mandatory=False,
skip_reboot=True,
categories=None,
severities=None,):
'''
Ensure Microsoft Updates that match the passed criteria are installed.
... | python | def uptodate(name,
software=True,
drivers=False,
skip_hidden=False,
skip_mandatory=False,
skip_reboot=True,
categories=None,
severities=None,):
'''
Ensure Microsoft Updates that match the passed criteria are installed.
... | [
"def",
"uptodate",
"(",
"name",
",",
"software",
"=",
"True",
",",
"drivers",
"=",
"False",
",",
"skip_hidden",
"=",
"False",
",",
"skip_mandatory",
"=",
"False",
",",
"skip_reboot",
"=",
"True",
",",
"categories",
"=",
"None",
",",
"severities",
"=",
"N... | Ensure Microsoft Updates that match the passed criteria are installed.
Updates will be downloaded if needed.
This state allows you to update a system without specifying a specific
update to apply. All matching updates will be installed.
Args:
name (str):
The name has no functional... | [
"Ensure",
"Microsoft",
"Updates",
"that",
"match",
"the",
"passed",
"criteria",
"are",
"installed",
".",
"Updates",
"will",
"be",
"downloaded",
"if",
"needed",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_wua.py#L338-L504 | train |
saltstack/salt | salt/log/handlers/fluent_mod.py | MessageFormatter.format_graylog_v0 | def format_graylog_v0(self, record):
'''
Graylog 'raw' format is essentially the raw record, minimally munged to provide
the bare minimum that td-agent requires to accept and route the event. This is
well suited to a config where the client td-agents log directly to Graylog.
'''... | python | def format_graylog_v0(self, record):
'''
Graylog 'raw' format is essentially the raw record, minimally munged to provide
the bare minimum that td-agent requires to accept and route the event. This is
well suited to a config where the client td-agents log directly to Graylog.
'''... | [
"def",
"format_graylog_v0",
"(",
"self",
",",
"record",
")",
":",
"message_dict",
"=",
"{",
"'message'",
":",
"record",
".",
"getMessage",
"(",
")",
",",
"'timestamp'",
":",
"self",
".",
"formatTime",
"(",
"record",
")",
",",
"# Graylog uses syslog levels, not... | Graylog 'raw' format is essentially the raw record, minimally munged to provide
the bare minimum that td-agent requires to accept and route the event. This is
well suited to a config where the client td-agents log directly to Graylog. | [
"Graylog",
"raw",
"format",
"is",
"essentially",
"the",
"raw",
"record",
"minimally",
"munged",
"to",
"provide",
"the",
"bare",
"minimum",
"that",
"td",
"-",
"agent",
"requires",
"to",
"accept",
"and",
"route",
"the",
"event",
".",
"This",
"is",
"well",
"s... | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/log/handlers/fluent_mod.py#L218-L249 | train |
saltstack/salt | salt/log/handlers/fluent_mod.py | MessageFormatter.format_logstash_v0 | def format_logstash_v0(self, record):
'''
Messages are formatted in logstash's expected format.
'''
host = salt.utils.network.get_fqhostname()
message_dict = {
'@timestamp': self.formatTime(record),
'@fields': {
'levelname': record.levelnam... | python | def format_logstash_v0(self, record):
'''
Messages are formatted in logstash's expected format.
'''
host = salt.utils.network.get_fqhostname()
message_dict = {
'@timestamp': self.formatTime(record),
'@fields': {
'levelname': record.levelnam... | [
"def",
"format_logstash_v0",
"(",
"self",
",",
"record",
")",
":",
"host",
"=",
"salt",
".",
"utils",
".",
"network",
".",
"get_fqhostname",
"(",
")",
"message_dict",
"=",
"{",
"'@timestamp'",
":",
"self",
".",
"formatTime",
"(",
"record",
")",
",",
"'@f... | Messages are formatted in logstash's expected format. | [
"Messages",
"are",
"formatted",
"in",
"logstash",
"s",
"expected",
"format",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/log/handlers/fluent_mod.py#L286-L339 | train |
saltstack/salt | salt/wheel/minions.py | connected | def connected():
'''
List all connected minions on a salt-master
'''
opts = salt.config.master_config(__opts__['conf_file'])
if opts.get('con_cache'):
cache_cli = CacheCli(opts)
minions = cache_cli.get_cached()
else:
minions = list(salt.utils.minions.CkMinions(opts).conn... | python | def connected():
'''
List all connected minions on a salt-master
'''
opts = salt.config.master_config(__opts__['conf_file'])
if opts.get('con_cache'):
cache_cli = CacheCli(opts)
minions = cache_cli.get_cached()
else:
minions = list(salt.utils.minions.CkMinions(opts).conn... | [
"def",
"connected",
"(",
")",
":",
"opts",
"=",
"salt",
".",
"config",
".",
"master_config",
"(",
"__opts__",
"[",
"'conf_file'",
"]",
")",
"if",
"opts",
".",
"get",
"(",
"'con_cache'",
")",
":",
"cache_cli",
"=",
"CacheCli",
"(",
"opts",
")",
"minions... | List all connected minions on a salt-master | [
"List",
"all",
"connected",
"minions",
"on",
"a",
"salt",
"-",
"master"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/wheel/minions.py#L15-L26 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | get_configured_provider | def get_configured_provider():
'''
Return the first configured instance.
'''
return config.is_provider_configured(
opts=__opts__,
provider=__active_provider_name__ or __virtualname__,
aliases=__virtual_aliases__,
required_keys=('personal_access_token',)
) | python | def get_configured_provider():
'''
Return the first configured instance.
'''
return config.is_provider_configured(
opts=__opts__,
provider=__active_provider_name__ or __virtualname__,
aliases=__virtual_aliases__,
required_keys=('personal_access_token',)
) | [
"def",
"get_configured_provider",
"(",
")",
":",
"return",
"config",
".",
"is_provider_configured",
"(",
"opts",
"=",
"__opts__",
",",
"provider",
"=",
"__active_provider_name__",
"or",
"__virtualname__",
",",
"aliases",
"=",
"__virtual_aliases__",
",",
"required_keys... | Return the first configured instance. | [
"Return",
"the",
"first",
"configured",
"instance",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L81-L90 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | avail_locations | def avail_locations(call=None):
'''
Return a dict of all available VM locations on the cloud provider with
relevant data
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_locations function must be called with '
'-f or --function, or with the --list-locat... | python | def avail_locations(call=None):
'''
Return a dict of all available VM locations on the cloud provider with
relevant data
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_locations function must be called with '
'-f or --function, or with the --list-locat... | [
"def",
"avail_locations",
"(",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The avail_locations function must be called with '",
"'-f or --function, or with the --list-locations option'",
")",
"items",
"=",
"quer... | Return a dict of all available VM locations on the cloud provider with
relevant data | [
"Return",
"a",
"dict",
"of",
"all",
"available",
"VM",
"locations",
"on",
"the",
"cloud",
"provider",
"with",
"relevant",
"data"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L103-L121 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | avail_images | def avail_images(call=None):
'''
Return a list of the images that are on the provider
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_images function must be called with '
'-f or --function, or with the --list-images option'
)
fetch = True
... | python | def avail_images(call=None):
'''
Return a list of the images that are on the provider
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_images function must be called with '
'-f or --function, or with the --list-images option'
)
fetch = True
... | [
"def",
"avail_images",
"(",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The avail_images function must be called with '",
"'-f or --function, or with the --list-images option'",
")",
"fetch",
"=",
"True",
"pag... | Return a list of the images that are on the provider | [
"Return",
"a",
"list",
"of",
"the",
"images",
"that",
"are",
"on",
"the",
"provider"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L124-L152 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | avail_sizes | def avail_sizes(call=None):
'''
Return a list of the image sizes that are on the provider
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_sizes function must be called with '
'-f or --function, or with the --list-sizes option'
)
items = query(m... | python | def avail_sizes(call=None):
'''
Return a list of the image sizes that are on the provider
'''
if call == 'action':
raise SaltCloudSystemExit(
'The avail_sizes function must be called with '
'-f or --function, or with the --list-sizes option'
)
items = query(m... | [
"def",
"avail_sizes",
"(",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The avail_sizes function must be called with '",
"'-f or --function, or with the --list-sizes option'",
")",
"items",
"=",
"query",
"(",
... | Return a list of the image sizes that are on the provider | [
"Return",
"a",
"list",
"of",
"the",
"image",
"sizes",
"that",
"are",
"on",
"the",
"provider"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L155-L172 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | list_nodes_full | def list_nodes_full(call=None, for_output=True):
'''
Return a list of the VMs that are on the provider
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes_full function must be called with -f or --function.'
)
return _list_nodes(full=True, for_output=for_o... | python | def list_nodes_full(call=None, for_output=True):
'''
Return a list of the VMs that are on the provider
'''
if call == 'action':
raise SaltCloudSystemExit(
'The list_nodes_full function must be called with -f or --function.'
)
return _list_nodes(full=True, for_output=for_o... | [
"def",
"list_nodes_full",
"(",
"call",
"=",
"None",
",",
"for_output",
"=",
"True",
")",
":",
"if",
"call",
"==",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The list_nodes_full function must be called with -f or --function.'",
")",
"return",
"_list_nodes",
... | Return a list of the VMs that are on the provider | [
"Return",
"a",
"list",
"of",
"the",
"VMs",
"that",
"are",
"on",
"the",
"provider"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L186-L194 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | get_image | def get_image(vm_):
'''
Return the image object to use
'''
images = avail_images()
vm_image = config.get_cloud_config_value(
'image', vm_, __opts__, search_global=False
)
if not isinstance(vm_image, six.string_types):
vm_image = six.text_type(vm_image)
for image in image... | python | def get_image(vm_):
'''
Return the image object to use
'''
images = avail_images()
vm_image = config.get_cloud_config_value(
'image', vm_, __opts__, search_global=False
)
if not isinstance(vm_image, six.string_types):
vm_image = six.text_type(vm_image)
for image in image... | [
"def",
"get_image",
"(",
"vm_",
")",
":",
"images",
"=",
"avail_images",
"(",
")",
"vm_image",
"=",
"config",
".",
"get_cloud_config_value",
"(",
"'image'",
",",
"vm_",
",",
"__opts__",
",",
"search_global",
"=",
"False",
")",
"if",
"not",
"isinstance",
"(... | Return the image object to use | [
"Return",
"the",
"image",
"object",
"to",
"use"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L206-L226 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | get_size | def get_size(vm_):
'''
Return the VM's size. Used by create_node().
'''
sizes = avail_sizes()
vm_size = six.text_type(config.get_cloud_config_value(
'size', vm_, __opts__, search_global=False
))
for size in sizes:
if vm_size.lower() == sizes[size]['slug']:
return ... | python | def get_size(vm_):
'''
Return the VM's size. Used by create_node().
'''
sizes = avail_sizes()
vm_size = six.text_type(config.get_cloud_config_value(
'size', vm_, __opts__, search_global=False
))
for size in sizes:
if vm_size.lower() == sizes[size]['slug']:
return ... | [
"def",
"get_size",
"(",
"vm_",
")",
":",
"sizes",
"=",
"avail_sizes",
"(",
")",
"vm_size",
"=",
"six",
".",
"text_type",
"(",
"config",
".",
"get_cloud_config_value",
"(",
"'size'",
",",
"vm_",
",",
"__opts__",
",",
"search_global",
"=",
"False",
")",
")... | Return the VM's size. Used by create_node(). | [
"Return",
"the",
"VM",
"s",
"size",
".",
"Used",
"by",
"create_node",
"()",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L229-L242 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | get_location | def get_location(vm_):
'''
Return the VM's location
'''
locations = avail_locations()
vm_location = six.text_type(config.get_cloud_config_value(
'location', vm_, __opts__, search_global=False
))
for location in locations:
if vm_location in (locations[location]['name'],
... | python | def get_location(vm_):
'''
Return the VM's location
'''
locations = avail_locations()
vm_location = six.text_type(config.get_cloud_config_value(
'location', vm_, __opts__, search_global=False
))
for location in locations:
if vm_location in (locations[location]['name'],
... | [
"def",
"get_location",
"(",
"vm_",
")",
":",
"locations",
"=",
"avail_locations",
"(",
")",
"vm_location",
"=",
"six",
".",
"text_type",
"(",
"config",
".",
"get_cloud_config_value",
"(",
"'location'",
",",
"vm_",
",",
"__opts__",
",",
"search_global",
"=",
... | Return the VM's location | [
"Return",
"the",
"VM",
"s",
"location"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L245-L262 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | create | def create(vm_):
'''
Create a single VM from a data dict
'''
try:
# Check for required profile parameters before sending any API calls.
if vm_['profile'] and config.is_profile_configured(__opts__,
__active_provider_name__ or 'dig... | python | def create(vm_):
'''
Create a single VM from a data dict
'''
try:
# Check for required profile parameters before sending any API calls.
if vm_['profile'] and config.is_profile_configured(__opts__,
__active_provider_name__ or 'dig... | [
"def",
"create",
"(",
"vm_",
")",
":",
"try",
":",
"# Check for required profile parameters before sending any API calls.",
"if",
"vm_",
"[",
"'profile'",
"]",
"and",
"config",
".",
"is_profile_configured",
"(",
"__opts__",
",",
"__active_provider_name__",
"or",
"'digit... | Create a single VM from a data dict | [
"Create",
"a",
"single",
"VM",
"from",
"a",
"data",
"dict"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L273-L546 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | query | def query(method='droplets', droplet_id=None, command=None, args=None, http_method='get'):
'''
Make a web call to DigitalOcean
'''
base_path = six.text_type(config.get_cloud_config_value(
'api_root',
get_configured_provider(),
__opts__,
search_global=False,
defaul... | python | def query(method='droplets', droplet_id=None, command=None, args=None, http_method='get'):
'''
Make a web call to DigitalOcean
'''
base_path = six.text_type(config.get_cloud_config_value(
'api_root',
get_configured_provider(),
__opts__,
search_global=False,
defaul... | [
"def",
"query",
"(",
"method",
"=",
"'droplets'",
",",
"droplet_id",
"=",
"None",
",",
"command",
"=",
"None",
",",
"args",
"=",
"None",
",",
"http_method",
"=",
"'get'",
")",
":",
"base_path",
"=",
"six",
".",
"text_type",
"(",
"config",
".",
"get_clo... | Make a web call to DigitalOcean | [
"Make",
"a",
"web",
"call",
"to",
"DigitalOcean"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L549-L604 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | show_instance | def show_instance(name, call=None):
'''
Show the details from DigitalOcean concerning a droplet
'''
if call != 'action':
raise SaltCloudSystemExit(
'The show_instance action must be called with -a or --action.'
)
node = _get_node(name)
__utils__['cloud.cache_node'](no... | python | def show_instance(name, call=None):
'''
Show the details from DigitalOcean concerning a droplet
'''
if call != 'action':
raise SaltCloudSystemExit(
'The show_instance action must be called with -a or --action.'
)
node = _get_node(name)
__utils__['cloud.cache_node'](no... | [
"def",
"show_instance",
"(",
"name",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The show_instance action must be called with -a or --action.'",
")",
"node",
"=",
"_get_node",
"(",
"name",
")",
"_... | Show the details from DigitalOcean concerning a droplet | [
"Show",
"the",
"details",
"from",
"DigitalOcean",
"concerning",
"a",
"droplet"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L622-L632 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | list_keypairs | def list_keypairs(call=None):
'''
Return a dict of all available VM locations on the cloud provider with
relevant data
'''
if call != 'function':
log.error(
'The list_keypairs function must be called with -f or --function.'
)
return False
fetch = True
pag... | python | def list_keypairs(call=None):
'''
Return a dict of all available VM locations on the cloud provider with
relevant data
'''
if call != 'function':
log.error(
'The list_keypairs function must be called with -f or --function.'
)
return False
fetch = True
pag... | [
"def",
"list_keypairs",
"(",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'function'",
":",
"log",
".",
"error",
"(",
"'The list_keypairs function must be called with -f or --function.'",
")",
"return",
"False",
"fetch",
"=",
"True",
"page",
"=",
"1",
"re... | Return a dict of all available VM locations on the cloud provider with
relevant data | [
"Return",
"a",
"dict",
"of",
"all",
"available",
"VM",
"locations",
"on",
"the",
"cloud",
"provider",
"with",
"relevant",
"data"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L651-L691 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | show_keypair | def show_keypair(kwargs=None, call=None):
'''
Show the details of an SSH keypair
'''
if call != 'function':
log.error(
'The show_keypair function must be called with -f or --function.'
)
return False
if not kwargs:
kwargs = {}
if 'keyname' not in kwa... | python | def show_keypair(kwargs=None, call=None):
'''
Show the details of an SSH keypair
'''
if call != 'function':
log.error(
'The show_keypair function must be called with -f or --function.'
)
return False
if not kwargs:
kwargs = {}
if 'keyname' not in kwa... | [
"def",
"show_keypair",
"(",
"kwargs",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'function'",
":",
"log",
".",
"error",
"(",
"'The show_keypair function must be called with -f or --function.'",
")",
"return",
"False",
"if",
"not",
"kwa... | Show the details of an SSH keypair | [
"Show",
"the",
"details",
"of",
"an",
"SSH",
"keypair"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L694-L717 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | import_keypair | def import_keypair(kwargs=None, call=None):
'''
Upload public key to cloud provider.
Similar to EC2 import_keypair.
.. versionadded:: 2016.11.0
kwargs
file(mandatory): public key file-name
keyname(mandatory): public key name in the provider
'''
with salt.utils.files.fopen(k... | python | def import_keypair(kwargs=None, call=None):
'''
Upload public key to cloud provider.
Similar to EC2 import_keypair.
.. versionadded:: 2016.11.0
kwargs
file(mandatory): public key file-name
keyname(mandatory): public key name in the provider
'''
with salt.utils.files.fopen(k... | [
"def",
"import_keypair",
"(",
"kwargs",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"with",
"salt",
".",
"utils",
".",
"files",
".",
"fopen",
"(",
"kwargs",
"[",
"'file'",
"]",
",",
"'r'",
")",
"as",
"public_key_filename",
":",
"public_key_content",... | Upload public key to cloud provider.
Similar to EC2 import_keypair.
.. versionadded:: 2016.11.0
kwargs
file(mandatory): public key file-name
keyname(mandatory): public key name in the provider | [
"Upload",
"public",
"key",
"to",
"cloud",
"provider",
".",
"Similar",
"to",
"EC2",
"import_keypair",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L720-L740 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | create_key | def create_key(kwargs=None, call=None):
'''
Upload a public key
'''
if call != 'function':
log.error(
'The create_key function must be called with -f or --function.'
)
return False
try:
result = query(
method='account',
command='ke... | python | def create_key(kwargs=None, call=None):
'''
Upload a public key
'''
if call != 'function':
log.error(
'The create_key function must be called with -f or --function.'
)
return False
try:
result = query(
method='account',
command='ke... | [
"def",
"create_key",
"(",
"kwargs",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'function'",
":",
"log",
".",
"error",
"(",
"'The create_key function must be called with -f or --function.'",
")",
"return",
"False",
"try",
":",
"result",... | Upload a public key | [
"Upload",
"a",
"public",
"key"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L743-L765 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | get_keyid | def get_keyid(keyname):
'''
Return the ID of the keyname
'''
if not keyname:
return None
keypairs = list_keypairs(call='function')
keyid = keypairs[keyname]['id']
if keyid:
return keyid
raise SaltCloudNotFound('The specified ssh key could not be found.') | python | def get_keyid(keyname):
'''
Return the ID of the keyname
'''
if not keyname:
return None
keypairs = list_keypairs(call='function')
keyid = keypairs[keyname]['id']
if keyid:
return keyid
raise SaltCloudNotFound('The specified ssh key could not be found.') | [
"def",
"get_keyid",
"(",
"keyname",
")",
":",
"if",
"not",
"keyname",
":",
"return",
"None",
"keypairs",
"=",
"list_keypairs",
"(",
"call",
"=",
"'function'",
")",
"keyid",
"=",
"keypairs",
"[",
"keyname",
"]",
"[",
"'id'",
"]",
"if",
"keyid",
":",
"re... | Return the ID of the keyname | [
"Return",
"the",
"ID",
"of",
"the",
"keyname"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L791-L801 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | destroy | def destroy(name, call=None):
'''
Destroy a node. Will check termination protection and warn if enabled.
CLI Example:
.. code-block:: bash
salt-cloud --destroy mymachine
'''
if call == 'function':
raise SaltCloudSystemExit(
'The destroy action must be called with -... | python | def destroy(name, call=None):
'''
Destroy a node. Will check termination protection and warn if enabled.
CLI Example:
.. code-block:: bash
salt-cloud --destroy mymachine
'''
if call == 'function':
raise SaltCloudSystemExit(
'The destroy action must be called with -... | [
"def",
"destroy",
"(",
"name",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"==",
"'function'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The destroy action must be called with -d, --destroy, '",
"'-a or --action.'",
")",
"__utils__",
"[",
"'cloud.fire_event'",
... | Destroy a node. Will check termination protection and warn if enabled.
CLI Example:
.. code-block:: bash
salt-cloud --destroy mymachine | [
"Destroy",
"a",
"node",
".",
"Will",
"check",
"termination",
"protection",
"and",
"warn",
"if",
"enabled",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L804-L871 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | post_dns_record | def post_dns_record(**kwargs):
'''
Creates a DNS record for the given name if the domain is managed with DO.
'''
if 'kwargs' in kwargs: # flatten kwargs if called via salt-cloud -f
f_kwargs = kwargs['kwargs']
del kwargs['kwargs']
kwargs.update(f_kwargs)
mandatory_kwargs = ('... | python | def post_dns_record(**kwargs):
'''
Creates a DNS record for the given name if the domain is managed with DO.
'''
if 'kwargs' in kwargs: # flatten kwargs if called via salt-cloud -f
f_kwargs = kwargs['kwargs']
del kwargs['kwargs']
kwargs.update(f_kwargs)
mandatory_kwargs = ('... | [
"def",
"post_dns_record",
"(",
"*",
"*",
"kwargs",
")",
":",
"if",
"'kwargs'",
"in",
"kwargs",
":",
"# flatten kwargs if called via salt-cloud -f",
"f_kwargs",
"=",
"kwargs",
"[",
"'kwargs'",
"]",
"del",
"kwargs",
"[",
"'kwargs'",
"]",
"kwargs",
".",
"update",
... | Creates a DNS record for the given name if the domain is managed with DO. | [
"Creates",
"a",
"DNS",
"record",
"for",
"the",
"given",
"name",
"if",
"the",
"domain",
"is",
"managed",
"with",
"DO",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L874-L902 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | destroy_dns_records | def destroy_dns_records(fqdn):
'''
Deletes DNS records for the given hostname if the domain is managed with DO.
'''
domain = '.'.join(fqdn.split('.')[-2:])
hostname = '.'.join(fqdn.split('.')[:-2])
# TODO: remove this when the todo on 754 is available
try:
response = query(method='do... | python | def destroy_dns_records(fqdn):
'''
Deletes DNS records for the given hostname if the domain is managed with DO.
'''
domain = '.'.join(fqdn.split('.')[-2:])
hostname = '.'.join(fqdn.split('.')[:-2])
# TODO: remove this when the todo on 754 is available
try:
response = query(method='do... | [
"def",
"destroy_dns_records",
"(",
"fqdn",
")",
":",
"domain",
"=",
"'.'",
".",
"join",
"(",
"fqdn",
".",
"split",
"(",
"'.'",
")",
"[",
"-",
"2",
":",
"]",
")",
"hostname",
"=",
"'.'",
".",
"join",
"(",
"fqdn",
".",
"split",
"(",
"'.'",
")",
"... | Deletes DNS records for the given hostname if the domain is managed with DO. | [
"Deletes",
"DNS",
"records",
"for",
"the",
"given",
"hostname",
"if",
"the",
"domain",
"is",
"managed",
"with",
"DO",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L905-L936 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | show_pricing | def show_pricing(kwargs=None, call=None):
'''
Show pricing for a particular profile. This is only an estimate, based on
unofficial pricing sources.
.. versionadded:: 2015.8.0
CLI Examples:
.. code-block:: bash
salt-cloud -f show_pricing my-digitalocean-config profile=my-profile
'... | python | def show_pricing(kwargs=None, call=None):
'''
Show pricing for a particular profile. This is only an estimate, based on
unofficial pricing sources.
.. versionadded:: 2015.8.0
CLI Examples:
.. code-block:: bash
salt-cloud -f show_pricing my-digitalocean-config profile=my-profile
'... | [
"def",
"show_pricing",
"(",
"kwargs",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"profile",
"=",
"__opts__",
"[",
"'profiles'",
"]",
".",
"get",
"(",
"kwargs",
"[",
"'profile'",
"]",
",",
"{",
"}",
")",
"if",
"not",
"profile",
":",
"return",
... | Show pricing for a particular profile. This is only an estimate, based on
unofficial pricing sources.
.. versionadded:: 2015.8.0
CLI Examples:
.. code-block:: bash
salt-cloud -f show_pricing my-digitalocean-config profile=my-profile | [
"Show",
"pricing",
"for",
"a",
"particular",
"profile",
".",
"This",
"is",
"only",
"an",
"estimate",
"based",
"on",
"unofficial",
"pricing",
"sources",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L939-L975 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | show_floating_ip | def show_floating_ip(kwargs=None, call=None):
'''
Show the details of a floating IP
.. versionadded:: 2016.3.0
CLI Examples:
.. code-block:: bash
salt-cloud -f show_floating_ip my-digitalocean-config floating_ip='45.55.96.47'
'''
if call != 'function':
log.error(
... | python | def show_floating_ip(kwargs=None, call=None):
'''
Show the details of a floating IP
.. versionadded:: 2016.3.0
CLI Examples:
.. code-block:: bash
salt-cloud -f show_floating_ip my-digitalocean-config floating_ip='45.55.96.47'
'''
if call != 'function':
log.error(
... | [
"def",
"show_floating_ip",
"(",
"kwargs",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'function'",
":",
"log",
".",
"error",
"(",
"'The show_floating_ip function must be called with -f or --function.'",
")",
"return",
"False",
"if",
"not"... | Show the details of a floating IP
.. versionadded:: 2016.3.0
CLI Examples:
.. code-block:: bash
salt-cloud -f show_floating_ip my-digitalocean-config floating_ip='45.55.96.47' | [
"Show",
"the",
"details",
"of",
"a",
"floating",
"IP"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L1018-L1048 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | create_floating_ip | def create_floating_ip(kwargs=None, call=None):
'''
Create a new floating IP
.. versionadded:: 2016.3.0
CLI Examples:
.. code-block:: bash
salt-cloud -f create_floating_ip my-digitalocean-config region='NYC2'
salt-cloud -f create_floating_ip my-digitalocean-config droplet_id='12... | python | def create_floating_ip(kwargs=None, call=None):
'''
Create a new floating IP
.. versionadded:: 2016.3.0
CLI Examples:
.. code-block:: bash
salt-cloud -f create_floating_ip my-digitalocean-config region='NYC2'
salt-cloud -f create_floating_ip my-digitalocean-config droplet_id='12... | [
"def",
"create_floating_ip",
"(",
"kwargs",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'function'",
":",
"log",
".",
"error",
"(",
"'The create_floating_ip function must be called with -f or --function.'",
")",
"return",
"False",
"if",
"... | Create a new floating IP
.. versionadded:: 2016.3.0
CLI Examples:
.. code-block:: bash
salt-cloud -f create_floating_ip my-digitalocean-config region='NYC2'
salt-cloud -f create_floating_ip my-digitalocean-config droplet_id='1234567' | [
"Create",
"a",
"new",
"floating",
"IP"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L1051-L1090 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | delete_floating_ip | def delete_floating_ip(kwargs=None, call=None):
'''
Delete a floating IP
.. versionadded:: 2016.3.0
CLI Examples:
.. code-block:: bash
salt-cloud -f delete_floating_ip my-digitalocean-config floating_ip='45.55.96.47'
'''
if call != 'function':
log.error(
'The ... | python | def delete_floating_ip(kwargs=None, call=None):
'''
Delete a floating IP
.. versionadded:: 2016.3.0
CLI Examples:
.. code-block:: bash
salt-cloud -f delete_floating_ip my-digitalocean-config floating_ip='45.55.96.47'
'''
if call != 'function':
log.error(
'The ... | [
"def",
"delete_floating_ip",
"(",
"kwargs",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'function'",
":",
"log",
".",
"error",
"(",
"'The delete_floating_ip function must be called with -f or --function.'",
")",
"return",
"False",
"if",
"... | Delete a floating IP
.. versionadded:: 2016.3.0
CLI Examples:
.. code-block:: bash
salt-cloud -f delete_floating_ip my-digitalocean-config floating_ip='45.55.96.47' | [
"Delete",
"a",
"floating",
"IP"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L1093-L1125 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | unassign_floating_ip | def unassign_floating_ip(kwargs=None, call=None):
'''
Unassign a floating IP
.. versionadded:: 2016.3.0
CLI Examples:
.. code-block:: bash
salt-cloud -f unassign_floating_ip my-digitalocean-config floating_ip='45.55.96.47'
'''
if call != 'function':
log.error(
... | python | def unassign_floating_ip(kwargs=None, call=None):
'''
Unassign a floating IP
.. versionadded:: 2016.3.0
CLI Examples:
.. code-block:: bash
salt-cloud -f unassign_floating_ip my-digitalocean-config floating_ip='45.55.96.47'
'''
if call != 'function':
log.error(
... | [
"def",
"unassign_floating_ip",
"(",
"kwargs",
"=",
"None",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'function'",
":",
"log",
".",
"error",
"(",
"'The inassign_floating_ip function must be called with -f or --function.'",
")",
"return",
"False",
"if",... | Unassign a floating IP
.. versionadded:: 2016.3.0
CLI Examples:
.. code-block:: bash
salt-cloud -f unassign_floating_ip my-digitalocean-config floating_ip='45.55.96.47' | [
"Unassign",
"a",
"floating",
"IP"
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L1161-L1191 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | _list_nodes | def _list_nodes(full=False, for_output=False):
'''
Helper function to format and parse node data.
'''
fetch = True
page = 1
ret = {}
while fetch:
items = query(method='droplets',
command='?page=' + six.text_type(page) + '&per_page=200')
for node in item... | python | def _list_nodes(full=False, for_output=False):
'''
Helper function to format and parse node data.
'''
fetch = True
page = 1
ret = {}
while fetch:
items = query(method='droplets',
command='?page=' + six.text_type(page) + '&per_page=200')
for node in item... | [
"def",
"_list_nodes",
"(",
"full",
"=",
"False",
",",
"for_output",
"=",
"False",
")",
":",
"fetch",
"=",
"True",
"page",
"=",
"1",
"ret",
"=",
"{",
"}",
"while",
"fetch",
":",
"items",
"=",
"query",
"(",
"method",
"=",
"'droplets'",
",",
"command",
... | Helper function to format and parse node data. | [
"Helper",
"function",
"to",
"format",
"and",
"parse",
"node",
"data",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L1194-L1228 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | reboot | def reboot(name, call=None):
'''
Reboot a droplet in DigitalOcean.
.. versionadded:: 2015.8.8
name
The name of the droplet to restart.
CLI Example:
.. code-block:: bash
salt-cloud -a reboot droplet_name
'''
if call != 'action':
raise SaltCloudSystemExit(
... | python | def reboot(name, call=None):
'''
Reboot a droplet in DigitalOcean.
.. versionadded:: 2015.8.8
name
The name of the droplet to restart.
CLI Example:
.. code-block:: bash
salt-cloud -a reboot droplet_name
'''
if call != 'action':
raise SaltCloudSystemExit(
... | [
"def",
"reboot",
"(",
"name",
",",
"call",
"=",
"None",
")",
":",
"if",
"call",
"!=",
"'action'",
":",
"raise",
"SaltCloudSystemExit",
"(",
"'The restart action must be called with -a or --action.'",
")",
"data",
"=",
"show_instance",
"(",
"name",
",",
"call",
"... | Reboot a droplet in DigitalOcean.
.. versionadded:: 2015.8.8
name
The name of the droplet to restart.
CLI Example:
.. code-block:: bash
salt-cloud -a reboot droplet_name | [
"Reboot",
"a",
"droplet",
"in",
"DigitalOcean",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L1231-L1265 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | _get_full_output | def _get_full_output(node, for_output=False):
'''
Helper function for _list_nodes to loop through all node information.
Returns a dictionary containing the full information of a node.
'''
ret = {}
for item in six.iterkeys(node):
value = node[item]
if value is not None and for_out... | python | def _get_full_output(node, for_output=False):
'''
Helper function for _list_nodes to loop through all node information.
Returns a dictionary containing the full information of a node.
'''
ret = {}
for item in six.iterkeys(node):
value = node[item]
if value is not None and for_out... | [
"def",
"_get_full_output",
"(",
"node",
",",
"for_output",
"=",
"False",
")",
":",
"ret",
"=",
"{",
"}",
"for",
"item",
"in",
"six",
".",
"iterkeys",
"(",
"node",
")",
":",
"value",
"=",
"node",
"[",
"item",
"]",
"if",
"value",
"is",
"not",
"None",... | Helper function for _list_nodes to loop through all node information.
Returns a dictionary containing the full information of a node. | [
"Helper",
"function",
"for",
"_list_nodes",
"to",
"loop",
"through",
"all",
"node",
"information",
".",
"Returns",
"a",
"dictionary",
"containing",
"the",
"full",
"information",
"of",
"a",
"node",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L1342-L1353 | train |
saltstack/salt | salt/cloud/clouds/digitalocean.py | _get_ips | def _get_ips(networks):
'''
Helper function for list_nodes. Returns public and private ip lists based on a
given network dictionary.
'''
v4s = networks.get('v4')
v6s = networks.get('v6')
public_ips = []
private_ips = []
if v4s:
for item in v4s:
ip_type = item.get... | python | def _get_ips(networks):
'''
Helper function for list_nodes. Returns public and private ip lists based on a
given network dictionary.
'''
v4s = networks.get('v4')
v6s = networks.get('v6')
public_ips = []
private_ips = []
if v4s:
for item in v4s:
ip_type = item.get... | [
"def",
"_get_ips",
"(",
"networks",
")",
":",
"v4s",
"=",
"networks",
".",
"get",
"(",
"'v4'",
")",
"v6s",
"=",
"networks",
".",
"get",
"(",
"'v6'",
")",
"public_ips",
"=",
"[",
"]",
"private_ips",
"=",
"[",
"]",
"if",
"v4s",
":",
"for",
"item",
... | Helper function for list_nodes. Returns public and private ip lists based on a
given network dictionary. | [
"Helper",
"function",
"for",
"list_nodes",
".",
"Returns",
"public",
"and",
"private",
"ip",
"lists",
"based",
"on",
"a",
"given",
"network",
"dictionary",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L1356-L1384 | train |
saltstack/salt | salt/modules/deb_postgres.py | cluster_create | def cluster_create(version,
name='main',
port=None,
locale=None,
encoding=None,
datadir=None,
allow_group_access=None,
data_checksums=None,
wal_segsize=None):
'''
... | python | def cluster_create(version,
name='main',
port=None,
locale=None,
encoding=None,
datadir=None,
allow_group_access=None,
data_checksums=None,
wal_segsize=None):
'''
... | [
"def",
"cluster_create",
"(",
"version",
",",
"name",
"=",
"'main'",
",",
"port",
"=",
"None",
",",
"locale",
"=",
"None",
",",
"encoding",
"=",
"None",
",",
"datadir",
"=",
"None",
",",
"allow_group_access",
"=",
"None",
",",
"data_checksums",
"=",
"Non... | Adds a cluster to the Postgres server.
.. warning:
Only works for debian family distros so far.
CLI Example:
.. code-block:: bash
salt '*' postgres.cluster_create '9.3'
salt '*' postgres.cluster_create '9.3' 'main'
salt '*' postgres.cluster_create '9.3' locale='fr_FR'
... | [
"Adds",
"a",
"cluster",
"to",
"the",
"Postgres",
"server",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/deb_postgres.py#L32-L85 | train |
saltstack/salt | salt/modules/deb_postgres.py | cluster_list | def cluster_list(verbose=False):
'''
Return a list of cluster of Postgres server (tuples of version and name).
CLI Example:
.. code-block:: bash
salt '*' postgres.cluster_list
salt '*' postgres.cluster_list verbose=True
'''
cmd = [salt.utils.path.which('pg_lsclusters'), '--no... | python | def cluster_list(verbose=False):
'''
Return a list of cluster of Postgres server (tuples of version and name).
CLI Example:
.. code-block:: bash
salt '*' postgres.cluster_list
salt '*' postgres.cluster_list verbose=True
'''
cmd = [salt.utils.path.which('pg_lsclusters'), '--no... | [
"def",
"cluster_list",
"(",
"verbose",
"=",
"False",
")",
":",
"cmd",
"=",
"[",
"salt",
".",
"utils",
".",
"path",
".",
"which",
"(",
"'pg_lsclusters'",
")",
",",
"'--no-header'",
"]",
"ret",
"=",
"__salt__",
"[",
"'cmd.run_all'",
"]",
"(",
"' '",
".",... | Return a list of cluster of Postgres server (tuples of version and name).
CLI Example:
.. code-block:: bash
salt '*' postgres.cluster_list
salt '*' postgres.cluster_list verbose=True | [
"Return",
"a",
"list",
"of",
"cluster",
"of",
"Postgres",
"server",
"(",
"tuples",
"of",
"version",
"and",
"name",
")",
"."
] | e8541fd6e744ab0df786c0f76102e41631f45d46 | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/deb_postgres.py#L88-L107 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.