Skip to content
Snippets Groups Projects

Draft: Resolve "(TID) NBI for SAP Topology"

Open Pablo Armingol requested to merge feat/264-tid-nbi-fot-sap-topology into develop
Files
59
@@ -26,6 +26,7 @@ XPATH_IPV6ADDRESSES = ".//ociip:ipv6/ociip:addresses/ociip:address"
@@ -26,6 +26,7 @@ XPATH_IPV6ADDRESSES = ".//ociip:ipv6/ociip:addresses/ociip:address"
def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
response = []
response = []
 
sap_interface_counter = 0
for xml_interface in xml_data.xpath(XPATH_INTERFACES, namespaces=NAMESPACES):
for xml_interface in xml_data.xpath(XPATH_INTERFACES, namespaces=NAMESPACES):
#LOGGER.info('xml_interface = {:s}'.format(str(ET.tostring(xml_interface))))
#LOGGER.info('xml_interface = {:s}'.format(str(ET.tostring(xml_interface))))
@@ -43,7 +44,13 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
@@ -43,7 +44,13 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
interface_name = xml_interface.find('oci:name', namespaces=NAMESPACES)
interface_name = xml_interface.find('oci:name', namespaces=NAMESPACES)
if interface_name is None or interface_name.text is None: continue
if interface_name is None or interface_name.text is None: continue
add_value_from_tag(interface, 'name', interface_name)
add_value_from_tag(interface, 'name', interface_name)
 
sap_interface = ET.Element('dummy')
 
sap_interface.text =str(sap_interface_counter)
 
aux =str(sap_interface_counter)
 
add_value_from_tag(interface, 'sap_id', sap_interface)
 
sap_interface_counter += 1
 
# Get the type of interface according to the vendor's type
# Get the type of interface according to the vendor's type
if 'ianaift:' in interface_type.text:
if 'ianaift:' in interface_type.text:
interface_type.text = interface_type.text.replace('ianaift:', '') #ADVA
interface_type.text = interface_type.text.replace('ianaift:', '') #ADVA
@@ -57,6 +64,8 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
@@ -57,6 +64,8 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
interface_description = xml_interface.find('oci:config/oci:description', namespaces=NAMESPACES)
interface_description = xml_interface.find('oci:config/oci:description', namespaces=NAMESPACES)
add_value_from_tag(interface, 'description', interface_description)
add_value_from_tag(interface, 'description', interface_description)
 
sap_subinterface_counter = 65
 
for xml_subinterface in xml_interface.xpath(XPATH_SUBINTERFACES, namespaces=NAMESPACES):
for xml_subinterface in xml_interface.xpath(XPATH_SUBINTERFACES, namespaces=NAMESPACES):
#LOGGER.info('xml_subinterface = {:s}'.format(str(ET.tostring(xml_subinterface))))
#LOGGER.info('xml_subinterface = {:s}'.format(str(ET.tostring(xml_subinterface))))
@@ -74,6 +83,12 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
@@ -74,6 +83,12 @@ def parse(xml_data : ET.Element) -> List[Tuple[str, Dict[str, Any]]]:
vlan_id = xml_subinterface.find('ocv:vlan/ocv:match/ocv:single-tagged/ocv:config/ocv:vlan-id', namespaces=NAMESPACES)
vlan_id = xml_subinterface.find('ocv:vlan/ocv:match/ocv:single-tagged/ocv:config/ocv:vlan-id', namespaces=NAMESPACES)
add_value_from_tag(subinterface, 'vlan_id', vlan_id, cast=int)
add_value_from_tag(subinterface, 'vlan_id', vlan_id, cast=int)
 
sap_subinterface = ET.Element('dummy')
 
value = (aux + chr(sap_subinterface_counter))
 
sap_subinterface.text = value
 
add_value_from_tag(subinterface, 'sap_id', sap_subinterface)
 
sap_subinterface_counter += 1
 
# TODO: implement support for multiple IP addresses per subinterface
# TODO: implement support for multiple IP addresses per subinterface
#ipv4_addresses = []
#ipv4_addresses = []
for xml_ipv4_address in xml_subinterface.xpath(XPATH_IPV4ADDRESSES, namespaces=NAMESPACES):
for xml_ipv4_address in xml_subinterface.xpath(XPATH_IPV4ADDRESSES, namespaces=NAMESPACES):
Loading