1*** Settings ***
2Documentation  Network interface IPv6 configuration and verification
3               ...  tests.
4
5Resource       ../../lib/bmc_redfish_resource.robot
6Resource       ../../lib/openbmc_ffdc.robot
7Resource       ../../lib/bmc_ipv6_utils.robot
8Library        ../../lib/bmc_network_utils.py
9Library        Collections
10
11Test Setup     Test Setup Execution
12Test Teardown  Test Teardown Execution
13
14
15*** Variables ***
16${test_ipv6_addr}          2001:db8:3333:4444:5555:6666:7777:8888
17${test_ipv6_invalid_addr}  2001:db8:3333:4444:5555:6666:7777:JJJJ
18
19# Valid prefix length is a intiger ranges from 1 to 128.
20${test_prefix_lenght}     64
21
22
23*** Test Cases ***
24
25Get IPv6 Address And Verify
26    [Documentation]  Get IPv6 Address And Verify.
27    [Tags]  Get_IPv6_Address_And_Verify
28
29    FOR  ${ipv6_network_configuration}  IN  @{ipv6_network_configurations}
30      Verify IPv6 On BMC  ${ipv6_network_configuration['Address']}
31    END
32
33
34*** Keywords ***
35
36Test Setup Execution
37    [Documentation]  Test setup execution.
38
39    Redfish.Login
40
41    @{ipv6_network_configurations}=  Get IPv6 Network Configuration
42    Set Test Variable  @{ipv6_network_configurations}
43
44    # Get BMC IPv6 address and prefix length.
45    ${ipv6_data}=  Get BMC IPv6 Info
46    Set Test Variable  ${ipv6_data}
47
48
49Test Teardown Execution
50    [Documentation]  Test teardown execution.
51
52    FFDC On Test Case Fail
53    Redfish.Logout
54
55
56Get IPv6 Network Configuration
57    [Documentation]  Get Ipv6 network configuration.
58    # Sample output:
59    # {
60    #  "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0",
61    #  "@odata.type": "#EthernetInterface.v1_4_1.EthernetInterface",
62    #   "DHCPv4": {
63    #    "DHCPEnabled": false,
64    #    "UseDNSServers": false,
65    #    "UseDomainName": true,
66    #    "UseNTPServers": false
67    #  },
68    #  "DHCPv6": {
69    #    "OperatingMode": "Disabled",
70    #    "UseDNSServers": false,
71    #    "UseDomainName": true,
72    #    "UseNTPServers": false
73    #  },
74    #  "Description": "Management Network Interface",
75    #  "FQDN": "localhost",
76    #  "HostName": "localhost",
77    #  "IPv4Addresses": [
78    #    {
79    #      "Address": "xx.xx.xx.xx",
80    #      "AddressOrigin": "Static",
81    #      "Gateway": "xx.xx.xx.1",
82    #      "SubnetMask": "xx.xx.xx.0"
83    #    },
84    #    {
85    #      "Address": "169.254.xx.xx",
86    #      "AddressOrigin": "IPv4LinkLocal",
87    #      "Gateway": "0.0.0.0",
88    #      "SubnetMask": "xx.xx.0.0"
89    #    },
90    #  ],
91    #  "IPv4StaticAddresses": [
92    #    {
93    #      "Address": "xx.xx.xx.xx",
94    #      "AddressOrigin": "Static",
95    #      "Gateway": "xx.xx.xx.1",
96    #      "SubnetMask": "xx.xx.0.0"
97    #    }
98    # }
99    #  ],
100    #  "IPv6AddressPolicyTable": [],
101    #  "IPv6Addresses": [
102    #    {
103    #      "Address": "fe80::xxxx:xxxx:xxxx:xxxx",
104    #      "AddressOrigin": "LinkLocal",
105    #      "AddressState": null,
106    #      "PrefixLength": xx
107    #    }
108    #  ],
109    #  "IPv6DefaultGateway": "",
110    #  "IPv6StaticAddresses": [
111    #    { "Address": "xxxx:xxxx:xxxx:xxxx::xxxx",
112    #      "AddressOrigin": "Static",
113    #      "AddressState": null,
114    #      "PrefixLength": xxx
115    #    }
116    #  ],
117    #  "Id": "eth0",
118    #  "InterfaceEnabled": true,
119    #  "LinkStatus": "LinkUp",
120    #  "MACAddress": "xx:xx:xx:xx:xx:xx",
121    #  "Name": "Manager Ethernet Interface",
122    #  "NameServers": [],
123    #  "SpeedMbps": 0,
124    #  "StaticNameServers": [],
125    #  "Status": {
126    #    "Health": "OK",
127    #    "HealthRollup": "OK",
128    #    "State": "Enabled"
129    #  },
130    #  "VLANs": {
131    #    "@odata.id": "/redfish/v1/Managers/bmc/EthernetInterfaces/eth0/VLANs"
132
133
134    ${active_channel_config}=  Get Active Channel Config
135    ${resp}=  Redfish.Get  ${REDFISH_NW_ETH_IFACE}${active_channel_config['${CHANNEL_NUMBER}']['name']}
136
137    @{ipv6_network_configurations}=  Get From Dictionary  ${resp.dict}  IPv6StaticAddresses
138    [Return]  @{ipv6_network_configurations}
139