CSIT-106 Cleanup of add_pci functions 05/1905/3
authorMiroslav Miklus <mmiklus@cisco.com>
Thu, 7 Jul 2016 16:11:32 +0000 (18:11 +0200)
committerMiroslav Miklus <mmiklus@cisco.com>
Fri, 8 Jul 2016 10:50:15 +0000 (12:50 +0200)
Change-Id: If53cae5871b41af2a11a420d9f83ab57149a9096
Signed-off-by: Miroslav Miklus <mmiklus@cisco.com>
resources/libraries/python/VppConfigGenerator.py
resources/libraries/robot/default.robot

index 9663fdc..24fb8ce 100644 (file)
@@ -69,33 +69,37 @@ class VppConfigGenerator(object):
     def __init__(self):
         self._nodeconfig = {}
 
     def __init__(self):
         self._nodeconfig = {}
 
-    def add_pci_device(self, node, pci_device=None):
+    def add_pci_all_devices(self, node):
+        """Add all PCI devices from topology file to startup config
+
+        :param node: DUT node
+        :type node: dict
+        :return: nothing
+        """
+        for port in node['interfaces'].keys():
+            pci_addr = Topology.get_interface_pci_addr(node, port)
+            if pci_addr:
+                self.add_pci_device(node, pci_addr)
+
+
+    def add_pci_device(self, node, *pci_devices):
         """Add PCI device configuration for node.
 
         :param node: DUT node.
         """Add PCI device configuration for node.
 
         :param node: DUT node.
-        :param pci_device: PCI device (format 0000:00:00.0 or 00:00.0).
-        If none given, all PCI devices for this node as per topology will be
-        added.
+        :param pci_device: PCI devices (format 0000:00:00.0 or 00:00.0)
         :type node: dict
         :type node: dict
-        :type pci_device: str
+        :type pci_devices: tuple
         :return: nothing
         """
         if node['type'] != NodeType.DUT:
             raise ValueError('Node type is not a DUT')
 
         :return: nothing
         """
         if node['type'] != NodeType.DUT:
             raise ValueError('Node type is not a DUT')
 
-        if pci_device is None:
-            # No PCI device was given. Add all device from topology.
-            for port in node['interfaces'].values():
-                port_name = port.get('name')
-                pci_addr = Topology.get_interface_pci_addr(node, port_name)
-                if pci_addr:
-                    self.add_pci_device(node, pci_addr)
-        else:
-            # Specific device was given.
-            hostname = Topology.get_node_hostname(node)
-
-            pattern = re.compile("^[0-9A-Fa-f]{4}:[0-9A-Fa-f]{2}:"
-                                 "[0-9A-Fa-f]{2}\\.[0-9A-Fa-f]$")
+        # Specific device was given.
+        hostname = Topology.get_node_hostname(node)
+
+        pattern = re.compile("^[0-9A-Fa-f]{4}:[0-9A-Fa-f]{2}:"
+                             "[0-9A-Fa-f]{2}\\.[0-9A-Fa-f]$")
+        for pci_device in pci_devices:
             if not pattern.match(pci_device):
                 raise ValueError('PCI address {} to be added to host {} '
                                  'is not in valid format xxxx:xx:xx.x'.
             if not pattern.match(pci_device):
                 raise ValueError('PCI address {} to be added to host {} '
                                  'is not in valid format xxxx:xx:xx.x'.
index 81f991b..6591b3c 100644 (file)
@@ -90,7 +90,7 @@
 | | ...             | startup configuration to all DUTs
 | | ${duts}= | Get Matches | ${nodes} | DUT*
 | | :FOR | ${dut} | IN | @{duts}
 | | ...             | startup configuration to all DUTs
 | | ${duts}= | Get Matches | ${nodes} | DUT*
 | | :FOR | ${dut} | IN | @{duts}
-| | | Add PCI device | ${nodes['${dut}']}
+| | | Add PCI all devices | ${nodes['${dut}']}
 
 | Add PCI device to DUT
 | | [Documentation] | Add PCI device to VPP startup configuration
 
 | Add PCI device to DUT
 | | [Documentation] | Add PCI device to VPP startup configuration