+ if len(path) == 1:
+ config[path[0]] = value
+ return
+ if not config.has_key(path[0]):
+ config[path[0]] = {}
+ self.add_config_item(config[path[0]], value, path[1:])
+
+ def dump_config(self, obj, level=-1):
+ """Dump the startup configuration in VPP config format.
+
+ :param obj: Python Object to print.
+ :param nested_level: Nested level for indentation.
+ :type obj: Obj
+ :type nested_level: int
+ :returns: nothing
+ """
+ indent = ' '
+ if level >= 0:
+ self._vpp_config += '{}{{\n'.format((level) * indent)
+ if isinstance(obj, dict):
+ for key, val in obj.items():
+ if hasattr(val, '__iter__'):
+ self._vpp_config += '{}{}\n'.format((level + 1) * indent,
+ key)
+ self.dump_config(val, level + 1)
+ else:
+ self._vpp_config += '{}{} {}\n'.format((level + 1) * indent,
+ key, val)
+ else:
+ for val in obj:
+ self._vpp_config += '{}{}\n'.format((level + 1) * indent, val)
+ if level >= 0:
+ self._vpp_config += '{}}}\n'.format(level * indent)
+
+ def add_unix_log(self, value='/tmp/vpe.log'):
+ """Add UNIX log configuration.
+
+ :param value: Log file.
+ :type value: str
+ """
+ path = ['unix', 'log']
+ self.add_config_item(self._nodeconfig, value, path)
+
+ def add_unix_cli_listen(self, value='localhost:5002'):
+ """Add UNIX cli-listen configuration.
+
+ :param value: CLI listen address and port.
+ :type value: str
+ """
+ path = ['unix', 'cli-listen']
+ self.add_config_item(self._nodeconfig, value, path)
+
+ def add_unix_nodaemon(self):
+ """Add UNIX nodaemon configuration."""
+ path = ['unix', 'nodaemon']
+ self.add_config_item(self._nodeconfig, '', path)
+
+ def add_unix_exec(self, value):
+ """Add UNIX exec configuration."""
+ path = ['unix', 'exec']
+ self.add_config_item(self._nodeconfig, value, path)
+
+ def add_dpdk_dev(self, *devices):
+ """Add DPDK PCI device configuration.
+
+ :param devices: PCI device(s) (format xxxx:xx:xx.x)
+ :type devices: tuple
+ :raises ValueError: If PCI address format is not valid.
+ """