Modified cases for ipmi network
"REDFISH_NW_ETH0" is hardcode as
"Managers/bmc/EthernetInterfaces/eth0/" and the command "lan print"
didn't specify the channel number. Therefore, the default will print
information on the first found LAN channel.
Signed-off-by: Tony Lee <tony.lee@quantatw.com>
Change-Id: I86a0a41275cdfb98aa502fc29f8bc9074dc62280
diff --git a/lib/bmc_network_utils.py b/lib/bmc_network_utils.py
index 33c5166..93f932b 100644
--- a/lib/bmc_network_utils.py
+++ b/lib/bmc_network_utils.py
@@ -13,6 +13,8 @@
import re
import ipaddress
from robot.libraries.BuiltIn import BuiltIn
+import json
+import bmc_ssh_utils as bsu
def netmask_prefix_length(netmask):
@@ -122,3 +124,55 @@
return parse_nping_output(output)
return output
+
+
+def get_channel_config():
+ r"""
+ Get the channel config data and return as a dictionary.
+
+ Example:
+ channel_config = get_channel_config()
+ print_vars(channel_config)
+
+ channel_config:
+ [0]:
+ [name]: IPMB
+ [is_valid]: True
+ [active_sessions]: 0
+ [channel_info]:
+ [medium_type]: ipmb
+ [protocol_type]: ipmb-1.0
+ [session_supported]: session-less
+ [is_ipmi]: True
+ [1]:
+ [name]: eth0
+ [is_valid]: True
+ [active_sessions]: 0
+ [channel_info]:
+ [medium_type]: other-lan
+ [protocol_type]: ipmb-1.0
+ [session_supported]: multi-session
+ [is_ipmi]: True
+ [2]:
+ [name]: eth1
+ [is_valid]: True
+ [active_sessions]: 0
+ [channel_info]:
+ [medium_type]: lan-802.3
+ [protocol_type]: ipmb-1.0
+ [session_supported]: multi-session
+ [is_ipmi]: True
+ (etc.)
+ """
+
+ stdout, stderr, rc = bsu.bmc_execute_command("cat /usr/share/ipmi-providers/channel_config.json")
+ return json.loads(stdout)
+
+
+def get_active_channel_config():
+ r"""
+ Channel configs which medium_type are 'other-lan' or 'lan-802.3' returned by
+ this function.
+ """
+
+ return vf.filter_struct(get_channel_config(), "[('medium_type', 'other-lan|lan-802.3')]", regex=1)
diff --git a/lib/ipmi_utils.py b/lib/ipmi_utils.py
index 2a75994..7c474a9 100644
--- a/lib/ipmi_utils.py
+++ b/lib/ipmi_utils.py
@@ -121,7 +121,7 @@
return stdout, stderr, rc
-def get_lan_print_dict(ipmi_cmd_type='external'):
+def get_lan_print_dict(channel_number='', ipmi_cmd_type='external'):
r"""
Get IPMI 'lan print' output and return it as a dictionary.
@@ -168,18 +168,19 @@
'inband', 'external').
"""
+ channel_number = str(channel_number)
# Notice in the example of data above that 'Auth Type Enable' needs some
# special processing. We essentially want to isolate its data and remove
# the 'Auth Type Enable' string so that key_value_outbuf_to_dict can
# process it as a sub-dictionary.
- cmd_buf = "lan print | grep -E '^(Auth Type Enable)" +\
+ cmd_buf = "lan print " + channel_number + " | grep -E '^(Auth Type Enable)" +\
"?[ ]+: ' | sed -re 's/^(Auth Type Enable)?[ ]+: //g'"
stdout1, stderr, rc = execute_ipmi_cmd(cmd_buf, ipmi_cmd_type,
print_output=0)
# Now get the remainder of the data and exclude the lines with no field
# names (i.e. the 'Auth Type Enable' sub-fields).
- cmd_buf = "lan print | grep -E -v '^[ ]+: '"
+ cmd_buf = "lan print " + channel_number + " | grep -E -v '^[ ]+: '"
stdout2, stderr, rc = execute_ipmi_cmd(cmd_buf, ipmi_cmd_type,
print_output=0)