2 Documentation Utils for Restconf operations for GBP
3 Library RequestsLibrary
4 Library OperatingSystem
6 Variables ../../variables/Variables.py
7 Resource ../Utils.robot
10 ${ENDPOINT_UNREG_PATH} ${GBP_UNREGEP_API}
11 ${ENDPOINTS_OPER_PATH} /restconf/operational/endpoint:endpoints
15 [Documentation] Unregister Endpoints Endpoints from ODL
16 ${result} = RequestsLibrary.Get Request session ${ENDPOINTS_OPER_PATH}
17 ${json_result} = json.loads ${result.text}
18 Pass Execution If ${json_result['endpoints']}=={} No Endpoints available
19 ${L2_ENDPOINTS} = Set Variable ${json_result['endpoints']['endpoint']}
20 ${L3_ENDPOINTS} = Set Variable ${json_result['endpoints']['endpoint-l3']}
22 Unregister L2Endpoints ${L2_ENDPOINTS}
24 Unregister L3Endpoints ${L3_ENDPOINTS}
25 ${result} = RequestsLibrary.Get Request session ${ENDPOINTS_OPER_PATH}
26 ${json_result} = json.loads ${result.text}
27 Should Be Empty ${json_result['endpoints']}
29 Unregister L2Endpoints
31 [Documentation] Unregister Endpoints L2Endpoints from ODL
32 : FOR ${endpoint} IN @{l2_eps}
33 \ ${l2_data} = Create L2 Endpoint JSON Data ${endpoint}
34 \ Post Elements To URI ${ENDPOINT_UNREG_PATH} ${l2_data} ${HEADERS_YANG_JSON}
36 Unregister L3Endpoints
38 [Documentation] Unregister Endpoints L3Endpoints from ODL
39 : FOR ${endpoint} IN @{l3_eps}
40 \ ${l3_data} = Create L3 Endpoint JSON Data ${endpoint}
41 \ Post Elements To URI ${ENDPOINT_UNREG_PATH} ${l3_data} ${HEADERS_YANG_JSON}
43 Create L2 Endpoint JSON Data
44 [Arguments] ${endpoint}
45 [Documentation] Generate the JSON data required for unregistering L2 Endpoints
46 ${data} Set Variable {"input": {"l2": [{"mac-address": "${endpoint['mac-address']}", "l2-context": "${endpoint['l2-context']}"}]}}
49 Create L3 Endpoint JSON Data
50 [Arguments] ${endpoint}
51 [Documentation] Generate the JSON data required for unregistering L3 Endpoints
52 ${data} Set Variable {"input": {"l3": [{"l3-context": "${endpoint['l3-context']}", "ip-address": "${endpoint['ip-address']}"}]}}