IPv6: support in basic vpn_service tests
[integration/test.git] / csit / suites / netvirt / Netvirt_Vpnservice / 03_basic_ipv6_vpnservice.robot
1 *** Settings ***
2 Documentation     Test suite to validate IPv6 vpnservice functionality in an Openstack integrated environment.
3 ...               The assumption of this suite is that the environment is already configured with the proper
4 ...               integration bridges and vxlan tunnels.
5 Suite Setup       Basic Vpnservice Suite Setup
6 Suite Teardown    Basic Vpnservice Suite Teardown
7 Test Setup        SetupUtils.Setup_Test_With_Logging_And_Without_Fast_Failing
8 Test Teardown     Get Test Teardown Debugs
9 Library           OperatingSystem
10 Library           RequestsLibrary
11 Resource          ../../../libraries/Utils.robot
12 Resource          ../../../libraries/OpenStackOperations.robot
13 Resource          ../../../libraries/DevstackUtils.robot
14 Resource          ../../../libraries/VpnOperations.robot
15 Resource          ../../../libraries/OVSDB.robot
16 Resource          ../../../libraries/SetupUtils.robot
17 Resource          ../../../libraries/Tcpdump.robot
18 Resource          ../../../variables/Variables.robot
19 Resource          ../../../variables/netvirt/Variables.robot
20
21 *** Variables ***
22 @{NETWORKS}       NET1_IPV6    NET2_IPV6
23 @{SUBNETS}        SUBNET1_IPV6    SUBNET2_IPV6
24 @{SUBNETS_CIDR}    2001:db8:0:2::/64    2001:db8:0:3::/64
25 @{PORT_LIST}      PORT11_IPV6    PORT21_IPV6    PORT12_IPV6    PORT22_IPV6
26 @{VM_INSTANCES_NET10}    VM11_IPV6    VM21_IPV6
27 @{VM_INSTANCES_NET20}    VM12_IPV6    VM22_IPV6
28 @{ROUTERS}        ROUTER_1_IPV6
29 @{EXTRA_NW_IP}    2001:db9:cafe:d::10    2001:db9:abcd:d::20
30 @{EXTRA_NW_SUBNET}    2001:db9:cafe:d::/64    2001:db9:abcd:d::/64
31 ${NET1_ADDR_POOL}    --allocation-pool start=2001:db8:0:2::2,end=2001:db8:0:2:ffff:ffff:ffff:fffe
32 ${NET2_ADDR_POOL}    --allocation-pool start=2001:db8:0:3::2,end=2001:db8:0:3:ffff:ffff:ffff:fffe
33 ${SECURITY_GROUP}    sg-ipv6-vpnservice
34 ${UPDATE_NETWORK}    UpdateNetwork
35 ${UPDATE_SUBNET}    UpdateSubnet
36 ${UPDATE_PORT}    UpdatePort
37
38 *** Test Cases ***
39 Create Neutron Networks
40     [Documentation]    Create two networks
41     Create Network    ${NETWORKS[0]}
42     Create Network    ${NETWORKS[1]}
43     ${NET_LIST}    List Networks
44     Log    ${NET_LIST}
45     Should Contain    ${NET_LIST}    ${NETWORKS[0]}
46     Should Contain    ${NET_LIST}    ${NETWORKS[1]}
47     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${NETWORK_URL}    ${NETWORKS}
48     Update Network    ${NETWORKS[0]}    additional_args=--description ${UPDATE_NETWORK}
49     ${output} =    Show Network    ${NETWORKS[0]}
50     Should Contain    ${output}    ${UPDATE_NETWORK}
51
52 Create Neutron Subnets
53     [Documentation]    Create two subnets for previously created networks
54     ${net1_additional_args}=    Catenate    --ip-version=6 --ipv6-address-mode=slaac --ipv6-ra-mode=slaac ${NET1_ADDR_POOL}
55     ${net2_additional_args}=    Catenate    --ip-version=6 --ipv6-address-mode=slaac --ipv6-ra-mode=slaac ${NET2_ADDR_POOL}
56     Create SubNet    ${NETWORKS[0]}    ${SUBNETS[0]}    ${SUBNETS_CIDR[0]}    ${net1_additional_args}
57     Create SubNet    ${NETWORKS[1]}    ${SUBNETS[1]}    ${SUBNETS_CIDR[1]}    ${net2_additional_args}
58     ${SUB_LIST}    List Subnets
59     Log    ${SUB_LIST}
60     Should Contain    ${SUB_LIST}    ${SUBNETS[0]}
61     Should Contain    ${SUB_LIST}    ${SUBNETS[1]}
62     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${SUBNETWORK_URL}    ${SUBNETS}
63     Update SubNet    ${SUBNETS[0]}    additional_args=--description ${UPDATE_SUBNET}
64     ${output} =    Show SubNet    ${SUBNETS[0]}
65     Should Contain    ${output}    ${UPDATE_SUBNET}
66
67 Create Routers
68     [Documentation]    Create Router
69     Create Router    ${ROUTERS[0]}
70     ${router_output} =    List Router
71     Log    ${router_output}
72     Should Contain    ${router_output}    ${ROUTERS[0]}
73     ${router_list} =    Create List    ${ROUTERS[0]}
74     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${ROUTER_URL}    ${router_list}
75
76 Add Interfaces To Router
77     [Documentation]    Add Interfaces
78     ${devstack_conn_id} =    Get ControlNode Connection
79     : FOR    ${INTERFACE}    IN    @{SUBNETS}
80     \    Add Router Interface    ${ROUTERS[0]}    ${INTERFACE}
81     ${interface_output} =    Show Router Interface    ${ROUTERS[0]}
82     : FOR    ${INTERFACE}    IN    @{SUBNETS}
83     \    ${subnet_id} =    Get Subnet Id    ${INTERFACE}    ${devstack_conn_id}
84     \    Should Contain    ${interface_output}    ${subnet_id}
85     ${GWMAC_ADDRS}    ${GWIP_ADDRS} =    Get Gateway MAC And IP Address    ${ROUTERS[0]}
86     Log    ${GWMAC_ADDRS}
87     Set Suite Variable    ${GWMAC_ADDRS}
88     Log    ${GWIP_ADDRS}
89     Set Suite Variable    ${GWIP_ADDRS}
90
91 Add Ssh V6 Allow Rule
92     [Documentation]    Allow all TCP/UDP/ICMP6 packets for this suite
93     Neutron Security Group Create    ${SECURITY_GROUP}
94     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=ingress    ethertype=IPv6    port_range_max=65535    port_range_min=1    protocol=tcp
95     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=egress    ethertype=IPv6    port_range_max=65535    port_range_min=1    protocol=tcp
96     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=ingress    ethertype=IPv6    protocol=icmp
97     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=egress    ethertype=IPv6    protocol=icmp
98     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=ingress    ethertype=IPv6    port_range_max=65535    port_range_min=1    protocol=udp
99     Neutron Security Group Rule Create    ${SECURITY_GROUP}    direction=egress    ethertype=IPv6    port_range_max=65535    port_range_min=1    protocol=udp
100
101 Create Neutron Ports
102     [Documentation]    Create four ports under previously created subnets
103     ${allowed_address_pairs_args}=    Set Variable    --allowed-address-pairs type=dict list=true ip_address=${EXTRA_NW_SUBNET[0]} ip_address=${EXTRA_NW_SUBNET[1]}
104     Create Port    ${NETWORKS[0]}    ${PORT_LIST[0]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
105     Create Port    ${NETWORKS[0]}    ${PORT_LIST[1]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
106     Create Port    ${NETWORKS[1]}    ${PORT_LIST[2]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
107     Create Port    ${NETWORKS[1]}    ${PORT_LIST[3]}    sg=${SECURITY_GROUP}    additional_args=${allowed_address_pairs_args}
108     Wait Until Keyword Succeeds    3s    1s    Check For Elements At URI    ${PORT_URL}    ${PORT_LIST}
109     Update Port    ${PORT_LIST[0]}    additional_args=--name ${UPDATE_PORT}
110     ${output} =    Show Port    ${UPDATE_PORT}
111     Should Contain    ${output}    ${UPDATE_PORT}
112     Update Port    ${UPDATE_PORT}    additional_args=--name ${PORT_LIST[0]}
113
114 Create Nova VMs
115     [Documentation]    Create Vm instances on compute node with port
116     Create Vm Instance With Port On Compute Node    ${PORT_LIST[0]}    ${VM_INSTANCES_NET10[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
117     Create Vm Instance With Port On Compute Node    ${PORT_LIST[1]}    ${VM_INSTANCES_NET10[1]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
118     Create Vm Instance With Port On Compute Node    ${PORT_LIST[2]}    ${VM_INSTANCES_NET20[0]}    ${OS_COMPUTE_1_IP}    sg=${SECURITY_GROUP}
119     Create Vm Instance With Port On Compute Node    ${PORT_LIST[3]}    ${VM_INSTANCES_NET20[1]}    ${OS_COMPUTE_2_IP}    sg=${SECURITY_GROUP}
120     ${VM_INSTANCES}=    Create List    @{VM_INSTANCES_NET10}    @{VM_INSTANCES_NET20}
121     : FOR    ${VM}    IN    @{VM_INSTANCES}
122     \    Wait Until Keyword Succeeds    25s    5s    Verify VM Is ACTIVE    ${VM}
123     Log    Check for routes
124     Wait Until Keyword Succeeds    30s    10s    Wait For Routes To Propogate    ${NETWORKS}    ${SUBNETS_CIDR}
125     ${prefix_net10}=    Replace String    ${SUBNETS_CIDR[0]}    ::/64    (:[a-f0-9]{,4}){,4}
126     Log    ${prefix_net10}
127     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    5x    60s    Collect VM IPv6 SLAAC Addresses
128     ...    true    ${prefix_net10}    @{VM_INSTANCES_NET10}
129     ${prefix_net20}=    Replace String    ${SUBNETS_CIDR[1]}    ::/64    (:[a-f0-9]{,4}){,4}
130     Log    ${prefix_net20}
131     ${status}    ${message}    Run Keyword And Ignore Error    Wait Until Keyword Succeeds    5x    60s    Collect VM IPv6 SLAAC Addresses
132     ...    true    ${prefix_net20}    @{VM_INSTANCES_NET20}
133     ${VM_IP_NET10}=    Collect VM IPv6 SLAAC Addresses    false    ${prefix_net10}    @{VM_INSTANCES_NET10}
134     ${VM_IP_NET20}=    Collect VM IPv6 SLAAC Addresses    false    ${prefix_net20}    @{VM_INSTANCES_NET20}
135     Log    ${VM_IP_NET10}
136     Log    ${VM_IP_NET20}
137     ${VM_INSTANCES}=    Collections.Combine Lists    ${VM_INSTANCES_NET10}    ${VM_INSTANCES_NET20}
138     ${VM_IPS}=    Collections.Combine Lists    ${VM_IP_NET10}    ${VM_IP_NET20}
139     Log Many    Obtained IPs    ${VM_IPS}
140     ${LOOP_COUNT}    Get Length    ${VM_INSTANCES_NET10}
141     : FOR    ${index}    IN RANGE    0    ${LOOP_COUNT}
142     \    ${status}    ${message}    Run Keyword And Ignore Error    Should Not Contain    @{VM_IPS}[${index}]    None
143     \    Run Keyword If    '${status}' == 'FAIL'    Write Commands Until Prompt    nova console-log @{VM_INSTANCES}[${index}]    30s
144     Log    ${VM_IP_NET10}
145     Set Suite Variable    ${VM_IP_NET10}
146     Log    ${VM_IP_NET20}
147     Set Suite Variable    ${VM_IP_NET20}
148     Should Not Contain    ${VM_IP_NET10}    None
149     Should Not Contain    ${VM_IP_NET20}    None
150     [Teardown]    Run Keywords    Show Debugs    @{VM_INSTANCES_NET10}    @{VM_INSTANCES_NET20}
151     ...    AND    Get Suite Teardown Debugs
152
153 Check ELAN Datapath Traffic Within The Networks
154     [Documentation]    Checks datapath within the same network with different vlans.
155     ${output}=    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ping6 -c 3 ${VM_IP_NET10[1]}
156     Should Contain    ${output}    64 bytes
157     ${output}=    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET20[0]}    ping6 -c 3 ${VM_IP_NET20[1]}
158     Should Contain    ${output}    64 bytes
159
160 Check L3_Datapath Traffic Across Networks With Router
161     [Documentation]    Datapath test across the networks using router for L3.
162     Log    Verification of FIB Entries and Flow
163     ${cn1_conn_id} =    Start Packet Capture on Node    ${OS_COMPUTE_1_IP}    file_Name=tcpDumpCN1
164     ${cn2_conn_id} =    Start Packet Capture on Node    ${OS_COMPUTE_2_IP}    file_Name=tcpDumpCN2
165     ${os_conn_id} =    Start Packet Capture on Node    ${OS_CONTROL_NODE_IP}    file_Name=tcpDumpOS
166     ${vm_instances} =    Create List    @{VM_IP_NET10}    @{VM_IP_NET20}
167     Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${FIB_ENTRY_URL}    ${vm_instances}
168     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_1_IP}    ${VM_IP_NET10}
169     Wait Until Keyword Succeeds    30s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_1_IP}    ${VM_IP_NET20}
170     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Entry On ODL    ${GWMAC_ADDRS}
171     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_1_IP}
172     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_2_IP}
173     Log    L3 Datapath test across the networks using router
174     ${dst_ip_list} =    Create List    ${VM_IP_NET10[1]}    @{VM_IP_NET20}
175     Log Many    Destination IPs list    ${dst_ip_list}
176     Log Many    Source IP    ${VM_IP_NET10[1]}
177     Test Operations From Vm Instance    ${NETWORKS[0]}    ${VM_IP_NET10[0]}    ${dst_ip_list}
178     ${dst_ip_list} =    Create List    ${VM_IP_NET20[1]}    @{VM_IP_NET10}
179     Log Many    Destination IPs list    ${dst_ip_list}
180     Log Many    Source IP    ${VM_IP_NET20[0]}
181     Test Operations From Vm Instance    ${NETWORKS[1]}    ${VM_IP_NET20[0]}    ${dst_ip_list}
182     [Teardown]    Test Teardown With Tcpdump Stop    ${cn1_conn_id}    ${cn2_conn_id}    ${os_conn_id}
183
184 Add Multiple Extra Routes And Check Datapath Before L3VPN Creation
185     [Documentation]    Add multiple extra routes and check data path before L3VPN creation
186     Log    "Adding extra one route to VM"
187     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ip -6 addr add ${EXTRA_NW_IP[0]}/64 dev eth0
188     Log    ${CONFIG_EXTRA_ROUTE_IP1}
189     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP1}
190     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ip -6 a
191     ${CONFIG_EXTRA_ROUTE_IP2} =    Catenate    sudo ip -6 addr add ${EXTRA_NW_IP[1]}/64 dev eth0
192     Log    ${CONFIG_EXTRA_ROUTE_IP2}
193     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP2}
194     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ip -6 a
195     ${EXT_RT1} =    Set Variable    destination=${EXTRA_NW_SUBNET[0]},gateway=${VM_IP_NET10[0]}
196     ${EXT_RT2} =    Set Variable    destination=${EXTRA_NW_SUBNET[1]},gateway=${VM_IP_NET10[0]}
197     ${cmd} =    Catenate    ${RT_OPTIONS}    ${EXT_RT1}    ${RT_OPTIONS}    ${EXT_RT2}
198     Update Router    @{ROUTERS}[0]    ${cmd}
199     Show Router    @{ROUTERS}[0]    -D
200     Log    "Verify FIB table"
201     ${vm_instances} =    Create List    @{EXTRA_NW_SUBNET}
202     Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${FIB_ENTRY_URL}    ${vm_instances}
203     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping6 -c 3 @{EXTRA_NW_IP}[1]
204     Should Contain    ${output}    64 bytes
205     ${output} =    Execute Command on VM Instance    @{NETWORKS}[1]    ${VM_IP_NET20[1]}    ping6 -c 3 @{EXTRA_NW_IP}[1]
206     Should Contain    ${output}    64 bytes
207     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping6 -c 3 @{EXTRA_NW_IP}[0]
208     Should Contain    ${output}    64 bytes
209
210 Delete Extra Route
211     [Documentation]    Delete the extra routes
212     Update Router    @{ROUTERS}[0]    ${RT_CLEAR}
213     Show Router    @{ROUTERS}[0]    -D
214
215 Delete And Recreate Extra Route
216     [Documentation]    Recreate multiple extra route and check data path before L3VPN creation
217     Log    "Adding extra route to VM"
218     ${CONFIG_EXTRA_ROUTE_IP1} =    Catenate    sudo ip -6 addr add ${EXTRA_NW_IP[1]}/64 dev eth0
219     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[0]}    ${CONFIG_EXTRA_ROUTE_IP1}
220     ${EXT_RT1} =    Set Variable    destination=${EXTRA_NW_SUBNET[0]},gateway=${VM_IP_NET10[0]}
221     ${cmd} =    Catenate    ${RT_OPTIONS}    ${EXT_RT1}
222     Update Router    @{ROUTERS}[0]    ${cmd}
223     Show Router    @{ROUTERS}[0]    -D
224     ${output} =    Execute Command on VM Instance    @{NETWORKS}[0]    ${VM_IP_NET10[1]}    ping6 -c 3 @{EXTRA_NW_IP}[0]
225     Should Contain    ${output}    64 bytes
226     # clear off extra-routes before the next set of tests
227     [Teardown]    Run Keywords    Update Router    @{ROUTERS}[0]    ${RT_CLEAR}
228     ...    AND    Show Router    @{ROUTERS}[0]    -D
229     ...    AND    Get Test Teardown Debugs
230
231 Create L3VPN
232     [Documentation]    Creates L3VPN and verify the same
233     ${devstack_conn_id} =    Get ControlNode Connection
234     Switch Connection    ${devstack_conn_id}
235     ${net_id} =    Get Net Id    @{NETWORKS}[0]    ${devstack_conn_id}
236     ${tenant_id} =    Get Tenant ID From Network    ${net_id}
237     VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID[0]}    name=${VPN_NAME[0]}    rd=@{RDS}[0]    exportrt=@{RDS}[0]    importrt=@{RDS}[0]    tenantid=${tenant_id}
238     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
239     Should Contain    ${resp}    ${VPN_INSTANCE_ID[0]}
240
241 Associate L3VPN To Routers
242     [Documentation]    Associating router to L3VPN
243     ${devstack_conn_id}=    Get ControlNode Connection
244     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
245     Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
246     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
247     Should Contain    ${resp}    ${router_id}
248
249 Verify L3VPN Datapath With Router Association
250     [Documentation]    Datapath test across the networks using L3VPN with router association.
251     Log    Verify VPN interfaces, FIB entries and Flow table
252     ${vm_instances} =    Create List    @{VM_IP_NET10}    @{VM_IP_NET20}
253     Wait Until Keyword Succeeds    30s    5s    Check For Elements At URI    ${VPN_IFACES_URL}    ${vm_instances}
254     ${RD} =    Strip String    ${RDS[0]}    characters="[]
255     Log    ${RD}
256     Wait Until Keyword Succeeds    60s    5s    Check For Elements At URI    ${CONFIG_API}/odl-fib:fibEntries/vrfTables/${RD}/    ${vm_instances}
257     Wait Until Keyword Succeeds    60s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_1_IP}    ${vm_instances}
258     Wait Until Keyword Succeeds    60s    5s    Verify Flows Are Present For L3VPN    ${OS_COMPUTE_2_IP}    ${vm_instances}
259     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Entry On ODL    ${GWMAC_ADDRS}
260     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_1_IP}
261     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry On Flow Table    ${OS_COMPUTE_2_IP}
262     Log    Check datapath from network1 to network2
263     ${dst_ip_list} =    Create List    @{VM_IP_NET10}[1]    @{VM_IP_NET20}
264     Log    ${dst_ip_list}
265     Test Operations From Vm Instance    ${NETWORKS[0]}    @{VM_IP_NET10}[0]    ${dst_ip_list}
266     Log    Check datapath from network2 to network1
267     ${dst_ip_list} =    Create List    @{VM_IP_NET20}[1]    @{VM_IP_NET10}
268     Log    ${dst_ip_list}
269     Test Operations From Vm Instance    ${NETWORKS[1]}    @{VM_IP_NET20}[0]    ${dst_ip_list}
270
271 Dissociate L3VPN From Routers
272     [Documentation]    Dissociating router from L3VPN
273     ${devstack_conn_id}=    Get ControlNode Connection
274     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
275     Dissociate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
276     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
277     Should Not Contain    ${resp}    ${router_id}
278
279 Delete Router And Router Interfaces With L3VPN
280     [Documentation]    Delete Router and Interface to the subnets with L3VPN associate
281     # Asscoiate router with L3VPN
282     ${devstack_conn_id} =    Get ControlNode Connection
283     ${router_id}=    Get Router Id    ${ROUTERS[0]}    ${devstack_conn_id}
284     Associate VPN to Router    routerid=${router_id}    vpnid=${VPN_INSTANCE_ID[0]}
285     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
286     Should Contain    ${resp}    ${router_id}
287     #Delete Interface
288     : FOR    ${INTERFACE}    IN    @{SUBNETS}
289     \    Remove Interface    ${ROUTERS[0]}    ${INTERFACE}
290     ${interface_output} =    Show Router Interface    ${ROUTERS[0]}
291     : FOR    ${INTERFACE}    IN    @{SUBNETS}
292     \    ${subnet_id} =    Get Subnet Id    ${INTERFACE}    ${devstack_conn_id}
293     \    Should Not Contain    ${interface_output}    ${subnet_id}
294     # Delete Router and Interface to the subnets.
295     Delete Router    ${ROUTERS[0]}
296     ${router_output} =    List Router
297     Log    ${router_output}
298     Should Not Contain    ${router_output}    ${ROUTERS[0]}
299     ${router_list} =    Create List    ${ROUTERS[0]}
300     Wait Until Keyword Succeeds    3s    1s    Check For Elements Not At URI    ${ROUTER_URL}    ${router_list}
301     # Verify Router Entry removed from L3VPN
302     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
303     Should Not Contain    ${resp}    ${router_id}
304     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry Removed From Flow Table    ${OS_COMPUTE_1_IP}
305     Wait Until Keyword Succeeds    30s    5s    Verify GWMAC Flow Entry Removed From Flow Table    ${OS_COMPUTE_2_IP}
306
307 Delete Router With NonExistentRouter Name
308     [Documentation]    Delete router with nonExistentRouter name
309     ${devstack_conn_id}=    Get ControlNode Connection
310     Switch Connection    ${devstack_conn_id}
311     ${output} =    Write Commands Until Prompt    neutron router-delete nonExistentRouter    30s
312     Close Connection
313     Should Match Regexp    ${output}    Unable to find router with name or id 'nonExistentRouter'|Unable to find router\\(s\\) with id\\(s\\) 'nonExistentRouter'
314
315 Associate L3VPN To Networks
316     [Documentation]    Associates L3VPN to networks and verify
317     ${devstack_conn_id} =    Get ControlNode Connection
318     ${network1_id} =    Get Net Id    ${NETWORKS[0]}    ${devstack_conn_id}
319     ${network2_id} =    Get Net Id    ${NETWORKS[1]}    ${devstack_conn_id}
320     Associate L3VPN To Network    networkid=${network1_id}    vpnid=${VPN_INSTANCE_ID[0]}
321     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
322     Should Contain    ${resp}    ${network1_id}
323     Associate L3VPN To Network    networkid=${network2_id}    vpnid=${VPN_INSTANCE_ID[0]}
324     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
325     Should Contain    ${resp}    ${network2_id}
326
327 Dissociate L3VPN From Networks
328     [Documentation]    Dissociate L3VPN from networks
329     ${devstack_conn_id} =    Get ControlNode Connection
330     ${network1_id} =    Get Net Id    ${NETWORKS[0]}    ${devstack_conn_id}
331     ${network2_id} =    Get Net Id    ${NETWORKS[1]}    ${devstack_conn_id}
332     Dissociate L3VPN From Networks    networkid=${network1_id}    vpnid=${VPN_INSTANCE_ID[0]}
333     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
334     Should Not Contain    ${resp}    ${network1_id}
335     Dissociate L3VPN From Networks    networkid=${network2_id}    vpnid=${VPN_INSTANCE_ID[0]}
336     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
337     Should Not Contain    ${resp}    ${network2_id}
338
339 Delete L3VPN
340     [Documentation]    Delete L3VPN
341     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
342
343 Create Multiple L3VPN
344     [Documentation]    Creates three L3VPNs and then verify the same
345     ${devstack_conn_id} =    Get ControlNode Connection
346     Switch Connection    ${devstack_conn_id}
347     ${net_id} =    Get Net Id    @{NETWORKS}[0]    ${devstack_conn_id}
348     ${tenant_id} =    Get Tenant ID From Network    ${net_id}
349     VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID[0]}    name=${VPN_NAME[0]}    rd=${RDS[0]}    exportrt=${RDS[0]}    importrt=${RDS[0]}    tenantid=${tenant_id}
350     VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID[1]}    name=${VPN_NAME[1]}    rd=${RDS[1]}    exportrt=${RDS[1]}    importrt=${RDS[1]}    tenantid=${tenant_id}
351     VPN Create L3VPN    vpnid=${VPN_INSTANCE_ID[2]}    name=${VPN_NAME[2]}    rd=${RDS[2]}    exportrt=${RDS[2]}    importrt=${RDS[2]}    tenantid=${tenant_id}
352     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
353     Should Contain    ${resp}    ${VPN_INSTANCE_ID[0]}
354     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[1]}
355     Should Contain    ${resp}    ${VPN_INSTANCE_ID[1]}
356     ${resp}=    VPN Get L3VPN    vpnid=${VPN_INSTANCE_ID[2]}
357     Should Contain    ${resp}    ${VPN_INSTANCE_ID[2]}
358
359 Delete Multiple L3VPN
360     [Documentation]    Delete three L3VPNs created using Multiple L3VPN Test
361     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[0]}
362     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[1]}
363     VPN Delete L3VPN    vpnid=${VPN_INSTANCE_ID[2]}
364
365 *** Keywords ***
366 Test Teardown With Tcpdump Stop
367     [Arguments]    ${cn1_conn_id}    ${cn2_conn_id}    ${os_conn_id}
368     Stop Packet Capture on Node    ${cn1_conn_id}
369     Stop Packet Capture on Node    ${cn2_conn_id}
370     Stop Packet Capture on Node    ${os_conn_id}
371     Get Test Teardown Debugs
372
373 Get Gateway MAC And IP Address
374     [Arguments]    ${router_Name}
375     [Documentation]    Get Gateway mac and IP Address
376     ${devstack_conn_id}=    Get ControlNode Connection
377     Switch Connection    ${devstack_conn_id}
378     ${output} =    Write Commands Until Prompt    neutron router-port-list ${router_Name}    30s
379     @{MacAddr-list} =    Get Regexp Matches    ${output}    ${MAC_REGEX}
380     @{IpAddr-list} =    Get Regexp Matches    ${output}    ${IP6_REGEX}
381     [Return]    ${MacAddr-list}    ${IpAddr-list}
382
383 Verify GWMAC Flow Entry On Flow Table
384     [Arguments]    ${cnIp}
385     [Documentation]    Verify the GWMAC Table, ARP Response table and Dispatcher table.
386     ${flow_output}=    Run Command On Remote System    ${cnIp}    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
387     Log    ${flow_output}
388     ${group_output}=    Run Command On Remote System    ${cnIp}    sudo ovs-ofctl -O OpenFlow13 dump-groups br-int
389     Log    ${group_output}
390     Should Contain    ${flow_output}    table=${DISPATCHER_TABLE}
391     ${dispatcher_table} =    Get Lines Containing String    ${flow_output}    table=${DISPATCHER_TABLE}
392     Log    ${dispatcher_table}
393     Should Contain    ${dispatcher_table}    goto_table:${GWMAC_TABLE}
394     Should Not Contain    ${dispatcher_table}    goto_table:${ARP_RESPONSE_TABLE}
395     Should Contain    ${flow_output}    table=${GWMAC_TABLE}
396     ${gwmac_table} =    Get Lines Containing String    ${flow_output}    table=${GWMAC_TABLE}
397     Log    ${gwmac_table}
398     #Verify GWMAC address present in table 19
399     : FOR    ${macAdd}    IN    @{GWMAC_ADDRS}
400     \    Should Contain    ${gwmac_table}    dl_dst=${macAdd} actions=goto_table:${L3_TABLE}
401     #verify Miss entry
402     Should Contain    ${gwmac_table}    actions=resubmit(,17)
403     #arp request and response
404     Should Match Regexp    ${gwmac_table}    ${ARP_RESPONSE_REGEX}
405     ${match} =    Should Match Regexp    ${gwmac_table}    ${ARP_REQUEST_REGEX}
406     ${groupID} =    Split String    ${match}    separator=:
407     Log    groupID
408     Should Contain    ${flow_output}    table=${IPV6_TABLE}
409     ${icmp_ipv6_flows} =    Get Lines Containing String    ${flow_output}    icmp_type=135
410     Log    ${icmp_ipv6_flows}
411     : FOR    ${ip_addr}    IN    @{GWIP_ADDRS}
412     \    ${rule} =    Set Variable    icmp_type=135,icmp_code=0,nd_target=${ip_addr} actions=CONTROLLER:65535
413     \    Should Match Regexp    ${icmp_ipv6_flows}    ${rule}