Tue, Oct 22, 2019 at 02:36:59PM CEST, jurbanov(a)redhat.com wrote:
From: Jozef Urbanovsky <jurbanov(a)redhat.com>
IFLA_BOND_XMIT_HASH_POLICY requires numeral value of the setting,
dict was created to represent correct values of xmit_hash_policy
in kernel
Signed-off-by: Jozef Urbanovsky <jurbanov(a)redhat.com>
---
lnst/Devices/BondDevice.py | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/lnst/Devices/BondDevice.py b/lnst/Devices/BondDevice.py
index ce01427..48f4de6 100644
--- a/lnst/Devices/BondDevice.py
+++ b/lnst/Devices/BondDevice.py
@@ -354,12 +354,15 @@ class BondDevice(MasterDevice):
@xmit_hash_policy.setter
def xmit_hash_policy(self, val):
- m = ["layer2", "layer2+3", "layer3+4",
"encap2+3", "encap3+4"]
+ m = {"layer2": 0, "layer3+4": 1, "layer2+3": 2,
+ "encap2+3": 3, "encap3+4": 4}
if val in m:
+ self._set_linkinfo_data_attr("IFLA_BOND_XMIT_HASH_POLICY", m[val])
+ elif val in m.values():
self._set_linkinfo_data_attr("IFLA_BOND_XMIT_HASH_POLICY", val)
else:
- raise DeviceConfigError("Invalid value, must be in
{}}.".format(m))
+ raise DeviceConfigError("Invalid value, must be in {}.".format(m))
This would print following message:
Invalid value, must be in {'layer2': 0, 'layer3+4': 1, 'layer2+3':
2, 'encap2+3': 3, 'encap3+4': 4}.
That looks ugly.
How about the following:
... .format(list(m.keys()) + list(m.values())
Which would print:
Invalid value, must be in ['layer2', 'layer3+4', 'layer2+3',
'encap2+3', 'encap3+4', 0, 1, 2, 3, 4].
self._nl_link_sync("set")
@property
--
2.21.0
_______________________________________________
LNST-developers mailing list -- lnst-developers(a)lists.fedorahosted.org
To unsubscribe send an email to lnst-developers-leave(a)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.fedora...