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