003 File Manager
Current Path:
/usr/local/lib/python3.8/site-packages/salt/matchers
usr
/
local
/
lib
/
python3.8
/
site-packages
/
salt
/
matchers
/
📁
..
📄
__init__.py
(0 B)
📁
__pycache__
📄
cache_match.py
(917 B)
📄
compound_match.py
(3.75 KB)
📄
compound_pillar_exact_match.py
(571 B)
📄
confirm_top.py
(911 B)
📄
data_match.py
(1.07 KB)
📄
glob_match.py
(444 B)
📄
grain_match.py
(606 B)
📄
grain_pcre_match.py
(665 B)
📄
ipcidr_match.py
(980 B)
📄
list_match.py
(1.35 KB)
📄
nodegroup_match.py
(750 B)
📄
pcre_match.py
(305 B)
📄
pillar_exact_match.py
(764 B)
📄
pillar_match.py
(782 B)
📄
pillar_pcre_match.py
(842 B)
📄
range_match.py
(638 B)
Editing: ipcidr_match.py
""" This is the default ipcidr matcher. """ import logging import salt.utils.network from salt._compat import ipaddress log = logging.getLogger(__name__) def match(tgt, opts=None, minion_id=None): """ Matches based on IP address or CIDR notation """ if not opts: opts = __opts__ try: # Target is an address? tgt = ipaddress.ip_address(tgt) except: # pylint: disable=bare-except try: # Target is a network? tgt = ipaddress.ip_network(tgt) except: # pylint: disable=bare-except log.error("Invalid IP/CIDR target: %s", tgt) return [] proto = "ipv{}".format(tgt.version) grains = opts["grains"] if proto not in grains: match = False elif isinstance(tgt, (ipaddress.IPv4Address, ipaddress.IPv6Address)): match = str(tgt) in grains[proto] else: match = salt.utils.network.in_subnet(tgt, grains[proto]) return match
Upload File
Create Folder