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

#!/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 

 

import re 

import util 

import glob 

import os 

 

SYSFS_NET_PATH='/sys/class/net' 

 

def parse_fcoe_eth_info(): 

    fcoe_eth_info = {} 

    # create a dictionary of rport to eth 

    try: 

        cmd = ['fcoeadm', '-l'] 

        regex = re.compile("eth[0-9]") 

        for line in util.doexec(cmd)[1].split('\n'): 

            if line.find("Interface") != -1: 

                searchObj = regex.search(line, 0) 

                if searchObj: 

                    eth = searchObj.group() 

                    util.SMlog("eth: %s" % eth) 

            if line.find("rport") != -1: 

                str1, str2 = line.split(":", 1) 

                fcoe_eth_info[str2.strip()] = eth 

                eth = "" 

    except: 

        pass 

 

    return fcoe_eth_info 

 

def parse_fcoe_port_name_info(): 

    fcoe_port_info = [] 

    fcoe_ports = glob.glob(os.path.join(SYSFS_NET_PATH, "eth*")) 

50    for port in fcoe_ports: 

        try: 

            cmd= ['fcoeadm', '-i', os.path.basename(port)] 

            for line in util.doexec(cmd)[1].split('\n'): 

                if line.find("Port Name") != -1: 

                    str1, str2 = line.split(":") 

                    str2 = str2.strip() 

                    port = int(str2,0) 

                    util.SMlog(" port is %d" % port) 

                    fcoe_port_info.append(port) 

                    break 

        except: 

            pass 

 

    return fcoe_port_info