Skip to content
Snippets Groups Projects
Commit f30caae2 authored by Erik Reid's avatar Erik Reid
Browse files

DBOARD3-965 workaround

parent a9881ec6
Branches
Tags
No related merge requests found
......@@ -3,6 +3,7 @@ import re
from ncclient import manager, xml_
from lxml import etree
logger = logging.getLogger(__name__)
......@@ -236,15 +237,16 @@ def get_lags_config(netconf_config):
def get_interfaces_config(netconf_config):
def _get_address_node_info(_e):
# HACKHACK: quick workaround for DBOARD3-965
# TODO: fix this properly
yield from _e.xpath('n:address', namespaces=NS)
yield from _e.xpath('n:primary', namespaces=NS)
def _get_ip_address(e):
for details_parent in e:
# example element
# <primary> # details_parent - not always primary
# <address>62.40.119.9</address>
# <prefix-length>32</prefix-length>
# </primary>
address = details_parent[0].text
prefix_length = details_parent[1].text
for _address_elem in _get_address_node_info(e):
address = _address_elem[0].text
prefix_length = _address_elem[1].text
ip_string = f'{address}/{prefix_length}'
yield ip_string
......@@ -263,6 +265,7 @@ def get_interfaces_config(netconf_config):
if admin_state is not None:
details["admin-state"] = admin_state.text
for element in interface.xpath('n:ipv4', namespaces=NS):
details["ipv4"].extend(_get_ip_address(element))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment