+
+Create Isis Node
+ [Arguments] ${node-id} ${ovs-version}=23 ${router-id-ipv4}=10.0.0.1
+ [Documentation] Create an isis node element with id and ip
+ ${request} Set Element Text ${NODE_ISIS} ${node-id} xpath=.//node-id
+ ${request} Set Element Text ${request} ${ovs-version} xpath=.//ovs-version
+ ${request} Set Element Text ${request} ${router-id-ipv4} xpath=.//igp-node-attributes/isis-node-attributes/ted/te-router-id-ipv4
+ ${request} Element to String ${request}
+ [Return] ${request}
+
+Create Openflow Node
+ [Arguments] ${node-id} ${ip-address}=10.0.0.1 ${serial-number}=27
+ [Documentation] Create an Openflow node element with id and ip
+ ${request} Set Element Text ${NODE_OPENFLOW} ${node-id} xpath=.//id
+ ${request} Set Element Text ${request} ${ip-address} xpath=.//ip-address
+ ${request} Set Element Text ${request} ${serial-number} xpath=.//serial-number
+ ${request} Element to String ${request}
+ [Return] ${request}
+
+Create OVSDB Termination Point
+ [Arguments] ${tp-id} ${ofport}
+ [Documentation] Create an OVSDB termination point element with id and port
+ ${request} Set Element Text ${TERMINATION_POINT_OVSDB} ${tp-id} xpath=.//tp-id
+ ${request} Set Element Text ${request} ${ofport} xpath=.//ofport
+ ${request} Element to String ${request}
+ [Return] ${request}
+
+Create Openflow Node Connector
+ [Arguments] ${nc-id} ${port-number}
+ [Documentation] Create an Openflow node connector element with id and port number
+ ${request} Set Element Text ${NODE_CONNECTOR_OPENFLOW} ${nc-id} xpath=.//id
+ ${request} Set Element Text ${request} ${port-number} xpath=.//port-number
+ ${request} Element to String ${request}
+ [Return] ${request}
+
+Create Link
+ [Arguments] ${link-id} ${source-node} ${dest-node} ${name} ${metric}
+ ${request} Set Element Text ${LINK} ${link-id} xpath=.//link-id
+ ${request} Set Element Text ${request} ${source-node} xpath=.//source/source-node
+ ${request} Set Element Text ${request} ${dest-node} xpath=.//destination/dest-node
+ ${request} Set Element Text ${request} ${name} xpath=.//igp-link-attributes/name
+ ${request} Set Element Text ${request} ${metric} xpath=.//igp-link-attributes/metric
+ ${request} Element to String ${request}
+ [Return] ${request}
+
+Extract Node from Topology
+ [Arguments] ${topology} ${supp_node_id}
+ [Documentation] Returns node that contains supporting node with ID specified in argument supp_node_id
+ ${xpath} Set Variable .//node/supporting-node[node-ref='${supp_node_id}']/..
+ ${node} Get Element ${topology} xpath=${xpath}
+ ${node} Element to String ${node}
+ [Return] ${node}
+
+Extract Termination Point from Topology
+ [Arguments] ${model} ${topology} ${topo_id} ${node_id} ${tp_id}
+ [Documentation] Returns termination point that contains supporting termination point from specified topology, node and with specified id
+ Check Supported Model ${model}
+ ${xpath} Set Variable If '${model}' == 'network-topology-model' or '${model}' == 'opendaylight-inventory-model' .//termination-point[tp-ref='/network-topology:network-topology/topology/${topo_id}/node/${node_id}/termination-point/${tp_id}'] .//termination-point/supporting-termination-point[tp-ref='${tp_id}']/..
+ ${tp} Get Element ${topology} xpath=${xpath}
+ ${tp} Element to String ${tp}
+ [Return] ${tp}
+
+Extract Link from Topology
+ [Arguments] ${model} ${topology} ${topo_id} ${link_id}
+ [Documentation] Returns link that contains supporting link
+ Check Supported Model ${model}
+ ${xpath} Set Variable If '${model}' == 'network-topology-model' or '${model}' == 'opendaylight-inventory-model' .//link/supporting-link[link-ref='/network-topology/topology/${topo_id}/link/${link_id}']/.. .//link/supporting-link[tp-ref='${tp_id}']/..
+ ${link} Get Element ${topology} xpath=${xpath}
+ ${link} Element to String ${link}
+ [Return] ${link}
+
+Check Supported Model
+ [Arguments] ${model}
+ [Documentation] Checks if model is supported.
+ Run Keyword If '${model}' != 'network-topology-model' and '${model}' != 'i2rs-model' and '${model}' != 'opendaylight-inventory-model' Fail Not supported model
+
+Check Aggregated Node in Topology
+ [Arguments] ${model} ${topology} ${tp_count} @{supp_node_ids}
+ [Documentation] Checks number of termination points and concrete supporting nodes in aggregated node and returns overlay node id. Model should be 'network-topology-model', 'opendaylight-inventory-model' or 'i2rs-model'.
+ Check Supported Model ${model}
+ ${node_id} Get From List ${supp_node_ids} 0
+ ${aggregated_node} Extract Node from Topology ${topology} ${node_id}
+ ${supp_node_count} Get Length ${supp_node_ids}
+ Should Contain X Times ${aggregated_node} <supporting-node> ${supp_node_count}
+ Should Contain X Times ${aggregated_node} <termination-point> ${tp_count}
+ Should Contain X Times ${aggregated_node} <tp-ref> ${tp_count}
+ : FOR ${supp_node_id} IN @{supp_node_ids}
+ \ Element Text Should Be ${aggregated_node} ${supp_node_id} xpath=.//supporting-node[node-ref='${supp_node_id}']/node-ref
+ ${overlay_node_id} Get Element Text ${aggregated_node} xpath=./node-id
+ [Return] ${overlay_node_id}
+
+Check Aggregated Termination Point in Node
+ [Arguments] ${model} ${topology} ${topology_id} ${node_id} ${tp_id} @{supp_tp_ids}
+ [Documentation] Checks supporting termination points in aggregated termination point. Model should be 'network-topology-model', 'opendaylight-inventory-model' or 'i2rs-model'.
+ Check Supported Model ${model}
+ ${tp} Extract Termination Point from Topology ${model} ${topology} ${topology_id} ${node_id} ${tp_id}
+ ${supp_tp_count} Get Length ${supp_tp_ids}
+ Should Contain X Times ${tp} <tp-ref> ${supp_tp_count}
+ : FOR ${supp_tp_id} IN @{supp_tp_ids}
+ \ Should Contain X Times ${tp} ${supp_tp_id}</tp-ref> 1
+
+Check Filtered Nodes in Topology
+ [Arguments] ${topology} ${tp_count} @{node_ids}
+ [Documentation] Checks nodes in filtered topology
+ : FOR ${node_id} IN @{node_ids}
+ \ Element Text Should Be ${topology} ${node_id} xpath=.//node/supporting-node[node-ref='${node_id}']/node-ref
+
+Check Filtered Termination Points in Node
+ [Arguments] ${topology} ${supp_node_id} @{supp_tp_ids}
+ [Documentation] Checks termination points in filtered topology
+ ${node} Extract Node from Topology ${topology} ${supp_node_id}
+ ${supp_tp_count} Get Length ${supp_tp_ids}
+ Should Contain X Times ${node} <supporting-node> 1
+ Should Contain X Times ${node} <termination-point> ${supp_tp_count}
+ Should Contain X Times ${node} <tp-ref> ${supp_tp_count}
+ : FOR ${supp_tp_id} IN @{supp_tp_ids}
+ \ Should Contain X Times ${node} ${supp_tp_id} 1
+
+Check Filtered Links In Topology
+ [Arguments] ${topology} @{supp_link_ids}
+ [Documentation] Checks links in filtered topology
+ : FOR ${supp_link_id} IN @{supp_link_ids}
+ \ Should Contain X Times ${topology} ${supp_link_id}</link-ref> 1
+
+Check Overlay Link Source And Destination
+ [Arguments] ${model} ${topology} ${topo_id} ${link_id} ${expected_source} ${expected_destination}
+ [Documentation] Checks if the overlay link's source and destination specified by a supporting link ref matches given source and destination
+ ${link} Extract Link from Topology ${model} ${topology} ${topo_id} ${link_id}
+ ${link_source} Get Element Text ${link} xpath=.//source-node
+ ${link_destination} Get Element Text ${link} xpath=.//dest-node
+ Should Be Equal As Strings ${link_source} ${expected_source}
+ Should Be Equal As Strings ${link_destination} ${expected_destination}
+
+Output Topo Should Be Complete
+ [Arguments] ${node_count}=-1 ${supporting-node_count}=-1 ${node-ref_count}=-1 ${tp_count}=-1 ${tp-ref_count}=-1 ${link_count}=-1
+ ... ${link-ref_count}=-1
+ [Documentation] Verifies that the output topology contains the expected amount of essential elements
+ ${resp} Wait Until Keyword Succeeds 5x 250ms Basic Request Get ${OVERLAY_TOPO_URL}
+ Should Contain ${resp.content} <topology-id>${OUTPUT_TOPO_NAME}</topology-id>
+ Run Keyword If ${node_count}>-1 Should Contain X Times ${resp.content} <node> ${node_count}
+ Run Keyword If ${supporting-node_count}>-1 Should Contain X Times ${resp.content} <supporting-node> ${supporting-node_count}
+ Run Keyword If ${node-ref_count}>-1 Should Contain X Times ${resp.content} <node-ref> ${node-ref_count}
+ Run Keyword If ${link_count}>-1 Should Contain X Times ${resp.content} <link> ${link_count}
+ Run Keyword If ${link-ref_count}>-1 Should Contain X Times ${resp.content} <link-ref> ${link-ref_count}
+ Run Keyword If ${tp_count}>-1 Should Contain X Times ${resp.content} <termination-point> ${tp_count}
+ Run Keyword If ${tp-ref_count}>-1 Should Contain X Times ${resp.content} <tp-ref> ${tp-ref_count}
+ Log ---- Output Topo ----
+ Log ${resp.content}
+ [Return] ${resp}
+
+Set Global Variable If It Does Not Exist
+ [Arguments] ${name} ${value}
+ ${status} ${message} = Run Keyword And Ignore Error Variable Should Exist ${name}
+ Run Keyword If "${status}" == "FAIL" Set Global Variable ${name} ${value}