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