Added testcase when LAN and VLAN exist with IP address
Change-Id: Ida40c6eb1646f1b08c2a37871636e20e47d81391
Signed-off-by: Anvesh Kumar Rayankula <anvesr77@in.ibm.com>
diff --git a/data/variables.py b/data/variables.py
index 00120bb..7727029 100755
--- a/data/variables.py
+++ b/data/variables.py
@@ -17,6 +17,7 @@
WATCHDOG_URI = OPENBMC_BASE_URI + 'watchdog/'
TIME_MANAGER_URI = OPENBMC_BASE_URI + 'time/'
NETWORK_MANAGER = OPENBMC_BASE_URI + 'network/'
+NETWORK_RESOURCE = 'xyz.openbmc_project.Network.IP.Protocol.IPv4'
# SNMP
SNMP_MANAGER_URI = NETWORK_MANAGER + 'snmp/manager/'
# Sensors base variables.
diff --git a/ipmi/test_ipmi_network_configuration.robot b/ipmi/test_ipmi_network_configuration.robot
index a9d75ba..4313480 100644
--- a/ipmi/test_ipmi_network_configuration.robot
+++ b/ipmi/test_ipmi_network_configuration.robot
@@ -10,19 +10,24 @@
Library ../lib/bmc_network_utils.py
Suite Setup Suite Setup Execution
+Suite Teardown Redfish.Logout
Test Setup Printn
-Test Teardown FFDC On Test Case Fail
+Test Teardown Test Teardown Execution
Force Tags IPMI_Network_Config
*** Variables ***
-${vlan_id} ${10}
+${vlan_id_for_ipmi} ${10}
@{vlan_ids} ${20} ${30}
${interface} eth0
${ip} 10.0.0.1
${initial_lan_config} &{EMPTY}
${vlan_resource} ${NETWORK_MANAGER}action/VLAN
+${netmask} ${24}
+${gateway} 0.0.0.0
+${vlan_id_for_rest} ${30}
+
*** Test Cases ***
@@ -45,13 +50,9 @@
Disable VLAN Via IPMI When Multiple VLAN Exist On BMC
[Documentation] Disable VLAN Via IPMI When Multiple VLAN Exist On BMC.
[Tags] Disable_VLAN_Via_IPMI_When_LAN_And_VLAN_Exist_On_BMC
- [Teardown] Run Keywords FFDC On Test Case Fail AND
- ... Create VLAN Via IPMI off AND Restore Configuration
FOR ${id} IN @{vlan_ids}
- @{data_vlan_id}= Create List ${interface} ${id}
- ${data}= Create Dictionary data=@{data_vlan_id}
- ${resp}= OpenBMC Post Request ${vlan_resource} data=${data}
+ Create VLAN ${vlan_id_for_rest}
END
Create VLAN Via IPMI off
@@ -63,62 +64,63 @@
Configure IP On VLAN Via IPMI
[Documentation] Configure IP On VLAN Via IPMI.
[Tags] Configure_IP_On_VLAN_Via_IPMI
- [Teardown] Run Keywords FFDC On Test Case Fail AND
- ... Create VLAN Via IPMI off AND Restore Configuration
- Create VLAN Via IPMI ${vlan_id}
+ Create VLAN Via IPMI ${vlan_id_for_ipmi}
Run Inband IPMI Standard Command
... lan set ${CHANNEL_NUMBER} ipaddr ${ip} login_host=${0}
${lan_config}= Get LAN Print Dict ${CHANNEL_NUMBER} ipmi_cmd_type=inband
- Valid Value lan_config['802.1q VLAN ID'] ['${vlan_id}']
+ Valid Value lan_config['802.1q VLAN ID'] ['${vlan_id_for_ipmi}']
Valid Value lan_config['IP Address'] ["${ip}"]
Create VLAN Via IPMI When LAN And VLAN Exist On BMC
[Documentation] Create VLAN Via IPMI When LAN And VLAN Exist On BMC.
[Tags] Create_VLAN_Via_IPMI_When_LAN_And_VLAN_Exist_On_BMC
- [Teardown] Run Keywords FFDC On Test Case Fail AND
- ... Create VLAN Via IPMI off AND Restore Configuration
+ [Setup] Create VLAN ${vlan_id_for_rest}
- @{data_vlan_id}= Create List ${interface} ${vlan_id}
- ${data}= Create Dictionary data=@{data_vlan_id}
- ${resp}= OpenBMC Post Request ${vlan_resource} data=${data}
-
- Create VLAN Via IPMI ${vlan_id}
+ Create VLAN Via IPMI ${vlan_id_for_ipmi}
${lan_config}= Get LAN Print Dict ${CHANNEL_NUMBER} ipmi_cmd_type=inband
- Valid Value lan_config['802.1q VLAN ID'] ['${vlan_id}']
+ Valid Value lan_config['802.1q VLAN ID'] ['${vlan_id_for_ipmi}']
-Create VLAN Via IPMI
+Create VLAN Via IPMI And Verify
[Documentation] Create and verify VLAN via IPMI.
[Tags] Create_VLAN_Via_IPMI_And_Verify
- [Teardown] Run Keywords FFDC On Test Case Fail AND
- ... Create VLAN Via IPMI off AND Restore Configuration
- Create VLAN Via IPMI ${vlan_id}
+ Create VLAN Via IPMI ${vlan_id_for_ipmi}
${lan_config}= Get LAN Print Dict ${CHANNEL_NUMBER} ipmi_cmd_type=inband
- Valid Value lan_config['802.1q VLAN ID'] ['${vlan_id}']
+ Valid Value lan_config['802.1q VLAN ID'] ['${vlan_id_for_ipmi}']
Valid Value lan_config['IP Address'] ['${network_configurations[0]['Address']}']
Valid Value lan_config['Subnet Mask'] ['${network_configurations[0]['SubnetMask']}']
-Create VLAN Via IPMI And Disable VLAN
+Test Disabling Of VLAN Via IPMI
[Documentation] Disable VLAN and verify via IPMI.
- [Tags] Test_Disable_VLAN_Via_IPMI
- [Teardown] Run Keywords FFDC On Test Case Fail AND
- ... Create VLAN Via IPMI off AND Restore Configuration
+ [Tags] Test_Disabling_Of_VLAN_Via_IPMI
- Create VLAN Via IPMI ${vlan_id}
+ Create VLAN Via IPMI ${vlan_id_for_ipmi}
Create VLAN Via IPMI off
- ${lan_config}= Get LAN Print Dict
+ ${lan_config}= Get LAN Print Dict ${CHANNEL_NUMBER} ipmi_cmd_type=inband
Valid Value lan_config['802.1q VLAN ID'] ['Disabled']
+Create VLAN When LAN And VLAN Exist With IP Address Configured
+ [Documentation] Create VLAN when LAN and VLAN exist with IP address configured.
+ [Tags] Create_VLAN_When_LAN_And_VLAN_Exist_With_IP_Address_Configured
+ [Setup] Run Keywords Create VLAN ${vlan_id_for_rest} AND Configure Network Settings On VLAN
+ ... ${vlan_id_for_rest} ${ip} ${netmask} ${gateway}
+
+ Create VLAN Via IPMI ${vlan_id_for_ipmi}
+
+ ${lan_config}= Get LAN Print Dict ${CHANNEL_NUMBER} ipmi_cmd_type=inband
+ Valid Value lan_config['802.1q VLAN ID'] ['${vlan_id_for_ipmi}']
+ Valid Value lan_config['IP Address'] ['${ip}']
+
*** Keywords ***
Create VLAN Via IPMI
@@ -175,3 +177,12 @@
${initial_lan_config}= Get LAN Print Dict ${CHANNEL_NUMBER} ipmi_cmd_type=inband
Set Suite Variable ${initial_lan_config}
+
+
+Test Teardown Execution
+ [Documentation] Test Teardown Execution.
+
+ FFDC On Test Case Fail
+ Create VLAN Via IPMI off
+ Restore Configuration
+
diff --git a/lib/bmc_network_utils.robot b/lib/bmc_network_utils.robot
index 587883d..3c5592e 100644
--- a/lib/bmc_network_utils.robot
+++ b/lib/bmc_network_utils.robot
@@ -66,10 +66,11 @@
@{ip_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 ${ip_data} ${ip_n_prefix}
+ FOR ${ip_component} IN @{ip_components}
+ @{if_info}= Split String ${ip_component}
+ ${ip_n_prefix}= Get From List ${if_info} 1
+ Append To List ${ip_data} ${ip_n_prefix}
+ END
[Return] ${ip_data}
@@ -123,9 +124,10 @@
${mac_list}= Create List
@{lines}= Split To Lines ${cmd_output}
- :FOR ${line} IN @{lines}
- \ @{words}= Split String ${line}
- \ Append To List ${mac_list} ${words[1]}
+ FOR ${line} IN @{lines}
+ @{words}= Split String ${line}
+ Append To List ${mac_list} ${words[1]}
+ END
[Return] ${mac_list}
@@ -153,9 +155,10 @@
${ip_list}= Create List
- : FOR ${ip_uri} IN @{ip_uri_list}
- \ ${ip_addr}= Read Attribute ${ip_uri} Address
- \ Append To List ${ip_list} ${ip_addr}
+ FOR ${ip_uri} IN @{ip_uri_list}
+ ${ip_addr}= Read Attribute ${ip_uri} Address
+ Append To List ${ip_list} ${ip_addr}
+ END
[Return] @{ip_list}
@@ -169,9 +172,10 @@
# Find IP object having this IP address.
- : FOR ${ip_uri} IN @{ip_uri_list}
- \ ${ip_addr1}= Read Attribute ${ip_uri} Address
- \ Run Keyword If '${ip_addr}' == '${ip_addr1}' Exit For Loop
+ FOR ${ip_uri} IN @{ip_uri_list}
+ ${ip_addr1}= Read Attribute ${ip_uri} Address
+ Run Keyword If '${ip_addr}' == '${ip_addr1}' Exit For Loop
+ END
# If the given IP address is not configured, return.
# Otherwise, delete the IP and object.
@@ -215,11 +219,12 @@
# First element in list is Network part.
${network_part}= Get From List ${split_ip} 0
- : FOR ${octet4} IN RANGE 1 255
- \ ${new_ip}= Catenate ${network_part}.${octet4}
- \ ${status}= Run Keyword And Return Status Ping Host ${new_ip}
- # If IP is non-pingable, return it.
- \ Return From Keyword If '${status}' == 'False' ${new_ip}
+ FOR ${octet4} IN RANGE 1 255
+ ${new_ip}= Catenate ${network_part}.${octet4}
+ ${status}= Run Keyword And Return Status Ping Host ${new_ip}
+ # If IP is non-pingable, return it.
+ Return From Keyword If '${status}' == 'False' ${new_ip}
+ END
Fail msg=No non-pingable IP could be found in subnet ${network_part}.
@@ -352,6 +357,7 @@
@{network_configurations}= Get From Dictionary ${resp.dict} IPv4StaticAddresses
[Return] @{network_configurations}
+
Add IP Address
[Documentation] Add IP Address To BMC.
[Arguments] ${ip} ${subnet_mask} ${gateway}
@@ -374,8 +380,9 @@
${network_configurations}= Get Network Configuration
${num_entries}= Get Length ${network_configurations}
- : FOR ${INDEX} IN RANGE 0 ${num_entries}
- \ Append To List ${patch_list} ${empty_dict}
+ FOR ${INDEX} IN RANGE 0 ${num_entries}
+ Append To List ${patch_list} ${empty_dict}
+ END
# We need not check for existence of IP on BMC while adding.
Append To List ${patch_list} ${ip_data}
@@ -408,10 +415,11 @@
${patch_list}= Create List
@{network_configurations}= Get Network Configuration
- : FOR ${network_configuration} IN @{network_configurations}
- \ Run Keyword If '${network_configuration['Address']}' == '${ip}'
- ... Append To List ${patch_list} ${null}
- ... ELSE Append To List ${patch_list} ${empty_dict}
+ FOR ${network_configuration} IN @{network_configurations}
+ Run Keyword If '${network_configuration['Address']}' == '${ip}'
+ ... Append To List ${patch_list} ${null}
+ ... ELSE Append To List ${patch_list} ${empty_dict}
+ END
${ip_found}= Run Keyword And Return Status List Should Contain Value
... ${patch_list} ${null} msg=${ip} does not exist on BMC
@@ -441,7 +449,76 @@
@{network_configurations}= Get Network Configuration
${ip_data}= Get BMC IP Info
- : FOR ${network_configuration} IN @{network_configurations}
- \ Should Contain Match ${ip_data} ${network_configuration['Address']}/*
- ... msg=IP address does not exist.
+ FOR ${network_configuration} IN @{network_configurations}
+ Should Contain Match ${ip_data} ${network_configuration['Address']}/*
+ ... msg=IP address does not exist.
+ END
+
+
+Create VLAN
+ [Documentation] Create a VLAN.
+ [Arguments] ${id} ${interface}=eth0 ${expected_result}=valid
+
+ # Description of argument(s):
+ # id The VLAN ID (e.g. '53').
+ # interface The physical interface for the VLAN(e.g. 'eth0').
+ # expected_result Expected status of VLAN configuration.
+
+ @{data_vlan_id}= Create List ${interface} ${id}
+ ${data}= Create Dictionary data=@{data_vlan_id}
+ ${resp}= OpenBMC Post Request ${vlan_resource} data=${data}
+ ${resp.status_code}= Convert To String ${resp.status_code}
+ ${status}= Run Keyword And Return Status
+ ... Valid Value resp.status_code ["${HTTP_OK}"]
+
+ Run Keyword If '${expected_result}' == 'error'
+ ... Should Be Equal ${status} ${False}
+ ... msg=Configuration of an invalid VLAN ID Failed.
+ ... ELSE
+ ... Should Be Equal ${status} ${True}
+ ... msg=Configuration of a valid VLAN ID Failed.
+
+ Sleep ${NETWORK_TIMEOUT}s
+
+
+Configure Network Settings On VLAN
+ [Documentation] Configure network settings.
+ [Arguments] ${id} ${ip_addr} ${prefix_len} ${gateway_ip}=${gateway}
+ ... ${expected_result}=valid ${interface}=eth0
+
+ # Description of argument(s):
+ # id The VLAN ID (e.g. '53').
+ # ip_addr IP address of VLAN Interface.
+ # prefix_len Prefix length of VLAN Interface.
+ # gateway_ip Gateway IP address of VLAN Interface.
+ # expected_result Expected status of network setting configuration.
+ # interface Physical Interface on which the VLAN is defined.
+
+ @{ip_parm_list}= Create List ${network_resource}
+ ... ${ip_addr} ${prefix_len} ${gateway_ip}
+
+ ${data}= Create Dictionary data=@{ip_parm_list}
+
+ Run Keyword And Ignore Error OpenBMC Post Request
+ ... ${NETWORK_MANAGER}${interface}_${id}/action/IP data=${data}
+
+ # After any modification on network interface, BMC restarts network
+ # module, wait until it is reachable. Then wait 15 seconds for new
+ # configuration to be updated on BMC.
+
+ Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
+ ... ${NETWORK_RETRY_TIME}
+ Sleep ${NETWORK_TIMEOUT}s
+
+ # Verify whether new IP address is populated on BMC system.
+ # It should not allow to configure invalid settings.
+ ${status}= Run Keyword And Return Status
+ ... Verify IP On BMC ${ip_addr}
+
+ Run Keyword If '${expected_result}' == 'error'
+ ... Should Be Equal ${status} ${False}
+ ... msg=Configuration of invalid IP Failed.
+ ... ELSE
+ ... Should Be Equal ${status} ${True}
+ ... msg=Configuration of valid IP Failed.
diff --git a/network/test_vlan_network.robot b/network/test_vlan_network.robot
index 38e205a..c3cd886 100644
--- a/network/test_vlan_network.robot
+++ b/network/test_vlan_network.robot
@@ -301,31 +301,6 @@
Run Key U Sleep \ ${NETWORK_TIMEOUT}s
-Create VLAN
- [Documentation] Create a VLAN.
- [Arguments] ${id} ${interface}=eth0 ${expected_result}=valid
-
- # Description of argument(s):
- # id The VLAN ID (e.g. '53').
- # interface The physical interface for the VLAN(e.g. 'eth0').
-
- @{data_vlan_id}= Create List ${interface} ${id}
- ${data}= Create Dictionary data=@{data_vlan_id}
- ${resp}= OpenBMC Post Request ${vlan_resource} data=${data}
- ${resp.status_code}= Convert To String ${resp.status_code}
- ${status}= Run Keyword And Return Status
- ... Valid Value resp.status_code ["${HTTP_OK}"]
-
- Run Keyword If '${expected_result}' == 'error'
- ... Should Be Equal ${status} ${False}
- ... msg=Configuration of an invalid VLAN ID Failed.
- ... ELSE
- ... Should Be Equal ${status} ${True}
- ... msg=Configuration of a valid VLAN ID Failed.
-
- Sleep ${NETWORK_TIMEOUT}s
-
-
Get VLAN IDs
[Documentation] Return all VLAN IDs.
@@ -336,48 +311,6 @@
[Return] @{vlan_ids}
-Configure Network Settings On VLAN
- [Documentation] Configure network settings.
- [Arguments] ${id} ${ip_addr} ${prefix_len} ${gateway_ip}=${gateway}
- ... ${expected_result}=valid ${interface}=eth0
-
- # Description of argument(s):
- # id The VLAN ID (e.g. '53').
- # ip_addr IP address of VLAN Interface.
- # prefix_len Prefix length of VLAN Interface.
- # gateway_ip Gateway IP address of VLAN Interface.
- # expected_result Expected status of network setting configuration.
- # interface Physical Interface on which the VLAN is defined.
-
- @{ip_parm_list}= Create List ${network_resource}
- ... ${ip_addr} ${prefix_len} ${gateway_ip}
-
- ${data}= Create Dictionary data=@{ip_parm_list}
-
- Run Keyword And Ignore Error OpenBMC Post Request
- ... ${NETWORK_MANAGER}${interface}_${id}/action/IP data=${data}
-
- # After any modification on network interface, BMC restarts network
- # module, wait until it is reachable. Then wait 15 seconds for new
- # configuration to be updated on BMC.
-
- Wait For Host To Ping ${OPENBMC_HOST} ${NETWORK_TIMEOUT}
- ... ${NETWORK_RETRY_TIME}
- Sleep ${NETWORK_TIMEOUT}s
-
- # Verify whether new IP address is populated on BMC system.
- # It should not allow to configure invalid settings.
- ${status}= Run Keyword And Return Status
- ... Verify IP On BMC ${ip_addr}
-
- Run Keyword If '${expected_result}' == 'error'
- ... Should Be Equal ${status} ${False}
- ... msg=Configuration of invalid IP Failed.
- ... ELSE
- ... Should Be Equal ${status} ${True}
- ... msg=Configuration of valid IP Failed.
-
-
Get VLAN URI For IP
[Documentation] Get and return the URI for a VLAN IP.
[Arguments] ${vlan_id} ${vlan_ip} ${expected_result}=valid