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

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

#!/usr/bin/python 

# 

# Copyright (C) Citrix Systems Inc. 

# 

# This program is free software; you can redistribute it and/or modify 

# it under the terms of the GNU Lesser General Public License as published 

# by the Free Software Foundation; version 2.1 only. 

# 

# This program is distributed in the hope that it will be useful, 

# but WITHOUT ANY WARRANTY; without even the implied warranty of 

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

# GNU Lesser General Public License for more details. 

# 

# You should have received a copy of the GNU Lesser General Public License 

# along with this program; if not, write to the Free Software Foundation, Inc., 

# 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA 

 

from __future__ import print_function 

import sys 

import mpath_cli 

import time 

 

 

def list(): 

    maps = mpath_cli.list_maps() 

    for m in maps: 

        print(m) 

 

 

def wait_for_multipathd(): 

    for i in range(0, 120): 

        if mpath_cli.is_working(): 

            return 

        time.sleep(1) 

    print("Unable to contact Multipathd daemon") 

    sys.exit(-1) 

 

 

def status(): 

    for line in (mpath_cli.get_all_topologies()): 

        print(line) 

 

 

def usage(): 

    print("Usage:") 

    print("%s list" % sys.argv[0]) 

    print("%s status" % sys.argv[0]) 

 

 

def main(): 

    if len(sys.argv) < 2: 

        usage() 

        sys.exit(-1) 

 

    mode = sys.argv[1] 

 

    # Check that multipathd is up and running first 

    wait_for_multipathd() 

 

    if mode == "list": 

        list() 

    elif mode == "status": 

        status() 

    else: 

        usage() 

        sys.exit(-1) 

 

if __name__ == "__main__": 

    main()