Coverage for drivers/fcoelib.py : 22%

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# Copyright (C) Citrix Systems Inc.
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU Lesser General Public License as published
5# by the Free Software Foundation; version 2.1 only.
6#
7# This program is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10# GNU Lesser General Public License for more details.
11#
12# You should have received a copy of the GNU Lesser General Public License
13# along with this program; if not, write to the Free Software Foundation, Inc.,
14# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16import re
17import util
18import glob
19import os
21SYSFS_NET_PATH = '/sys/class/net'
24def parse_fcoe_eth_info():
25 fcoe_eth_info = {}
26 # create a dictionary of rport to eth
27 try:
28 cmd = ['fcoeadm', '-l']
29 regex = re.compile("eth[0-9]")
30 for line in util.doexec(cmd)[1].split('\n'):
31 if line.find("Interface") != -1:
32 searchObj = regex.search(line, 0)
33 if searchObj:
34 eth = searchObj.group()
35 util.SMlog("eth: %s" % eth)
36 if line.find("rport") != -1:
37 str1, str2 = line.split(":", 1)
38 fcoe_eth_info[str2.strip()] = eth
39 eth = ""
40 except:
41 pass
43 return fcoe_eth_info
46def parse_fcoe_port_name_info():
47 fcoe_port_info = []
48 fcoe_ports = glob.glob(os.path.join(SYSFS_NET_PATH, "eth*"))
49 for port in fcoe_ports: 49 ↛ 50line 49 didn't jump to line 50, because the loop on line 49 never started
50 try:
51 cmd = ['fcoeadm', '-i', os.path.basename(port)]
52 for line in util.doexec(cmd)[1].split('\n'):
53 if line.find("Port Name") != -1:
54 str1, str2 = line.split(":")
55 str2 = str2.strip()
56 port = int(str2, 0)
57 util.SMlog(" port is %d" % port)
58 fcoe_port_info.append(port)
59 break
60 except:
61 pass
63 return fcoe_port_info