2 Documentation Openstack library. This library is useful for tests to create network, subnet, router and vm instances
5 Resource TemplatedRequests.robot
6 Resource ../variables/Variables.robot
9 Library OperatingSystem
10 Variables ../variables/Variables.py
13 ${VPN_INSTANCE_DELETE} vpn1_instance_delete.json
14 ${GETL3VPN} GETL3vpn.json
15 ${CREATE_RESP_CODE} 200
16 ${CREATE_ID_DEFAULT} "4ae8cd92-48ca-49b5-94e1-b2921a2661c7"
17 ${CREATE_NAME_DEFAULT} "vpn1"
18 ${CREATE_ROUTER_DISTINGUISHER_DEFAULT} ["2200:1"]
19 ${CREATE_EXPORT_RT_DEFAULT} ["3300:1","8800:1"]
20 ${CREATE_IMPORT_RT_DEFAULT} ["3300:1","8800:1"]
21 ${CREATE_TENANT_ID_DEFAULT} "6c53df3a-3456-11e5-a151-feff819cdc9f"
22 ${VPN_CONFIG_DIR} ${CURDIR}/../variables/vpnservice
23 ${ITM_CREATE_JSON} itm_tunnel_create.json
24 ${itm_prefix_def} "1.1.1.1/24"
27 ${itm_portname1_def} "BR1-eth1"
28 ${itm_ip-address1_def} "2.2.2.2"
30 ${itm_portname2_def} "BR2-eth1"
31 ${itm_ip-address2_def} "3.3.3.3"
32 ${itm_gateway-ip_def} "0.0.0.0"
33 ${itm_tunnel-type_def} vxlan
34 ${itm_zone-name_def} TZA
35 ${VAR_BASE} ${CURDIR}/../variables/vpnservice/
39 [Arguments] ${vpn_instance} &{Kwargs}
40 [Documentation] Create an L3VPN using the Json using the list of optional arguments received.
41 @{KeysList} Create List CREATE_ID CREATE_NAME CREATE_ROUTER_DISTINGUISHER CREATE_EXPORT_RT CREATE_IMPORT_RT
43 ${body} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${vpn_instance}
45 Run Keyword If ${Kwargs} Log ${Kwargs}
46 ${CREATE_ID} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[0]} default=${CREATE_ID_DEFAULT}
47 ${body} = Replace String ${body} ${CREATE_ID_DEFAULT} ${CREATE_ID}
49 ${CREATE_NAME} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[1]} default=${CREATE_NAME_DEFAULT}
50 ${body} = Replace String ${body} ${CREATE_NAME_DEFAULT} ${CREATE_NAME}
51 Log NAME:${CREATE_NAME}
52 ${CREATE_ROUTER_DISTINGUISHER} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[2]} default=${CREATE_ROUTER_DISTINGUISHER_DEFAULT}
53 ${body} = Replace String ${body} ${CREATE_ROUTER_DISTINGUISHER_DEFAULT} ${CREATE_ROUTER_DISTINGUISHER}
54 Log ROUTER_DISTIGNSHER:${CREATE_ROUTER_DISTINGUISHER}
55 ${CREATE_EXPORT_RT} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[3]} default=${CREATE_EXPORT_RT_DEFAULT}
56 ${body} = Replace String ${body} ${CREATE_EXPORT_RT_DEFAULT} ${CREATE_EXPORT_RT}
57 Log EXPORT_RT:${CREATE_EXPORT_RT}
58 ${CREATE_IMPORT_RT} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[4]} default=${CREATE_IMPORT_RT_DEFAULT}
59 ${body} = Replace String ${body} ${CREATE_IMPORT_RT_DEFAULT} ${CREATE_IMPORT_RT}
60 Log IMPORT_RT:${CREATE_IMPORT_RT}
61 ${CREATE_TENANT_ID} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[5]} default=${CREATE_TENANT_ID_DEFAULT}
62 ${body} = Replace String ${body} ${CREATE_TENANT_ID_DEFAULT} ${CREATE_TENANT_ID}
63 Log TENANT_ID:${CREATE_TENANT_ID}
64 Set Global Variable ${GET_ID} ${CREATE_ID}
66 ${resp} = RequestsLibrary.Post Request session ${OPERATIONS_API}/neutronvpn:createL3VPN data=${body}
68 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
69 ${body1} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${GETL3VPN}
70 ${body1} = Replace String ${body1} ${CREATE_ID_DEFAULT} ${CREATE_ID}
71 ${resp} = RequestsLibrary.Post Request session ${OPERATIONS_API}/neutronvpn:getL3VPN data=${body1}
73 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
76 [Arguments] ${GET_L3VPN_ID}
77 [Documentation] Will return detailed list of the L3VPN_ID received
78 ${body1} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${GETL3VPN}
79 ${body1} = Replace String ${body1} ${CREATE_ID_DEFAULT} ${GET_L3VPN_ID}
80 ${resp} = RequestsLibrary.Post Request session ${OPERATIONS_API}/neutronvpn:getL3VPN data=${body1}
82 Log BODY:${resp.content}
83 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
84 [Return] ${resp.content}
86 Associate L3VPN To Network
88 [Documentation] Associate the created L3VPN to a network-id received as dictionary argument
89 ${resp} = TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/assoc_l3vpn mapping=${Kwargs} session=session
93 Dissociate L3VPN From Networks
95 [Documentation] Disssociate the already associated networks from L3VPN
96 ${resp} = TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/dissoc_l3vpn mapping=${Kwargs} session=session
100 Get L3VPN Association
101 [Documentation] Will return detailed list of L3VPN created and associated networks
102 ${resp} = TemplatedRequests.Post_As_Json_Templated folder=${VAR_BASE}/get_l3vpn mapping={"getid":${GET_ID}} session=session
106 Associate VPN to Router
107 [Arguments] ${ROUTER} ${VPN_INSTANCE_NAME}
108 [Documentation] Associate the created L3VPN to a router-id received as argument
109 ${body} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/vpn_router.json
110 ${body} = Replace String ${body} VPN_ID ${VPN_INSTANCE_NAME}
111 ${body} = Replace String ${body} ROUTER_ID ${ROUTER}
112 ${resp} = RequestsLibrary.Post Request session ${OPERATIONS_API}/neutronvpn:associateRouter data=${body}
114 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
115 ${body1} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${GETL3VPN}
116 ${body1} = Replace String ${body1} ${CREATE_ID_DEFAULT} ${GET_ID}
117 ${resp} = RequestsLibrary.Post Request session ${OPERATIONS_API}/neutronvpn:getL3VPN data=${body1}
119 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
121 Dissociate VPN to Router
122 [Arguments] ${ROUTER} ${VPN_INSTANCE_NAME}
123 [Documentation] Dissociate the already associated routers from L3VPN
124 ${body} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/vpn_router.json
125 ${body} = Replace String ${body} VPN_ID ${VPN_INSTANCE_NAME}
126 ${body} = Replace String ${body} ROUTER_ID ${ROUTER}
127 ${resp} = RequestsLibrary.Post Request session ${OPERATIONS_API}/neutronvpn:dissociateRouter data=${body}
129 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
130 ${body1} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${GETL3VPN}
131 ${body1} = Replace String ${body1} ${CREATE_ID_DEFAULT} ${GET_ID}
132 ${resp} = RequestsLibrary.Post Request session ${OPERATIONS_API}/neutronvpn:getL3VPN data=${body1}
134 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
137 [Arguments] ${DEL_L3VPN_ID}
138 [Documentation] Delete the created L3VPN
139 ${body1} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${VPN_INSTANCE_DELETE}
141 ${body1} = Replace String ${body1} ${CREATE_ID_DEFAULT} ${DEL_L3VPN_ID}
142 ${resp} = RequestsLibrary.Post Request session ${OPERATIONS_API}/neutronvpn:deleteL3VPN ${body1}
144 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
147 [Arguments] &{Kwargs}
148 [Documentation] Creates Tunnel between the two DPNs received in the dictionary argument
149 @{KeysList} Create List prefix vlan-id dpn-id1 portname1 ip-address1
150 ... dpn-id2 portname2 ip-address2 gateway-ip tunnel-type zone-name
151 Log Arguments Received:${Kwargs}
152 ${json_body} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${ITM_CREATE_JSON}
153 Run Keyword If ${Kwargs} Log ${Kwargs}
154 Log json_body:${json_body}
155 ${prefix} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[0]} default=${itm_prefix_def}
156 ${json_body} = Replace String ${json_body} prefix\"\:${itm_prefix_def} prefix\"\:${prefix}
157 ${vlan-id} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[1]} default=${itm_vlan-id_def}
158 ${json_body} = Replace String ${json_body} vlan-id\"\:${itm_vlan-id_def} vlan-id\"\:${vlan-id}
159 ${dpn-id1} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[2]} default=${itm_dpn-id1_def}
160 ${json_body} = Replace String ${json_body} dpn-id\"\:${itm_dpn-id1_def}, dpn-id\"\:${dpn-id1},
161 ${portname1} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[3]} default=${itm_portname1_def}
162 ${json_body} = Replace String ${json_body} portname\"\:${itm_portname1_def} portname\"\:${portname1}
163 ${ip-address1} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[4]} default=${itm_ip-address1_def}
164 ${json_body} = Replace String ${json_body} ip-address\"\:${itm_ip-address1_def} ip-address\"\:${ip-address1}
165 ${dpn-id2} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[5]} default=${itm_dpn-id2_def}
166 ${json_body} = Replace String ${json_body} dpn-id\"\:${itm_dpn-id2_def}, dpn-id\"\:${dpn-id2},
167 ${portname2} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[6]} default=${itm_portname2_def}
168 ${json_body} = Replace String ${json_body} portname\"\:${itm_portname2_def} portname\"\:${portname2}
169 ${ip-address2} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[7]} default=${itm_ip-address2_def}
170 ${json_body} = Replace String ${json_body} ip-address\"\:${itm_ip-address2_def} ip-address\"\:${ip-address2}
171 ${gateway-ip} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[8]} default=${itm_gateway-ip_def}
172 ${json_body} = Replace String ${json_body} gateway-ip\"\:${itm_gateway-ip_def} gateway-ip\"\:${gateway-ip}
173 ${tunnel-type} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[9]} default=${itm_tunnel-type_def}
174 ${json_body} = Replace String ${json_body} \:tunnel-type-${itm_tunnel-type_def} \:tunnel-type-${tunnel-type}
175 ${zone-name} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[10]} default=${itm_zone-name_def}
176 ${json_body} = Replace String ${json_body} \"zone-name\":\"${itm_zone-name_def} \"zone-name\":\"${zone-name}
178 ${resp} = RequestsLibrary.Post Request session ${CONFIG_API}/itm:transport-zones/ data=${json_body}
180 Log ${resp.status_code}
181 Should Be Equal As Strings ${resp.status_code} 204
184 [Documentation] Get all Tunnels and return the contents
185 ${resp} = RequestsLibrary.Get Request session ${CONFIG_API}/itm:transport-zones/
187 Should Be Equal As Strings ${resp.status_code} 200
188 [Return] ${resp.content}
191 [Arguments] ${zone-name}
192 [Documentation] Delete Tunnels created under the transport-zone
193 ${resp} = RequestsLibrary.Delete Request session ${CONFIG_API}/itm:transport-zones/transport-zone/${zone-name}/
195 Should Be Equal As Strings ${resp.status_code} 200
196 [Return] ${resp.content}