Coverage for drivers/mpathutil.py : 0%

Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1#!/usr/bin/python3
2#
3# Copyright (C) Citrix Systems Inc.
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU Lesser General Public License as published
7# by the Free Software Foundation; version 2.1 only.
8#
9# This program is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12# GNU Lesser General Public License for more details.
13#
14# You should have received a copy of the GNU Lesser General Public License
15# along with this program; if not, write to the Free Software Foundation, Inc.,
16# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18import sys
19import mpath_cli
20import time
23def list():
24 maps = mpath_cli.list_maps()
25 for m in maps:
26 print(m)
29def wait_for_multipathd():
30 for i in range(0, 120):
31 if mpath_cli.is_working():
32 return
33 time.sleep(1)
34 print("Unable to contact Multipathd daemon")
35 sys.exit(-1)
38def status():
39 for line in (mpath_cli.get_all_topologies()):
40 print(line)
43def usage():
44 print("Usage:")
45 print("%s list" % sys.argv[0])
46 print("%s status" % sys.argv[0])
49def main():
50 if len(sys.argv) < 2:
51 usage()
52 sys.exit(-1)
54 mode = sys.argv[1]
56 # Check that multipathd is up and running first
57 wait_for_multipathd()
59 if mode == "list":
60 list()
61 elif mode == "status":
62 status()
63 else:
64 usage()
65 sys.exit(-1)
67if __name__ == "__main__":
68 main()