cnaas-nms icon indicating copy to clipboard operation
cnaas-nms copied to clipboard

Add an ipwrap template filter to ensure IPv6 addresses used in URLs are wrapped in brackets

Open lunkwill42 opened this issue 4 years ago • 2 comments

The ipwrap filter is functionally equivalent to that provided by Ansible (see https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters_ipaddr.html#wrapping-ipv6-addresses-in-brackets).

A template may look like

url https://{{ file_server }}/somefile.py

However, if the file_server variable is not a FQDN or an IPv4 address, but an IPv6 address, it needs to be enclosed in brackets to make a valid URL. The value itself may come from the NMS settings and is used for other things than just URLs, so the brackets cannot be part of the set value.

This depends on #225, so keeping it as draft until that can be merged.

lunkwill42 avatar Nov 19 '21 15:11 lunkwill42

Codecov Report

Merging #231 (3eac9f8) into develop (52840ef) will decrease coverage by 4.36%. The diff coverage is 30.00%.

:exclamation: Current head 3eac9f8 differs from pull request most recent head de9d49e. Consider uploading reports for the commit de9d49e to get more accurate results

@@             Coverage Diff             @@
##           develop     #231      +/-   ##
===========================================
- Coverage    63.78%   59.41%   -4.37%     
===========================================
  Files           63       61       -2     
  Lines         6627     6197     -430     
===========================================
- Hits          4227     3682     -545     
- Misses        2400     2515     +115     
Impacted Files Coverage Δ
src/cnaas_nms/tools/jinja_filters.py 34.61% <30.00%> (-2.12%) :arrow_down:
src/cnaas_nms/api/linknet.py 19.56% <0.00%> (-46.93%) :arrow_down:
src/cnaas_nms/confpush/underlay.py 19.60% <0.00%> (-37.26%) :arrow_down:
src/cnaas_nms/db/session.py 75.00% <0.00%> (-9.85%) :arrow_down:
src/cnaas_nms/db/linknet.py 79.71% <0.00%> (-9.32%) :arrow_down:
src/cnaas_nms/db/git.py 53.99% <0.00%> (-9.30%) :arrow_down:
src/cnaas_nms/api/app.py 68.42% <0.00%> (-8.51%) :arrow_down:
src/cnaas_nms/confpush/init_device.py 50.11% <0.00%> (-7.88%) :arrow_down:
src/cnaas_nms/api/repository.py 54.76% <0.00%> (-7.15%) :arrow_down:
src/cnaas_nms/api/device.py 40.40% <0.00%> (-6.15%) :arrow_down:
... and 32 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

codecov[bot] avatar Nov 19 '21 16:11 codecov[bot]

Rebased to latest develop branch.

lunkwill42 avatar Sep 14 '22 12:09 lunkwill42