text stringlengths 81 112k |
|---|
Check to see if a cache cluster exists.
CLI example::
salt myminion boto_elasticache.exists myelasticache
def exists(name, region=None, key=None, keyid=None, profile=None):
'''
Check to see if a cache cluster exists.
CLI example::
salt myminion boto_elasticache.exists myelasticache
... |
Check to see if a replication group exists.
CLI example::
salt myminion boto_elasticache.group_exists myelasticache
def group_exists(name, region=None, key=None, keyid=None, profile=None):
'''
Check to see if a replication group exists.
CLI example::
salt myminion boto_elasticache.g... |
Create replication group.
CLI example::
salt myminion boto_elasticache.create_replication_group myelasticache myprimarycluster description
def create_replication_group(name, primary_cluster_id, replication_group_description,
wait=None, region=None, key=None,
... |
Get replication group information.
CLI example::
salt myminion boto_elasticache.describe_replication_group mygroup
def describe_replication_group(name, region=None, key=None, keyid=None,
profile=None, parameter=None):
'''
Get replication group information.
CLI ... |
Get the configuration for a cache cluster.
CLI example::
salt myminion boto_elasticache.get_config myelasticache
def get_config(name, region=None, key=None, keyid=None, profile=None):
'''
Get the configuration for a cache cluster.
CLI example::
salt myminion boto_elasticache.get_con... |
Get hostname from cache node
CLI example::
salt myminion boto_elasticache.get_node_host myelasticache
def get_node_host(name, region=None, key=None, keyid=None, profile=None):
'''
Get hostname from cache node
CLI example::
salt myminion boto_elasticache.get_node_host myelasticache
... |
Get hostname from replication cache group
CLI example::
salt myminion boto_elasticache.get_group_host myelasticachegroup
def get_group_host(name, region=None, key=None, keyid=None, profile=None):
'''
Get hostname from replication cache group
CLI example::
salt myminion boto_elastica... |
Return a list of all cache subnet groups with details
CLI example::
salt myminion boto_elasticache.get_all_subnet_groups region=us-east-1
def get_all_cache_subnet_groups(name=None, region=None, key=None,
keyid=None, profile=None):
'''
Return a list of all cache sub... |
Return a list of all cache subnet group names
CLI example::
salt myminion boto_elasticache.list_subnet_groups region=us-east-1
def list_cache_subnet_groups(name=None, region=None, key=None,
keyid=None, profile=None):
'''
Return a list of all cache subnet group names
... |
Check to see if an ElastiCache subnet group exists.
CLI example::
salt myminion boto_elasticache.subnet_group_exists my-param-group \
region=us-east-1
def subnet_group_exists(name, tags=None, region=None, key=None, keyid=None, profile=None):
'''
Check to see if an ElastiCache subn... |
Create an ElastiCache subnet group
CLI example to create an ElastiCache subnet group::
salt myminion boto_elasticache.create_subnet_group my-subnet-group \
"group description" subnet_ids='[subnet-12345678, subnet-87654321]' \
region=us-east-1
def create_subnet_group(name, descript... |
Get information about a cache subnet group.
CLI example::
salt myminion boto_elasticache.get_cache_subnet_group mycache_subnet_group
def get_cache_subnet_group(name, region=None, key=None, keyid=None,
profile=None):
'''
Get information about a cache subnet group.
C... |
Delete an ElastiCache subnet group.
CLI example::
salt myminion boto_elasticache.delete_subnet_group my-subnet-group \
region=us-east-1
def delete_subnet_group(name, region=None, key=None, keyid=None, profile=None):
'''
Delete an ElastiCache subnet group.
CLI example::
... |
Create a cache cluster.
CLI example::
salt myminion boto_elasticache.create myelasticache 1 redis cache.t1.micro
cache_security_group_names='["myelasticachesg"]'
def create(name, num_cache_nodes=None, engine=None, cache_node_type=None,
replication_group_id=None, engine_version=None,
... |
Delete a cache cluster.
CLI example::
salt myminion boto_elasticache.delete myelasticache
def delete(name, wait=False, region=None, key=None, keyid=None, profile=None):
'''
Delete a cache cluster.
CLI example::
salt myminion boto_elasticache.delete myelasticache
'''
conn = _... |
Create a cache security group.
CLI example::
salt myminion boto_elasticache.create_cache_security_group myelasticachesg 'My Cache Security Group'
def create_cache_security_group(name, description, region=None, key=None,
keyid=None, profile=None):
'''
Create a cache... |
Delete a cache security group.
CLI example::
salt myminion boto_elasticache.delete_cache_security_group myelasticachesg 'My Cache Security Group'
def delete_cache_security_group(name, region=None, key=None, keyid=None,
profile=None):
'''
Delete a cache security gro... |
Authorize network ingress from an ec2 security group to a cache security
group.
CLI example::
salt myminion boto_elasticache.authorize_cache_security_group_ingress myelasticachesg myec2sg 879879
def authorize_cache_security_group_ingress(name, ec2_security_group_name,
... |
Safely get the string to print out, try the configured outputter, then
fall back to nested and then to raw
def try_printout(data, out, opts, **kwargs):
'''
Safely get the string to print out, try the configured outputter, then
fall back to nested and then to raw
'''
try:
printout = get_... |
Get the progress bar from the given outputter
def get_progress(opts, out, progress):
'''
Get the progress bar from the given outputter
'''
return salt.loader.raw_mod(opts,
out,
'rawmodule',
mod='output')['{0... |
Update the progress iterator for the given outputter
def update_progress(opts, progress, progress_iter, out):
'''
Update the progress iterator for the given outputter
'''
# Look up the outputter
try:
progress_outputter = salt.loader.outputters(opts)[out]
except KeyError: # Outputter is... |
Print the passed data using the desired output
def display_output(data, out=None, opts=None, **kwargs):
'''
Print the passed data using the desired output
'''
if opts is None:
opts = {}
display_data = try_printout(data, out, opts, **kwargs)
output_filename = opts.get('output_file', Non... |
Return a printer function
def get_printout(out, opts=None, **kwargs):
'''
Return a printer function
'''
if opts is None:
opts = {}
if 'output' in opts and opts['output'] != 'highstate':
# new --out option, but don't choke when using --out=highstate at CLI
# See Issue #29796... |
Return the formatted outputter string for the passed data
def out_format(data, out, opts=None, **kwargs):
'''
Return the formatted outputter string for the passed data
'''
return try_printout(data, out, opts, **kwargs) |
Return the formatted outputter string, removing the ANSI escape sequences.
def string_format(data, out, opts=None, **kwargs):
'''
Return the formatted outputter string, removing the ANSI escape sequences.
'''
raw_output = try_printout(data, out, opts, **kwargs)
ansi_escape = re.compile(r'\x1b[^m]*m... |
Return the formatted string as HTML.
def html_format(data, out, opts=None, **kwargs):
'''
Return the formatted string as HTML.
'''
ansi_escaped_string = string_format(data, out, opts, **kwargs)
return ansi_escaped_string.replace(' ', ' ').replace('\n', '<br />') |
Replace ESC (ASCII 27/Oct 33) to prevent unsafe strings
from writing their own terminal manipulation commands
def strip_esc_sequence(txt):
'''
Replace ESC (ASCII 27/Oct 33) to prevent unsafe strings
from writing their own terminal manipulation commands
'''
if isinstance(txt, six.string_types):
... |
Split out a domain in its parents
Leverages tldextract to take the TLDs from publicsuffix.org
or makes a valiant approximation of that
:param domain: dc2.ams2.example.com
:param tld: Include TLD in list
:return: [ 'dc2.ams2.example.com', 'ams2.example.com', 'example.com']
def _tree(domain, tld=Fa... |
schema = OrderedDict({
'prio': int,
'weight': int,
'port': to_port,
'name': str,
})
rec_data = '10 20 25 myawesome.nl'
res = {'prio': 10, 'weight': 20, 'port': 25 'name': 'myawesome.nl'}
def _data2rec(schema, rec_data):
'''
schema = OrderedDict({
'prio': int... |
Use dig to lookup addresses
:param name: Name of record to search
:param rdtype: DNS record type
:param timeout: server response timeout
:param servers: [] of servers to use
:return: [] of records or False if error
def _lookup_dig(name, rdtype, timeout=None, servers=None, secure=None):
'''
... |
Use drill to lookup addresses
:param name: Name of record to search
:param rdtype: DNS record type
:param timeout: command return timeout
:param servers: [] of servers to use
:return: [] of records or False if error
def _lookup_drill(name, rdtype, timeout=None, servers=None, secure=None):
'''
... |
Use Python's socket interface to lookup addresses
:param name: Name of record to search
:param rdtype: A or AAAA
:param timeout: ignored
:return: [] of addresses or False if error
def _lookup_gai(name, rdtype, timeout=None):
'''
Use Python's socket interface to lookup addresses
:param name:... |
Use host to lookup addresses
:param name: Name of record to search
:param server: Server to query
:param rdtype: DNS record type
:param timeout: server response wait
:return: [] of records or False if error
def _lookup_host(name, rdtype, timeout=None, server=None):
'''
Use host to lookup ad... |
Use dnspython to lookup addresses
:param name: Name of record to search
:param rdtype: DNS record type
:param timeout: query timeout
:param server: [] of server(s) to try in order
:return: [] of records or False if error
def _lookup_dnspython(name, rdtype, timeout=None, servers=None, secure=None):
... |
Use nslookup to lookup addresses
:param name: Name of record to search
:param rdtype: DNS record type
:param timeout: server response timeout
:param server: server to query
:return: [] of records or False if error
def _lookup_nslookup(name, rdtype, timeout=None, server=None):
'''
Use nslook... |
Lookup DNS records and return their data
:param name: name to lookup
:param rdtype: DNS record type
:param method: gai (getaddrinfo()), dnspython, dig, drill, host, nslookup or auto (default)
:param servers: (list of) server(s) to try in-order
:param timeout: query timeout or a valiant approximatio... |
Query DNS for information.
Where `lookup()` returns record data, `query()` tries to interpret the data and return it's results
:param name: name to lookup
:param rdtype: DNS record type
:param method: gai (getaddrinfo()), pydns, dig, drill, host, nslookup or auto (default)
:param servers: (list of)... |
Return a list of addresses for name
ip6:
Return IPv6 addresses
ip4:
Return IPv4 addresses
the rest is passed on to lookup()
def host(name, ip4=True, ip6=True, **kwargs):
'''
Return a list of addresses for name
ip6:
Return IPv6 addresses
ip4:
Return IPv4 ad... |
Validate and parse DNS record data for a CAA record
:param rdata: DNS record data
:return: dict w/fields
def caa_rec(rdatas):
'''
Validate and parse DNS record data for a CAA record
:param rdata: DNS record data
:return: dict w/fields
'''
rschema = OrderedDict((
('flags', lambda... |
Return PTR name of given IP
:param rdata: IP address
:return: PTR record name
def ptr_name(rdata):
'''
Return PTR name of given IP
:param rdata: IP address
:return: PTR record name
'''
try:
return ipaddress.ip_address(rdata).reverse_pointer
except ValueError:
log.err... |
Validate and parse DNS record data for SOA record(s)
:param rdata: DNS record data
:return: dict w/fields
def soa_rec(rdata):
'''
Validate and parse DNS record data for SOA record(s)
:param rdata: DNS record data
:return: dict w/fields
'''
rschema = OrderedDict((
('mname', str),... |
Validate and parse DNS record data for SPF record(s)
:param rdata: DNS record data
:return: dict w/fields
def spf_rec(rdata):
'''
Validate and parse DNS record data for SPF record(s)
:param rdata: DNS record data
:return: dict w/fields
'''
spf_fields = rdata.split(' ')
if not spf_fi... |
Generate SRV record data
:param target:
:param port:
:param prio:
:param weight:
:return:
def srv_data(target, port, prio=10, weight=10):
'''
Generate SRV record data
:param target:
:param port:
:param prio:
:param weight:
:return:
'''
return _rec2data(prio, weig... |
Generate SRV record name
:param svc: ldap, 389 etc
:param proto: tcp, udp, sctp etc.
:param domain: name to append
:return:
def srv_name(svc, proto='tcp', domain=None):
'''
Generate SRV record name
:param svc: ldap, 389 etc
:param proto: tcp, udp, sctp etc.
:param domain: name to ap... |
Validate and parse DNS record data for SRV record(s)
:param rdata: DNS record data
:return: dict w/fields
def srv_rec(rdatas):
'''
Validate and parse DNS record data for SRV record(s)
:param rdata: DNS record data
:return: dict w/fields
'''
rschema = OrderedDict((
('prio', int),... |
Generate an SSHFP record
:param key_t: rsa/dsa/ecdsa/ed25519
:param hash_t: sha1/sha256
:param pub: the SSH public key
def sshfp_data(key_t, hash_t, pub):
'''
Generate an SSHFP record
:param key_t: rsa/dsa/ecdsa/ed25519
:param hash_t: sha1/sha256
:param pub: the SSH public key
'''
... |
Validate and parse DNS record data for TLSA record(s)
:param rdata: DNS record data
:return: dict w/fields
def sshfp_rec(rdata):
'''
Validate and parse DNS record data for TLSA record(s)
:param rdata: DNS record data
:return: dict w/fields
'''
rschema = OrderedDict((
('algorithm... |
Generate a TLSA rec
:param pub: Pub key in PEM format
:param usage:
:param selector:
:param matching:
:return: TLSA data portion
def tlsa_data(pub, usage, selector, matching):
'''
Generate a TLSA rec
:param pub: Pub key in PEM format
:param usage:
:param selector:
:param mat... |
Validate and parse DNS record data for TLSA record(s)
:param rdata: DNS record data
:return: dict w/fields
def tlsa_rec(rdata):
'''
Validate and parse DNS record data for TLSA record(s)
:param rdata: DNS record data
:return: dict w/fields
'''
rschema = OrderedDict((
('usage', RF... |
Find an SRV service in a domain or it's parents
:param svc: service to find (ldap, 389, etc)
:param proto: protocol the service talks (tcp, udp, etc)
:param domain: domain to start search in
:param walk: walk the parents if domain doesn't provide the service
:param secure: only return DNSSEC-validat... |
Parse through system-known services
:return: {
'svc': [
{ 'port': port
'proto': proto,
'desc': comment
},
],
}
def services(services_file='/etc/services'):
'''
Parse through system-known services
:return: {
'svc': [
{ ... |
Parse a resolver configuration file (traditionally /etc/resolv.conf)
def parse_resolv(src='/etc/resolv.conf'):
'''
Parse a resolver configuration file (traditionally /etc/resolv.conf)
'''
nameservers = []
ip4_nameservers = []
ip6_nameservers = []
search = []
sortlist = []
domain = ... |
Get the returner options from salt.
:param str virtualname: The returner virtualname (as returned
by __virtual__()
:param ret: result of the module that ran. dict-like object
May contain a `ret_config` key pointing to a string
If a `ret_config` is specified, config options are read fro... |
Fetch a given option value from the config.
@see :func:`get_returner_options`
def _fetch_option(cfg, ret_config, virtualname, attr_name):
"""
Fetch a given option value from the config.
@see :func:`get_returner_options`
"""
# c_cfg is a dictionary returned from config.option for
# any opt... |
Iterator generating all duples ```option name -> value```
@see :func:`get_returner_options`
def _options_browser(cfg, ret_config, defaults, virtualname, options):
"""
Iterator generating all duples ```option name -> value```
@see :func:`get_returner_options`
"""
for option in options:
... |
Fetches profile specific options if applicable
@see :func:`get_returner_options`
:return: a options dict
def _fetch_profile_opts(
cfg, virtualname,
__salt__,
_options,
profile_attr,
profile_attrs
):
"""
Fetches profile specific options if applicable
@s... |
Ensure the RabbitMQ plugin is enabled.
name
The name of the plugin
runas
The user to run the rabbitmq-plugin command as
def enabled(name, runas=None):
'''
Ensure the RabbitMQ plugin is enabled.
name
The name of the plugin
runas
The user to run the rabbitmq-plug... |
Shorthand helper function for comparing SHA1s. If rev_type == 'sha1' then
the comparison will be done using str.startwith() to allow short SHA1s to
compare successfully.
NOTE: This means that rev2 must be the short rev.
def _revs_equal(rev1, rev2, rev_type):
'''
Shorthand helper function for compa... |
DRY helper to build list of opts for git.branch, for the purposes of
setting upstream tracking branch
def _get_branch_opts(branch, local_branch, all_local_branches,
desired_upstream, git_ver=None):
'''
DRY helper to build list of opts for git.branch, for the purposes of
setting ups... |
Return the local revision for before/after comparisons
def _get_local_rev_and_branch(target, user, password, output_encoding=None):
'''
Return the local revision for before/after comparisons
'''
log.info('Checking local revision for %s', target)
try:
local_rev = __salt__['git.revision'](
... |
Ensure that a repository exists in the given directory
.. warning::
If the minion has Git 2.5 or later installed, ``name`` points to a
worktree_, and ``force`` is set to ``True``, then the worktree will be
deleted. This has been corrected in Salt 2015.8.0.
name
Path to the dire... |
.. versionadded:: 2016.3.0
Make sure a repository is cloned to the given target directory and is
a detached HEAD checkout of the commit ID resolved from ``rev``.
name
Address of the remote repository.
rev
The branch, tag, or commit ID to checkout after clone.
If a branch or ta... |
.. versionadded:: 2018.3.3,2019.2.0
Ensure that a repository has been cloned to the specified target directory.
If not, clone that repository. No fetches will be performed once cloned.
name
Address of the remote repository
target
Name of the target directory where repository should be... |
r'''
.. versionadded:: 2015.8.0
Ensure that the named config key is not present
name
The name of the configuration key to unset. This value can be a regex,
but the regex must match the entire key name. For example, ``foo\.``
would not match all keys in the ``foo`` section, it would... |
.. versionadded:: 2014.7.0
.. versionchanged:: 2015.8.0
Renamed from ``git.config`` to ``git.config_set``. For earlier
versions, use ``git.config``.
Ensure that a config value is set to the desired value(s)
name
Name of the git config value to set
value
Set a single va... |
Execute the onlyif and unless logic. Return a result dict if:
* onlyif failed (onlyif != 0)
* unless succeeded (unless == 0)
Otherwise, returns ``True``
def mod_run_check(cmd_kwargs, onlyif, unless):
'''
Execute the onlyif and unless logic. Return a result dict if:
* onlyif failed (onlyif !=... |
Pushing a text note.
:param device: Pushbullet target device
:param title: Note title
:param body: Note body
:return: Boolean if message was sent successfully.
CLI Example:
.. code-block:: bash
salt "*" pushbullet.push_note device="Chrome" title="Example title" b... |
Verify the webhook signature from travisci
signature
The signature header from the webhook header
body
The full payload body from the webhook post
.. note:: The body needs to be the urlencoded version of the body.
CLI Example:
.. code-block:: bash
salt '*' travisci.veri... |
Ensure that the named interface is configured properly.
name
The name of the interface to manage
type
Type of interface and configuration.
enabled
Designates the state of this interface.
kwargs
The IP parameters for this interface.
def managed(name, type, enabled=Tru... |
Manage network interface static routes.
name
Interface name to apply the route to.
kwargs
Named routes
def routes(name, **kwargs):
'''
Manage network interface static routes.
name
Interface name to apply the route to.
kwargs
Named routes
'''
ret = {
... |
Ensure that global network settings are configured properly.
name
Custom name to represent this configuration change.
kwargs
The global parameters for the system.
def system(name, **kwargs):
'''
Ensure that global network settings are configured properly.
name
Custom name... |
Creates new mediatype.
NOTE: This function accepts all standard mediatype properties: keyword argument names differ depending on your
zabbix version, see:
https://www.zabbix.com/documentation/3.0/manual/api/reference/host/object#host_inventory
:param name: name of the mediatype
:param _connection_u... |
Ensures that the mediatype does not exist, eventually deletes the mediatype.
:param name: name of the mediatype
:param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
:param _connection_password: Optional - zabbix password (can also be set in opts or pil... |
Sanitize host string.
https://tools.ietf.org/html/rfc1123#section-2.1
def sanitize_host(host):
'''
Sanitize host string.
https://tools.ietf.org/html/rfc1123#section-2.1
'''
RFC952_characters = ascii_letters + digits + ".-"
return "".join([c for c in host[0:255] if c in RFC952_characters]) |
Return status of a port
def isportopen(host, port):
'''
Return status of a port
'''
if not 1 <= int(port) <= 65535:
return False
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
out = sock.connect_ex((sanitize_host(host), int(port)))
return out |
Returns a list of IP addresses of a given hostname or None if not found.
def host_to_ips(host):
'''
Returns a list of IP addresses of a given hostname or None if not found.
'''
ips = []
try:
for family, socktype, proto, canonname, sockaddr in socket.getaddrinfo(
host, 0, soc... |
Get list of possible host names and convention names.
:return:
def _generate_minion_id():
'''
Get list of possible host names and convention names.
:return:
'''
# There are three types of hostnames:
# 1. Network names. How host is accessed from the network.
# 2. Host aliases. They mig... |
Return only first element of the hostname from all possible list.
:return:
def generate_minion_id():
'''
Return only first element of the hostname from all possible list.
:return:
'''
try:
ret = salt.utils.stringutils.to_unicode(_generate_minion_id().first())
except TypeError:
... |
Return a socket object for the addr
IP-version agnostic
def get_socket(addr, type=socket.SOCK_STREAM, proto=0):
'''
Return a socket object for the addr
IP-version agnostic
'''
version = ipaddress.ip_address(addr).version
if version == 4:
family = socket.AF_INET
elif version == ... |
Returns the fully qualified hostname
def get_fqhostname():
'''
Returns the fully qualified hostname
'''
# try getaddrinfo()
fqdn = None
try:
addrinfo = socket.getaddrinfo(
socket.gethostname(), 0, socket.AF_UNSPEC, socket.SOCK_STREAM,
socket.SOL_TCP, socket.AI_CA... |
Returns the hostname of a given IP
def ip_to_host(ip):
'''
Returns the hostname of a given IP
'''
try:
hostname, aliaslist, ipaddrlist = socket.gethostbyaddr(ip)
except Exception as exc:
log.debug('salt.utils.network.ip_to_host(%r) failed: %s', ip, exc)
hostname = None
r... |
Returns a bool telling if the entity name is a reachable host (IPv4/IPv6/FQDN/etc).
:param hostname:
:return:
def is_reachable_host(entity_name):
'''
Returns a bool telling if the entity name is a reachable host (IPv4/IPv6/FQDN/etc).
:param hostname:
:return:
'''
try:
assert typ... |
Returns a bool telling if the passed IP is a valid IPv4 or IPv6 address.
def is_ip_filter(ip, options=None):
'''
Returns a bool telling if the passed IP is a valid IPv4 or IPv6 address.
'''
return is_ipv4_filter(ip, options=options) or is_ipv6_filter(ip, options=options) |
Returns a bool telling if the value passed to it was a valid IPv4 address.
ip
The IP address.
net: False
Consider IP addresses followed by netmask.
options
CSV of options regarding the nature of the IP address. E.g.: loopback, multicast, private etc.
def is_ipv4_filter(ip, option... |
Returns a bool telling if the value passed to it was a valid IPv6 address.
ip
The IP address.
net: False
Consider IP addresses followed by netmask.
options
CSV of options regarding the nature of the IP address. E.g.: loopback, multicast, private etc.
def is_ipv6_filter(ip, option... |
Filters and returns only valid IP objects.
def ipaddr(value, options=None):
'''
Filters and returns only valid IP objects.
'''
ipv4_obj = ipv4(value, options=options)
ipv6_obj = ipv6(value, options=options)
if ipv4_obj is None or ipv6_obj is None:
# an IP address can be either IPv4 eith... |
Returns the interfaces IP address, e.g.: 192.168.0.1/28.
def ip_host(value, options=None, version=None):
'''
Returns the interfaces IP address, e.g.: 192.168.0.1/28.
'''
ipaddr_filter_out = _filter_ipaddr(value, options=options, version=version)
if not ipaddr_filter_out:
return
if not i... |
Return the list of hosts within a network.
.. note::
When running this command with a large IPv6 network, the command will
take a long time to gather all of the hosts.
def network_hosts(value, options=None, version=None):
'''
Return the list of hosts within a network.
.. note::
... |
Get the size of a network.
def network_size(value, options=None, version=None):
'''
Get the size of a network.
'''
ipaddr_filter_out = _filter_ipaddr(value, options=options, version=version)
if not ipaddr_filter_out:
return
if not isinstance(value, (list, tuple, types.GeneratorType)):
... |
Returns the "natural" mask of an IPv4 address
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'
... |
Returns an IPv4 netmask
def cidr_to_ipv4_netmask(cidr_bits):
'''
Returns an IPv4 netmask
'''
try:
cidr_bits = int(cidr_bits)
if not 1 <= cidr_bits <= 32:
return ''
except ValueError:
return ''
netmask = ''
for idx in range(4):
if idx:
... |
Returns the number of bits that are set in a 32bit int
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 >... |
Uses ifconfig to return a dictionary of interfaces with various information
about each (up/down state, ip address, netmask, and hwaddr)
def _interfaces_ifconfig(out):
'''
Uses ifconfig to return a dictionary of interfaces with various information
about each (up/down state, ip address, netmask, and hwad... |
Obtain interface information for *NIX/BSD variants
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 = subpr... |
Uses ifconfig to return a dictionary of interfaces with various information
about each (up/down state, ip address, netmask, and hwaddr)
def _netbsd_interfaces_ifconfig(out):
'''
Uses ifconfig to return a dictionary of interfaces with various information
about each (up/down state, ip address, netmask, a... |
Obtain interface information for NetBSD >= 8 where the ifconfig
output diverged from other BSD variants (Netmask is now part of the
address)
def netbsd_interfaces():
'''
Obtain interface information for NetBSD >= 8 where the ifconfig
output diverged from other BSD variants (Netmask is now part of t... |
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.
def _interfaces_ipconfig(out):
'''
Returns a dictionary of interfaces with various information... |
Obtain interface information for Windows systems
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.Descrip... |
Return a dictionary of information about all the interfaces on the minion
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 net... |
Return the address of the network
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) |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.