003 File Manager
Current Path:
/usr/local/lib/python3.8/site-packages/salt/grains
usr
/
local
/
lib
/
python3.8
/
site-packages
/
salt
/
grains
/
📁
..
📄
__init__.py
(32 B)
📁
__pycache__
📄
chronos.py
(535 B)
📄
cimc.py
(635 B)
📄
core.py
(111.98 KB)
📄
disks.py
(5.62 KB)
📄
esxi.py
(2.52 KB)
📄
extra.py
(2.77 KB)
📄
fibre_channel.py
(1.76 KB)
📄
fx2.py
(3.06 KB)
📄
iscsi.py
(2.35 KB)
📄
junos.py
(1.51 KB)
📄
lvm.py
(1.43 KB)
📄
marathon.py
(928 B)
📄
mdadm.py
(800 B)
📄
mdata.py
(4.09 KB)
📄
metadata.py
(2.7 KB)
📄
minion_process.py
(988 B)
📄
napalm.py
(11.2 KB)
📄
nvme.py
(1.16 KB)
📄
nxos.py
(901 B)
📄
opts.py
(353 B)
📄
panos.py
(640 B)
📄
pending_reboot.py
(650 B)
📄
philips_hue.py
(1.03 KB)
📄
rest_sample.py
(1.03 KB)
📄
smartos.py
(6.32 KB)
📄
ssh_sample.py
(927 B)
📄
zfs.py
(2.13 KB)
Editing: esxi.py
""" Generate baseline proxy minion grains for ESXi hosts. .. versionadded:: 2015.8.4 """ import logging import salt.utils.proxy from salt.exceptions import SaltSystemExit __proxyenabled__ = ["esxi"] __virtualname__ = "esxi" log = logging.getLogger(__file__) GRAINS_CACHE = {} def __virtual__(): # import salt.utils.proxy again # so it is available for tests. import salt.utils.proxy try: if salt.utils.proxy.is_proxytype(__opts__, "esxi"): import salt.modules.vsphere return __virtualname__ except KeyError: pass return False def esxi(): return _grains() def kernel(): return {"kernel": "proxy"} def os(): if not GRAINS_CACHE: GRAINS_CACHE.update(_grains()) try: return {"os": GRAINS_CACHE.get("fullName")} except AttributeError: return {"os": "Unknown"} def os_family(): return {"os_family": "proxy"} def _find_credentials(host): """ Cycle through all the possible credentials and return the first one that works. """ user_names = [__pillar__["proxy"].get("username", "root")] passwords = __pillar__["proxy"]["passwords"] for user in user_names: for password in passwords: try: # Try to authenticate with the given user/password combination ret = salt.modules.vsphere.system_info( host=host, username=user, password=password ) except SaltSystemExit: # If we can't authenticate, continue on to try the next password. continue # If we have data returned from above, we've successfully authenticated. if ret: return user, password # We've reached the end of the list without successfully authenticating. raise SaltSystemExit( "Cannot complete login due to an incorrect user name or password." ) def _grains(): """ Get the grains from the proxied device. """ try: host = __pillar__["proxy"]["host"] if host: username, password = _find_credentials(host) protocol = __pillar__["proxy"].get("protocol") port = __pillar__["proxy"].get("port") ret = salt.modules.vsphere.system_info( host=host, username=username, password=password, protocol=protocol, port=port, ) GRAINS_CACHE.update(ret) except KeyError: pass return GRAINS_CACHE
Upload File
Create Folder