feat(infra): Remove system.d dependency
[csit.git] / resources / libraries / python / VppConfigGenerator.py
1 # Copyright (c) 2023 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13
14 """VPP Configuration File Generator library."""
15
16 import re
17
18 from resources.libraries.python.Constants import Constants
19 from resources.libraries.python.ssh import exec_cmd_no_error
20 from resources.libraries.python.topology import NodeType
21 from resources.libraries.python.topology import Topology
22 from resources.libraries.python.VPPUtil import VPPUtil
23
24 __all__ = ["VppConfigGenerator", "VppInitConfig"]
25
26
27 def pci_dev_check(pci_dev):
28     """Check if provided PCI address is in correct format.
29
30     :param pci_dev: PCI address (expected format: xxxx:xx:xx.x).
31     :type pci_dev: str
32     :returns: True if PCI address is in correct format.
33     :rtype: bool
34     :raises ValueError: If PCI address is in incorrect format.
35     """
36     pattern = re.compile(
37         r"^[0-9A-Fa-f]{4}:[0-9A-Fa-f]{2}:[0-9A-Fa-f]{2}\.[0-9A-Fa-f]$"
38     )
39     if not re.match(pattern, pci_dev):
40         raise ValueError(
41             f"PCI address {pci_dev} is not in valid format xxxx:xx:xx.x"
42         )
43     return True
44
45
46 class VppConfigGenerator:
47     """VPP Configuration File Generator."""
48
49     def __init__(self):
50         """Initialize library."""
51         # VPP Node to apply configuration on
52         self._node = u""
53         # Topology node key
54         self._node_key = u""
55         # VPP Configuration
56         self._nodeconfig = dict()
57         # Serialized VPP Configuration
58         self._vpp_config = u""
59         # VPP Service name
60         self._vpp_service_name = u"vpp"
61         # VPP Startup config location
62         self._vpp_startup_conf = u"/etc/vpp/startup.conf"
63
64     def set_node(self, node, node_key=None):
65         """Set DUT node.
66
67         :param node: Node to store configuration on.
68         :param node_key: Topology node key.
69         :type node: dict
70         :type node_key: str
71         :raises RuntimeError: If Node type is not DUT.
72         """
73         if node[u"type"] != NodeType.DUT:
74             raise RuntimeError(
75                 u"Startup config can only be applied to DUTnode."
76             )
77         self._node = node
78         self._node_key = node_key
79
80     def get_config_str(self):
81         """Get dumped startup configuration in VPP config format.
82
83         :returns: Startup configuration in VPP config format.
84         :rtype: str
85         """
86         self.dump_config(self._nodeconfig)
87         return self._vpp_config
88
89     def add_config_item(self, config, value, path):
90         """Add startup configuration item.
91
92         :param config: Startup configuration of node.
93         :param value: Value to insert.
94         :param path: Path where to insert item.
95         :type config: dict
96         :type value: str
97         :type path: list
98         """
99         if len(path) == 1:
100             config[path[0]] = value
101             return
102         if path[0] not in config:
103             config[path[0]] = dict()
104         elif isinstance(config[path[0]], str):
105             config[path[0]] = dict() if config[path[0]] == u"" \
106                 else {config[path[0]]: u""}
107         self.add_config_item(config[path[0]], value, path[1:])
108
109     def dump_config(self, obj, level=-1):
110         """Dump the startup configuration in VPP config format.
111
112         :param obj: Python Object to print.
113         :param level: Nested level for indentation.
114         :type obj: Obj
115         :type level: int
116         :returns: nothing
117         """
118         indent = u"  "
119         if level >= 0:
120             self._vpp_config += f"{level * indent}{{\n"
121         if isinstance(obj, dict):
122             for key, val in obj.items():
123                 if hasattr(val, u"__iter__") and not isinstance(val, str):
124                     self._vpp_config += f"{(level + 1) * indent}{key}\n"
125                     self.dump_config(val, level + 1)
126                 else:
127                     self._vpp_config += f"{(level + 1) * indent}{key} {val}\n"
128         else:
129             for val in obj:
130                 self._vpp_config += f"{(level + 1) * indent}{val}\n"
131         if level >= 0:
132             self._vpp_config += f"{level * indent}}}\n"
133
134     def add_unix_log(self, value="/var/log/vpp/vpp.log"):
135         """Add UNIX log configuration.
136
137         :param value: Log file.
138         :type value: str
139         """
140         path = [u"unix", u"log"]
141         self.add_config_item(self._nodeconfig, value, path)
142
143     def add_unix_cli_listen(self, value=u"/run/vpp/cli.sock"):
144         """Add UNIX cli-listen configuration.
145
146         :param value: CLI listen address and port or path to CLI socket.
147         :type value: str
148         """
149         path = [u"unix", u"cli-listen"]
150         self.add_config_item(self._nodeconfig, value, path)
151
152     def add_unix_cli_no_pager(self):
153         """Add UNIX cli-no-pager configuration."""
154         path = [u"unix", u"cli-no-pager"]
155         self.add_config_item(self._nodeconfig, u"", path)
156
157     def add_unix_gid(self, value=u"vpp"):
158         """Add UNIX gid configuration.
159
160         :param value: Gid.
161         :type value: str
162         """
163         path = [u"unix", u"gid"]
164         self.add_config_item(self._nodeconfig, value, path)
165
166     def add_unix_nodaemon(self):
167         """Add UNIX nodaemon configuration."""
168         path = [u"unix", u"nodaemon"]
169         self.add_config_item(self._nodeconfig, u"", path)
170
171     def add_unix_coredump(self):
172         """Add UNIX full-coredump configuration."""
173         path = [u"unix", u"full-coredump"]
174         self.add_config_item(self._nodeconfig, u"", path)
175
176     def add_unix_exec(self, value):
177         """Add UNIX exec configuration."""
178         path = [u"unix", u"exec"]
179         self.add_config_item(self._nodeconfig, value, path)
180
181     def add_socksvr(self, socket=Constants.SOCKSVR_PATH):
182         """Add socksvr configuration."""
183         path = [u"socksvr", u"socket-name"]
184         self.add_config_item(self._nodeconfig, socket, path)
185
186     def add_graph_node_variant(self, variant=Constants.GRAPH_NODE_VARIANT):
187         """Add default graph node variant.
188
189         :param value: Graph node variant default value.
190         :type value: str
191         """
192         if variant == u"":
193             return
194         variant_list = [u"hsw", u"skx", u"icl"]
195         if variant not in variant_list:
196             raise ValueError("Invalid graph node variant value")
197         path = [u"node", u"default", u"variant"]
198         self.add_config_item(self._nodeconfig, variant, path)
199
200     def add_api_segment_gid(self, value=u"vpp"):
201         """Add API-SEGMENT gid configuration.
202
203         :param value: Gid.
204         :type value: str
205         """
206         path = [u"api-segment", u"gid"]
207         self.add_config_item(self._nodeconfig, value, path)
208
209     def add_api_segment_global_size(self, value):
210         """Add API-SEGMENT global-size configuration.
211
212         :param value: Global size.
213         :type value: str
214         """
215         path = [u"api-segment", u"global-size"]
216         self.add_config_item(self._nodeconfig, value, path)
217
218     def add_api_segment_api_size(self, value):
219         """Add API-SEGMENT api-size configuration.
220
221         :param value: API size.
222         :type value: str
223         """
224         path = [u"api-segment", u"api-size"]
225         self.add_config_item(self._nodeconfig, value, path)
226
227     def add_buffers_per_numa(self, value):
228         """Increase number of buffers allocated.
229
230         :param value: Number of buffers allocated.
231         :type value: int
232         """
233         path = [u"buffers", u"buffers-per-numa"]
234         self.add_config_item(self._nodeconfig, value, path)
235
236     def add_buffers_default_data_size(self, value):
237         """Increase buffers data-size allocated.
238
239         :param value: Buffers data-size allocated.
240         :type value: int
241         """
242         path = [u"buffers", u"default data-size"]
243         self.add_config_item(self._nodeconfig, value, path)
244
245     def add_dpdk_dev(self, *devices):
246         """Add DPDK PCI device configuration.
247
248         :param devices: PCI device(s) (format xxxx:xx:xx.x)
249         :type devices: tuple
250         """
251         for device in devices:
252             if pci_dev_check(device):
253                 path = [u"dpdk", f"dev {device}"]
254                 self.add_config_item(self._nodeconfig, u"", path)
255
256     def add_dpdk_cryptodev(self, count):
257         """Add DPDK Crypto PCI device configuration.
258
259         :param count: Number of HW crypto devices to add.
260         :type count: int
261         """
262         cryptodev = Topology.get_cryptodev(self._node)
263         for i in range(count):
264             cryptodev_config = re.sub(r"\d.\d$", f"1.{str(i)}", cryptodev)
265             path = [u"dpdk", f"dev {cryptodev_config}"]
266             self.add_config_item(self._nodeconfig, u"", path)
267         self.add_dpdk_uio_driver(u"vfio-pci")
268
269     def add_dpdk_sw_cryptodev(self, sw_pmd_type, socket_id, count):
270         """Add DPDK SW Crypto device configuration.
271
272         :param sw_pmd_type: Type of SW crypto device PMD to add.
273         :param socket_id: Socket ID.
274         :param count: Number of SW crypto devices to add.
275         :type sw_pmd_type: str
276         :type socket_id: int
277         :type count: int
278         """
279         for _ in range(count):
280             cryptodev_config = f"vdev cryptodev_{sw_pmd_type}_pmd," \
281                 f"socket_id={str(socket_id)}"
282             path = [u"dpdk", cryptodev_config]
283             self.add_config_item(self._nodeconfig, u"", path)
284
285     def add_dpdk_dev_default_rxq(self, value):
286         """Add DPDK dev default rxq configuration.
287
288         :param value: Default number of rxqs.
289         :type value: str
290         """
291         path = [u"dpdk", u"dev default", u"num-rx-queues"]
292         self.add_config_item(self._nodeconfig, value, path)
293
294     def add_dpdk_dev_default_txq(self, value):
295         """Add DPDK dev default txq configuration.
296
297         :param value: Default number of txqs.
298         :type value: str
299         """
300         path = [u"dpdk", u"dev default", u"num-tx-queues"]
301         self.add_config_item(self._nodeconfig, value, path)
302
303     def add_dpdk_dev_default_rxd(self, value):
304         """Add DPDK dev default rxd configuration.
305
306         :param value: Default number of rxds.
307         :type value: str
308         """
309         path = [u"dpdk", u"dev default", u"num-rx-desc"]
310         self.add_config_item(self._nodeconfig, value, path)
311
312     def add_dpdk_dev_default_txd(self, value):
313         """Add DPDK dev default txd configuration.
314
315         :param value: Default number of txds.
316         :type value: str
317         """
318         path = [u"dpdk", u"dev default", u"num-tx-desc"]
319         self.add_config_item(self._nodeconfig, value, path)
320
321     def add_dpdk_log_level(self, value):
322         """Add DPDK log-level configuration.
323
324         :param value: Log level.
325         :type value: str
326         """
327         path = [u"dpdk", u"log-level"]
328         self.add_config_item(self._nodeconfig, value, path)
329
330     def add_dpdk_no_pci(self):
331         """Add DPDK no-pci."""
332         path = [u"dpdk", u"no-pci"]
333         self.add_config_item(self._nodeconfig, u"", path)
334
335     def add_dpdk_uio_driver(self, value=None):
336         """Add DPDK uio-driver configuration.
337
338         :param value: DPDK uio-driver configuration. By default, driver will be
339             loaded automatically from Topology file, still leaving option
340             to manually override by parameter.
341         :type value: str
342         """
343         if value is None:
344             value = Topology.get_uio_driver(self._node)
345         path = [u"dpdk", u"uio-driver"]
346         self.add_config_item(self._nodeconfig, value, path)
347
348     def add_dpdk_max_simd_bitwidth(self, variant=Constants.GRAPH_NODE_VARIANT):
349         """Add DPDK max-simd-bitwidth configuration.
350
351         :param value: Graph node variant default value.
352         :type value: str
353         """
354         if variant == u"icl":
355             value = 512
356         elif variant in [u"skx", u"hsw"]:
357             value = 256
358         else:
359             return
360
361         path = [u"dpdk", u"max-simd-bitwidth"]
362         self.add_config_item(self._nodeconfig, value, path)
363
364     def add_cpu_main_core(self, value):
365         """Add CPU main core configuration.
366
367         :param value: Main core option.
368         :type value: str
369         """
370         path = [u"cpu", u"main-core"]
371         self.add_config_item(self._nodeconfig, value, path)
372
373     def add_cpu_corelist_workers(self, value):
374         """Add CPU corelist-workers configuration.
375
376         :param value: Corelist-workers option.
377         :type value: str
378         """
379         path = [u"cpu", u"corelist-workers"]
380         self.add_config_item(self._nodeconfig, value, path)
381
382     def add_main_heap_size(self, value):
383         """Add Main Heap Size configuration.
384
385         :param value: Amount of heap.
386         :type value: str
387         """
388         path = [u"memory", u"main-heap-size"]
389         self.add_config_item(self._nodeconfig, value, path)
390
391     def add_main_heap_page_size(self, value):
392         """Add Main Heap Page Size configuration.
393
394         :param value: Heap page size.
395         :type value: str
396         """
397         path = [u"memory", u"main-heap-page-size"]
398         self.add_config_item(self._nodeconfig, value, path)
399
400     def add_default_hugepage_size(self, value=Constants.DEFAULT_HUGEPAGE_SIZE):
401         """Add Default Hugepage Size configuration.
402
403         :param value: Hugepage size.
404         :type value: str
405         """
406         path = [u"memory", u"default-hugepage-size"]
407         self.add_config_item(self._nodeconfig, value, path)
408
409     def add_api_trace(self):
410         """Add API trace configuration."""
411         path = [u"api-trace", u"on"]
412         self.add_config_item(self._nodeconfig, u"", path)
413
414     def add_ip6_hash_buckets(self, value):
415         """Add IP6 hash buckets configuration.
416
417         :param value: Number of IP6 hash buckets.
418         :type value: str
419         """
420         path = [u"ip6", u"hash-buckets"]
421         self.add_config_item(self._nodeconfig, value, path)
422
423     def add_ip6_heap_size(self, value):
424         """Add IP6 heap-size configuration.
425
426         :param value: IP6 Heapsize amount.
427         :type value: str
428         """
429         path = [u"ip6", u"heap-size"]
430         self.add_config_item(self._nodeconfig, value, path)
431
432     def add_ipsec_spd_flow_cache_ipv4_inbound(self, value):
433         """Add IPsec spd flow cache for IP4 inbound.
434
435         :param value: "on" to enable spd flow cache.
436         :type value: str
437         """
438         path = [u"ipsec", u"ipv4-inbound-spd-flow-cache"]
439         self.add_config_item(self._nodeconfig, value, path)
440
441     def add_ipsec_spd_flow_cache_ipv4_outbound(self, value):
442         """Add IPsec spd flow cache for IP4 outbound.
443
444         :param value: "on" to enable spd flow cache.
445         :type value: str
446         """
447         path = [u"ipsec", u"ipv4-outbound-spd-flow-cache"]
448         self.add_config_item(self._nodeconfig, value, path)
449
450     def add_ipsec_spd_fast_path_ipv4_inbound(self, value):
451         """Add IPsec spd fast path for IP4 inbound.
452
453         :param value: "on" to enable spd fast path.
454         :type value: str
455         """
456         path = [u"ipsec", u"ipv4-inbound-spd-fast-path"]
457         self.add_config_item(self._nodeconfig, value, path)
458
459     def add_ipsec_spd_fast_path_ipv4_outbound(self, value):
460         """Add IPsec spd fast path for IP4 outbound.
461
462         :param value: "on" to enable spd fast path.
463         :type value: str
464         """
465         path = [u"ipsec", u"ipv4-outbound-spd-fast-path"]
466         self.add_config_item(self._nodeconfig, value, path)
467
468     def add_ipsec_spd_fast_path_num_buckets(self, value):
469         """Add num buckets for IPsec spd fast path.
470
471         :param value: Number of buckets.
472         :type value: int
473         """
474         path = [u"ipsec", u"spd-fast-path-num-buckets"]
475         self.add_config_item(self._nodeconfig, value, path)
476
477     def add_statseg_size(self, value):
478         """Add Stats Heap Size configuration.
479
480         :param value: Stats heapsize amount.
481         :type value: str
482         """
483         path = [u"statseg", u"size"]
484         self.add_config_item(self._nodeconfig, value, path)
485
486     def add_statseg_page_size(self, value):
487         """Add Stats Heap Page Size configuration.
488
489         :param value: Stats heapsize amount.
490         :type value: str
491         """
492         path = [u"statseg", u"page-size"]
493         self.add_config_item(self._nodeconfig, value, path)
494
495     def add_statseg_per_node_counters(self, value):
496         """Add stats per-node-counters configuration.
497
498         :param value: "on" to switch the counters on.
499         :type value: str
500         """
501         path = [u"statseg", u"per-node-counters"]
502         self.add_config_item(self._nodeconfig, value, path)
503
504     def add_plugin(self, state, *plugins):
505         """Add plugin section for specific plugin(s).
506
507         :param state: State of plugin [enable|disable].
508         :param plugins: Plugin(s) to disable.
509         :type state: str
510         :type plugins: list
511         """
512         for plugin in plugins:
513             path = [u"plugins", f"plugin {plugin}", state]
514             self.add_config_item(self._nodeconfig, u" ", path)
515
516     def add_dpdk_no_multi_seg(self):
517         """Add DPDK no-multi-seg configuration."""
518         path = [u"dpdk", u"no-multi-seg"]
519         self.add_config_item(self._nodeconfig, u"", path)
520
521     def add_dpdk_no_tx_checksum_offload(self):
522         """Add DPDK no-tx-checksum-offload configuration."""
523         path = [u"dpdk", u"no-tx-checksum-offload"]
524         self.add_config_item(self._nodeconfig, u"", path)
525
526     def add_nat(self, value=u"deterministic"):
527         """Add NAT mode configuration.
528
529         :param value: NAT mode.
530         :type value: str
531         """
532         path = [u"nat", value]
533         self.add_config_item(self._nodeconfig, u"", path)
534
535     def add_nat_max_translations_per_thread(self, value):
536         """Add NAT max. translations per thread number configuration.
537
538         :param value: NAT mode.
539         :type value: str
540         """
541         path = [u"nat", u"max translations per thread"]
542         self.add_config_item(self._nodeconfig, value, path)
543
544     def add_nsim_poll_main_thread(self):
545         """Add NSIM poll-main-thread configuration."""
546         path = [u"nsim", u"poll-main-thread"]
547         self.add_config_item(self._nodeconfig, u"", path)
548
549     def add_tcp_congestion_control_algorithm(self, value=u"cubic"):
550         """Add TCP congestion control algorithm.
551
552         :param value: The congestion control algorithm to use. Example: cubic
553         :type value: str
554         """
555         path = [u"tcp", u"cc-algo"]
556         self.add_config_item(self._nodeconfig, value, path)
557
558     def add_tcp_preallocated_connections(self, value):
559         """Add TCP pre-allocated connections.
560
561         :param value: The number of pre-allocated connections.
562         :type value: int
563         """
564         path = [u"tcp", u"preallocated-connections"]
565         self.add_config_item(self._nodeconfig, value, path)
566
567     def add_tcp_preallocated_half_open_connections(self, value):
568         """Add TCP pre-allocated half open connections.
569
570         :param value: The number of pre-allocated half open connections.
571         :type value: int
572         """
573         path = [u"tcp", u"preallocated-half-open-connections"]
574         self.add_config_item(self._nodeconfig, value, path)
575
576     def add_session_enable(self):
577         """Add session enable."""
578         path = [u"session", u"enable"]
579         self.add_config_item(self._nodeconfig, u"", path)
580
581     def add_session_app_socket_api(self):
582         """Use session app socket api."""
583         path = [u"session", u"use-app-socket-api"]
584         self.add_config_item(self._nodeconfig, u"", path)
585
586     def add_session_event_queues_memfd_segment(self):
587         """Add session event queue memfd segment."""
588         path = [u"session", u"evt_qs_memfd_seg"]
589         self.add_config_item(self._nodeconfig, u"", path)
590
591     def add_session_event_queue_length(self, value):
592         """Add session event queue length.
593
594         :param value: Session event queue length.
595         :type value: int
596         """
597         path = [u"session", u"event-queue-length"]
598         self.add_config_item(self._nodeconfig, value, path)
599
600     def add_session_event_queues_segment_size(self, value):
601         """Add session event queue length.
602
603         :param value: Session event queue segment size.
604         :type value: str
605         """
606         path = [u"session", u"evt_qs_seg_size"]
607         self.add_config_item(self._nodeconfig, value, path)
608
609     def add_session_preallocated_sessions(self, value):
610         """Add the number of pre-allocated sessions.
611
612         :param value: Number of pre-allocated sessions.
613         :type value: int
614         """
615         path = [u"session", u"preallocated-sessions"]
616         self.add_config_item(self._nodeconfig, value, path)
617
618     def add_session_v4_session_table_buckets(self, value):
619         """Add number of v4 session table buckets to the config.
620
621         :param value: Number of v4 session table buckets.
622         :type value: int
623         """
624         path = [u"session", u"v4-session-table-buckets"]
625         self.add_config_item(self._nodeconfig, value, path)
626
627     def add_session_v4_session_table_memory(self, value):
628         """Add the size of v4 session table memory.
629
630         :param value: Size of v4 session table memory.
631         :type value: str
632         """
633         path = [u"session", u"v4-session-table-memory"]
634         self.add_config_item(self._nodeconfig, value, path)
635
636     def add_session_v4_halfopen_table_buckets(self, value):
637         """Add the number of v4 halfopen table buckets.
638
639         :param value: Number of v4 halfopen table buckets.
640         :type value: int
641         """
642         path = [u"session", u"v4-halfopen-table-buckets"]
643         self.add_config_item(self._nodeconfig, value, path)
644
645     def add_session_v4_halfopen_table_memory(self, value):
646         """Add the size of v4 halfopen table memory.
647
648         :param value: Size of v4 halfopen table memory.
649         :type value: str
650         """
651         path = [u"session", u"v4-halfopen-table-memory"]
652         self.add_config_item(self._nodeconfig, value, path)
653
654     def add_session_local_endpoints_table_buckets(self, value):
655         """Add the number of local endpoints table buckets.
656
657         :param value: Number of local endpoints table buckets.
658         :type value: int
659         """
660         path = [u"session", u"local-endpoints-table-buckets"]
661         self.add_config_item(self._nodeconfig, value, path)
662
663     def add_session_local_endpoints_table_memory(self, value):
664         """Add the size of local endpoints table memory.
665
666         :param value: Size of local endpoints table memory.
667         :type value: str
668         """
669         path = [u"session", u"local-endpoints-table-memory"]
670         self.add_config_item(self._nodeconfig, value, path)
671
672     def write_config(self, filename=None):
673         """Generate and write VPP startup configuration to file.
674
675         Use data from calls to this class to form a startup.conf file and
676         replace /etc/vpp/startup.conf with it on topology node.
677
678         :param filename: Startup configuration file name.
679         :type filename: str
680         """
681         self.dump_config(self._nodeconfig)
682
683         if filename is None:
684             filename = self._vpp_startup_conf
685
686         cmd = f"echo \"{self._vpp_config}\" | sudo tee {filename}"
687         exec_cmd_no_error(
688             self._node, cmd, message=u"Writing config file failed!"
689         )
690
691     def apply_config(self, filename=None, verify_vpp=True):
692         """Generate and write VPP startup configuration to file and restart VPP.
693
694         Use data from calls to this class to form a startup.conf file and
695         replace /etc/vpp/startup.conf with it on topology node.
696
697         :param filename: Startup configuration file name.
698         :param verify_vpp: Verify VPP is running after restart.
699         :type filename: str
700         :type verify_vpp: bool
701         """
702         self.write_config(filename=filename)
703
704         VPPUtil.restart_vpp_service(self._node, self._node_key)
705         if verify_vpp:
706             VPPUtil.verify_vpp(self._node)
707
708
709 class VppInitConfig:
710     """VPP Initial Configuration."""
711     @staticmethod
712     def init_vpp_startup_configuration_on_all_duts(nodes):
713         """Apply initial VPP startup configuration on all DUTs.
714
715         :param nodes: Nodes in the topology.
716         :type nodes: dict
717         """
718         huge_size = Constants.DEFAULT_HUGEPAGE_SIZE
719         for node in nodes.values():
720             if node[u"type"] == NodeType.DUT:
721                 vpp_config = VppConfigGenerator()
722                 vpp_config.set_node(node)
723                 vpp_config.add_unix_log()
724                 vpp_config.add_unix_cli_listen()
725                 vpp_config.add_unix_cli_no_pager()
726                 vpp_config.add_unix_gid()
727                 vpp_config.add_unix_coredump()
728                 vpp_config.add_socksvr(socket=Constants.SOCKSVR_PATH)
729                 vpp_config.add_main_heap_size("2G")
730                 vpp_config.add_main_heap_page_size(huge_size)
731                 vpp_config.add_default_hugepage_size(huge_size)
732                 vpp_config.add_statseg_size("2G")
733                 vpp_config.add_statseg_page_size(huge_size)
734                 vpp_config.add_statseg_per_node_counters("on")
735                 vpp_config.add_plugin("disable", "default")
736                 vpp_config.add_plugin("enable", "dpdk_plugin.so")
737                 vpp_config.add_dpdk_dev(
738                     *[node["interfaces"][interface].get("pci_address") \
739                         for interface in node[u"interfaces"]]
740                 )
741                 vpp_config.add_ip6_hash_buckets(2000000)
742                 vpp_config.add_ip6_heap_size("4G")
743                 vpp_config.apply_config()