Skip to content

Commit

Permalink
for ipv6 uri, explode, replace multi 0s to a single. (#325)
Browse files Browse the repository at this point in the history
  • Loading branch information
juztas authored Oct 8, 2023
1 parent 9b941ce commit 22e6383
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 3 additions & 1 deletion src/python/SiteFE/LookUpService/modules/switchinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ def _genIPv6(cls, inval, inkey, esc=True):
But for some switches, it will return dict if a single entry
"""
if isinstance(inval, dict):
subnet = 128 # Default we will use /128 just to secure code from diff ansible-switch outputs
subnet = 64 # Default we will use /64 just to secure code from diff ansible-switch outputs
if 'subnet' in inval:
subnet = inval['subnet'].split('/')[-1]
if 'masklen' in inval:
subnet = inval['masklen']
if 'address' in inval:
if esc:
return validMRMLName(f"{inval['address']}/{subnet}")
Expand Down
6 changes: 5 additions & 1 deletion src/python/SiteRMLibs/ipaddr.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,11 @@ def validMRMLName(valIn):
# See https://datatracker.ietf.org/doc/html/rfc4291.html
# Because of this - we always use a short version
if ipVersion(valIn) == 6:
valIn = ip_address(valIn.split('/')[0]).compressed
tmpspl = valIn.split('/')
longip = ip_address(tmpspl[0]).exploded
if len(tmpspl) == 2:
return f"{longip}_{tmpspl[1]}".replace('0000', '0').replace(':', '_')
return f"{longip}".replace('0000', '0').replace(':', '_')
return replaceSpecialSymbols(valIn)


Expand Down

0 comments on commit 22e6383

Please sign in to comment.