Verify SLAAC on both interfaces

    Changes:
        - Added the test case:
        Verify SLAAC on both interfaces

     Tested:
        Ran and Tested on BMC Environment.

Change-Id: Id846d7b4694c917bb3c06d13dfabce12b4f5339b
Signed-off-by: Sweta Potthuri <spotthur@in.ibm.com>
diff --git a/redfish/managers/test_bmc_ipv6.robot b/redfish/managers/test_bmc_ipv6.robot
index 78a8af2..d11a4a1 100644
--- a/redfish/managers/test_bmc_ipv6.robot
+++ b/redfish/managers/test_bmc_ipv6.robot
@@ -114,11 +114,11 @@
     Verify IPv6 On BMC  ${test_ipv6_addr}
 
 
-Enable SLAACv6 On BMC And Verify
-    [Documentation]  Enable SLAACv6 on BMC and verify.
-    [Tags]  Enable_SLAACv6_On_BMC_And_Verify
+Enable SLAAC On BMC And Verify
+    [Documentation]  Enable SLAAC on BMC and verify.
+    [Tags]  Enable_SLAAC_On_BMC_And_Verify
 
-    Set SLAACv6 Configuration State And Verify  ${True}
+    Set SLAAC Configuration State And Verify  ${True}
 
 
 Enable DHCPv6 Property On BMC And Verify
@@ -198,18 +198,17 @@
 Verify BMC Gets SLAAC Address On Enabling SLAAC
     [Documentation]  On enabling SLAAC verify SLAAC address comes up.
     [Tags]  Verify_BMC_Gets_SLAAC_Address_On_Enabling_SLAAC
-    [Setup]  Set SLAACv6 Configuration State And Verify  ${False}
+    [Setup]  Set SLAAC Configuration State And Verify  ${False}
 
-    Set SLAACv6 Configuration State And Verify  ${True}
+    Set SLAAC Configuration State And Verify  ${True}
     Sleep  ${NETWORK_TIMEOUT}
-    Check BMC Gets SLAACv6 Address
+    Check BMC Gets SLAAC Address
 
 
 Enable And Verify DHCPv6 Property On Eth1 When DHCPv6 Property Enabled On Eth0
     [Documentation]  Verify DHCPv6 on eth1 when DHCPv6 property is enabled on eth0.
     [Tags]  Enable_And_Verify_DHCPv6_Property_On_Eth1_When_DHCPv6_Property_Enabled_On_Eth0
-    [Setup]  Run Keywords  Get The Initial DHCPv6 Setting  ${1}  dhcpv6_channel_1
-    ...  AND  Get The Initial DHCPv6 Setting  ${2}  dhcpv6_channel_2
+    [Setup]  Get The Initial DHCPv6 Settings
     [Teardown]  Run Keywords  Set And Verify DHCPv6 Property  ${dhcpv6_channel_1}  ${1}
     ...  AND  Set And Verify DHCPv6 Property  ${dhcpv6_channel_2}  ${2}
 
@@ -217,6 +216,20 @@
     Set And Verify DHCPv6 Property  Enabled  ${2}
 
 
+Enable And Verify SLAAC Property On Eth1 When SLAAC Property Enabled On Eth0
+    [Documentation]  Enable and verify SLAAC property on Eth1 when SLAAC property enabled on Eth0.
+    [Tags]  Enable_And_Verify_SLAAC_Property_On_Eth1_When_SLAAC_Property_Enabled_On_Eth0
+    [Setup]  Get The Initial SLAAC Settings
+    [Teardown]  Run Keywords  Set SLAAC Configuration State And Verify  ${slaac_channel_1}  [${HTTP_OK}]  ${1}
+    ...  AND  Set SLAAC Configuration State And Verify  ${slaac_channel_2}  [${HTTP_OK}]  ${2}
+
+    Set SLAAC Configuration State And Verify   ${True}  [${HTTP_OK}]  ${1}
+    Set SLAAC Configuration State And Verify   ${True}  [${HTTP_OK}]  ${2}
+
+    # Check all the addresses and address origins remain intact.
+    Verify All The Addresses Are Intact
+
+
 *** Keywords ***
 
 Suite Setup Execution
@@ -230,6 +243,14 @@
 
     Set Suite variable  ${ethernet_interface}
 
+    ${initial_ipv4_addressorigin_list}  ${initial_ipv4_addr_list}=  Get Address Origin List And IPv4 or IPv6 Address  IPv4Addresses
+    ${initial_ipv6_addressorigin_list}  ${initial_ipv6_addr_list}=  Get Address Origin List And IPv4 or IPv6 Address  IPv6Addresses
+
+    Set Suite Variable   ${initial_ipv4_addressorigin_list}
+    Set Suite Variable   ${initial_ipv4_addr_list}
+    Set Suite Variable   ${initial_ipv6_addressorigin_list}
+    Set Suite Variable   ${initial_ipv6_addr_list}
+
 
 Test Setup Execution
     [Documentation]  Test setup execution.
