xref: /openbmc/openbmc-test-automation/network/test_host_network.robot (revision 6fb70d98f2f1cb9273ba912deaa2cebe3c23ea86)
1f0199a08SGeorge Keishing*** Settings ***
2f0199a08SGeorge Keishing
3f0199a08SGeorge KeishingDocumentation       Test setting network address of host OS.
4f0199a08SGeorge Keishing
5f0199a08SGeorge KeishingResource            ../lib/rest_client.robot
6f0199a08SGeorge KeishingResource            ../lib/ipmi_client.robot
7f0199a08SGeorge KeishingResource            ../lib/utils.robot
8f0199a08SGeorge KeishingResource            ../lib/openbmc_ffdc.robot
9f0199a08SGeorge KeishingLibrary             ../lib/utilities.py
10f0199a08SGeorge Keishing
11f0199a08SGeorge KeishingTest Setup          Open Connection And Log In
12f0199a08SGeorge KeishingTest Teardown       Test Teardown Execution
13f0199a08SGeorge Keishing
14*6fb70d98SMatt FischerTest Tags          Host_Network
15f0199a08SGeorge Keishing
16f0199a08SGeorge Keishing*** Variables ***
17f0199a08SGeorge Keishing${SET_ADDR_PREFIX}  0x00 0x08 0x61 0x80 0x21 0x70 0x62 0x21 0x00 0x01 0x06 0x04
18f0199a08SGeorge Keishing${STATIC}           0x00 0x01                       #equivalent address type 1
19f0199a08SGeorge Keishing${DHCP}             0x00 0x00                       #equivalent address type 0
20f0199a08SGeorge Keishing${CLEAR_ADDR}       0x00 0x08 0x61 0x80 0x00 0x00 0x00 0x00
21f0199a08SGeorge Keishing
22f0199a08SGeorge Keishing
23f0199a08SGeorge Keishing*** Test Cases ***
24f0199a08SGeorge Keishing
25f0199a08SGeorge KeishingSet Static Host Network Address Via IPMI
26f0199a08SGeorge Keishing    [Documentation]  Set static host network address via IPMI and verify
27f0199a08SGeorge Keishing    ...  IP address set with REST.
28f0199a08SGeorge Keishing    [Tags]  Set_Static_Host_Network_Address_Via_IPMI
29f0199a08SGeorge Keishing
30f0199a08SGeorge Keishing    ${ip_address}=  utilities.random_ip
31f0199a08SGeorge Keishing    ${gateway_ip}=  utilities.random_ip
32f0199a08SGeorge Keishing    ${mac_address}=  utilities.random_mac
33f0199a08SGeorge Keishing    ${prefix_length}=  Evaluate  random.randint(0, 32)  modules=random
34f0199a08SGeorge Keishing
35f0199a08SGeorge Keishing    ${mac_address_hex}=  Mac Address To Hex String  ${mac_address}
36f0199a08SGeorge Keishing    ${ip_address_hex}=  IP Address To Hex String  ${ip_address}
37f0199a08SGeorge Keishing    ${gateway_hex}=  IP Address To Hex String  ${gateway_ip}
38f0199a08SGeorge Keishing    ${prefix_hex}=  Convert To Hex  ${prefix_length}  prefix=0x  lowercase=yes
39f0199a08SGeorge Keishing
40f0199a08SGeorge Keishing    ${ipmi_raw_cmd}=  Catenate  SEPARATOR=
41f0199a08SGeorge Keishing    ...  ${SET_ADDR_PREFIX}${SPACE}${mac_address_hex}${SPACE}${STATIC}${SPACE}
42f0199a08SGeorge Keishing    ...  ${ip_address_hex}${SPACE}${prefix_hex}${SPACE}${gateway_hex}
43f0199a08SGeorge Keishing
44f0199a08SGeorge Keishing    Run IPMI command  ${ipmi_raw_cmd}
45f0199a08SGeorge Keishing
46f0199a08SGeorge Keishing    ${data}=  Read Properties  ${NETWORK_MANAGER}host0/intf/addr
47f0199a08SGeorge Keishing    Should Contain  ${data["Origin"]}  Static
48f0199a08SGeorge Keishing    Should Be Equal  ${data["Address"]}  ${ip_address}
49f0199a08SGeorge Keishing    Should Be Equal  ${data["Gateway"]}  ${gateway_ip}
50f0199a08SGeorge Keishing
51f0199a08SGeorge Keishing    ${new_mac_address}=
52f0199a08SGeorge Keishing    ...  Read Attribute  ${NETWORK_MANAGER}host0/intf  MACAddress
53f0199a08SGeorge Keishing    Should Be Equal  ${new_mac_address}  ${mac_address}
54f0199a08SGeorge Keishing
55f0199a08SGeorge Keishing
56f0199a08SGeorge KeishingSet DHCP Host Address Via IPMI
57f0199a08SGeorge Keishing    [Documentation]  Set dhcp host network address via IPMI and verify
58f0199a08SGeorge Keishing    ...  IP address set with REST.
59f0199a08SGeorge Keishing    [Tags]  Set_DHCP_Host_Address_Via_IPMI
60f0199a08SGeorge Keishing
61f0199a08SGeorge Keishing    ${mac_address}=  utilities.random_mac
62f0199a08SGeorge Keishing    ${mac_address_hex}=  Mac Address To Hex String  ${mac_address}
63f0199a08SGeorge Keishing
64f0199a08SGeorge Keishing    ${ipmi_raw_cmd}=  Catenate  SEPARATOR=
65f0199a08SGeorge Keishing    ...  ${SET_ADDR_PREFIX}${SPACE}${mac_address_hex}${SPACE}${DHCP}
66f0199a08SGeorge Keishing    Run IPMI command  ${ipmi_raw_cmd}
67f0199a08SGeorge Keishing
68f0199a08SGeorge Keishing    ${origin}=  Read Attribute  ${NETWORK_MANAGER}host0/intf/addr  Origin
69f0199a08SGeorge Keishing    ${new_mac_address}=
70f0199a08SGeorge Keishing    ...  Read Attribute  ${NETWORK_MANAGER}host0/intf  MACAddress
71f0199a08SGeorge Keishing    Should Contain  ${origin}  DHCP
72f0199a08SGeorge Keishing    Should Be Equal  ${new_mac_address}  ${mac_address}
73f0199a08SGeorge Keishing
74f0199a08SGeorge Keishing
75f0199a08SGeorge Keishing*** Keywords ***
76f0199a08SGeorge Keishing
77f0199a08SGeorge KeishingTest Teardown Execution
78f0199a08SGeorge Keishing    [Documentation]  Do the post test teardown.
79f0199a08SGeorge Keishing
80f0199a08SGeorge Keishing    FFDC On Test Case Fail
81f0199a08SGeorge Keishing    Run IPMI command  ${CLEAR_ADDR}
82f0199a08SGeorge Keishing    Close All Connections
83