repository_name stringclasses 316
values | func_path_in_repository stringlengths 6 223 | func_name stringlengths 1 134 | language stringclasses 1
value | func_code_string stringlengths 57 65.5k | func_documentation_string stringlengths 1 46.3k | split_name stringclasses 1
value | func_code_url stringlengths 91 315 | called_functions listlengths 1 156 ⌀ | enclosing_scope stringlengths 2 1.48M |
|---|---|---|---|---|---|---|---|---|---|
saltstack/salt | salt/utils/network.py | natural_ipv4_netmask | python | def natural_ipv4_netmask(ip, fmt='prefixlen'):
'''
Returns the "natural" mask of an IPv4 address
'''
bits = _ipv4_to_bits(ip)
if bits.startswith('11'):
mask = '24'
elif bits.startswith('1'):
mask = '16'
else:
mask = '8'
if fmt == 'netmask':
return cidr_t... | Returns the "natural" mask of an IPv4 address | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L576-L592 | [
"def _ipv4_to_bits(ipaddr):\n '''\n Accepts an IPv4 dotted quad and returns a string representing its binary\n counterpart\n '''\n return ''.join([bin(int(x))[2:].rjust(8, '0') for x in ipaddr.split('.')])\n",
"def cidr_to_ipv4_netmask(cidr_bits):\n '''\n Returns an IPv4 netmask\n '''\n ... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | cidr_to_ipv4_netmask | python | def cidr_to_ipv4_netmask(cidr_bits):
'''
Returns an IPv4 netmask
'''
try:
cidr_bits = int(cidr_bits)
if not 1 <= cidr_bits <= 32:
return ''
except ValueError:
return ''
netmask = ''
for idx in range(4):
if idx:
netmask += '.'
i... | Returns an IPv4 netmask | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L606-L627 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | _number_of_set_bits | python | def _number_of_set_bits(x):
'''
Returns the number of bits that are set in a 32bit int
'''
# Taken from http://stackoverflow.com/a/4912729. Many thanks!
x -= (x >> 1) & 0x55555555
x = ((x >> 2) & 0x33333333) + (x & 0x33333333)
x = ((x >> 4) + x) & 0x0f0f0f0f
x += x >> 8
x += x >> 16
... | Returns the number of bits that are set in a 32bit int | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L640-L650 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | _interfaces_ifconfig | python | def _interfaces_ifconfig(out):
'''
Uses ifconfig to return a dictionary of interfaces with various information
about each (up/down state, ip address, netmask, and hwaddr)
'''
ret = dict()
piface = re.compile(r'^([^\s:]+)')
pmac = re.compile('.*?(?:HWaddr|ether|address:|lladdr) ([0-9a-fA-F:]... | Uses ifconfig to return a dictionary of interfaces with various information
about each (up/down state, ip address, netmask, and hwaddr) | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L748-L841 | [
"def _number_of_set_bits_to_ipv4_netmask(set_bits): # pylint: disable=C0103\n '''\n Returns an IPv4 netmask from the integer representation of that mask.\n\n Ex. 0xffffff00 -> '255.255.255.0'\n '''\n return cidr_to_ipv4_netmask(_number_of_set_bits(set_bits))\n"
] | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | linux_interfaces | python | def linux_interfaces():
'''
Obtain interface information for *NIX/BSD variants
'''
ifaces = dict()
ip_path = salt.utils.path.which('ip')
ifconfig_path = None if ip_path else salt.utils.path.which('ifconfig')
if ip_path:
cmd1 = subprocess.Popen(
'{0} link show'.format(ip_p... | Obtain interface information for *NIX/BSD variants | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L844-L874 | [
"def to_str(s, encoding=None, errors='strict', normalize=False):\n '''\n Given str, bytes, bytearray, or unicode (py2), return str\n '''\n def _normalize(s):\n try:\n return unicodedata.normalize('NFC', s) if normalize else s\n except TypeError:\n return s\n\n if e... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | _netbsd_interfaces_ifconfig | python | def _netbsd_interfaces_ifconfig(out):
'''
Uses ifconfig to return a dictionary of interfaces with various information
about each (up/down state, ip address, netmask, and hwaddr)
'''
ret = dict()
piface = re.compile(r'^([^\s:]+)')
pmac = re.compile('.*?address: ([0-9a-f:]+)')
pip = re.c... | Uses ifconfig to return a dictionary of interfaces with various information
about each (up/down state, ip address, netmask, and hwaddr) | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L877-L934 | [
"def cidr_to_ipv4_netmask(cidr_bits):\n '''\n Returns an IPv4 netmask\n '''\n try:\n cidr_bits = int(cidr_bits)\n if not 1 <= cidr_bits <= 32:\n return ''\n except ValueError:\n return ''\n\n netmask = ''\n for idx in range(4):\n if idx:\n netma... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | netbsd_interfaces | python | def netbsd_interfaces():
'''
Obtain interface information for NetBSD >= 8 where the ifconfig
output diverged from other BSD variants (Netmask is now part of the
address)
'''
# NetBSD versions prior to 8.0 can still use linux_interfaces()
if LooseVersion(os.uname()[2]) < LooseVersion('8.0'):
... | Obtain interface information for NetBSD >= 8 where the ifconfig
output diverged from other BSD variants (Netmask is now part of the
address) | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L937-L953 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | _interfaces_ipconfig | python | def _interfaces_ipconfig(out):
'''
Returns a dictionary of interfaces with various information about each
(up/down state, ip address, netmask, and hwaddr)
NOTE: This is not used by any function and may be able to be removed in the
future.
'''
ifaces = dict()
iface = None
adapter_ifa... | Returns a dictionary of interfaces with various information about each
(up/down state, ip address, netmask, and hwaddr)
NOTE: This is not used by any function and may be able to be removed in the
future. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L956-L1002 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | win_interfaces | python | def win_interfaces():
'''
Obtain interface information for Windows systems
'''
with salt.utils.winapi.Com():
c = wmi.WMI()
ifaces = {}
for iface in c.Win32_NetworkAdapterConfiguration(IPEnabled=1):
ifaces[iface.Description] = dict()
if iface.MACAddress:
... | Obtain interface information for Windows systems | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1005-L1048 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | interfaces | python | def interfaces():
'''
Return a dictionary of information about all the interfaces on the minion
'''
if salt.utils.platform.is_windows():
return win_interfaces()
elif salt.utils.platform.is_netbsd():
return netbsd_interfaces()
else:
return linux_interfaces() | Return a dictionary of information about all the interfaces on the minion | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1051-L1060 | [
"def win_interfaces():\n '''\n Obtain interface information for Windows systems\n '''\n with salt.utils.winapi.Com():\n c = wmi.WMI()\n ifaces = {}\n for iface in c.Win32_NetworkAdapterConfiguration(IPEnabled=1):\n ifaces[iface.Description] = dict()\n if iface.... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | get_net_start | python | def get_net_start(ipaddr, netmask):
'''
Return the address of the network
'''
net = ipaddress.ip_network('{0}/{1}'.format(ipaddr, netmask), strict=False)
return six.text_type(net.network_address) | Return the address of the network | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1063-L1068 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | get_net_size | 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')) | Turns an IPv4 netmask into it's corresponding prefix length
(255.255.255.0 -> 24 as in 192.168.1.10/24). | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1071-L1079 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | calc_net | 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.... | Takes IP (CIDR notation supported) and optionally netmask
and returns the network in CIDR-notation.
(The IP can be any IP inside the subnet) | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1082-L1091 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | _ipv4_to_bits | 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('.')]) | Accepts an IPv4 dotted quad and returns a string representing its binary
counterpart | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1094-L1099 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | _get_iface_info | 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 ... | If `iface` is available, return interface info and no error, otherwise
return no info and log and return an error | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1102-L1115 | [
"def interfaces():\n '''\n Return a dictionary of information about all the interfaces on the minion\n '''\n if salt.utils.platform.is_windows():\n return win_interfaces()\n elif salt.utils.platform.is_netbsd():\n return netbsd_interfaces()\n else:\n return linux_interfaces()\... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | _hw_addr_aix | 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... | Return the hardware address (a.k.a. MAC address) for a given interface on AIX
MAC address not available in through interfaces | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1118-L1137 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | hw_addr | 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:
... | Return the hardware address (a.k.a. MAC address) for a given interface
.. versionchanged:: 2016.11.4
Added support for AIX | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1140-L1156 | [
"def _get_iface_info(iface):\n '''\n If `iface` is available, return interface info and no error, otherwise\n return no info and log and return an error\n '''\n iface_info = interfaces()\n\n if iface in iface_info.keys():\n return iface_info, False\n else:\n error_msg = ('Interfac... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | interface | 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 | Return the details of `iface` or an error if it does not exist | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1159-L1168 | [
"def _get_iface_info(iface):\n '''\n If `iface` is available, return interface info and no error, otherwise\n return no info and log and return an error\n '''\n iface_info = interfaces()\n\n if iface in iface_info.keys():\n return iface_info, False\n else:\n error_msg = ('Interfac... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | interface_ip | 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... | Return `iface` IPv4 addr or an error if `iface` does not exist | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1171-L1181 | [
"def _get_iface_info(iface):\n '''\n If `iface` is available, return interface info and no error, otherwise\n return no info and log and return an error\n '''\n iface_info = interfaces()\n\n if iface in iface_info.keys():\n return iface_info, False\n else:\n error_msg = ('Interfac... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | _subnets | 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... | Returns a list of subnets to which the host belongs | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1184-L1221 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def itervalues(d, **kw):\n return d.itervalues(**kw)\n",
"def interfaces():\n '''\n Return a dictionary of information about all the interfaces on the minion\n '''\n if salt.utils.platform.is_windows():\n return win_interfaces()\n... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | in_subnet | 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... | Returns True if host or (any of) addrs is within specified subnet, otherwise False | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1238-L1254 | [
"def ip_addrs(interface=None, include_loopback=False, interface_data=None):\n '''\n Returns a list of IPv4 addresses assigned to the host. 127.0.0.1 is\n ignored, unless 'include_loopback=True' is indicated. If 'interface' is\n provided, then only IP addresses from that interface will be returned.\n ... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | _ip_addrs | 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... | Return the full list of IP adresses matching the criteria
proto = inet|inet6 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1257-L1283 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def itervalues(d, **kw):\n return d.itervalues(**kw)\n",
"def interfaces():\n '''\n Return a dictionary of information about all the interfaces on the minion\n '''\n if salt.utils.platform.is_windows():\n return win_interfaces()\n... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | hex2ip | 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]
... | 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> | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1304-L1340 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | mac2eui64 | 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:... | Convert a MAC address to a EUI64 identifier
or, with prefix provided, a full IPv6 address | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1343-L1361 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | active_tcp | 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_:
... | Return a dict describing all active tcp connections as quickly as possible | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1364-L1381 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | _remotes_on | 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']:
... | Return a set of ip addrs active tcp connections | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1400-L1441 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | _parse_tcp_line | 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']... | Parse a single line from the contents of /proc/net/tcp or /proc/net/tcp6 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1444-L1459 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | _netlink_tool_remote_on | 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 ... | 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 ... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1462-L1504 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | _netbsd_remotes_on | 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... | 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... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1605-L1661 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | _openbsd_remotes_on | 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... | 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 ... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1664-L1698 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | _windows_remotes_on | 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... | 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
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1701-L1736 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | _linux_remotes_on | 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... | 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... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1739-L1793 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | gen_mac | 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... | 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... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1847-L1868 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | mac_str_to_bytes | 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... | 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) | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1872-L1889 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | connection_check | 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) | Provides a convenient alias for the dns_check filter. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1904-L1908 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | dns_check | 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... | 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 ... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L1912-L2002 | [
"def ip_bracket(addr):\n '''\n Convert IP address representation to ZMQ (URL) format. ZMQ expects\n brackets around IPv6 literals, since they are used in URLs.\n '''\n addr = ipaddress.ip_address(addr)\n return ('[{}]' if addr.version == 6 else '{}').format(addr)\n",
"def is_console_configured()... | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | parse_host_port | python | def parse_host_port(host_port):
host, port = None, None # default
_s_ = host_port[:]
if _s_[0] == "[":
if "]" in host_port:
host, _s_ = _s_.lstrip("[").rsplit("]", 1)
host = ipaddress.IPv6Address(host).compressed
if _s_[0] == ":":
port = int(_s_.... | 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... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L2005-L2054 | [
"def sanitize_host(host):\n '''\n Sanitize host string.\n https://tools.ietf.org/html/rfc1123#section-2.1\n '''\n RFC952_characters = ascii_letters + digits + \".-\"\n return \"\".join([c for c in host[0:255] if c in RFC952_characters])\n"
] | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/utils/network.py | is_fqdn | python | def is_fqdn(hostname):
compliant = re.compile(r"(?!-)[A-Z\d\-\_]{1,63}(?<!-)$", re.IGNORECASE)
return "." in hostname and len(hostname) < 0xff and all(compliant.match(x) for x in hostname.rstrip(".").split(".")) | 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 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/network.py#L2057-L2066 | null | # -*- coding: utf-8 -*-
'''
Define some generic socket functions for network modules
'''
# Import python libs
from __future__ import absolute_import, unicode_literals, print_function
import itertools
import os
import re
import types
import socket
import logging
import platform
import random
import subprocess
from stri... |
saltstack/salt | salt/modules/mount.py | _active_mounts | 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... | List active mounts on Linux systems | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L102-L119 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | _active_mounts_aix | 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... | List active mounts on AIX systems | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L122-L152 | [
"def _resolve_user_group_names(opts):\n '''\n Resolve user and group names in related opts\n '''\n name_id_opts = {'uid': 'user.info',\n 'gid': 'group.info'}\n for ind, opt in enumerate(opts):\n if opt.split('=')[0] in name_id_opts:\n _givenid = opt.split('=')[1]\... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | _active_mounts_freebsd | 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],
... | List active mounts on FreeBSD systems | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L155-L164 | [
"def _resolve_user_group_names(opts):\n '''\n Resolve user and group names in related opts\n '''\n name_id_opts = {'uid': 'user.info',\n 'gid': 'group.info'}\n for ind, opt in enumerate(opts):\n if opt.split('=')[0] in name_id_opts:\n _givenid = opt.split('=')[1]\... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | _active_mounts_openbsd | 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... | List active mounts on OpenBSD systems | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L179-L199 | [
"def _resolve_user_group_names(opts):\n '''\n Resolve user and group names in related opts\n '''\n name_id_opts = {'uid': 'user.info',\n 'gid': 'group.info'}\n for ind, opt in enumerate(opts):\n if opt.split('=')[0] in name_id_opts:\n _givenid = opt.split('=')[1]\... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | _active_mounts_darwin | 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... | List active mounts on Mac OS systems | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L202-L212 | [
"def _resolve_user_group_names(opts):\n '''\n Resolve user and group names in related opts\n '''\n name_id_opts = {'uid': 'user.info',\n 'gid': 'group.info'}\n for ind, opt in enumerate(opts):\n if opt.split('=')[0] in name_id_opts:\n _givenid = opt.split('=')[1]\... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | _resolve_user_group_names | 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]
_... | Resolve user and group names in related opts | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L215-L232 | null | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | active | 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... | List the active mounts.
CLI Example:
.. code-block:: bash
salt '*' mount.active | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L235-L264 | [
"def _active_mountinfo(ret):\n _list = _list_mounts()\n filename = '/proc/self/mountinfo'\n if not os.access(filename, os.R_OK):\n msg = 'File not readable {0}'\n raise CommandExecutionError(msg.format(filename))\n\n if 'disk.blkid' not in __context__:\n __context__['disk.blkid'] = ... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | fstab | 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 ... | .. versionchanged:: 2016.3.2
List the contents of the fstab
CLI Example:
.. code-block:: bash
salt '*' mount.fstab | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L577-L617 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | rm_fstab | 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... | .. versionchanged:: 2016.3.2
Remove the mount point from the fstab
CLI Example:
.. code-block:: bash
salt '*' mount.rm_fstab /mnt/foo /dev/sdg | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L636-L685 | [
"def encode(data, encoding=None, errors='strict', keep=False,\n preserve_dict_class=False, preserve_tuples=False):\n '''\n Generic function which will encode whichever type is passed, if necessary\n\n If `strict` is True, and `keep` is False, and we fail to encode, a\n UnicodeEncodeError will ... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | set_fstab | 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... | 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 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L704-L826 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | rm_automaster | 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... | Remove the mount point from the auto_master
CLI Example:
.. code-block:: bash
salt '*' mount.rm_automaster /mnt/foo /dev/sdg | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L958-L1016 | [
"def encode(data, encoding=None, errors='strict', keep=False,\n preserve_dict_class=False, preserve_tuples=False):\n '''\n Generic function which will encode whichever type is passed, if necessary\n\n If `strict` is True, and `keep` is False, and we fail to encode, a\n UnicodeEncodeError will ... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | set_automaster | 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... | 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 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1019-L1136 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | automaster | 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:... | List the contents of the auto master
CLI Example:
.. code-block:: bash
salt '*' mount.automaster | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1139-L1174 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | mount | 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 ... | Mount a device
CLI Example:
.. code-block:: bash
salt '*' mount.mount /mnt/foo /dev/sdz1 True | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1177-L1230 | [
"def iterkeys(d, **kw):\n return d.iterkeys(**kw)\n"
] | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | remount | 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... | 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 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1233-L1288 | [
"def active(extended=False):\n '''\n List the active mounts.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' mount.active\n '''\n ret = {}\n if __grains__['os'] == 'FreeBSD':\n _active_mounts_freebsd(ret)\n elif 'AIX' in __grains__['kernel']:\n _active_mounts_aix(... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | umount | 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... | 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 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1291-L1324 | [
"def active(extended=False):\n '''\n List the active mounts.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' mount.active\n '''\n ret = {}\n if __grains__['os'] == 'FreeBSD':\n _active_mounts_freebsd(ret)\n elif 'AIX' in __grains__['kernel']:\n _active_mounts_aix(... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | is_fuse_exec | 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... | Returns true if the command passed is a fuse mountable application.
CLI Example:
.. code-block:: bash
salt '*' mount.is_fuse_exec sshfs | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1327-L1346 | null | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | swaps | 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():
... | Return a dict containing information on active swap
.. versionchanged:: 2016.3.2
CLI Example:
.. code-block:: bash
salt '*' mount.swaps | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1349-L1405 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | swapon | 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... | Activate a swap disk
.. versionchanged:: 2016.3.2
CLI Example:
.. code-block:: bash
salt '*' mount.swapon /root/swapfile | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1408-L1444 | [
"def swaps():\n '''\n Return a dict containing information on active swap\n\n .. versionchanged:: 2016.3.2\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' mount.swaps\n '''\n ret = {}\n if __grains__['kernel'] == 'SunOS':\n for line in __salt__['cmd.run_stdout']('swap -l... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | swapoff | 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... | Deactivate a named swap mount
.. versionchanged:: 2016.3.2
CLI Example:
.. code-block:: bash
salt '*' mount.swapoff /root/swapfile | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1447-L1475 | [
"def swaps():\n '''\n Return a dict containing information on active swap\n\n .. versionchanged:: 2016.3.2\n\n CLI Example:\n\n .. code-block:: bash\n\n salt '*' mount.swaps\n '''\n ret = {}\n if __grains__['kernel'] == 'SunOS':\n for line in __salt__['cmd.run_stdout']('swap -l... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | read_mount_cache | 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... | .. versionadded:: 2018.3.0
Provide information if the path is mounted
CLI Example:
.. code-block:: bash
salt '*' mount.read_mount_cache /mnt/share | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1497-L1514 | [
"def read_cache(opts):\n '''\n Write the mount cache file.\n '''\n cache_file = get_cache(opts)\n return _read_file(cache_file)\n"
] | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | write_mount_cache | 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... | .. 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: ... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1517-L1558 | [
"def read_cache(opts):\n '''\n Write the mount cache file.\n '''\n cache_file = get_cache(opts)\n return _read_file(cache_file)\n",
"def write_cache(cache, opts):\n '''\n Write the mount cache file.\n '''\n cache_file = get_cache(opts)\n\n try:\n _cache = salt.utils.stringutil... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | delete_mount_cache | 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... | .. versionadded:: 2018.3.0
Provide information if the path is mounted
CLI Example:
.. code-block:: bash
salt '*' mount.delete_mount_cache /mnt/share | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1561-L1582 | [
"def read_cache(opts):\n '''\n Write the mount cache file.\n '''\n cache_file = get_cache(opts)\n return _read_file(cache_file)\n",
"def write_cache(cache, opts):\n '''\n Write the mount cache file.\n '''\n cache_file = get_cache(opts)\n\n try:\n _cache = salt.utils.stringutil... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | _filesystems | 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)... | 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', ...... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1585-L1639 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | filesystems | 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... | .. versionadded:: 2018.3.3
List the contents of the filesystems
CLI Example:
.. code-block:: bash
salt '*' mount.filesystems | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1642-L1663 | [
"def _filesystems(config='/etc/filesystems', leading_key=True):\n '''\n Return the contents of the filesystems in an OrderedDict\n\n config\n File containing filesystem infomation\n\n leading_key\n True return dictionary keyed by 'name' and value as dictionary with other keys, values (n... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | set_filesystems | 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 ... | .. 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.
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1666-L1810 | [
"def encode(data, encoding=None, errors='strict', keep=False,\n preserve_dict_class=False, preserve_tuples=False):\n '''\n Generic function which will encode whichever type is passed, if necessary\n\n If `strict` is True, and `keep` is False, and we fail to encode, a\n UnicodeEncodeError will ... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | rm_filesystems | 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 ... | .. versionadded:: 2018.3.3
Remove the mount point from the filesystems
CLI Example:
.. code-block:: bash
salt '*' mount.rm_filesystems /mnt/foo /dev/sdg | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L1813-L1857 | [
"def encode(data, encoding=None, errors='strict', keep=False,\n preserve_dict_class=False, preserve_tuples=False):\n '''\n Generic function which will encode whichever type is passed, if necessary\n\n If `strict` is True, and `keep` is False, and we fail to encode, a\n UnicodeEncodeError will ... | # -*- coding: utf-8 -*-
'''
Salt module to manage Unix mounts and the fstab file
'''
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
import os
import re
import logging
# Import salt libs
import salt.utils.args
import salt.utils.data
import salt.utils.files
import salt.uti... |
saltstack/salt | salt/modules/mount.py | _fstab_entry.pick | 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) | Returns an instance with just those keys | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L323-L328 | null | class _fstab_entry(object):
'''
Utility class for manipulating fstab entries. Primarily we're parsing,
formatting, and comparing lines. Parsing emits dicts expected from
fstab() or raises a ValueError.
Note: We'll probably want to use os.normpath and os.normcase on 'name'
'''
class ParseEr... |
saltstack/salt | salt/modules/mount.py | _fstab_entry.match | 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 | Compare potentially partial criteria against line | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L345-L353 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def dict_from_line(cls, line, keys=fstab_keys):\n if len(keys) != 6:\n raise ValueError('Invalid key array: {0}'.format(keys))\n if line.startswith('#'):\n raise cls.ParseError(\"Comment!\")\n\n comps = line.split()\n if len(com... | class _fstab_entry(object):
'''
Utility class for manipulating fstab entries. Primarily we're parsing,
formatting, and comparing lines. Parsing emits dicts expected from
fstab() or raises a ValueError.
Note: We'll probably want to use os.normpath and os.normcase on 'name'
'''
class ParseEr... |
saltstack/salt | salt/modules/mount.py | _FileSystemsEntry.match | 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:
... | Compare potentially partial criteria against built filesystems entry dictionary | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/modules/mount.py#L557-L568 | null | class _FileSystemsEntry(object):
'''
Utility class for manipulating filesystem entries. Primarily we're parsing,
formatting, and comparing lines. Parsing emits dicts expected from
fstab() or raises a ValueError.
Note: We'll probably want to use os.normpath and os.normcase on 'name'
'''
cla... |
saltstack/salt | salt/utils/napalm.py | virtual | 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... | Returns the __virtual__. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/napalm.py#L94-L110 | [
"def is_proxy(opts):\n '''\n Is this a NAPALM proxy?\n '''\n return salt.utils.platform.is_proxy() and opts.get('proxy', {}).get('proxytype') == 'napalm'\n"
] | # -*- coding: utf-8 -*-
'''
Utils for the NAPALM modules and proxy.
.. seealso::
- :mod:`NAPALM grains: select network devices based on their characteristics <salt.grains.napalm>`
- :mod:`NET module: network basic features <salt.modules.napalm_network>`
- :mod:`NTP operational and configuration management... |
saltstack/salt | salt/utils/napalm.py | call | 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... | 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
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/napalm.py#L113-L258 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def get_device(opts, salt_obj=None):\n '''\n Initialise the connection with the network device through NAPALM.\n :param: opts\n :return: the network device object\n '''\n log.debug('Setting up NAPALM connection')\n network_device = g... | # -*- coding: utf-8 -*-
'''
Utils for the NAPALM modules and proxy.
.. seealso::
- :mod:`NAPALM grains: select network devices based on their characteristics <salt.grains.napalm>`
- :mod:`NET module: network basic features <salt.modules.napalm_network>`
- :mod:`NTP operational and configuration management... |
saltstack/salt | salt/utils/napalm.py | get_device_opts | 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', {})
... | Returns the options of the napalm device.
:pram: opts
:return: the network device opts | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/napalm.py#L261-L301 | [
"def is_proxy(opts):\n '''\n Is this a NAPALM proxy?\n '''\n return salt.utils.platform.is_proxy() and opts.get('proxy', {}).get('proxytype') == 'napalm'\n"
] | # -*- coding: utf-8 -*-
'''
Utils for the NAPALM modules and proxy.
.. seealso::
- :mod:`NAPALM grains: select network devices based on their characteristics <salt.grains.napalm>`
- :mod:`NET module: network basic features <salt.modules.napalm_network>`
- :mod:`NTP operational and configuration management... |
saltstack/salt | salt/utils/napalm.py | get_device | 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
... | Initialise the connection with the network device through NAPALM.
:param: opts
:return: the network device object | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/napalm.py#L304-L355 | [
"def get_device_opts(opts, salt_obj=None):\n '''\n Returns the options of the napalm device.\n :pram: opts\n :return: the network device opts\n '''\n network_device = {}\n # by default, look in the proxy config details\n device_dict = opts.get('proxy', {}) if is_proxy(opts) else opts.get('na... | # -*- coding: utf-8 -*-
'''
Utils for the NAPALM modules and proxy.
.. seealso::
- :mod:`NAPALM grains: select network devices based on their characteristics <salt.grains.napalm>`
- :mod:`NET module: network basic features <salt.modules.napalm_network>`
- :mod:`NTP operational and configuration management... |
saltstack/salt | salt/utils/napalm.py | proxy_napalm_wrap | 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... | 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.
... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/napalm.py#L358-L486 | null | # -*- coding: utf-8 -*-
'''
Utils for the NAPALM modules and proxy.
.. seealso::
- :mod:`NAPALM grains: select network devices based on their characteristics <salt.grains.napalm>`
- :mod:`NET module: network basic features <salt.modules.napalm_network>`
- :mod:`NTP operational and configuration management... |
saltstack/salt | salt/utils/napalm.py | loaded_ret | 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... | Return the final state output.
ret
The initial state output structure.
loaded
The loaded dictionary. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/utils/napalm.py#L502-L553 | [
"def string_format(data, out, opts=None, **kwargs):\n '''\n Return the formatted outputter string, removing the ANSI escape sequences.\n '''\n raw_output = try_printout(data, out, opts, **kwargs)\n ansi_escape = re.compile(r'\\x1b[^m]*m')\n return ansi_escape.sub('', raw_output)\n"
] | # -*- coding: utf-8 -*-
'''
Utils for the NAPALM modules and proxy.
.. seealso::
- :mod:`NAPALM grains: select network devices based on their characteristics <salt.grains.napalm>`
- :mod:`NET module: network basic features <salt.modules.napalm_network>`
- :mod:`NTP operational and configuration management... |
saltstack/salt | salt/engines/webhook.py | start | 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... | 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... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/engines/webhook.py#L17-L88 | [
"def get_master_event(opts, sock_dir, listen=True, io_loop=None, raise_errors=False, keep_loop=False):\n '''\n Return an event object suitable for the named transport\n '''\n # TODO: AIO core is separate from transport\n if opts['transport'] in ('zeromq', 'tcp', 'detect'):\n return MasterEvent... | # -*- coding: utf-8 -*-
'''
Send events from webhook api
'''
from __future__ import absolute_import, print_function, unicode_literals
# import tornado library
import tornado.httpserver
import tornado.ioloop
import tornado.web
# import salt libs
import salt.utils.event
import salt.utils.stringutils
|
saltstack/salt | salt/states/win_wua.py | installed | 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
... | 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... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_wua.py#L80-L211 | [
"def is_true(value=None):\n '''\n Returns a boolean value representing the \"truth\" of the value passed. The\n rules for what is a \"True\" value are:\n\n 1. Integer/float values greater than 0\n 2. The string values \"True\" and \"true\"\n 3. Any object for which bool(obj) returns Tr... | # -*- coding: utf-8 -*-
'''
Installation of Windows Updates using the Windows Update Agent
.. versionadded:: 2017.7.0
Salt can manage Windows updates via the "wua" state module. Updates can be
installed and removed. Update management declarations are as follows:
For installation:
.. code-block:: yaml
# Install... |
saltstack/salt | salt/states/win_wua.py | removed | 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.
.... | 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 ... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_wua.py#L214-L335 | [
"def is_true(value=None):\n '''\n Returns a boolean value representing the \"truth\" of the value passed. The\n rules for what is a \"True\" value are:\n\n 1. Integer/float values greater than 0\n 2. The string values \"True\" and \"true\"\n 3. Any object for which bool(obj) returns Tr... | # -*- coding: utf-8 -*-
'''
Installation of Windows Updates using the Windows Update Agent
.. versionadded:: 2017.7.0
Salt can manage Windows updates via the "wua" state module. Updates can be
installed and removed. Update management declarations are as follows:
For installation:
.. code-block:: yaml
# Install... |
saltstack/salt | salt/states/win_wua.py | uptodate | 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.
... | 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... | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/states/win_wua.py#L338-L504 | [
"def is_true(value=None):\n '''\n Returns a boolean value representing the \"truth\" of the value passed. The\n rules for what is a \"True\" value are:\n\n 1. Integer/float values greater than 0\n 2. The string values \"True\" and \"true\"\n 3. Any object for which bool(obj) returns Tr... | # -*- coding: utf-8 -*-
'''
Installation of Windows Updates using the Windows Update Agent
.. versionadded:: 2017.7.0
Salt can manage Windows updates via the "wua" state module. Updates can be
installed and removed. Update management declarations are as follows:
For installation:
.. code-block:: yaml
# Install... |
saltstack/salt | salt/log/handlers/fluent_mod.py | MessageFormatter.format_graylog_v0 | 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.
'''... | 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. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/log/handlers/fluent_mod.py#L218-L249 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def formatTime(self, record, datefmt=None):\n if self.payload_type == 'gelf': # GELF uses epoch times\n return record.created\n return datetime.datetime.utcfromtimestamp(record.created).isoformat()[:-3] + 'Z'\n"
] | class MessageFormatter(logging.Formatter, NewStyleClassMixIn):
def __init__(self, payload_type, version, tags, msg_type=None, msg_path=None):
self.payload_type = payload_type
self.version = version
self.tag = tags[0] if tags else 'salt' # 'salt' for backwards compat
self.tags = tags... |
saltstack/salt | salt/log/handlers/fluent_mod.py | MessageFormatter.format_logstash_v0 | 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... | Messages are formatted in logstash's expected format. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/log/handlers/fluent_mod.py#L286-L339 | [
"def iteritems(d, **kw):\n return d.iteritems(**kw)\n",
"def get_fqhostname():\n '''\n Returns the fully qualified hostname\n '''\n # try getaddrinfo()\n fqdn = None\n try:\n addrinfo = socket.getaddrinfo(\n socket.gethostname(), 0, socket.AF_UNSPEC, socket.SOCK_STREAM,\n ... | class MessageFormatter(logging.Formatter, NewStyleClassMixIn):
def __init__(self, payload_type, version, tags, msg_type=None, msg_path=None):
self.payload_type = payload_type
self.version = version
self.tag = tags[0] if tags else 'salt' # 'salt' for backwards compat
self.tags = tags... |
saltstack/salt | salt/wheel/minions.py | connected | 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... | List all connected minions on a salt-master | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/wheel/minions.py#L15-L26 | [
"def master_config(path, env_var='SALT_MASTER_CONFIG', defaults=None, exit_on_config_errors=False):\n '''\n Reads in the master configuration file and sets up default options\n\n This is useful for running the actual master daemon. For running\n Master-side client interfaces that need the master opts se... | # -*- coding: utf-8 -*-
'''
Wheel system wrapper for connected minions
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
# Import Salt libs
from salt.utils.cache import CacheCli
import salt.config
import salt.utils.minions
|
saltstack/salt | salt/cloud/clouds/digitalocean.py | get_configured_provider | 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',)
) | Return the first configured instance. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L81-L90 | [
"def is_provider_configured(opts, provider, required_keys=(), log_message=True, aliases=()):\n '''\n Check and return the first matching and fully configured cloud provider\n configuration.\n '''\n if ':' in provider:\n alias, driver = provider.split(':')\n if alias not in opts['provide... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | avail_locations | 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... | Return a dict of all available VM locations on the cloud provider with
relevant data | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L103-L121 | [
"def iterkeys(d, **kw):\n return d.iterkeys(**kw)\n",
"def query(method='droplets', droplet_id=None, command=None, args=None, http_method='get'):\n '''\n Make a web call to DigitalOcean\n '''\n base_path = six.text_type(config.get_cloud_config_value(\n 'api_root',\n get_configured_pro... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | avail_images | 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
... | Return a list of the images that are on the provider | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L124-L152 | [
"def iterkeys(d, **kw):\n return d.iterkeys(**kw)\n",
"def query(method='droplets', droplet_id=None, command=None, args=None, http_method='get'):\n '''\n Make a web call to DigitalOcean\n '''\n base_path = six.text_type(config.get_cloud_config_value(\n 'api_root',\n get_configured_pro... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | avail_sizes | 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... | Return a list of the image sizes that are on the provider | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L155-L172 | [
"def iterkeys(d, **kw):\n return d.iterkeys(**kw)\n",
"def query(method='droplets', droplet_id=None, command=None, args=None, http_method='get'):\n '''\n Make a web call to DigitalOcean\n '''\n base_path = six.text_type(config.get_cloud_config_value(\n 'api_root',\n get_configured_pro... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | list_nodes_full | 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... | Return a list of the VMs that are on the provider | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L186-L194 | [
"def _list_nodes(full=False, for_output=False):\n '''\n Helper function to format and parse node data.\n '''\n fetch = True\n page = 1\n ret = {}\n\n while fetch:\n items = query(method='droplets',\n command='?page=' + six.text_type(page) + '&per_page=200')\n ... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | get_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... | Return the image object to use | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L206-L226 | [
"def get_cloud_config_value(name, vm_, opts, default=None, search_global=True):\n '''\n Search and return a setting in a known order:\n\n 1. In the virtual machine's configuration\n 2. In the virtual machine's profile configuration\n 3. In the virtual machine's provider configuration\n ... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | get_size | 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 ... | Return the VM's size. Used by create_node(). | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L229-L242 | [
"def get_cloud_config_value(name, vm_, opts, default=None, search_global=True):\n '''\n Search and return a setting in a known order:\n\n 1. In the virtual machine's configuration\n 2. In the virtual machine's profile configuration\n 3. In the virtual machine's provider configuration\n ... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | get_location | 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'],
... | Return the VM's location | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L245-L262 | [
"def get_cloud_config_value(name, vm_, opts, default=None, search_global=True):\n '''\n Search and return a setting in a known order:\n\n 1. In the virtual machine's configuration\n 2. In the virtual machine's profile configuration\n 3. In the virtual machine's provider configuration\n ... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | create | 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... | Create a single VM from a data dict | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L273-L546 | [
"def destroy(name, call=None):\n '''\n Destroy a node. Will check termination protection and warn if enabled.\n\n CLI Example:\n\n .. code-block:: bash\n\n salt-cloud --destroy mymachine\n '''\n if call == 'function':\n raise SaltCloudSystemExit(\n 'The destroy action must... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | query | 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... | Make a web call to DigitalOcean | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L549-L604 | [
"def loads(s, **kwargs):\n '''\n .. versionadded:: 2018.3.0\n\n Wraps json.loads and prevents a traceback in the event that a bytestring is\n passed to the function. (Python < 3.6 cannot load bytestrings)\n\n You can pass an alternate json module (loaded via import_json() above)\n using the _json_... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | show_instance | 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... | Show the details from DigitalOcean concerning a droplet | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L622-L632 | [
"def _get_node(name):\n attempts = 10\n while attempts >= 0:\n try:\n return list_nodes_full(for_output=False)[name]\n except KeyError:\n attempts -= 1\n log.debug(\n 'Failed to get the data for node \\'%s\\'. Remaining '\n 'attempts... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | list_keypairs | 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... | Return a dict of all available VM locations on the cloud provider with
relevant data | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L651-L691 | [
"def iterkeys(d, **kw):\n return d.iterkeys(**kw)\n",
"def query(method='droplets', droplet_id=None, command=None, args=None, http_method='get'):\n '''\n Make a web call to DigitalOcean\n '''\n base_path = six.text_type(config.get_cloud_config_value(\n 'api_root',\n get_configured_pro... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | show_keypair | 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... | Show the details of an SSH keypair | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L694-L717 | [
"def query(method='droplets', droplet_id=None, command=None, args=None, http_method='get'):\n '''\n Make a web call to DigitalOcean\n '''\n base_path = six.text_type(config.get_cloud_config_value(\n 'api_root',\n get_configured_provider(),\n __opts__,\n search_global=False,\n... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | import_keypair | 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... | 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 | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L720-L740 | [
"def fopen(*args, **kwargs):\n '''\n Wrapper around open() built-in to set CLOEXEC on the fd.\n\n This flag specifies that the file descriptor should be closed when an exec\n function is invoked;\n\n When a file descriptor is allocated (as with open or dup), this bit is\n initially cleared on the ... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | create_key | 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... | Upload a public key | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L743-L765 | [
"def query(method='droplets', droplet_id=None, command=None, args=None, http_method='get'):\n '''\n Make a web call to DigitalOcean\n '''\n base_path = six.text_type(config.get_cloud_config_value(\n 'api_root',\n get_configured_provider(),\n __opts__,\n search_global=False,\n... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | get_keyid | 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.') | Return the ID of the keyname | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L791-L801 | [
"def list_keypairs(call=None):\n '''\n Return a dict of all available VM locations on the cloud provider with\n relevant data\n '''\n if call != 'function':\n log.error(\n 'The list_keypairs function must be called with -f or --function.'\n )\n return False\n\n fetc... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | destroy | 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 -... | Destroy a node. Will check termination protection and warn if enabled.
CLI Example:
.. code-block:: bash
salt-cloud --destroy mymachine | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L804-L871 | [
"def query(method='droplets', droplet_id=None, command=None, args=None, http_method='get'):\n '''\n Make a web call to DigitalOcean\n '''\n base_path = six.text_type(config.get_cloud_config_value(\n 'api_root',\n get_configured_provider(),\n __opts__,\n search_global=False,\n... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | post_dns_record | 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 = ('... | Creates a DNS record for the given name if the domain is managed with DO. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L874-L902 | [
"def query(method='droplets', droplet_id=None, command=None, args=None, http_method='get'):\n '''\n Make a web call to DigitalOcean\n '''\n base_path = six.text_type(config.get_cloud_config_value(\n 'api_root',\n get_configured_provider(),\n __opts__,\n search_global=False,\n... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
saltstack/salt | salt/cloud/clouds/digitalocean.py | destroy_dns_records | 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... | Deletes DNS records for the given hostname if the domain is managed with DO. | train | https://github.com/saltstack/salt/blob/e8541fd6e744ab0df786c0f76102e41631f45d46/salt/cloud/clouds/digitalocean.py#L905-L936 | [
"def query(method='droplets', droplet_id=None, command=None, args=None, http_method='get'):\n '''\n Make a web call to DigitalOcean\n '''\n base_path = six.text_type(config.get_cloud_config_value(\n 'api_root',\n get_configured_provider(),\n __opts__,\n search_global=False,\n... | # -*- coding: utf-8 -*-
'''
DigitalOcean Cloud Module
=========================
The DigitalOcean cloud module is used to control access to the DigitalOcean VPS system.
Use of this module requires a requires a ``personal_access_token``, an ``ssh_key_file``,
and at least one SSH key name in ``ssh_key_names``. More ``ss... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.