Skip to content

Instantly share code, notes, and snippets.

@WaltHP
Created September 28, 2016 22:24
Show Gist options
  • Select an option

  • Save WaltHP/b884d2e66ee89d17181a291f1e8c563c to your computer and use it in GitHub Desktop.

Select an option

Save WaltHP/b884d2e66ee89d17181a291f1e8c563c to your computer and use it in GitHub Desktop.
"""
"""
import pyudev
from infi.multipathtools import MultipathClient
mpath_client = MultipathClient()
context = pyudev.Context()
#wwn = '360000000000000000e00000000020001'
wwn = '360000000000000000e00000000020001'
wwn = '350002ace42ec383d'
def get_mpath_device(wwn):
if mpath_client.is_running():
devices = mpath_client.get_list_of_multipath_devices()
for dev in devices:
if dev.id == wwn:
return dev
else:
print("Multipath daemon doesn't seem to be running asshole.")
for device in context.list_devices(subsystem='block'):
#print(device.keys())
#for key in device.keys():
# print("%s = %s" % (key, device[key]))
#print("")
if 'ID_SERIAL' in device and device['ID_SERIAL'] == wwn:
print('{0} {1}'.format(device.device_node, device.device_type))
if 'ID_PATH' in device:
print("{0}".format(device['ID_PATH']))
for key in device.keys():
print("%s = %s" % (key, device[key]))
mpath = get_mpath_device(wwn)
print(mpath)
print("")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment