Skip to content

Commit

Permalink
BGP_AS regex disallowing valid values.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
allenrobel committed Apr 22, 2024
1 parent 3f518d7 commit ba8caef
Showing 1 changed file with 1 addition and 23 deletions.
24 changes: 1 addition & 23 deletions plugins/module_utils/common/conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit ba8caef

Please sign in to comment.