@@ -578,13 +599,14 @@
     Validate IPv6 Network Config On BMC
 
 
-Set SLAACv6 Configuration State And Verify
-    [Documentation]  Set SLAACv6 configuration state and verify.
-    [Arguments]  ${slaac_state}  ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]
+Set SLAAC Configuration State And Verify
+    [Documentation]  Set SLAAC configuration state and verify.
+    [Arguments]  ${slaac_state}  ${valid_status_codes}=[${HTTP_OK},${HTTP_ACCEPTED},${HTTP_NO_CONTENT}]  ${channel_number}=${CHANNEL_NUMBER}
 
     # Description of argument(s):
-    # slaac_state         SLAACv6 state('True' or 'False').
+    # slaac_state         SLAAC state('True' or 'False').
     # valid_status_code   Expected valid status codes.
+    # channel_number      Channel number 1(eth0) or 2(eth1).
 
     ${active_channel_config}=  Get Active Channel Config
     ${ethernet_interface}=  Set Variable  ${active_channel_config['${CHANNEL_NUMBER}']['name']}
@@ -593,12 +615,12 @@
     ${resp}=  Redfish.Patch  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
     ...  body=${data}  valid_status_codes=${valid_status_codes}
 
-    # Verify SLAACv6 is set correctly.
+    # Verify SLAAC is set correctly.
     ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
     ${slaac_verify}=  Get From Dictionary  ${resp.dict}  StatelessAddressAutoConfig
 
     IF  '${slaac_verify['IPv6AutoConfigEnabled']}' != '${slaac_state}'
-        Fail  msg=SLAACv6 not set properly.
+        Fail  msg=SLAAC not set properly.
     END
 
 Set And Verify DHCPv6 Property
@@ -814,9 +836,7 @@
     # Verify the address origin contains static and linklocal.
     @{ipv6_addressorigin_list}  ${ipv6_linklocal_addr}=  Get Address Origin List And Address For Type  LinkLocal
 
-    Should Not Be Empty  ${ipv6_linklocal_addr}  msg=LinkLocal address is not present.
     Should Match Regexp  ${ipv6_linklocal_addr}        ${linklocal_addr_format}
-    Should Contain       ${ipv6_addressorigin_list}    LinkLocal
     Should Contain       ${ipv6_addressorigin_list}    Static
 
 
@@ -825,8 +845,6 @@
 
     # Fetch the linklocal address.
     @{ipv6_addressorigin_list}  ${ipv6_linklocal_addr}=  Get Address Origin List And Address For Type  LinkLocal
-    Should Contain  ${ipv6_addressorigin_list}  LinkLocal
-    Should Not Be Empty  ${ipv6_linklocal_addr}  msg=LinkLocal address is not present.
 
     # Follow EUI64 from MAC.
     ${system_mac}=  Get BMC MAC Address
@@ -842,27 +860,58 @@
     Should Be Equal  ${linklocal}  ${ipv6_linklocal_addr}
 
 
-Check BMC Gets SLAACv6 Address
-    [Documentation]  Check BMC gets slaacv6 address.
+Check BMC Gets SLAAC Address
+    [Documentation]  Check BMC gets slaac address.
 
     @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=  Get Address Origin List And Address For Type  SLAAC
 
-    Should Contain  ${ipv6_addressorigin_list}  SLAAC
-    Should Not Be Empty  ${ipv6_slaac_addr}  msg=SLAACv6 address is not present.
 
-
-Get The Initial DHCPv6 Setting
-    [Documentation]  Get the initial DHCPv6 setting and store in a variable.
-    [Arguments]  ${channel_number}  ${initial_dhcpv6_before}
+Get The Initial DHCPv6 Setting On Each Interface
+    [Documentation]  Get the initial DHCPv6 setting of each interface.
+    [Arguments]  ${channel_number}
 
     # Description of the argument(s):
-    # channel_number         Channel number 1 or 2.
-    # initial_dhcpv6_before  Variable to store initial DHCPv6 setting.
+    # channel_number    Channel number 1 or 2.
 
     ${ethernet_interface}=  Set Variable  ${active_channel_config['${channel_number}']['name']}
     ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
     ${initial_dhcpv6_iface}=  Get From Dictionary  ${resp.dict}  DHCPv6
