2 Documentation Openstack library. This library is useful for tests to create network, subnet, router and vm instances
7 Library OperatingSystem
8 Variables ../variables/Variables.py
11 ${REST_CON} /restconf/config/
12 ${REST_CON_OP} /restconf/operations/
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
38 [Arguments] ${vpn_instance} &{Kwargs}
39 [Documentation] Create L3VPN .
40 @{KeysList} Create List CREATE_ID CREATE_NAME CREATE_ROUTER_DISTINGUISHER CREATE_EXPORT_RT CREATE_IMPORT_RT
42 ${body} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${vpn_instance}
44 Run Keyword If ${Kwargs} Log ${Kwargs}
45 ${CREATE_ID} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[0]} default=${CREATE_ID_DEFAULT}
46 ${body} = Replace String ${body} ${CREATE_ID_DEFAULT} ${CREATE_ID}
48 ${CREATE_NAME} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[1]} default=${CREATE_NAME_DEFAULT}
49 ${body} = Replace String ${body} ${CREATE_NAME_DEFAULT} ${CREATE_NAME}
50 Log NAME:${CREATE_NAME}
51 ${CREATE_ROUTER_DISTINGUISHER} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[2]} default=${CREATE_ROUTER_DISTINGUISHER_DEFAULT}
52 ${body} = Replace String ${body} ${CREATE_ROUTER_DISTINGUISHER_DEFAULT} ${CREATE_ROUTER_DISTINGUISHER}
53 Log ROUTER_DISTIGNSHER:${CREATE_ROUTER_DISTINGUISHER}
54 ${CREATE_EXPORT_RT} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[3]} default=${CREATE_EXPORT_RT_DEFAULT}
55 ${body} = Replace String ${body} ${CREATE_EXPORT_RT_DEFAULT} ${CREATE_EXPORT_RT}
56 Log EXPORT_RT:${CREATE_EXPORT_RT}
57 ${CREATE_IMPORT_RT} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[4]} default=${CREATE_IMPORT_RT_DEFAULT}
58 ${body} = Replace String ${body} ${CREATE_IMPORT_RT_DEFAULT} ${CREATE_IMPORT_RT}
59 Log IMPORT_RT:${CREATE_IMPORT_RT}
60 ${CREATE_TENANT_ID} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[5]} default=${CREATE_TENANT_ID_DEFAULT}
61 ${body} = Replace String ${body} ${CREATE_TENANT_ID_DEFAULT} ${CREATE_TENANT_ID}
62 Log TENANT_ID:${CREATE_TENANT_ID}
63 Set Global Variable ${GET_ID} ${CREATE_ID}
65 ${resp} = RequestsLibrary.Post Request session ${REST_CON_OP}neutronvpn:createL3VPN data=${body}
67 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
68 ${body1} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${GETL3VPN}
69 ${body1} = Replace String ${body1} ${CREATE_ID_DEFAULT} ${CREATE_ID}
70 ${resp} = RequestsLibrary.Post Request session ${REST_CON_OP}neutronvpn:getL3VPN data=${body1}
72 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
75 [Arguments] ${GET_L3VPN_ID}
76 ${body1} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${GETL3VPN}
77 ${body1} = Replace String ${body1} ${CREATE_ID_DEFAULT} ${GET_L3VPN_ID}
78 ${resp} = RequestsLibrary.Post Request session ${REST_CON_OP}neutronvpn:getL3VPN data=${body1}
80 Log BODY:${resp.content}
81 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
82 [Return] ${resp.content}
84 Associate VPN to Router
85 [Arguments] ${ROUTER} ${VPN_INSTANCE_NAME}
86 [Documentation] Associate VPN to Router
87 ${body} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/vpn_router.json
88 ${body} = Replace String ${body} VPN_ID ${VPN_INSTANCE_NAME}
89 ${body} = Replace String ${body} ROUTER_ID ${ROUTER}
90 ${resp} = RequestsLibrary.Post Request session ${REST_CON_OP}neutronvpn:associateRouter data=${body}
92 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
93 ${body1} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${GETL3VPN}
94 ${body1} = Replace String ${body1} ${CREATE_ID_DEFAULT} ${GET_ID}
95 ${resp} = RequestsLibrary.Post Request session ${REST_CON_OP}neutronvpn:getL3VPN data=${body1}
97 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
99 Dissociate VPN to Router
100 [Arguments] ${ROUTER} ${VPN_INSTANCE_NAME}
101 [Documentation] Dissociate VPN to Router
102 ${body} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/vpn_router.json
103 ${body} = Replace String ${body} VPN_ID ${VPN_INSTANCE_NAME}
104 ${body} = Replace String ${body} ROUTER_ID ${ROUTER}
105 ${resp} = RequestsLibrary.Post Request session ${REST_CON_OP}neutronvpn:dissociateRouter data=${body}
107 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
108 ${body1} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${GETL3VPN}
109 ${body1} = Replace String ${body1} ${CREATE_ID_DEFAULT} ${GET_ID}
110 ${resp} = RequestsLibrary.Post Request session ${REST_CON_OP}neutronvpn:getL3VPN data=${body1}
112 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
115 [Arguments] ${DEL_L3VPN_ID}
116 ${body1} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${VPN_INSTANCE_DELETE}
118 ${body1} = Replace String ${body1} ${CREATE_ID_DEFAULT} ${DEL_L3VPN_ID}
119 ${resp} = RequestsLibrary.Post Request session ${REST_CON_OP}neutronvpn:deleteL3VPN ${body1}
121 Should Be Equal As Strings ${resp.status_code} ${CREATE_RESP_CODE}
124 [Arguments] &{Kwargs}
125 [Documentation] Creates Tunnel between the two DPNs
126 @{KeysList} Create List prefix vlan-id dpn-id1 portname1 ip-address1
127 ... dpn-id2 portname2 ip-address2 gateway-ip tunnel-type zone-name
128 Log Arguments Received:${Kwargs}
129 ${json_body} = OperatingSystem.Get File ${VPN_CONFIG_DIR}/${ITM_CREATE_JSON}
130 Run Keyword If ${Kwargs} Log ${Kwargs}
131 Log json_body:${json_body}
132 ${prefix} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[0]} default=${itm_prefix_def}
133 ${json_body} = Replace String ${json_body} prefix\"\:${itm_prefix_def} prefix\"\:${prefix}
134 ${vlan-id} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[1]} default=${itm_vlan-id_def}
135 ${json_body} = Replace String ${json_body} vlan-id\"\:${itm_vlan-id_def} vlan-id\"\:${vlan-id}
136 ${dpn-id1} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[2]} default=${itm_dpn-id1_def}
137 ${json_body} = Replace String ${json_body} dpn-id\"\:${itm_dpn-id1_def}, dpn-id\"\:${dpn-id1},
138 ${portname1} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[3]} default=${itm_portname1_def}
139 ${json_body} = Replace String ${json_body} portname\"\:${itm_portname1_def} portname\"\:${portname1}
140 ${ip-address1} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[4]} default=${itm_ip-address1_def}
141 ${json_body} = Replace String ${json_body} ip-address\"\:${itm_ip-address1_def} ip-address\"\:${ip-address1}
142 ${dpn-id2} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[5]} default=${itm_dpn-id2_def}
143 ${json_body} = Replace String ${json_body} dpn-id\"\:${itm_dpn-id2_def}, dpn-id\"\:${dpn-id2},
144 ${portname2} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[6]} default=${itm_portname2_def}
145 ${json_body} = Replace String ${json_body} portname\"\:${itm_portname2_def} portname\"\:${portname2}
146 ${ip-address2} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[7]} default=${itm_ip-address2_def}
147 ${json_body} = Replace String ${json_body} ip-address\"\:${itm_ip-address2_def} ip-address\"\:${ip-address2}
148 ${gateway-ip} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[8]} default=${itm_gateway-ip_def}
149 ${json_body} = Replace String ${json_body} gateway-ip\"\:${itm_gateway-ip_def} gateway-ip\"\:${gateway-ip}
150 ${tunnel-type} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[9]} default=${itm_tunnel-type_def}
151 ${json_body} = Replace String ${json_body} \:tunnel-type-${itm_tunnel-type_def} \:tunnel-type-${tunnel-type}
152 ${zone-name} = Run Keyword If ${Kwargs} != None Pop From Dictionary ${Kwargs} ${KeysList[10]} default=${itm_zone-name_def}
153 ${json_body} = Replace String ${json_body} \"zone-name\":\"${itm_zone-name_def} \"zone-name\":\"${zone-name}
155 ${resp} = RequestsLibrary.Post Request session ${REST_CON}/itm:transport-zones/ data=${json_body}
157 Log ${resp.status_code}
158 Should Be Equal As Strings ${resp.status_code} 204
161 [Documentation] Get all Tunnels and return the contents
162 ${resp} = RequestsLibrary.Get Request session ${REST_CON}itm:transport-zones/
164 Should Be Equal As Strings ${resp.status_code} 200
165 [Return] ${resp.content}
168 [Arguments] ${zone-name}
169 [Documentation] Delete Tunnels created under the transport-zone
170 ${resp} = RequestsLibrary.Delete Request session ${REST_CON}/itm:transport-zones/transport-zone/${zone-name}/
172 Should Be Equal As Strings ${resp.status_code} 200
173 [Return] ${resp.content}