Added more VLAN testcases Via IPMI

Change-Id: I65433334681f712f347c642ef1b18e10ea866f85
Signed-off-by: Anvesh Kumar Rayankula <anvesr77@in.ibm.com>
diff --git a/ipmi/test_ipmi_network.robot b/ipmi/test_ipmi_network.robot
index 8f60889..a174952 100644
--- a/ipmi/test_ipmi_network.robot
+++ b/ipmi/test_ipmi_network.robot
@@ -9,7 +9,7 @@
 Library                ../lib/var_funcs.py
 Library                ../lib/bmc_network_utils.py
 
-Suite Setup            Redfish.Login
+Suite Setup            Suite Setup Execution
 Test Setup             Printn
 Test Teardown          FFDC On Test Case Fail
 
@@ -17,9 +17,12 @@
 
 
 *** Variables ***
-
+${vlan_id}              ${10}
+@{vlan_ids}             ${20}  ${30}
+${interface}            eth0
+${ip}                   10.0.0.1
 ${initial_lan_config}   &{EMPTY}
-
+${vlan_resource}        ${NETWORK_MANAGER}action/VLAN
 
 *** Test Cases ***
 
@@ -90,8 +93,6 @@
     [Teardown]  Run Keywords  Restore Configuration  AND  FFDC On Test Case Fail
 
     Redfish Power On
-    ${initial_lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
-    Set Suite Variable  ${initial_lan_config}
 
     Set IPMI Inband Network Configuration  10.10.10.10  255.255.255.0  10.10.10.10
     Sleep  10
@@ -122,6 +123,55 @@
 
     Valid Value  lan_config['IP Address Source']  ['${ip_address_source}']
 
+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}
+    END
+
+    Create VLAN Via IPMI  off
+
+    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
+    Valid Value  lan_config['802.1q VLAN ID']  ['Disabled']
+
+
+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}
+
+    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['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
+
+    @{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}
+
+    ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
+    Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id}']
+
 
 *** Keywords ***
 
@@ -163,8 +213,8 @@
     ${length}=  Get Length  ${initial_lan_config}
     Return From Keyword If  ${length} == ${0}
 
-    Set IPMI Inband Network Configuration  ${initial_lan_config['IP Address']}
-    ...  ${initial_lan_config['Subnet Mask']}
+    Set IPMI Inband Network Configuration  ${network_configurations[0]['Address']}
+    ...  ${network_configurations[0]['SubnetMask']}
     ...  ${initial_lan_config['Default Gateway IP']}  login=${0}
 
 
@@ -199,3 +249,28 @@
     ...  ${REDFISH_NW_ETH_IFACE}${active_channel_config['${channel_number}']['name']}  MACAddress
     Rprint Vars  lan_print_ipmi  redfish_mac_address
     Valid Value  lan_print_ipmi['MAC Address']  ['${redfish_mac_address}']
+
+
+Create VLAN Via IPMI
+    [Arguments]  ${vlan_id}  ${channel_number}=${CHANNEL_NUMBER}
+
+    # Description of argument(s):
+    # vlan_id  The VLAN ID (e.g. '10').
+
+    Run Inband IPMI Standard Command
+    ...  lan set ${channel_number} vlan id ${vlan_id}  login_host=${0}
+
+
+Suite Setup Execution
+    [Documentation]  Suite Setup Execution.
+
+    Redfish.Login
+
+    Run Inband IPMI Standard Command
+    ...  lan set ${CHANNEL_NUMBER} ipsrc static  login_host=${1}
+
+    @{network_configurations}=  Get Network Configuration
+    Set Suite Variable  @{network_configurations}
+
+    ${initial_lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
+    Set Suite Variable  ${initial_lan_config}