-    Set Test Variable  ${${initial_dhcpv6_before}}  ${initial_dhcpv6_iface['OperatingMode']}
+    IF  ${channel_number}==${1}
+        Set Test Variable  ${dhcpv6_channel_1}  ${initial_dhcpv6_iface['OperatingMode']}
+    ELSE
+        Set Test Variable  ${dhcpv6_channel_2}  ${initial_dhcpv6_iface['OperatingMode']}
+    END
+
+
+Get The Initial DHCPv6 Settings
+    [Documentation]  Get the initial DHCPv6 settings of both the interfaces.
+
+    Get The Initial DHCPv6 Setting On Each Interface  ${1}
+    Get The Initial DHCPv6 Setting On Each Interface  ${2}
+
+
+Get The Initial SLAAC Settings
+    [Documentation]  Get the initial SLAAC settings of both the interfaces.
+
+    Get The Initial SLAAC Setting On Each Interface  ${1}
+    Get The Initial SLAAC Setting On Each Interface   ${2}
+
+
+Get The Initial SLAAC Setting On Each Interface
+    [Documentation]  Get the initial SLAAC setting of the interface.
+    [Arguments]  ${channel_number}
+
+    # Description of the argument(s):
+    # channel_number     Channel number 1 or 2.
+
+    ${ethernet_interface}=  Set Variable  ${active_channel_config['${channel_number}']['name']}
+    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${ethernet_interface}
+    ${initial_slaac_iface}=  Get From Dictionary  ${resp.dict}  StatelessAddressAutoConfig
+    IF  ${channel_number}==${1}
+        Set Test Variable  ${slaac_channel_1}  ${initial_slaac_iface['IPv6AutoConfigEnabled']}
+    ELSE
+        Set Test Variable  ${slaac_channel_2}  ${initial_slaac_iface['IPv6AutoConfigEnabled']}
+    END
 
 
 Get Address Origin List And Address For Type
@@ -884,4 +933,48 @@
             Set Test Variable  ${ipv6_type_addr}  ${ipv6_address['Address']}
         END
     END
+    Should Contain  ${ipv6_addressorigin_list}  ${ipv6_address_type}
+    Should Not Be Empty  ${ipv6_type_addr}  msg=${ipv6_address_type} address is not present
     RETURN  @{ipv6_addressorigin_list}  ${ipv6_type_addr}
+
+
+Get Address Origin List And IPv4 or IPv6 Address
+    [Documentation]  Get address origin list and address for type.
+    [Arguments]  ${ip_address_type}
+
+    # Description of the argument(s):
+    # ipv4_address_type  Type of IPv4 or IPv6 address to be checked.
+
+    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
+    @{ip_addresses}=  Get From Dictionary  ${resp.dict}  ${ip_address_type}
+
+    ${ip_addressorigin_list}=  Create List
+    ${ip_addr_list}=  Create List
+    FOR  ${ip_address}  IN  @{ip_addresses}
+        ${ip_addressorigin}=  Get From Dictionary  ${ip_address}  AddressOrigin
+        Append To List  ${ip_addressorigin_list}  ${ip_addressorigin}
+        Append To List  ${ip_addr_list}  ${ip_address['Address']}
+    END
+    RETURN  ${ip_addressorigin_list}  ${ip_addr_list}
+
+
+Verify All The Addresses Are Intact
+    [Documentation]  Verify all the addresses and address origins remain intact.
+
+    # Verify that it will not impact the IPv4 configuration.
+    Sleep  ${NETWORK_TIMEOUT}
+    Wait For Host To Ping  ${OPENBMC_HOST}  ${NETWORK_TIMEOUT}
+
+    # IPv6 address must be present.
+    @{ipv6_addressorigin_list}  ${ipv6_slaac_addr}=  Get Address Origin List And Address For Type  SLAAC
+    @{ipv6_addressorigin_list}  ${ipv6_linklocal_addr}=  Get Address Origin List And Address For Type  LinkLocal
+
+    # IPv4 and IPv6 addresses must remain intact.
+    ${ipv4_addressorigin_list}  ${ipv4_addr_list}=  Get Address Origin List And IPv4 or IPv6 Address  IPv4Addresses
+    ${ipv6_addressorigin_list}  ${ipv6_addr_list}=  Get Address Origin List And IPv4 or IPv6 Address  IPv6Addresses
+
+    ${ipv6_is_subset}=  Evaluate  set(${initial_ipv6_addr_list}).issubset(set(${ipv6_addr_list}))
+    Should Be True  ${ipv6_is_subset}
+
+    Should be Equal  ${initial_ipv4_addressorigin_list}  ${ipv4_addressorigin_list}
+    Should be Equal  ${initial_ipv4_addr_list}  ${ipv4_addr_list}