aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries
diff options
context:
space:
mode:
authorMiroslav Miklus <mmiklus@cisco.com>2016-07-07 18:11:32 +0200
committerMiroslav Miklus <mmiklus@cisco.com>2016-07-08 12:50:15 +0200
commitdc1db8f3e4eb967cfce635ba8ff06a0cf4df5390 (patch)
tree6663aab94532fea0cfb49b9e158693a15cba1823 /resources/libraries
parent7dcef449259d6bc003fcc4e8705bb2fe9966bac6 (diff)
CSIT-106 Cleanup of add_pci functions
Change-Id: If53cae5871b41af2a11a420d9f83ab57149a9096 Signed-off-by: Miroslav Miklus <mmiklus@cisco.com>
Diffstat (limited to 'resources/libraries')
-rw-r--r--resources/libraries/python/VppConfigGenerator.py40
-rw-r--r--resources/libraries/robot/default.robot2
2 files changed, 23 insertions, 19 deletions
diff --git a/resources/libraries/python/VppConfigGenerator.py b/resources/libraries/python/VppConfigGenerator.py
index 9663fdc343..24fb8ce86f 100644
--- a/resources/libraries/python/VppConfigGenerator.py
+++ b/resources/libraries/python/VppConfigGenerator.py
@@ -69,33 +69,37 @@ class VppConfigGenerator(object):
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.
- :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 pci_device: str
+ :type pci_devices: tuple
: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'.
diff --git a/resources/libraries/robot/default.robot b/resources/libraries/robot/default.robot
index 81f991bb83..6591b3c874 100644
--- a/resources/libraries/robot/default.robot
+++ b/resources/libraries/robot/default.robot
@@ -90,7 +90,7 @@
| | ... | 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