IPv6 libraries and base code

Signed-off-by: Prashanth Katti <prkatti1@in.ibm.com>
Change-Id: I0bffbe24582f8adcf69755f318e3c2686eaab022
diff --git a/lib/bmc_ipv6_utils.robot b/lib/bmc_ipv6_utils.robot
new file mode 100644
index 0000000..b9e88a3
--- /dev/null
+++ b/lib/bmc_ipv6_utils.robot
@@ -0,0 +1,53 @@
+*** Settings ***
+Resource                ../lib/utils.robot
+Resource                ../lib/connection_client.robot
+Resource                ../lib/boot_utils.robot
+Library                 ../lib/gen_misc.py
+Library                 ../lib/utils.py
+Library                 ../lib/bmc_network_utils.py
+
+
+*** Keywords ***
+
+Get BMC IPv6 Info
+    [Documentation]  Get system IPv6 address and prefix length.
+
+    # Get system IP address and prefix length details using "ip addr"
+    # Sample Output of "ip addr":
+    # 1: eth0: <BROADCAST,MULTIAST> mtu 1500 qdisc mq state UP qlen 1000
+    #     link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
+    #     inet xx.xx.xx.xx/24 brd xx.xx.xx.xx scope global eth0
+    #     inet6 fe80::xxxx:xxxx:xxxx:xxxx/64 scope link
+    #     inet6 xxxx::xxxx:xxxx:xxxx:xxxx/64 scope global
+
+    ${cmd_output}  ${stderr}  ${rc}=  BMC Execute Command  /sbin/ip addr
+
+    # Get line having IPv6 address details.
+    ${lines}=  Get Lines Containing String  ${cmd_output}  inet6
+
+    # List IP address details.
+    @{ip_components}=  Split To Lines  ${lines}
+
+    @{ipv6_data}=  Create List
+
+    # Get all IP addresses and prefix lengths on system.
+    FOR  ${ip_component}  IN  @{ip_components}
+      @{if_info}=  Split String  ${ip_component}
+      ${ip_n_prefix}=  Get From List  ${if_info}  1
+      Append To List  ${ipv6_data}  ${ip_n_prefix}
+    END
+
+    [Return]  ${ipv6_data}
+
+
+Verify IPv6 On BMC
+    [Documentation]  Verify IPv6 on BMC.
+    [Arguments]  ${ipv6}
+
+    # Description of argument(s):
+    # ipv6  IPv6 address to be verified (e.g. "2001::1234:1234").
+
+    # Get IPv6 address details on BMC using IP command.
+    @{ip_data}=  Get BMC IPv6 Info
+    Should Contain Match  ${ip_data}  ${ipv6}/*
+    ...  msg=IPv6 address does not exist.
diff --git a/redfish/managers/test_bmc_ipv6.robot b/redfish/managers/test_bmc_ipv6.robot
new file mode 100644
index 0000000..87b8a30
--- /dev/null
+++ b/redfish/managers/test_bmc_ipv6.robot
@@ -0,0 +1,138 @@
+*** Settings ***
+Documentation  Network interface IPv6 configuration and verification
+               ...  tests.
+
+Resource       ../../lib/bmc_redfish_resource.robot
+Resource       ../../lib/openbmc_ffdc.robot
+Resource       ../../lib/bmc_ipv6_utils.robot
+Library        ../../lib/bmc_network_utils.py
+Library        Collections
+
+Test Setup     Test Setup Execution
+Test Teardown  Test Teardown Execution
+
+
+*** Variables ***
+${test_ipv6_addr}          2001:db8:3333:4444:5555:6666:7777:8888
+${test_ipv6_invalid_addr}  2001:db8:3333:4444:5555:6666:7777:JJJJ
+
+# Valid prefix length is a intiger ranges from 1 to 128.
+${test_prefix_lenght}     64
+
+
+*** Test Cases ***
+
+Get IPv6 Address And Verify
+    [Documentation]  Get IPv6 Address And Verify.
+    [Tags]  Get_IPv6_Address_And_Verify
+
+    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
+      Verify IPv6 On BMC  ${ipv6_network_configuration['Address']}
+    END
+
+
+*** Keywords ***
+
+Test Setup Execution
+    [Documentation]  Test setup execution.
+
+    Redfish.Login
+
+    @{ipv6_network_configurations}=  Get IPv6 Network Configuration
+    Set Test Variable  @{ipv6_network_configurations}
+
+    # Get BMC IPv6 address and prefix length.
+    ${ipv6_data}=  Get BMC IPv6 Info
+    Set Test Variable  ${ipv6_data}
+
+
+Test Teardown Execution
+    [Documentation]  Test teardown execution.
+
+    FFDC On Test Case Fail
+    Redfish.Logout
+
+
+Get IPv6 Network Configuration
+    [Documentation]  Get Ipv6 network configuration.
+    # Sample output:
+    # {
+    #  "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0",
+    #  "@odata.type": "#EthernetInterface.v1_4_1.EthernetInterface",
+    #   "DHCPv4": {
+    #    "DHCPEnabled": false,
+    #    "UseDNSServers": false,
+    #    "UseDomainName": true,
+    #    "UseNTPServers": false
+    #  },
+    #  "DHCPv6": {
+    #    "OperatingMode": "Disabled",
+    #    "UseDNSServers": false,
+    #    "UseDomainName": true,
+    #    "UseNTPServers": false
+    #  },
+    #  "Description": "Management Network Interface",
+    #  "FQDN": "localhost",
+    #  "HostName": "localhost",
+    #  "IPv4Addresses": [
+    #    {
+    #      "Address": "xx.xx.xx.xx",
+    #      "AddressOrigin": "Static",
+    #      "Gateway": "xx.xx.xx.1",
+    #      "SubnetMask": "xx.xx.xx.0"
+    #    },
+    #    {
+    #      "Address": "169.254.xx.xx",
+    #      "AddressOrigin": "IPv4LinkLocal",
+    #      "Gateway": "0.0.0.0",
+    #      "SubnetMask": "xx.xx.0.0"
+    #    },
+    #  ],
+    #  "IPv4StaticAddresses": [
+    #    {
+    #      "Address": "xx.xx.xx.xx",
+    #      "AddressOrigin": "Static",
+    #      "Gateway": "xx.xx.xx.1",
+    #      "SubnetMask": "xx.xx.0.0"
+    #    }
+    # }
+    #  ],
+    #  "IPv6AddressPolicyTable": [],
+    #  "IPv6Addresses": [
+    #    {
+    #      "Address": "fe80::xxxx:xxxx:xxxx:xxxx",
+    #      "AddressOrigin": "LinkLocal",
+    #      "AddressState": null,
+    #      "PrefixLength": xx
+    #    }
+    #  ],
+    #  "IPv6DefaultGateway": "",
+    #  "IPv6StaticAddresses": [
+    #    { "Address": "xxxx:xxxx:xxxx:xxxx::xxxx",
+    #      "AddressOrigin": "Static",
+    #      "AddressState": null,
+    #      "PrefixLength": xxx
+    #    }
+    #  ],
+    #  "Id": "eth0",
+    #  "InterfaceEnabled": true,
+    #  "LinkStatus": "LinkUp",
+    #  "MACAddress": "xx:xx:xx:xx:xx:xx",
+    #  "Name": "Manager Ethernet Interface",
+    #  "NameServers": [],
+    #  "SpeedMbps": 0,
+    #  "StaticNameServers": [],
+    #  "Status": {
+    #    "Health": "OK",
+    #    "HealthRollup": "OK",
+    #    "State": "Enabled"
+    #  },
+    #  "VLANs": {
+    #    "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0/VLANs"
+
+
+    ${active_channel_config}=  Get Active Channel Config
+    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
+
+    @{ipv6_network_configurations}=  Get From Dictionary  ${resp.dict}  IPv6StaticAddresses
+    [Return]  @{ipv6_network_configurations}