+ RETURN ${request}
+
+Extract Node from Topology
+ [Documentation] Returns node that contains supporting node with ID specified in argument supp_node_id
+ [Arguments] ${topology} ${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
+ [Documentation] Returns termination point that contains supporting termination point from specified topology, node and with specified id
+ [Arguments] ${model} ${topology} ${topo_id} ${node_id} ${tp_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
+ [Documentation] Returns link that contains supporting link
+ [Arguments] ${model} ${topology} ${topo_id} ${link_id}
+ 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
+ [Documentation] Checks if model is supported.
+ [Arguments] ${model}
+ IF '${model}' != 'network-topology-model' and '${model}' != 'i2rs-model' and '${model}' != 'opendaylight-inventory-model'
+ Fail Not supported model
+ END
+
+Check Aggregated Node in Topology
+ [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'.
+ [Arguments] ${model} ${topology} ${tp_count} @{supp_node_ids}
+ 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
+ END
+ ${overlay_node_id} Get Element Text ${aggregated_node} xpath=./node-id
+ RETURN ${overlay_node_id}
+
+Check Aggregated Termination Point in Node
+ [Documentation] Checks supporting termination points in aggregated termination point. Model should be 'network-topology-model', 'opendaylight-inventory-model' or 'i2rs-model'.
+ [Arguments] ${model} ${topology} ${topology_id} ${node_id} ${tp_id} @{supp_tp_ids}
+ 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
+ END
+
+Check Filtered Nodes in Topology
+ [Documentation] Checks nodes in filtered topology
+ [Arguments] ${topology} ${tp_count} @{node_ids}
+ FOR ${node_id} IN @{node_ids}
+ Element Text Should Be
+ ... ${topology}
+ ... ${node_id}
+ ... xpath=.//node/supporting-node[node-ref='${node_id}']/node-ref
+ END
+
+Check Filtered Termination Points in Node
+ [Documentation] Checks termination points in filtered topology
+ [Arguments] ${topology} ${supp_node_id} @{supp_tp_ids}
+ ${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
+ END
+
+Check Filtered Links In Topology
+ [Documentation] Checks links in filtered topology
+ [Arguments] ${topology} @{supp_link_ids}
+ FOR ${supp_link_id} IN @{supp_link_ids}
+ Should Contain X Times ${topology} ${supp_link_id}</link-ref> 1
+ END
+
+Check Overlay Link Source And Destination
+ [Documentation] Checks if the overlay link's source and destination specified by a supporting link ref matches given source and destination
+ [Arguments] ${model} ${topology} ${topo_id} ${link_id} ${expected_source} ${expected_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
+ [Documentation] Verifies that the output topology contains the expected amount of essential elements
+ [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
+ ${resp} Wait Until Keyword Succeeds 5x 250ms Basic Request Get ${OVERLAY_TOPO_URL}
+ Should Contain ${resp.text} <topology-id>${OUTPUT_TOPO_NAME}</topology-id>
+ IF ${node_count}>-1
+ Should Contain X Times ${resp.text} <node> ${node_count}
+ END
+ IF ${supporting-node_count}>-1
+ Should Contain X Times ${resp.text} <supporting-node> ${supporting-node_count}
+ END
+ IF ${node-ref_count}>-1
+ Should Contain X Times ${resp.text} <node-ref> ${node-ref_count}
+ END
+ IF ${link_count}>-1
+ Should Contain X Times ${resp.text} <link> ${link_count}
+ END
+ IF ${link-ref_count}>-1
+ Should Contain X Times ${resp.text} <link-ref> ${link-ref_count}
+ END
+ IF ${tp_count}>-1
+ Should Contain X Times ${resp.text} <termination-point> ${tp_count}
+ END
+ IF ${tp-ref_count}>-1
+ Should Contain X Times ${resp.text} <tp-ref> ${tp-ref_count}
+ END
+ Log ---- Output Topo ----
+ Log ${resp.text}
+ RETURN ${resp}
+
+Set Global Variable If It Does Not Exist
+ [Arguments] ${name} ${value}
+ ${status} ${message} Run Keyword And Ignore Error Variable Should Exist ${name}
+ IF "${status}" == "FAIL" Set Global Variable ${name} ${value}