From ba8caef66409a216046e3f6736c1530dc0b883d0 Mon Sep 17 00:00:00 2001 From: Allen Robel Date: Mon, 22 Apr 2024 10:58:25 -1000 Subject: [PATCH] BGP_AS regex disallowing valid values. I'd tried to avoid long line PEP8 error by breaking the template regex into multiple shorter lines, but must not have gotten it right. Reverting to the single-line regex from the template for now. --- plugins/module_utils/common/conversion.py | 24 +---------------------- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/plugins/module_utils/common/conversion.py b/plugins/module_utils/common/conversion.py index e58d497e8..a8c94078c 100644 --- a/plugins/module_utils/common/conversion.py +++ b/plugins/module_utils/common/conversion.py @@ -32,29 +32,7 @@ class ConversionUtils: """ def __init__(self): - re_asn_string = "^((" - re_asn_string += "(\\+)?[1-9]{1}[0-9]{0,8}|" - re_asn_string += "(\\+)?[1-3]{1}[0-9]{1,9}|" - re_asn_string += "(\\+)?" - re_asn_string += "[4]{1}([0-1]{1}[0-9]{8}|" - re_asn_string += "[2]{1}([0-8]{1}[0-9]{7}|" - re_asn_string += "[9]{1}([0-3]{1}[0-9]{6}|" - re_asn_string += "[4]{1}([0-8]{1}[0-9]{5}|" - re_asn_string += "[9]{1}([0-5]{1}[0-9]{4}|" - re_asn_string += "[6]{1}([0-6]{1}[0-9]{3}|" - re_asn_string += "[7]{1}([0-1]{1}[0-9]{2}|" - re_asn_string += "[2]{1}([0-8]{1}[0-9]{1}|" - re_asn_string += "[9]{1}[0-5]{1})))))))))|" - re_asn_string += "([1-5]\\d{4}|" - re_asn_string += "[1-9]\\d{0,3}|" - re_asn_string += "6[0-4]\\d{3}|" - re_asn_string += "65[0-4]\\d{2}|" - re_asn_string += "655[0-2]\\d|" - re_asn_string += "6553[0-5])(\\.[1-5]\\d{4}|[1-9]\\d{0,3}|" - re_asn_string += "6[0-4]\\d{3}|65[0-4]\\d{2}|" - re_asn_string += "655[0-2]\\d|6553[0-5]|0)?)$" - self.re_asn = re.compile(re_asn_string) - + self.re_asn = re.compile("^(((\\+)?[1-9]{1}[0-9]{0,8}|(\\+)?[1-3]{1}[0-9]{1,9}|(\\+)?[4]{1}([0-1]{1}[0-9]{8}|[2]{1}([0-8]{1}[0-9]{7}|[9]{1}([0-3]{1}[0-9]{6}|[4]{1}([0-8]{1}[0-9]{5}|[9]{1}([0-5]{1}[0-9]{4}|[6]{1}([0-6]{1}[0-9]{3}|[7]{1}([0-1]{1}[0-9]{2}|[2]{1}([0-8]{1}[0-9]{1}|[9]{1}[0-5]{1})))))))))|([1-5]\\d{4}|[1-9]\\d{0,3}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5])(\\.([1-5]\\d{4}|[1-9]\\d{0,3}|6[0-4]\\d{3}|65[0-4]\\d{2}|655[0-2]\\d|6553[0-5]|0))?)$") self.bgp_as_invalid_reason = None def bgp_as_is_valid(self, value):