2 Documentation Openstack library. This library is useful for tests to create network, subnet, router and vm instances
7 Variables ../variables/Variables.py
10 ${REST_CON} /restconf/config/
11 ${REST_CON_OP} /restconf/operations/
12 ${VPN_INSTANCE_DELETE} vpn1_instance_delete.json
13 ${GETL3VPN} GETL3vpn.json
14 ${CREATE_RESP_CODE} 200
15 ${CREATE_ID_DEFAULT} "4ae8cd92-48ca-49b5-94e1-b2921a2661c7"
16 ${CREATE_NAME_DEFAULT} "vpn1"
17 ${CREATE_ROUTER_DISTINGUISHER_DEFAULT} ["2200:1"]
18 ${CREATE_EXPORT_RT_DEFAULT} ["3300:1","8800:1"]
19 ${CREATE_IMPORT_RT_DEFAULT} ["3300:1","8800:1"]
20 ${CREATE_TENANT_ID_DEFAULT} "6c53df3a-3456-11e5-a151-feff819cdc9f"
21 ${VPN_CONFIG_DIR} ${CURDIR}/../variables/vpnservice
25 [Arguments] ${vpn_instance} &{Kwargs}
26 [Documentation] Create L3VPN .
27 @{KeysList} Create List CREATE_ID CREATE_NAME CREATE_ROUTER_DISTINGUISHER CREATE_EXPORT_RT CREATE_IMPORT_RT
29 ${body} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${vpn_instance}
31 Run Keyword If ${Kwargs} Log ${Kwargs}
32 ${CREATE_ID} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[0]} default=${CREATE_ID_DEFAULT}
33 ${body} = Replace String ${body} ${CREATE_ID_DEFAULT} ${CREATE_ID}
35 ${CREATE_NAME} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[1]} default=${CREATE_NAME_DEFAULT}
36 ${body} = Replace String ${body} ${CREATE_NAME_DEFAULT} ${CREATE_NAME}
37 Log NAME:${CREATE_NAME}
38 ${CREATE_ROUTER_DISTINGUISHER} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[2]} default=${CREATE_ROUTER_DISTINGUISHER_DEFAULT}
39 ${body} = Replace String ${body} ${CREATE_ROUTER_DISTINGUISHER_DEFAULT} ${CREATE_ROUTER_DISTINGUISHER}
40 Log ROUTER_DISTIGNSHER:${CREATE_ROUTER_DISTINGUISHER}
41 ${CREATE_EXPORT_RT} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[3]} default=${CREATE_EXPORT_RT_DEFAULT}
42 ${body} = Replace String ${body} ${CREATE_EXPORT_RT_DEFAULT} ${CREATE_EXPORT_RT}
43 Log EXPORT_RT:${CREATE_EXPORT_RT}
44 ${CREATE_IMPORT_RT} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[4]} default=${CREATE_IMPORT_RT_DEFAULT}
45 ${body} = Replace String ${body} ${CREATE_IMPORT_RT_DEFAULT} ${CREATE_IMPORT_RT}
46 Log IMPORT_RT:${CREATE_IMPORT_RT}
47 ${CREATE_TENANT_ID} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[5]} default=${CREATE_TENANT_ID_DEFAULT}
48 ${body} = Replace String ${body} ${CREATE_TENANT_ID_DEFAULT} ${CREATE_TENANT_ID}
49 Log TENANT_ID:${CREATE_TENANT_ID}
50 Set Global Variable ${GET_ID} ${CREATE_ID}
52 ${resp} = RequestsLibrary.Post Request session ${REST_CON_OP}neutronvpn:createL3VPN data=${body}
54 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
55 ${body1} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${GETL3VPN}
56 ${body1} = Replace String ${body1} ${CREATE_ID_DEFAULT} ${CREATE_ID}
57 ${resp} = RequestsLibrary.Post Request session ${REST_CON_OP}neutronvpn:getL3VPN data=${body1}
59 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
62 [Arguments] ${GET_L3VPN_ID}
63 ${body1} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${GETL3VPN}
64 ${body1} = Replace String ${body1} ${CREATE_ID_DEFAULT} ${GET_L3VPN_ID}
65 ${resp} = RequestsLibrary.Post Request session ${REST_CON_OP}neutronvpn:getL3VPN data=${body1}
67 Log BODY:${resp.content}
68 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
69 [Return] ${resp.content}
71 Associate VPN to Router
72 [Arguments] ${ROUTER} ${VPN_INSTANCE_NAME}
73 [Documentation] Associate VPN to Router
74 ${body} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/vpn_router.json
75 ${body} = Replace String ${body} VPN_ID ${VPN_INSTANCE_NAME}
76 ${body} = Replace String ${body} ROUTER_ID ${ROUTER}
77 ${resp} = RequestsLibrary.Post Request session ${REST_CON_OP}neutronvpn:associateRouter data=${body}
79 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
80 ${body1} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${GETL3VPN}
81 ${body1} = Replace String ${body1} ${CREATE_ID_DEFAULT} ${GET_ID}
82 ${resp} = RequestsLibrary.Post Request session ${REST_CON_OP}neutronvpn:getL3VPN data=${body1}
84 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
86 Dissociate VPN to Router
87 [Arguments] ${ROUTER} ${VPN_INSTANCE_NAME}
88 [Documentation] Dissociate VPN to Router
89 ${body} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/vpn_router.json
90 ${body} = Replace String ${body} VPN_ID ${VPN_INSTANCE_NAME}
91 ${body} = Replace String ${body} ROUTER_ID ${ROUTER}
92 ${resp} = RequestsLibrary.Post Request session ${REST_CON_OP}neutronvpn:dissociateRouter data=${body}
94 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
95 ${body1} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${GETL3VPN}
96 ${body1} = Replace String ${body1} ${CREATE_ID_DEFAULT} ${GET_ID}
97 ${resp} = RequestsLibrary.Post Request session ${REST_CON_OP}neutronvpn:getL3VPN data=${body1}
99 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
102 [Arguments] ${DEL_L3VPN_ID}
103 ${body1} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${VPN_INSTANCE_DELETE}
105 ${body1} = Replace String ${body1} ${CREATE_ID_DEFAULT} ${DEL_L3VPN_ID}
106 ${resp} = RequestsLibrary.Post Request session ${REST_CON_OP}neutronvpn:deleteL3VPN ${body1}
108 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}