Modified suite setup and Added TC  'Create Multiple VLANs Via IPMI And Verify'

Change-Id: I65ff199cbb4374c46f06f45c7f2a00ffbc47664f
Signed-off-by: Anvesh Kumar Rayankula <anvesr77@in.ibm.com>
diff --git a/ipmi/test_ipmi_network_configuration.robot b/ipmi/test_ipmi_network_configuration.robot
index 4313480..c862ed4 100644
--- a/ipmi/test_ipmi_network_configuration.robot
+++ b/ipmi/test_ipmi_network_configuration.robot
@@ -94,9 +94,8 @@
 
     ${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']  ['${network_configurations[0]['Address']}']
-    Valid Value  lan_config['Subnet Mask']  ['${network_configurations[0]['SubnetMask']}']
-
+    Valid Value  lan_config['IP Address']  ['${ip_address}']
+    Valid Value  lan_config['Subnet Mask']  ['${subnet_mask}']
 
 Test Disabling Of VLAN Via IPMI
     [Documentation]  Disable VLAN and verify via IPMI.
@@ -121,6 +120,28 @@
    Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id_for_ipmi}']
    Valid Value  lan_config['IP Address']  ['${ip}']
 
+
+Create Multiple VLANs Via IPMI And Verify
+    [Documentation]  Create multiple VLANs through IPMI.
+    [Tags]    Create_Multiple_VLANs_Via_IPMI_And_Verify
+
+    FOR  ${vlan_id}  IN  @{vlan_ids}
+
+      Create VLAN Via IPMI  ${vlan_id}
+
+      ${lan_config}=  Get LAN Print Dict  ${CHANNEL_NUMBER}  ipmi_cmd_type=inband
+
+      # Validate VLAN creation.
+      Valid Value  lan_config['802.1q VLAN ID']  ['${vlan_id}']
+
+      # Validate existing IP address.
+      Valid Value  lan_config['IP Address']  ['${ip_address}']
+
+      # Validate existing subnet mask.
+      Valid Value  lan_config['Subnet Mask']  ['${subnet_mask}']
+    END
+
+
 *** Keywords ***
 
 Create VLAN Via IPMI
@@ -155,12 +176,12 @@
 
 
 Restore Configuration
-    [Documentation]  Restore the configuration to its pre-test state
+    [Documentation]  Restore the configuration to its pre-test state.
+
     ${length}=  Get Length  ${initial_lan_config}
     Return From Keyword If  ${length} == ${0}
 
-    Set IPMI Inband Network Configuration  ${network_configurations[0]['Address']}
-    ...  ${network_configurations[0]['SubnetMask']}
+    Set IPMI Inband Network Configuration  ${ip_address}  ${subnet_mask}
     ...  ${initial_lan_config['Default Gateway IP']}  login=${0}
 
 
@@ -168,16 +189,18 @@
     [Documentation]  Suite Setup Execution.
 
     Redfish.Login
-
     Run Inband IPMI Standard Command
     ...  lan set ${CHANNEL_NUMBER} ipsrc static  login_host=${1}
 
+    ${host_name}  ${ip_address}=  Get Host Name IP  host=${OPENBMC_HOST}
+    Set Suite Variable  ${ip_address}
+
     @{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}
-
+    FOR  ${network_configuration}  IN  @{network_configurations}
+       Run Keyword If  '${network_configuration['Address']}' == '${ip_address}'
+       ...  Run Keywords  Set Suite Variable  ${subnet_mask}   ${network_configuration['SubnetMask']}  AND
+       ...  Exit For Loop
+    END
 
 Test Teardown Execution
    [Documentation]  Test Teardown Execution.
@@ -185,4 +208,3 @@
    FFDC On Test Case Fail
    Create VLAN Via IPMI  off
    Restore Configuration
-
diff --git a/lib/bmc_network_utils.py b/lib/bmc_network_utils.py
index f3c6fea..a01ee78 100644
--- a/lib/bmc_network_utils.py
+++ b/lib/bmc_network_utils.py
@@ -30,6 +30,18 @@
     return ipaddress.ip_network('0.0.0.0/' + netmask).prefixlen
 
 
+def get_netmask_address(prefix_len):
+    r"""
+    Return the netmask address.
+
+    Description of argument(s):
+    prefix_len     Prefix length value (e.g. "24", "23", "22", etc.).
+    """
+
+    # IP address netmask format: '0.0.0.0/24'
+    return ipaddress.ip_network('0.0.0.0/' + prefix_len).netmask
+
+
 def parse_nping_output(output):
     r"""
     Parse the output from the nping command and return as a dictionary.