New network lib file and minor fixes
Changes:
- Function to return netmask prefix length.
- Verify the prefix length.
Verified : Python 2.7 and 3.4
Tested : Master build.
Change-Id: I46d12acbadeb913f4aa7e164940c2f517d8acdb9
Signed-off-by: Prashanth Katti <prkatti1@in.ibm.com>
Signed-off-by: George Keishing <gkeishin@in.ibm.com>
diff --git a/lib/bmc_network_utils.py b/lib/bmc_network_utils.py
new file mode 100644
index 0000000..530f80f
--- /dev/null
+++ b/lib/bmc_network_utils.py
@@ -0,0 +1,22 @@
+#!/usr/bin/env python
+
+r"""
+Network generic functions.
+
+"""
+
+import ipaddress
+from robot.libraries.BuiltIn import BuiltIn
+
+
+def netmask_prefix_length(netmask):
+ r"""
+ Return the netmask prefix length.
+
+ Description of argument(s):
+ netmask Netmask value (e.g. "255.255.0.0", "255.255.255.0",
+ "255.252.0.0", etc.).
+ """
+
+ # IP address netmask format: '0.0.0.0/255.255.252.0'
+ return ipaddress.ip_network('0.0.0.0/' + netmask).prefixlen
diff --git a/redfish/managers/test_bmc_network_conf.robot b/redfish/managers/test_bmc_network_conf.robot
index 8bb1d4a..433a53a 100644
--- a/redfish/managers/test_bmc_network_conf.robot
+++ b/redfish/managers/test_bmc_network_conf.robot
@@ -5,6 +5,7 @@
Resource ../../lib/bmc_redfish_resource.robot
Resource ../../lib/bmc_network_utils.robot
Resource ../../lib/openbmc_ffdc.robot
+Library ../../lib/bmc_network_utils.py
Test Setup Test Setup Execution
Test Teardown Test Teardown Execution
@@ -16,14 +17,16 @@
[Tags] Get_IP_Address_And_Verify
: FOR ${network_configuration} IN @{network_configurations}
- \ Validate IP On BMC ${network_configuration['Address']}
+ \ Verify IP On BMC ${network_configuration['Address']}
+
Get Netmask And Verify
[Documentation] Get Netmask And Verify.
[Tags] Get_Netmask_And_Verify
: FOR ${network_configuration} IN @{network_configurations}
- \ Validate Netmask On BMC ${network_configuration['SubnetMask']}
+ \ Verify Netmask On BMC ${network_configuration['SubnetMask']}
+
*** Keywords ***
@@ -39,6 +42,7 @@
${ip_data}= Get BMC IP Info
Set Test Variable ${ip_data}
+
Get Network Configuration
[Documentation] Get network configuration.
@@ -76,8 +80,8 @@
[Return] @{network_configurations}
-Validate IP On BMC
- [Documentation] Validate IP on BMC.
+Verify IP On BMC
+ [Documentation] Verify IP on BMC.
[Arguments] ${ip}
# Description of the argument(s):
@@ -89,14 +93,17 @@
... msg=IP address does not exist.
-Validate Netmask On BMC
- [Documentation] Validate netmask on BMC.
+Verify Netmask On BMC
+ [Documentation] Verify netmask on BMC.
[Arguments] ${netmask}
# Description of the argument(s):
# netmask netmask value to be verified.
- # TBD- openbmc/openbmc-test-automation#1541
+ ${prefix_length}= Netmask Prefix Length ${netmask}
+
+ Should Contain Match ${ip_data} */${prefix_length}
+ ... msg=Prefix length does not exist.
Test Teardown Execution