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: fibre_channel.py
""" Grains for Fibre Channel WWN's. On Windows this runs a PowerShell command that queries WMI to get the Fibre Channel WWN's available. .. versionadded:: 2018.3.0 To enable these grains set ``fibre_channel_grains: True`` in the minion config. .. code-block:: yaml fibre_channel_grains: True """ import glob import logging import salt.modules.cmdmod import salt.utils.files import salt.utils.platform __virtualname__ = "fibre_channel" # Get logging started log = logging.getLogger(__name__) def __virtual__(): if __opts__.get("fibre_channel_grains", False) is False: return False else: return __virtualname__ def _linux_wwns(): """ Return Fibre Channel port WWNs from a Linux host. """ ret = [] for fc_file in glob.glob("/sys/class/fc_host/*/port_name"): with salt.utils.files.fopen(fc_file, "r") as _wwn: content = _wwn.read() for line in content.splitlines(): ret.append(line.rstrip()[2:]) return ret def _windows_wwns(): """ Return Fibre Channel port WWNs from a Windows host. """ ps_cmd = ( r"Get-WmiObject -ErrorAction Stop " r"-class MSFC_FibrePortHBAAttributes " r'-namespace "root\WMI" | ' r"Select -Expandproperty Attributes | " r'%{($_.PortWWN | % {"{0:x2}" -f $_}) -join ""}' ) ret = [] cmd_ret = salt.modules.cmdmod.powershell(ps_cmd) for line in cmd_ret: ret.append(line.rstrip()) return ret def fibre_channel_wwns(): """ Return list of fiber channel HBA WWNs """ grains = {"fc_wwn": False} if salt.utils.platform.is_linux(): grains["fc_wwn"] = _linux_wwns() elif salt.utils.platform.is_windows(): grains["fc_wwn"] = _windows_wwns() return grains
Upload File
Create Folder