Fri, Feb 12, 2021 at 05:22:52PM CET, olichtne@redhat.com wrote:
From: Ondrej Lichtner olichtne@redhat.com
The generate_sub_configurations method iterates over this list and generates two subconfigurations leading to two perf measurements in a single recipe run. Making this into a recipe parameter means we're able to differentiate these two perf measurements in external databases.
I also removed the "None" value and the associated conditions. This was originally used in the lnst-legacy recipe implementation to check the functionality of the underlying connection but it doesn't really make sense as a part of the recipe.
Signed-off-by: Ondrej Lichtner olichtne@redhat.com
lnst/Recipes/ENRT/SimpleMacsecRecipe.py | 155 +++++++++++------------- 1 file changed, 72 insertions(+), 83 deletions(-)
diff --git a/lnst/Recipes/ENRT/SimpleMacsecRecipe.py b/lnst/Recipes/ENRT/SimpleMacsecRecipe.py index 75161fb..389fa98 100644 --- a/lnst/Recipes/ENRT/SimpleMacsecRecipe.py +++ b/lnst/Recipes/ENRT/SimpleMacsecRecipe.py @@ -3,6 +3,7 @@ from lnst.Common.IpAddress import ipaddress from lnst.Common.IpAddress import AF_INET, AF_INET6 from lnst.Common.LnstError import LnstError +from lnst.Common.Parameters import Param from lnst.Controller import HostReq, DeviceReq, RecipeParam from lnst.Devices import MacsecDevice from lnst.Recipes.ENRT.BaremetalEnrtRecipe import BaremetalEnrtRecipe @@ -21,7 +22,7 @@ class SimpleMacsecRecipe(CommonHWSubConfigMixin, BaremetalEnrtRecipe): host2 = HostReq() host2.eth0 = DeviceReq(label="to_switch", driver=RecipeParam("driver"))
- macsec_settings = [None, 'on', 'off']
- macsec_settings = Param(default=['on', 'off'])
While we're at it, could we rename the parameter to something that more precisely describes what the parameter is about?
E.g. "macsec_encryption" ?
Otherwise looks good.
Ack to both patches in the series besides renaming the parameter in this recipe.
-Jan
ids = ['00', '01'] keys = ["7a16780284000775d4f0a3c0f0e092c0", "3212ef5c4cc5d0e4210b17208e88779e"]@@ -66,72 +67,60 @@ def test_wide_deconfiguration(self, config):
def generate_sub_configurations(self, config): for subconf in ConfMixin.generate_sub_configurations(self, config):
for encryption in self.macsec_settings:
for encryption in self.params.macsec_settings: new_config = copy.copy(subconf) new_config.encrypt = encryption
if encryption is not None:new_config.ip_vers = self.params.ip_versions
new_config.ip_vers = self.params.ip_versions yield new_configdef apply_sub_configuration(self, config): super().apply_sub_configuration(config)
if not config.encrypt:config.endpoint1.up()config.endpoint2.up()else:net_addr = "192.168.100"net_addr6 = "fc00:0:0:0"host1, host2 = config.host1, config.host2k_ids = list(zip(self.ids, self.keys))hosts_and_keys = [(host1, host2, k_ids), (host2, host1,k_ids[::-1])]for host_a, host_b, k_ids in hosts_and_keys:host_a.msec0 = MacsecDevice(realdev=host_a.eth0,encrypt=config.encrypt)rx_kwargs = dict(port=1, address=host_b.eth0.hwaddr)tx_sa_kwargs = dict(sa=0, pn=1, enable='on',id=k_ids[0][0], key=k_ids[0][1])rx_sa_kwargs = rx_kwargs.copy()rx_sa_kwargs.update(tx_sa_kwargs)rx_sa_kwargs['id'] = k_ids[1][0]rx_sa_kwargs['key'] = k_ids[1][1]host_a.msec0.rx('add', **rx_kwargs)host_a.msec0.tx_sa('add', **tx_sa_kwargs)host_a.msec0.rx_sa('add', **rx_sa_kwargs)for i, host in enumerate([host1, host2]):host.msec0.ip_add(ipaddress(net_addr + "." + str(i+1) +"/24"))host.msec0.ip_add(ipaddress(net_addr6 + "::" + str(i+1) +"/64"))host.eth0.up()host.msec0.up()self.wait_tentative_ips([host.eth0, host.msec0])
net_addr = "192.168.100"net_addr6 = "fc00:0:0:0"host1, host2 = config.host1, config.host2k_ids = list(zip(self.ids, self.keys))hosts_and_keys = [(host1, host2, k_ids), (host2, host1,k_ids[::-1])]for host_a, host_b, k_ids in hosts_and_keys:host_a.msec0 = MacsecDevice(realdev=host_a.eth0,encrypt=config.encrypt)rx_kwargs = dict(port=1, address=host_b.eth0.hwaddr)tx_sa_kwargs = dict(sa=0, pn=1, enable='on',id=k_ids[0][0], key=k_ids[0][1])rx_sa_kwargs = rx_kwargs.copy()rx_sa_kwargs.update(tx_sa_kwargs)rx_sa_kwargs['id'] = k_ids[1][0]rx_sa_kwargs['key'] = k_ids[1][1]host_a.msec0.rx('add', **rx_kwargs)host_a.msec0.tx_sa('add', **tx_sa_kwargs)host_a.msec0.rx_sa('add', **rx_sa_kwargs)for i, host in enumerate([host1, host2]):host.msec0.ip_add(ipaddress(net_addr + "." + str(i+1) +"/24"))host.msec0.ip_add(ipaddress(net_addr6 + "::" + str(i+1) +"/64"))host.eth0.up()host.msec0.up()self.wait_tentative_ips([host.eth0, host.msec0])def remove_sub_configuration(self, config):
if config.encrypt:host1, host2 = config.host1, config.host2for host in (host1, host2):host.msec0.destroy()del host.msec0
host1, host2 = config.host1, config.host2for host in (host1, host2):host.msec0.destroy()del host.msec0 config.endpoint1.down() config.endpoint2.down() super().remove_sub_configuration(config)def generate_ping_configurations(self, config):
if not config.encrypt:client_nic = config.endpoint1server_nic = config.endpoint2ip_vers = ('ipv4',)else:client_nic = config.host1.msec0server_nic = config.host2.msec0ip_vers = self.params.ip_versions
client_nic = config.host1.msec0server_nic = config.host2.msec0ip_vers = self.params.ip_versions count = self.params.ping_count interval = self.params.ping_interval size = self.params.ping_psize
common_args = {'count' : count, 'interval' : interval,'size' : size}
common_args = {'count': count, 'interval': interval, 'size': size} for ipv in ip_vers: kwargs = {}@@ -162,45 +151,45 @@ def generate_ping_configurations(self, config): yield [pconf]
def generate_perf_configurations(self, config):
if config.encrypt:client_nic = config.host1.msec0server_nic = config.host2.msec0client_netns = client_nic.netnsserver_netns = server_nic.netnsflow_combinations = self.generate_flow_combinations(config
client_nic = config.host1.msec0server_nic = config.host2.msec0client_netns = client_nic.netnsserver_netns = server_nic.netnsflow_combinations = self.generate_flow_combinations(config)for flows in flow_combinations:perf_recipe_conf=dict(recipe_config=config,flows=flows, )
for flows in flow_combinations:perf_recipe_conf=dict(recipe_config=config,flows=flows,)flows_measurement = self.params.net_perf_tool(flows,perf_recipe_conf)
flows_measurement = self.params.net_perf_tool(flows,perf_recipe_conf)
cpu_measurement = self.params.cpu_perf_tool([client_netns, server_netns],perf_recipe_conf,)
cpu_measurement = self.params.cpu_perf_tool([client_netns, server_netns],perf_recipe_conf,)
perf_conf = PerfRecipeConf(measurements=[cpu_measurement, flows_measurement],iterations=self.params.perf_iterations,)
perf_conf = PerfRecipeConf(measurements=[cpu_measurement, flows_measurement],iterations=self.params.perf_iterations,parent_recipe_config=copy.deepcopy(config),)
perf_conf.register_evaluators(cpu_measurement, self.cpu_perf_evaluators)perf_conf.register_evaluators(flows_measurement, self.net_perf_evaluators)
perf_conf.register_evaluators(cpu_measurement, self.cpu_perf_evaluators)perf_conf.register_evaluators(flows_measurement, self.net_perf_evaluators)
yield perf_conf
yield perf_confdef generate_perf_endpoints(self, config): return [(self.matched.host1.msec0, self.matched.host2.msec0)]
-- 2.30.0 _______________________________________________ LNST-developers mailing list -- lnst-developers@lists.fedorahosted.org To unsubscribe send an email to lnst-developers-leave@lists.fedorahosted.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/lnst-developers@lists.fedorahos... Do not reply to spam on the list, report it: https://pagure.io/fedora-infrastructure