Test code to configure IPv6 address on BMC
Signed-off-by: Prashanth Katti <prkatti1@in.ibm.com>
Change-Id: I0f1eb77677ba1a89ead359f71cd4ea0904ecb467
diff --git a/redfish/managers/test_bmc_ipv6.robot b/redfish/managers/test_bmc_ipv6.robot
index 9759a67..913ace8 100644
--- a/redfish/managers/test_bmc_ipv6.robot
+++ b/redfish/managers/test_bmc_ipv6.robot
@@ -15,7 +15,7 @@
*** Variables ***
${test_ipv6_addr} 2001:db8:3333:4444:5555:6666:7777:8888
-${test_ipv6_invalid_addr} 2001:db8:3333:4444:5555:6666:7777:JJJJ
+${test_ipv6_invalid_addr} 2001:db8:3333:4444:5555:6666:7777:JJKK
# Valid prefix length is a intiger ranges from 1 to 128.
${test_prefix_lenght} 64
@@ -50,6 +50,26 @@
Verify IPv6 Default Gateway On BMC ${ipv6_gateway}
+Verify All Configured IPv6 And PrefixLength On BMC
+ [Documentation] Verify IPv6 address and its prefix length on BMC.
+ [Tags] Verify_All_Configured_IPv6_And_PrefixLength_On_BMC
+
+ FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
+ Verify IPv6 And PrefixLength On BMC ${ipv6_network_configuration['Address']}
+ ... ${ipv6_network_configuration['PrefixLength']}
+ END
+
+
+Configure IPv6 Address And Verify
+ [Documentation] Configure IPv6 address and verify.
+ [Tags] Configure_IPv6_Address_And_Verify
+ [Template] Configure IPv6 Address On BMC
+
+
+ # IPv6 address Prefix length
+ ${test_ipv6_addr} ${test_prefix_length}
+
+
*** Keywords ***
Suite Setup Execution
@@ -164,3 +184,90 @@
@{ipv6_network_configurations}= Get From Dictionary ${resp.dict} IPv6StaticAddresses
[Return] @{ipv6_network_configurations}
+
+
+Verify IPv6 And PrefixLength
+ [Documentation] Verify IPv6 address and prefix length on BMC.
+ [Arguments] ${ipv6_addr} ${prefix_len}
+
+ # Description of the argument(s):
+ # ipv6_addr IPv6 address to be verified.
+ # prefix_len PrefixLength value to be verified.
+
+ # Catenate IPv6 address and its prefix length.
+ ${ipv6_with_prefix}= Catenate ${ipv6_addr}/${prefix_len}
+
+ # Get IPv6 address details on BMC using IP command.
+ @{ip_data}= Get BMC IPv6 Info
+
+ # Verify if IPv6 and prefix length is configured on BMC.
+
+ Should Contain ${ip_data} ${ipv6_with_prefix}
+ ... msg=IPv6 and prefix length pair does not exist.
+
+
+Configure IPv6 Address On BMC
+ [Documentation] Add IPv6 Address on BMC.
+ [Arguments] ${ipv6_addr} ${prefix_len} ${valid_status_codes}=${HTTP_OK}
+
+ # Description of argument(s):
+ # ipv6_addr IPv6 address to be added (e.g. "2001:EEEE:2222::2022").
+ # prefix_len Prefix length for the IPv6 to be added
+ # (e.g. "64").
+ # valid_status_codes Expected return code from patch operation
+ # (e.g. "200").
+
+ ${empty_dict}= Create Dictionary
+ ${ipv6_data}= Create Dictionary Address=${ipv6_addr}
+ ... PrefixLength=${prefix_len}
+
+ ${patch_list}= Create List
+
+ # Get existing static IPv6 configurations on BMC.
+ ${ipv6_network_configurations}= Get IPv6 Network Configuration
+ ${num_entries}= Get Length ${ipv6_network_configurations}
+
+ FOR ${INDEX} IN RANGE 0 ${num_entries}
+ Append To List ${patch_list} ${empty_dict}
+ END
+
+ ${valid_status_codes}= Run Keyword If '${valid_status_codes}' == '${HTTP_OK}'
+ ... Set Variable ${HTTP_OK},${HTTP_NO_CONTENT}
+ ... ELSE Set Variable ${valid_status_codes}
+
+ # We need not check for existence of IPv6 on BMC while adding.
+ Append To List ${patch_list} ${ipv6_data}
+ ${data}= Create Dictionary IPv6StaticAddresses=${patch_list}
+
+ ${active_channel_config}= Get Active Channel Config
+ ${ethernet_interface}= Set Variable ${active_channel_config['${CHANNEL_NUMBER}']['name']}
+
+ Redfish.patch ${REDFISH_NW_ETH_IFACE}${ethernet_interface} body=&{data}
+ ... valid_status_codes=[${valid_status_codes}]
+
+ Return From Keyword If '${valid_status_codes}' != '${HTTP_OK},${HTTP_NO_CONTENT}'
+
+ # Note: Network restart takes around 15-18s after patch request processing.
+ Sleep ${NETWORK_TIMEOUT}s
+ Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
+
+ Verify IPv6 And PrefixLength ${ipv6_addr} ${prefix_len}
+
+ # Verify if existing static IPv6 addresses still exist.
+ FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
+ Verify IPv6 On BMC ${ipv6_network_configuration['Address']}
+ END
+
+ Validate IPv6 Network Config On BMC
+
+
+Validate IPv6 Network Config On BMC
+ [Documentation] Check that IPv6 network info obtained via redfish matches info
+ ... obtained via CLI.
+ @{network_configurations}= Get IPv6 Network Configuration
+ ${ipv6_data}= Get BMC IPv6 Info
+ FOR ${ipv6_network_configuration} IN @{ipv6_network_configurations}
+ Should Contain Match ${ipv6_data} ${ipv6_network_configuration['Address']}/*
+ ... msg=IPv6 address does not exist.
+ END
+