simplify core parameter parsing 46/74646/1
authorLuc Provoost <luc.provoost@gmail.com>
Sun, 10 Nov 2024 11:02:46 +0000 (12:02 +0100)
committerLuc Provoost <luc.provoost@gmail.com>
Sun, 10 Nov 2024 11:02:46 +0000 (12:02 +0100)
Simplified some of the code to deal with the differrent core options

Signed-off-by: Luc Provoost <luc.provoost@gmail.com>
Change-Id: I4f33563b51370efe807e8ace807acc3fdcd2bfc4

VNFs/DPPD-PROX/helper-scripts/rapid/rapid_generator_machine.py
VNFs/DPPD-PROX/helper-scripts/rapid/rapid_machine.py
VNFs/DPPD-PROX/helper-scripts/rapid/rapid_parser.py

index e52b17d..fc2d86d 100644 (file)
@@ -103,12 +103,7 @@ class RapidGeneratorMachine(RapidMachine):
             self.machine_params['latcores'] = cpus_remapped
 
     def generate_lua(self):
-        appendix = 'gencores="%s"\n'% ','.join(map(str,
-            self.machine_params['gencores']))
-        appendix = appendix + 'latcores="%s"\n'% ','.join(map(str,
-            self.machine_params['latcores']))
-        appendix = (appendix +
-                'bucket_size_exp="{}"\n'.format(self.bucket_size_exp))
+        appendix = 'bucket_size_exp="{}"\n'.format(self.bucket_size_exp)
         if 'heartbeat' in self.machine_params.keys():
             appendix = (appendix +
                     'heartbeat="%s"\n'% self.machine_params['heartbeat'])
index b95f4ff..048895c 100644 (file)
@@ -121,21 +121,12 @@ class RapidMachine(object):
         if self.cpu_mapping is None:
             RapidLog.debug('{} ({}): cpu mapping is not defined! Please check the configuration!'.format(self.name, self.ip))
             return
-
-        if 'mcore' in self.machine_params.keys():
-            cpus_remapped = self.remap_cpus(self.machine_params['mcore'])
-            RapidLog.debug('{} ({}): mcore {} remapped to {}'.format(self.name, self.ip, self.machine_params['mcore'], cpus_remapped))
-            self.machine_params['mcore'] = cpus_remapped
-
-        if 'cores' in self.machine_params.keys():
-            cpus_remapped = self.remap_cpus(self.machine_params['cores'])
-            RapidLog.debug('{} ({}): cores {} remapped to {}'.format(self.name, self.ip, self.machine_params['cores'], cpus_remapped))
-            self.machine_params['cores'] = cpus_remapped
-
-        if 'altcores' in self.machine_params.keys():
-            cpus_remapped = self.remap_cpus(self.machine_params['altcores'])
-            RapidLog.debug('{} ({}): altcores {} remapped to {}'.format(self.name, self.ip, self.machine_params['altcores'], cpus_remapped))
-            self.machine_params['altcores'] = cpus_remapped
+        for key in self.machine_params.keys():
+            if 'core' in key:
+                cpus_remapped = self.remap_cpus(self.machine_params[key])
+                RapidLog.debug('{} ({}): {} {} remapped to {}'.format(self.name, self.ip, key, self.machine_params[key], cpus_remapped))
+                self.machine_params[key] = cpus_remapped
+        return
 
     def devbind(self):
         # Script to bind the right network interface to the poll mode driver
@@ -180,15 +171,11 @@ class RapidMachine(object):
                 LuaFile.write(eal_line)
             else:
                 LuaFile.write("eal=\"\"\n")
-            if 'mcore' in self.machine_params.keys():
-                LuaFile.write('mcore="%s"\n'% ','.join(map(str,
-                    self.machine_params['mcore'])))
-            if 'cores' in self.machine_params.keys():
-                LuaFile.write('cores="%s"\n'% ','.join(map(str,
-                    self.machine_params['cores'])))
-            if 'altcores' in self.machine_params.keys():
-                LuaFile.write('altcores="%s"\n'% ','.join(map(str,
-                    self.machine_params['altcores'])))
+            for key in self.machine_params.keys():
+                if 'core' in key:
+                    cores = ','.join(map(str,self.machine_params[key]))
+                    cores = (f'"{cores}"') 
+                    LuaFile.write('{}={}\n'.format(key,cores))
             if 'ports' in self.machine_params.keys():
                 LuaFile.write('ports="%s"\n'% ','.join(map(str,
                     self.machine_params['ports'])))
index 8583479..74c2c9f 100644 (file)
@@ -137,8 +137,7 @@ class RapidConfigParser(object):
             for option in options:
                 if option in ['prox_socket','prox_launch_exit','monitor']:
                     machine[option] = testconfig.getboolean(section, option)
-                elif option in ['mcore', 'cores', 'gencores', 'latcores',
-                        'altcores']:
+                elif 'core' in option:
                     machine[option] = ast.literal_eval(testconfig.get(
                         section, option))
                 elif option in ['bucket_size_exp']: