OpenStackOperations.robot: format output
[integration/test.git] / csit / libraries / OpenStackOperations.robot
1 *** Settings ***
2 Documentation     Openstack library. This library is useful for tests to create network, subnet, router and vm instances
3 Library           Collections
4 Library           SSHLibrary
5 Resource          DataModels.robot
6 Resource          Utils.robot
7 Resource          L2GatewayOperations.robot
8 Resource          ../variables/Variables.robot
9 Variables         ../variables/netvirt/Modules.py
10
11 *** Keywords ***
12 Source Password
13     [Arguments]    ${force}=no    ${source_pwd}=yes
14     [Documentation]    Sourcing the Openstack PAsswords for neutron configurations
15     Run Keyword If    '${source_pwd}' == 'yes' or '${force}' == 'yes'    Write Commands Until Prompt    cd ${DEVSTACK_DEPLOY_PATH}; source openrc admin admin
16
17 Get Tenant ID From Security Group
18     [Documentation]    Returns tenant ID by reading it from existing default security-group.
19     ${devstack_conn_id}=    Get ControlNode Connection
20     Switch Connection    ${devstack_conn_id}
21     ${output}=    Write Commands Until Prompt    openstack security group show default | grep "| tenant_id" | awk '{print $4}'
22     Log    ${output}
23     [Return]    ${output}
24
25 Get Tenant ID From Network
26     [Arguments]    ${network_uuid}
27     [Documentation]    Returns tenant ID by reading it from existing network.
28     ${resp}=    Get_From_Uri    uri=${CONFIG_API}/neutron:neutron/networks/network/${network_uuid}/    accept=${ACCEPT_EMPTY}    session=session
29     ${tenant_id}=    Utils.Extract Value From Content    ${resp}    /network/0/tenant-id    strip
30     [Return]    ${tenant_id}
31
32 Create Network
33     [Arguments]    ${network_name}    ${additional_args}=${EMPTY}    ${verbose}=TRUE
34     [Documentation]    Create Network with neutron request.
35     ${devstack_conn_id}=    Get ControlNode Connection
36     Switch Connection    ${devstack_conn_id}
37     ${output}=    Write Commands Until Prompt    openstack network create ${network_name} ${additional_args}    30s
38     Log    ${output}
39     Should Contain    ${output}    ${OS_CMD_SUCCESS}
40     [Return]    ${output}
41
42 Update Network
43     [Arguments]    ${network_name}    ${additional_args}=${EMPTY}
44     [Documentation]    Update Network with neutron request.
45     ${devstack_conn_id}=    Get ControlNode Connection
46     Switch Connection    ${devstack_conn_id}
47     ${cmd}=    Set Variable If    '${OPENSTACK_BRANCH}'=='stable/newton'    neutron -v net-update ${network_name} ${additional_args}    openstack network set ${network_name} ${additional_args}
48     ${output}=    Write Commands Until Prompt    ${cmd}    30s
49     Log    ${output}
50     Close Connection
51     [Return]    ${output}
52
53 Show Network
54     [Arguments]    ${network_name}
55     [Documentation]    Show Network with neutron request.
56     ${devstack_conn_id}=    Get ControlNode Connection
57     Switch Connection    ${devstack_conn_id}
58     ${output}=    Write Commands Until Prompt    openstack network show ${network_name}    30s
59     Log    ${output}
60     Close Connection
61     [Return]    ${output}
62
63 List Networks
64     [Documentation]    List networks and return output with neutron client.
65     ${devstack_conn_id}=    Get ControlNode Connection
66     Switch Connection    ${devstack_conn_id}
67     ${output}=    Write Commands Until Prompt    openstack network list    30s
68     Close Connection
69     Log    ${output}
70     [Return]    ${output}
71
72 List Subnets
73     [Documentation]    List subnets and return output with neutron client.
74     ${devstack_conn_id}=    Get ControlNode Connection
75     Switch Connection    ${devstack_conn_id}
76     ${output}=    Write Commands Until Prompt    openstack subnet list    30s
77     Close Connection
78     Log    ${output}
79     [Return]    ${output}
80
81 Delete Network
82     [Arguments]    ${network_name}
83     [Documentation]    Delete Network with neutron request.
84     ${devstack_conn_id}=    Get ControlNode Connection
85     Switch Connection    ${devstack_conn_id}
86     ${output}=    Write Commands Until Prompt    openstack network delete ${network_name}    30s
87     Close Connection
88     Log    ${output}
89     Should Contain    ${output}    ${OS_CMD_SUCCESS}
90
91 Create SubNet
92     [Arguments]    ${network_name}    ${subnet}    ${range_ip}    ${additional_args}=${EMPTY}
93     [Documentation]    Create SubNet for the Network with neutron request.
94     ${devstack_conn_id}=    Get ControlNode Connection
95     Switch Connection    ${devstack_conn_id}
96     ${output}=    Write Commands Until Prompt    openstack subnet create --network ${network_name} --subnet-range ${range_ip} ${subnet} ${additional_args}    30s
97     Close Connection
98     Log    ${output}
99     Should Contain    ${output}    ${OS_CMD_SUCCESS}
100
101 Update SubNet
102     [Arguments]    ${subnet_name}    ${additional_args}=${EMPTY}
103     [Documentation]    Update subnet with neutron request.
104     ${devstack_conn_id}=    Get ControlNode Connection
105     Switch Connection    ${devstack_conn_id}
106     ${cmd}=    Set Variable If    '${OPENSTACK_BRANCH}'=='stable/newton'    neutron -v subnet-update ${subnet_name} ${additional_args}    openstack subnet set ${subnet_name} ${additional_args}
107     ${output}=    Write Commands Until Prompt    ${cmd}    30s
108     Log    ${output}
109     Close Connection
110     [Return]    ${output}
111
112 Show SubNet
113     [Arguments]    ${subnet_name}
114     [Documentation]    Show subnet with neutron request.
115     ${devstack_conn_id}=    Get ControlNode Connection
116     Switch Connection    ${devstack_conn_id}
117     ${output}=    Write Commands Until Prompt    openstack subnet show ${subnet_name}    30s
118     Log    ${output}
119     Close Connection
120     [Return]    ${output}
121
122 Create Port
123     [Arguments]    ${network_name}    ${port_name}    ${sg}=default    ${additional_args}=${EMPTY}    ${allowed_address_pairs}=${EMPTY}
124     [Documentation]    Create Port with neutron request.
125     ${devstack_conn_id}=    Get ControlNode Connection
126     Switch Connection    ${devstack_conn_id}
127     # if allowed_address_pairs is not empty we need to create the arguments to pass to the port create command. They are
128     # in a different format with the neutron vs openstack cli.
129     ${address_pair_length}=    Get Length    ${allowed_address_pairs}
130     ${allowed_pairs_argv}=    Set Variable If    '${OPENSTACK_BRANCH}'=='stable/newton' and '${address_pair_length}'=='2'    --allowed-address-pairs type=dict list=true ip_address=@{allowed_address_pairs}[0] ip_address=@{allowed_address_pairs}[1]
131     ${allowed_pairs_argv}=    Set Variable If    '${OPENSTACK_BRANCH}'!='stable/newton' and '${address_pair_length}'=='2'    --allowed-address ip-address=@{allowed_address_pairs}[0] --allowed-address ip-address=@{allowed_address_pairs}[1]    ${allowed_pairs_argv}
132     ${allowed_pairs_argv}=    Set Variable If    '${address_pair_length}'=='0'    ${EMPTY}    ${allowed_pairs_argv}
133     ${cmd}=    Set Variable If    '${OPENSTACK_BRANCH}'=='stable/newton'    neutron -v port-create ${network_name} --name ${port_name} --security-group ${sg} ${additional_args} ${allowed_pairs_argv}    openstack port create --network ${network_name} ${port_name} --security-group ${sg} ${additional_args} ${allowed_pairs_argv}
134     ${output}=    Write Commands Until Prompt    ${cmd}    30s
135     Close Connection
136     Log    ${output}
137     Should Contain    ${output}    ${OS_CMD_SUCCESS}
138
139 Update Port
140     [Arguments]    ${port_name}    ${additional_args}=${EMPTY}
141     [Documentation]    Update port with neutron request.
142     ${devstack_conn_id}=    Get ControlNode Connection
143     Switch Connection    ${devstack_conn_id}
144     ${output}=    Write Commands Until Prompt    openstack port set ${port_name} ${additional_args}    30s
145     Log    ${output}
146     Close Connection
147     [Return]    ${output}
148
149 Show Port
150     [Arguments]    ${port_name}
151     [Documentation]    Show port with neutron request.
152     ${devstack_conn_id}=    Get ControlNode Connection
153     Switch Connection    ${devstack_conn_id}
154     ${output}=    Write Commands Until Prompt    openstack port show ${port_name}    30s
155     Log    ${output}
156     Close Connection
157     [Return]    ${output}
158
159 Delete Port
160     [Arguments]    ${port_name}
161     [Documentation]    Delete Port with neutron request.
162     ${devstack_conn_id}=    Get ControlNode Connection
163     Switch Connection    ${devstack_conn_id}
164     ${output}=    Write Commands Until Prompt    openstack port delete ${port_name}    30s
165     Close Connection
166     Log    ${output}
167     Should Contain    ${output}    ${OS_CMD_SUCCESS}
168
169 List Ports
170     [Documentation]    List ports and return output with neutron client.
171     ${devstack_conn_id}=    Get ControlNode Connection
172     Switch Connection    ${devstack_conn_id}
173     ${output}=    Write Commands Until Prompt    openstack port list    30s
174     Close Connection
175     Log    ${output}
176     [Return]    ${output}
177
178 List Nova VMs
179     [Documentation]    List VMs and return output with nova client.
180     ${devstack_conn_id}=    Get ControlNode Connection
181     Switch Connection    ${devstack_conn_id}
182     #TODO Change to Openstak CLI once the problem with Ocata is solved
183     ${output}=    Write Commands Until Prompt    nova list    30s
184     Close Connection
185     Log    ${output}
186     [Return]    ${output}
187
188 Create And Associate Floating IPs
189     [Arguments]    ${external_net}    @{vm_list}
190     [Documentation]    Create and associate floating IPs to VMs with nova request
191     ${devstack_conn_id}=    Get ControlNode Connection
192     Switch Connection    ${devstack_conn_id}
193     ${ip_list}=    Create List    @{EMPTY}
194     : FOR    ${vm}    IN    @{vm_list}
195     \    ${output}=    Write Commands Until Prompt    openstack floating ip create ${external_net}    30s
196     \    Log    ${output}
197     \    @{ip}    Get Regexp Matches    ${output}    [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
198     \    ${ip_length}    Get Length    ${ip}
199     \    Run Keyword If    ${ip_length}>0    Append To List    ${ip_list}    @{ip}[0]
200     \    ...    ELSE    Append To List    ${ip_list}    None
201     \    ${output}=    Write Commands Until Prompt    openstack server add floating ip ${vm} @{ip}[0]    30s
202     \    Log    ${output}
203     [Return]    ${ip_list}
204
205 Verify Gateway Ips
206     [Documentation]    Verifies the Gateway Ips with dump flow.
207     ${output}=    Write Commands Until Prompt    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
208     Log    ${output}
209     : FOR    ${GatewayIpElement}    IN    @{GATEWAY_IPS}
210     \    Should Contain    ${output}    ${GatewayIpElement}
211
212 Verify Dhcp Ips
213     [Documentation]    Verifies the Dhcp Ips with dump flow.
214     ${output}=    Write Commands Until Prompt    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
215     Log    ${output}
216     : FOR    ${DhcpIpElement}    IN    @{DHCP_IPS}
217     \    Should Contain    ${output}    ${DhcpIpElement}
218
219 Verify No Dhcp Ips
220     [Documentation]    Verifies the Dhcp Ips with dump flow.
221     ${output}=    Write Commands Until Prompt    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
222     Log    ${output}
223     : FOR    ${DhcpIpElement}    IN    @{DHCP_IPS}
224     \    Should Not Contain    ${output}    ${DhcpIpElement}
225
226 Delete SubNet
227     [Arguments]    ${subnet}
228     [Documentation]    Delete SubNet for the Network with neutron request.
229     Log    ${subnet}
230     ${devstack_conn_id}=    Get ControlNode Connection
231     Switch Connection    ${devstack_conn_id}
232     ${output}=    Write Commands Until Prompt    openstack subnet delete ${subnet}
233     Close Connection
234     Log    ${output}
235     Should Contain    ${output}    ${OS_CMD_SUCCESS}
236
237 Verify No Gateway Ips
238     [Documentation]    Verifies the Gateway Ips removed with dump flow.
239     ${output}=    Write Commands Until Prompt    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
240     Log    ${output}
241     : FOR    ${GatewayIpElement}    IN    @{GATEWAY_IPS}
242     \    Should Not Contain    ${output}    ${GatewayIpElement}
243
244 Delete Vm Instance
245     [Arguments]    ${vm_name}
246     [Documentation]    Delete Vm instances using instance names.
247     ${devstack_conn_id}=    Get ControlNode Connection
248     Switch Connection    ${devstack_conn_id}
249     ${output}=    Write Commands Until Prompt    openstack server delete ${vm_name}    40s
250     Close Connection
251
252 Get Net Id
253     [Arguments]    ${network_name}    ${devstack_conn_id}
254     [Documentation]    Retrieve the net id for the given network name to create specific vm instance
255     Switch Connection    ${devstack_conn_id}
256     ${output}=    Write Commands Until Prompt    openstack network list | grep "${network_name}" | awk '{print $2}'    30s
257     Log    ${output}
258     ${splitted_output}=    Split String    ${output}    ${EMPTY}
259     ${net_id}=    Get from List    ${splitted_output}    0
260     Log    ${net_id}
261     [Return]    ${net_id}
262
263 Get Subnet Id
264     [Arguments]    ${subnet_name}    ${devstack_conn_id}
265     [Documentation]    Retrieve the subnet id for the given subnet name
266     Switch Connection    ${devstack_conn_id}
267     ${output}=    Write Commands Until Prompt    openstack subnet show "${subnet_name}" | grep " id " | awk '{print $4}'    30s
268     Log    ${output}
269     ${splitted_output}=    Split String    ${output}    ${EMPTY}
270     ${subnet_id}=    Get from List    ${splitted_output}    0
271     Log    ${subnet_id}
272     [Return]    ${subnet_id}
273
274 Get Port Id
275     [Arguments]    ${port_name}    ${devstack_conn_id}
276     [Documentation]    Retrieve the port id for the given port name to attach specific vm instance to a particular port
277     Switch Connection    ${devstack_conn_id}
278     ${output}=    Write Commands Until Prompt    openstack port list | grep "${port_name}" | awk '{print $2}'    30s
279     Log    ${output}
280     ${splitted_output}=    Split String    ${output}    ${EMPTY}
281     ${port_id}=    Get from List    ${splitted_output}    0
282     Log    ${port_id}
283     [Return]    ${port_id}
284
285 Get Router Id
286     [Arguments]    ${router1}    ${devstack_conn_id}
287     [Documentation]    Retrieve the router id for the given router name
288     Switch Connection    ${devstack_conn_id}
289     ${output}=    Write Commands Until Prompt    openstack router list | grep "${router1}" | awk '{print $2}'    30s
290     Log    ${output}
291     ${splitted_output}=    Split String    ${output}    ${EMPTY}
292     ${router_id}=    Get from List    ${splitted_output}    0
293     Log    ${router_id}
294     [Return]    ${router_id}
295
296 Create Vm Instances
297     [Arguments]    ${net_name}    ${vm_instance_names}    ${image}=cirros-0.3.4-x86_64-uec    ${flavor}=m1.nano    ${sg}=default
298     [Documentation]    Create X Vm Instance with the net id of the Netowrk.
299     ${devstack_conn_id}=    Get ControlNode Connection
300     Switch Connection    ${devstack_conn_id}
301     ${net_id}=    Get Net Id    ${net_name}    ${devstack_conn_id}
302     : FOR    ${VmElement}    IN    @{vm_instance_names}
303     \    ${output}=    Write Commands Until Prompt    openstack server create --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} --security-group ${sg}    30s
304     \    Log    ${output}
305
306 Create Vm Instance With Port
307     [Arguments]    ${port_name}    ${vm_instance_name}    ${image}=cirros-0.3.4-x86_64-uec    ${flavor}=m1.nano    ${sg}=default
308     [Documentation]    Create One VM instance using given ${port_name} and for given ${compute_node}
309     ${devstack_conn_id}=    Get ControlNode Connection
310     Switch Connection    ${devstack_conn_id}
311     ${port_id}=    Get Port Id    ${port_name}    ${devstack_conn_id}
312     ${output}=    Write Commands Until Prompt    openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} ${vm_instance_name} --security-groups ${sg}    30s
313     Log    ${output}
314
315 Create Vm Instance With Ports
316     [Arguments]    ${port_name}    ${port2_name}    ${vm_instance_name}    ${image}=cirros-0.3.4-x86_64-uec    ${flavor}=m1.nano    ${sg}=default
317     [Documentation]    Create One VM instance using given ${port_name} and for given ${compute_node}
318     ${devstack_conn_id}=    Get ControlNode Connection
319     Switch Connection    ${devstack_conn_id}
320     ${port_id}=    Get Port Id    ${port_name}    ${devstack_conn_id}
321     ${port2_id}=    Get Port Id    ${port2_name}    ${devstack_conn_id}
322     ${output}=    Write Commands Until Prompt    openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} --nic port-id=${port2_id} ${vm_instance_name} --security-group ${sg}    30s
323     Log    ${output}
324
325 Create Vm Instance With Port On Compute Node
326     [Arguments]    ${port_name}    ${vm_instance_name}    ${compute_node}    ${image}=cirros-0.3.4-x86_64-uec    ${flavor}=m1.nano    ${sg}=default
327     [Documentation]    Create One VM instance using given ${port_name} and for given ${compute_node}
328     ${devstack_conn_id}=    Get ControlNode Connection
329     Switch Connection    ${devstack_conn_id}
330     ${port_id}=    Get Port Id    ${port_name}    ${devstack_conn_id}
331     ${hostname_compute_node}=    Run Command On Remote System    ${compute_node}    hostname
332     ${output}=    Write Commands Until Prompt    openstack server create --image ${image} --flavor ${flavor} --nic port-id=${port_id} --security-group ${sg} --availability-zone nova:${hostname_compute_node} ${vm_instance_name}    30s
333     Log    ${output}
334
335 Verify VM Is ACTIVE
336     [Arguments]    ${vm_name}
337     [Documentation]    Run these commands to check whether the created vm instance is active or not.
338     ${devstack_conn_id}=    Get ControlNode Connection
339     Switch Connection    ${devstack_conn_id}
340     #TODO Change to Openstack CLI Command once the Ocata Issue is resolved
341     ${output}=    Write Commands Until Prompt    nova show ${vm_name} | grep OS-EXT-STS:vm_state    30s
342     Log    ${output}
343     Should Contain    ${output}    active
344
345 Collect VM IP Addresses
346     [Arguments]    ${fail_on_none}    @{vm_list}
347     [Documentation]    Using nova console-log on the provided ${vm_list} to search for the string "obtained" which
348     ...    correlates to the instance receiving it's IP address via DHCP. Also retrieved is the ip of the nameserver
349     ...    if available in the console-log output. The keyword will also return a list of the learned ips as it
350     ...    finds them in the console log output, and will have "None" for Vms that no ip was found.
351     ${devstack_conn_id}=    Get ControlNode Connection
352     Switch Connection    ${devstack_conn_id}
353     ${ip_list}    Create List    @{EMPTY}
354     : FOR    ${vm}    IN    @{vm_list}
355     \    ${vm_ip_line}=    Write Commands Until Prompt    openstack console log show ${vm} | grep -i "obtained"    30s
356     \    Log    ${vm_ip_line}
357     \    @{vm_ip}    Get Regexp Matches    ${vm_ip_line}    [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
358     \    ${vm_ip_length}    Get Length    ${vm_ip}
359     \    Run Keyword If    ${vm_ip_length}>0    Append To List    ${ip_list}    @{vm_ip}[0]
360     \    ...    ELSE    Append To List    ${ip_list}    None
361     \    ${dhcp_ip_line}=    Write Commands Until Prompt    openstack console log show ${vm} | grep "^nameserver"    30s
362     \    Log    ${dhcp_ip_line}
363     \    ${dhcp_ip}    Get Regexp Matches    ${dhcp_ip_line}    [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
364     \    ${dhcp_ip_length}    Get Length    ${dhcp_ip}
365     \    Run Keyword If    ${dhcp_ip_length}<=0    Append To List    ${dhcp_ip}    None
366     \    Log    ${dhcp_ip}
367     ${dhcp_length}    Get Length    ${dhcp_ip}
368     Run Keyword If    '${fail_on_none}' == 'true'    Should Not Contain    ${ip_list}    None
369     Run Keyword If    '${fail_on_none}' == 'true'    Should Not Contain    ${dhcp_ip}    None
370     Should Be True    ${dhcp_length} <= 1
371     Return From Keyword If    ${dhcp_length}==0    ${ip_list}    ${EMPTY}
372     [Return]    ${ip_list}    ${dhcp_ip}
373
374 Collect VM IPv6 SLAAC Addresses
375     [Arguments]    ${fail_on_none}    ${prefix}    @{vm_list}
376     [Documentation]    Using nova console-log on the provided ${vm_list} to search for the string "inet6" which
377     ...    correlates to the instance generated IPv6 address, based on the ${prefix} received from ODL (SLAAC mode).
378     ${devstack_conn_id}=    Get ControlNode Connection
379     Switch Connection    ${devstack_conn_id}
380     ${ip_list}    Create List    @{EMPTY}
381     : FOR    ${vm}    IN    @{vm_list}
382     \    Log    ${vm}
383     \    ${vm_ip_line}=    Write Commands Until Prompt    nova console-log ${vm} | grep -i "inet6"    30s
384     \    Log    ${vm_ip_line}
385     \    @{vm_ip_list}    Get Regexp Matches    ${vm_ip_line}    ${prefix}
386     \    ${vm_ip_length}    Get Length    ${vm_ip_list}
387     \    Run Keyword If    ${vm_ip_length}>0    Append To List    ${ip_list}    @{vm_ip_list}[0]
388     \    ...    ELSE    Append To List    ${ip_list}    None
389     \    Log    ${ip_list}
390     Run Keyword If    '${fail_on_none}' == 'true'    Should Not Contain    ${ip_list}    None
391     Log    ${ip_list}
392     [Return]    ${ip_list}
393
394 View Vm Console
395     [Arguments]    ${vm_instance_names}
396     [Documentation]    View Console log of the created vm instances using nova show.
397     : FOR    ${VmElement}    IN    @{vm_instance_names}
398     \    ${output}=    Write Commands Until Prompt    nova show ${VmElement}
399     \    Log    ${output}
400     \    ${output}=    Write Commands Until Prompt    openstack console log show ${VmElement}
401     \    Log    ${output}
402
403 Ping Vm From DHCP Namespace
404     [Arguments]    ${net_name}    ${vm_ip}
405     [Documentation]    Reach all Vm Instance with the net id of the Netowrk.
406     Log    ${vm_ip}
407     ${devstack_conn_id}=    Get ControlNode Connection
408     Switch Connection    ${devstack_conn_id}
409     ${net_id}=    Get Net Id    ${net_name}    ${devstack_conn_id}
410     Log    ${net_id}
411     ${output}=    Write Commands Until Prompt    sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip}    20s
412     Log    ${output}
413     Close Connection
414     Should Contain    ${output}    64 bytes
415
416 Ping From DHCP Should Not Succeed
417     [Arguments]    ${net_name}    ${vm_ip}
418     [Documentation]    Should Not Reach Vm Instance with the net id of the Netowrk.
419     Return From Keyword If    "skip_if_${SECURITY_GROUP_MODE}" in @{TEST_TAGS}
420     Log    ${vm_ip}
421     ${devstack_conn_id}=    Get ControlNode Connection
422     Switch Connection    ${devstack_conn_id}
423     ${net_id}=    Get Net Id    ${net_name}    ${devstack_conn_id}
424     Log    ${net_id}
425     ${output}=    Write Commands Until Prompt    sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip}    20s
426     Close Connection
427     Log    ${output}
428     Should Not Contain    ${output}    64 bytes
429
430 Ping Vm From Control Node
431     [Arguments]    ${vm_floating_ip}    ${additional_args}=${EMPTY}
432     [Documentation]    Ping VM floating IP from control node
433     Log    ${vm_floating_ip}
434     ${devstack_conn_id}=    Get ControlNode Connection
435     Switch Connection    ${devstack_conn_id}
436     ${output}=    Write Commands Until Prompt    ping ${additional_args} -c 3 ${vm_floating_ip}    20s
437     Log    ${output}
438     Close Connection
439     Should Contain    ${output}    64 bytes
440
441 Ping From Instance
442     [Arguments]    ${dest_vm_ip}
443     [Documentation]    Ping to the expected destination ip.
444     ${output}=    Write Commands Until Expected Prompt    ping -c 3 ${dest_vm_ip}    ${OS_SYSTEM_PROMPT}
445     Log    ${output}
446     [Return]    ${output}
447
448 Curl Metadata Server
449     [Documentation]    Ping to the expected destination ip.
450     ${output}=    Write Commands Until Expected Prompt    curl -i http://169.254.169.254    ${OS_SYSTEM_PROMPT}
451     Write Commands Until Prompt    exit
452     Should Contain    ${output}    200
453
454 Close Vm Instance
455     [Documentation]    Exit the vm instance.
456     ${output}=    Write Commands Until Prompt    exit
457     Log    ${output}
458
459 Check If Console Is VmInstance
460     [Arguments]    ${console}=cirros
461     [Documentation]    Check if the session has been able to login to the VM instance
462     ${output}=    Write Commands Until Expected Prompt    id    ${OS_SYSTEM_PROMPT}
463     Should Contain    ${output}    ${console}
464
465 Exit From Vm Console
466     [Documentation]    Check if the session has been able to login to the VM instance and exit the instance
467     ${rcode}=    Run Keyword And Return Status    Check If Console Is VmInstance    cirros
468     Run Keyword If    ${rcode}    Write Commands Until Prompt    exit
469
470 Check Ping
471     [Arguments]    ${ip_address}    ${ttl}=64
472     [Documentation]    Run Ping command on the IP available as argument
473     ${ethertype}=    Get Regexp Matches    ${ip_address}    ${IP_REGEX}
474     ${output}=    Run Keyword If    ${ethertype}    Write Commands Until Expected Prompt    ping -t ${ttl} -c 3 ${ip_address}    ${OS_SYSTEM_PROMPT}
475     ...    ELSE    Write Commands Until Expected Prompt    ping6 -t ${ttl} -c 3 ${ip_address}    ${OS_SYSTEM_PROMPT}
476     Should Contain    ${output}    64 bytes
477
478 Check No Ping
479     [Arguments]    ${ip_address}    ${ttl}=64
480     [Documentation]    Run Ping command to the IP given as argument, executing 3 times and expecting NOT to see "64 bytes"
481     ${output}=    Write Commands Until Expected Prompt    ping -t ${ttl} -c 3 ${ip_address}    ${OS_SYSTEM_PROMPT}
482     Should Not Contain    ${output}    64 bytes
483
484 Check Metadata Access
485     [Documentation]    Try curl on the Metadataurl and check if it is okay
486     ${output}=    Write Commands Until Expected Prompt    curl -i http://169.254.169.254    ${OS_SYSTEM_PROMPT}
487     Should Contain    ${output}    200
488
489 Execute Command on VM Instance
490     [Arguments]    ${net_name}    ${vm_ip}    ${cmd}    ${user}=cirros    ${password}=cubswin:)
491     [Documentation]    Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
492     ${devstack_conn_id} =    Get ControlNode Connection
493     Switch Connection    ${devstack_conn_id}
494     ${net_id} =    Get Net Id    ${net_name}    ${devstack_conn_id}
495     Log    ${vm_ip}
496     ${output} =    Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ssh ${user}@${vm_ip} -o ConnectTimeout=10 -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null    d:
497     Log    ${output}
498     ${output} =    Write Commands Until Expected Prompt    ${password}    ${OS_SYSTEM_PROMPT}
499     Log    ${output}
500     ${rcode} =    Run Keyword And Return Status    Check If Console Is VmInstance
501     ${output} =    Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    ${cmd}    ${OS_SYSTEM_PROMPT}
502     [Teardown]    Exit From Vm Console
503     [Return]    ${output}
504
505 Test Operations From Vm Instance
506     [Arguments]    ${net_name}    ${src_ip}    ${dest_ips}    ${user}=cirros    ${password}=cubswin:)    ${ttl}=64
507     ...    ${ping_should_succeed}=True    ${check_metadata}=True
508     [Documentation]    Login to the vm instance using ssh in the network.
509     ${devstack_conn_id}=    Get ControlNode Connection
510     Switch Connection    ${devstack_conn_id}
511     Log    ${src_ip}
512     ${net_id}=    Get Net Id    ${net_name}    ${devstack_conn_id}
513     ${output}=    Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ssh -o ConnectTimeout=10 -o StrictHostKeyChecking=no ${user}@${src_ip} -o UserKnownHostsFile=/dev/null    d:
514     Log    ${output}
515     ${output}=    Write Commands Until Expected Prompt    ${password}    ${OS_SYSTEM_PROMPT}
516     Log    ${output}
517     ${rcode}=    Run Keyword And Return Status    Check If Console Is VmInstance
518     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    ifconfig    ${OS_SYSTEM_PROMPT}
519     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    route -n    ${OS_SYSTEM_PROMPT}
520     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    route -A inet6    ${OS_SYSTEM_PROMPT}
521     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    arp -an    ${OS_SYSTEM_PROMPT}
522     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    ip -6 neigh    ${OS_SYSTEM_PROMPT}
523     : FOR    ${dest_ip}    IN    @{dest_ips}
524     \    Log    ${dest_ip}
525     \    ${string_empty}=    Run Keyword And Return Status    Should Be Empty    ${dest_ip}
526     \    Run Keyword If    ${string_empty}    Continue For Loop
527     \    Run Keyword If    ${rcode} and "${ping_should_succeed}" == "True"    Check Ping    ${dest_ip}    ttl=${ttl}
528     \    ...    ELSE    Check No Ping    ${dest_ip}    ttl=${ttl}
529     ${ethertype}=    Get Regexp Matches    ${src_ip}    ${IP_REGEX}
530     Run Keyword If    ${rcode} and "${check_metadata}" and ${ethertype} == "True"    Check Metadata Access
531     [Teardown]    Exit From Vm Console
532
533 Test Netcat Operations From Vm Instance
534     [Arguments]    ${net_name}    ${vm_ip}    ${dest_ip}    ${additional_args}=${EMPTY}    ${port}=12345    ${user}=cirros
535     ...    ${password}=cubswin:)
536     [Documentation]    Use Netcat to test TCP/UDP connections to the controller
537     ${client_data}    Set Variable    Test Client Data
538     ${server_data}    Set Variable    Test Server Data
539     ${devstack_conn_id}=    Get ControlNode Connection
540     Switch Connection    ${devstack_conn_id}
541     Log    ${vm_ip}
542     ${output}=    Write Commands Until Prompt    ( ( echo "${server_data}" | sudo timeout 60 nc -l ${additional_args} ${port} ) & )
543     Log    ${output}
544     ${output}=    Write Commands Until Prompt    sudo netstat -nlap | grep ${port}
545     Log    ${output}
546     ${nc_output}=    Execute Command on VM Instance    ${net_name}    ${vm_ip}    sudo echo "${client_data}" | nc -v -w 5 ${additional_args} ${dest_ip} ${port}
547     Log    ${nc_output}
548     ${output}=    Execute Command on VM Instance    ${net_name}    ${vm_ip}    sudo route -n
549     Log    ${output}
550     ${output}=    Execute Command on VM Instance    ${net_name}    ${vm_ip}    sudo arp -an
551     Log    ${output}
552     Should Match Regexp    ${nc_output}    ${server_data}
553
554 Ping Other Instances
555     [Arguments]    ${list_of_external_dst_ips}
556     [Documentation]    Check reachability with other network's instances.
557     ${rcode}=    Run Keyword And Return Status    Check If Console Is VmInstance
558     : FOR    ${dest_ip}    IN    @{list_of_external_dst_ips}
559     \    Log    ${dest_ip}
560     \    Check Ping    ${dest_ip}
561
562 Create Router
563     [Arguments]    ${router_name}
564     [Documentation]    Create Router and Add Interface to the subnets.
565     ${devstack_conn_id}=    Get ControlNode Connection
566     Switch Connection    ${devstack_conn_id}
567     ${output}=    Write Commands Until Prompt    openstack router create -f table ${router_name}    30s
568     Close Connection
569     Should Contain    ${output}    ${OS_CMD_SUCCESS}
570
571 List Router
572     [Documentation]    List Router and return output with neutron client.
573     ${devstack_conn_id}=    Get ControlNode Connection
574     Switch Connection    ${devstack_conn_id}
575     ${output}=    Write Commands Until Prompt    openstack router list    30s
576     Close Connection
577     Log    ${output}
578     [Return]    ${output}
579
580 Add Router Interface
581     [Arguments]    ${router_name}    ${interface_name}
582     ${devstack_conn_id}=    Get ControlNode Connection
583     Switch Connection    ${devstack_conn_id}
584     ${output}=    Write Commands Until Prompt    openstack router add subnet ${router_name} ${interface_name}
585     Close Connection
586     Should Contain    ${output}    ${OS_CMD_SUCCESS}
587
588 Show Router Interface
589     [Arguments]    ${router_name}
590     [Documentation]    List Router interface associated with given Router and return output with neutron client.
591     ${devstack_conn_id}=    Get ControlNode Connection
592     Switch Connection    ${devstack_conn_id}
593     ${output}=    Write Commands Until Prompt    openstack port list --router ${router_name}    30s
594     Close Connection
595     Log    ${output}
596     [Return]    ${output}
597
598 Add Router Gateway
599     [Arguments]    ${router_name}    ${external_network_name}
600     ${devstack_conn_id}=    Get ControlNode Connection
601     Switch Connection    ${devstack_conn_id}
602     ${cmd}=    Set Variable If    '${OPENSTACK_BRANCH}'=='stable/newton'    neutron -v router-gateway-set ${router_name} ${external_network_name}    openstack router set ${router_name} --external-gateway ${external_network_name}
603     ${output}=    Write Commands Until Prompt    ${cmd}    30s
604     Close Connection
605     Should Contain    ${output}    ${OS_CMD_SUCCESS}
606
607 Remove Interface
608     [Arguments]    ${router_name}    ${interface_name}
609     [Documentation]    Remove Interface to the subnets.
610     ${devstack_conn_id}=    Get ControlNode Connection
611     Switch Connection    ${devstack_conn_id}
612     ${output}=    Write Commands Until Prompt    openstack router remove subnet ${router_name} ${interface_name}
613     Close Connection
614     Should Contain    ${output}    ${OS_CMD_SUCCESS}
615
616 Update Router
617     [Arguments]    ${router_name}    ${cmd}
618     [Documentation]    Update the router with the command. Router name and command should be passed as argument.
619     ${devstack_conn_id} =    Get ControlNode Connection
620     Switch Connection    ${devstack_conn_id}
621     ${output} =    Write Commands Until Prompt    openstack router set ${router_name} ${cmd}    30s
622     Close Connection
623     Should Contain    ${output}    ${OS_CMD_SUCCESS}
624
625 Show Router
626     [Arguments]    ${router_name}    ${options}
627     [Documentation]    Show information of a given router. Router name and optional fields should be sent as arguments.
628     ${devstack_conn_id} =    Get ControlNode Connection
629     Switch Connection    ${devstack_conn_id}
630     ${output} =    Write Commands Until Prompt    openstack router show ${router_name}    30s
631     Log    ${output}
632     Close Connection
633
634 Delete Router
635     [Arguments]    ${router_name}
636     [Documentation]    Delete Router and Interface to the subnets.
637     ${devstack_conn_id}=    Get ControlNode Connection
638     Switch Connection    ${devstack_conn_id}
639     ${output}=    Write Commands Until Prompt    openstack router delete ${router_name}    60s
640     Close Connection
641     Should Contain    ${output}    ${OS_CMD_SUCCESS}
642
643 Get DumpFlows And Ovsconfig
644     [Arguments]    ${openstack_node_ip}
645     [Documentation]    Get the OvsConfig and Flow entries from OVS from the Openstack Node
646     Log    ${openstack_node_ip}
647     SSHLibrary.Open Connection    ${openstack_node_ip}    prompt=${DEFAULT_LINUX_PROMPT}
648     Utils.Flexible SSH Login    ${OS_USER}    ${DEVSTACK_SYSTEM_PASSWORD}
649     SSHLibrary.Set Client Configuration    timeout=${default_devstack_prompt_timeout}
650     Write Commands Until Expected Prompt    ip -o link    ${DEFAULT_LINUX_PROMPT_STRICT}
651     Write Commands Until Expected Prompt    ip -o addr    ${DEFAULT_LINUX_PROMPT_STRICT}
652     Write Commands Until Expected Prompt    ip route    ${DEFAULT_LINUX_PROMPT_STRICT}
653     Write Commands Until Expected Prompt    arp -an    ${DEFAULT_LINUX_PROMPT_STRICT}
654     ${nslist}=    Write Commands Until Expected Prompt    ip netns list | awk '{print $1}'    ${DEFAULT_LINUX_PROMPT_STRICT}
655     @{lines}    Split To Lines    ${nslist}
656     : FOR    ${line}    IN    @{lines}
657     \    Write Commands Until Expected Prompt    sudo ip netns exec ${line} ip -o link    ${DEFAULT_LINUX_PROMPT_STRICT}
658     \    Write Commands Until Expected Prompt    sudo ip netns exec ${line} ip -o addr    ${DEFAULT_LINUX_PROMPT_STRICT}
659     \    Write Commands Until Expected Prompt    sudo ip netns exec ${line} ip route    ${DEFAULT_LINUX_PROMPT_STRICT}
660     Write Commands Until Expected Prompt    sudo ovs-vsctl show    ${DEFAULT_LINUX_PROMPT_STRICT}
661     Write Commands Until Expected Prompt    sudo ovs-vsctl list Open_vSwitch    ${DEFAULT_LINUX_PROMPT_STRICT}
662     Write Commands Until Expected Prompt    sudo ovs-ofctl show br-int -OOpenFlow13    ${DEFAULT_LINUX_PROMPT_STRICT}
663     Write Commands Until Expected Prompt    sudo ovs-ofctl dump-flows br-int -OOpenFlow13    ${DEFAULT_LINUX_PROMPT_STRICT}
664     Write Commands Until Expected Prompt    sudo ovs-ofctl dump-groups br-int -OOpenFlow13    ${DEFAULT_LINUX_PROMPT_STRICT}
665     Write Commands Until Expected Prompt    sudo ovs-ofctl dump-group-stats br-int -OOpenFlow13    ${DEFAULT_LINUX_PROMPT_STRICT}
666
667 Get Karaf Log Type From Test Start
668     [Arguments]    ${ip}    ${test_name}    ${type}    ${user}=${ODL_SYSTEM_USER}    ${password}=${ODL_SYSTEM_PASSWORD}    ${prompt}=${ODL_SYSTEM_PROMPT}
669     ...    ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
670     ${cmd}    Set Variable    sed '1,/ROBOT MESSAGE: Starting test ${test_name}/d' ${log_file} | grep '${type}'
671     ${output}    Run Command On Controller    ${ip}    ${cmd}    ${user}    ${password}    ${prompt}
672     Log    ${output}
673
674 Get Karaf Log Types From Test Start
675     [Arguments]    ${ip}    ${test_name}    ${types}    ${user}=${ODL_SYSTEM_USER}    ${password}=${ODL_SYSTEM_PASSWORD}    ${prompt}=${ODL_SYSTEM_PROMPT}
676     ...    ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
677     : FOR    ${type}    IN    @{types}
678     \    Get Karaf Log Type From Test Start    ${ip}    ${test_name}    ${type}    ${user}    ${password}
679     \    ...    ${prompt}    ${log_file}
680
681 Get Karaf Log Events From Test Start
682     [Arguments]    ${test_name}    ${user}=${ODL_SYSTEM_USER}    ${password}=${ODL_SYSTEM_PASSWORD}    ${prompt}=${ODL_SYSTEM_PROMPT}
683     ${log_types} =    Create List    ERROR    WARN    Exception
684     Run Keyword If    0 < ${NUM_ODL_SYSTEM}    Get Karaf Log Types From Test Start    ${ODL_SYSTEM_IP}    ${test_name}    ${log_types}
685     Run Keyword If    1 < ${NUM_ODL_SYSTEM}    Get Karaf Log Types From Test Start    ${ODL_SYSTEM_2_IP}    ${test_name}    ${log_types}
686     Run Keyword If    2 < ${NUM_ODL_SYSTEM}    Get Karaf Log Types From Test Start    ${ODL_SYSTEM_3_IP}    ${test_name}    ${log_types}
687
688 Get ControlNode Connection
689     ${control_conn_id}=    SSHLibrary.Open Connection    ${OS_CONTROL_NODE_IP}    prompt=${DEFAULT_LINUX_PROMPT_STRICT}
690     Utils.Flexible SSH Login    ${OS_USER}    ${DEVSTACK_SYSTEM_PASSWORD}
691     SSHLibrary.Set Client Configuration    timeout=30s
692     Source Password    force=yes
693     [Return]    ${control_conn_id}
694
695 Get OvsDebugInfo
696     [Documentation]    Get the OvsConfig and Flow entries from all Openstack nodes
697     Run Keyword If    0 < ${NUM_OS_SYSTEM}    Get DumpFlows And Ovsconfig    ${OS_CONTROL_NODE_IP}
698     Run Keyword If    1 < ${NUM_OS_SYSTEM}    Get DumpFlows And Ovsconfig    ${OS_COMPUTE_1_IP}
699     Run Keyword If    2 < ${NUM_OS_SYSTEM}    Get DumpFlows And Ovsconfig    ${OS_COMPUTE_2_IP}
700
701 Get Test Teardown Debugs
702     [Arguments]    ${test_name}=${TEST_NAME}
703     Get OvsDebugInfo
704     Run Keyword And Ignore Error    Get Model Dump    ${HA_PROXY_IP}    ${netvirt_data_models}
705     Get Karaf Log Events From Test Start    ${test_name}
706
707 Get Suite Teardown Debugs
708     Get OvsDebugInfo
709     Get Model Dump    ${HA_PROXY_IP}    ${netvirt_data_models}
710
711 Show Debugs
712     [Arguments]    @{vm_indices}
713     [Documentation]    Run these commands for debugging, it can list state of VM instances and ip information in control node
714     ${devstack_conn_id}=    Get ControlNode Connection
715     Switch Connection    ${devstack_conn_id}
716     ${output}=    Write Commands Until Prompt    sudo ip netns list
717     Log    ${output}
718     : FOR    ${index}    IN    @{vm_indices}
719     \    ${output}=    Write Commands Until Prompt    nova show ${index}    30s
720     \    Log    ${output}
721     Close Connection
722     List Nova VMs
723     List Networks
724     List Subnets
725     List Ports
726
727 Create Security Group
728     [Arguments]    ${sg_name}    ${desc}
729     ${devstack_conn_id}=    Get ControlNode Connection
730     Switch Connection    ${devstack_conn_id}
731     ${output}=    Write Commands Until Prompt    openstack security group create ${sg_name} --description ${desc}    40s
732     Close Connection
733
734 Create Security Rule
735     [Arguments]    ${direction}    ${protocol}    ${min_port}    ${max_port}    ${remote_ip}    ${sg_name}
736     ${devstack_conn_id}=    Get ControlNode Connection
737     Switch Connection    ${devstack_conn_id}
738     ${output}=    Write Commands Until Prompt    openstack security group rule create --${direction} --protocol ${protocol} --dst-port ${min_port}:${max_port} --remote-ip ${remote_ip} ${sg_name}
739     Close Connection
740
741 Neutron Security Group Show
742     [Arguments]    ${SecurityGroupRuleName}
743     [Documentation]    Displays the neutron security group configurations that belongs to a given neutron security group name
744     ${devstack_conn_id}=    Get ControlNode Connection
745     Switch Connection    ${devstack_conn_id}
746     ${cmd}=    Set Variable    openstack security group show ${SecurityGroupRuleName}
747     Log    ${cmd}
748     ${output}=    Write Commands Until Prompt    ${cmd}    30s
749     Log    ${output}
750     Close Connection
751     [Return]    ${output}
752
753 Neutron Port Show
754     [Arguments]    ${PortName}
755     [Documentation]    Display the port configuration that belong to a given neutron port
756     ${devstack_conn_id}=    Get ControlNode Connection
757     Switch Connection    ${devstack_conn_id}
758     ${cmd}=    Set Variable    openstack port show ${PortName}
759     Log    ${cmd}
760     ${output}=    Write Commands Until Prompt    ${cmd}    30s
761     Log    ${output}
762     Close Connection
763     [Return]    ${output}
764
765 Neutron Security Group Create
766     [Arguments]    ${SecurityGroupName}    ${additional_args}=${EMPTY}
767     [Documentation]    Create a security group with specified name ,description & protocol value according to security group template
768     ${devstack_conn_id}=    Get ControlNode Connection
769     Switch Connection    ${devstack_conn_id}
770     ${cmd}=    Set Variable    openstack security group create ${SecurityGroupName} ${additional_args}
771     Log    ${cmd}
772     ${output}=    Write Commands Until Prompt    ${cmd}    30s
773     Log    ${output}
774     Should Contain    ${output}    ${OS_CMD_SUCCESS}
775     ${sgp_id}=    Should Match Regexp    ${output}    [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
776     Log    ${sgp_id}
777     Close Connection
778     [Return]    ${output}    ${sgp_id}
779
780 Neutron Security Group Update
781     [Arguments]    ${SecurityGroupName}    ${additional_args}=${EMPTY}
782     [Documentation]    Updating security groups
783     ${devstack_conn_id}=    Get ControlNode Connection
784     Switch Connection    ${devstack_conn_id}
785     ${cmd}=    Set Variable    openstack security group set ${SecurityGroupName} ${additional_args}
786     Log    ${cmd}
787     ${output}=    Write Commands Until Prompt    ${cmd}    30s
788     Log    ${output}
789     Close Connection
790     [Return]    ${output}
791
792 Delete SecurityGroup
793     [Arguments]    ${sg_name}
794     [Documentation]    Delete Security group
795     ${devstack_conn_id}=    Get ControlNode Connection
796     Switch Connection    ${devstack_conn_id}
797     ${output}=    Write Commands Until Prompt    openstack security group delete ${sg_name}    40s
798     Log    ${output}
799     Should Contain    ${output}    ${OS_CMD_SUCCESS}
800     Close Connection
801
802 Neutron Security Group Rule Create
803     [Arguments]    ${Security_group_name}    &{Kwargs}
804     [Documentation]    Creates neutron security rule with Openstack CLI with or without optional params, here security group name is mandatory args, rule with optional params can be created by passing the optional args values ex: direction=${INGRESS_EGRESS}, Then these optional params are catenated with mandatory args, example of usage: "Neutron Security Group Rule Create ${SGP_SSH} direction=${RULE_PARAMS[0]} ethertype=${RULE_PARAMS[1]} ..."
805     ${devstack_conn_id}=    Get ControlNode Connection
806     Switch Connection    ${devstack_conn_id}
807     Run Keyword If    ${Kwargs}    Log    ${Kwargs}
808     ${description}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    description    default=${None}
809     ${direction}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    direction    default=${None}
810     ${ethertype}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    ethertype    default=${None}
811     ${port_range_max}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    port_range_max    default=${None}
812     ${port_range_min}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    port_range_min    default=${None}
813     ${protocol}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    protocol    default=${None}
814     ${remote_group_id}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    remote_group_id    default=${None}
815     ${remote_ip_prefix}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    remote_ip_prefix    default=${None}
816     ${cmd}=    Set Variable    openstack security group rule create ${Security_group_name}
817     ${cmd}=    Run Keyword If    '${description}'!='None'    Catenate    ${cmd}    --description ${description}
818     ...    ELSE    Catenate    ${cmd}
819     ${cmd}=    Run Keyword If    '${direction}'!='None'    Catenate    ${cmd}    --${direction}
820     ...    ELSE    Catenate    ${cmd}
821     ${cmd}=    Run Keyword If    '${ethertype}'!='None'    Catenate    ${cmd}    --ethertype ${ethertype}
822     ...    ELSE    Catenate    ${cmd}
823     ${cmd}=    Run Keyword If    '${port_range_min}'!='None' and '${port_range_max}'!='None'    Catenate    ${cmd}    --dst-port ${port_range_min}:${port_range_max}
824     ...    ELSE IF    '${port_range_max}'!='None'    Catenate    ${cmd}    --dst-port ${port_range_max}
825     ...    ELSE IF    '${port_range_min}'!='None'    Catenate    ${cmd}    --dst-port ${port_range_min}
826     ...    ELSE    Catenate    ${cmd}
827     ${cmd}=    Run Keyword If    '${protocol}'!='None'    Catenate    ${cmd}    --protocol ${protocol}
828     ...    ELSE    Catenate    ${cmd}
829     ${cmd}=    Run Keyword If    '${remote_group_id}'!='None'    Catenate    ${cmd}    --remote-group ${remote_group_id}
830     ...    ELSE    Catenate    ${cmd}
831     ${cmd}=    Run Keyword If    '${remote_ip_prefix}'!='None'    Catenate    ${cmd}    --remote-ip ${remote_ip_prefix}
832     ...    ELSE    Catenate    ${cmd}
833     ${output}=    Write Commands Until Prompt    ${cmd}    30s
834     ${rule_id}=    Should Match Regexp    ${output}    [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
835     Log    ${rule_id}
836     Should Contain    ${output}    ${OS_CMD_SUCCESS}
837     Close Connection
838     [Return]    ${output}    ${rule_id}
839
840 Neutron Security Group Rule Create Legacy Cli
841     [Arguments]    ${Security_group_name}    &{Kwargs}
842     [Documentation]    Creates neutron security rule with neutron request with or without optional params, here security group name is mandatory args, rule with optional params can be created by passing the optional args values ex: direction=${INGRESS_EGRESS}, Then these optional params are catenated with mandatory args, example of usage: "Neutron Security Group Rule Create ${SGP_SSH} direction=${RULE_PARAMS[0]} ethertype=${RULE_PARAMS[1]} ..."
843     ${devstack_conn_id}=    Get ControlNode Connection
844     Switch Connection    ${devstack_conn_id}
845     Run Keyword If    ${Kwargs}    Log    ${Kwargs}
846     ${description}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    description    default=${None}
847     ${direction}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    direction    default=${None}
848     ${ethertype}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    ethertype    default=${None}
849     ${port_range_max}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    port_range_max    default=${None}
850     ${port_range_min}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    port_range_min    default=${None}
851     ${protocol}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    protocol    default=${None}
852     ${remote_group_id}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    remote_group_id    default=${None}
853     ${remote_ip_prefix}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    remote_ip_prefix    default=${None}
854     ${cmd}=    Set Variable    neutron security-group-rule-create ${Security_group_name}
855     ${cmd}=    Run Keyword If    '${description}'!='None'    Catenate    ${cmd}    --description ${description}
856     ...    ELSE    Catenate    ${cmd}
857     ${cmd}=    Run Keyword If    '${direction}'!='None'    Catenate    ${cmd}    --direction ${direction}
858     ...    ELSE    Catenate    ${cmd}
859     ${cmd}=    Run Keyword If    '${ethertype}'!='None'    Catenate    ${cmd}    --ethertype ${ethertype}
860     ...    ELSE    Catenate    ${cmd}
861     ${cmd}=    Run Keyword If    '${port_range_max}'!='None'    Catenate    ${cmd}    --port_range_max ${port_range_max}
862     ...    ELSE    Catenate    ${cmd}
863     ${cmd}=    Run Keyword If    '${port_range_min}'!='None'    Catenate    ${cmd}    --port_range_min ${port_range_min}
864     ...    ELSE    Catenate    ${cmd}
865     ${cmd}=    Run Keyword If    '${protocol}'!='None'    Catenate    ${cmd}    --protocol ${protocol}
866     ...    ELSE    Catenate    ${cmd}
867     ${cmd}=    Run Keyword If    '${remote_group_id}'!='None'    Catenate    ${cmd}    --remote_group_id ${remote_group_id}
868     ...    ELSE    Catenate    ${cmd}
869     ${cmd}=    Run Keyword If    '${remote_ip_prefix}'!='None'    Catenate    ${cmd}    --remote_ip_prefix ${remote_ip_prefix}
870     ...    ELSE    Catenate    ${cmd}
871     ${output}=    Write Commands Until Prompt    ${cmd}    30s
872     ${rule_id}=    Should Match Regexp    ${output}    [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
873     Log    ${rule_id}
874     Should Contain    ${output}    Created a new security_group_rule
875     Close Connection
876     [Return]    ${output}    ${rule_id}
877
878 Security Group Create Without Default Security Rules
879     [Arguments]    ${sg_name}    ${additional_args}=${EMPTY}
880     [Documentation]    Create Neutron Security Group with no default rules, using specified name and optional arguments.
881     Neutron Security Group Create    ${sg_name}    ${additional_args}
882     Delete All Security Group Rules    ${sg_name}
883
884 Delete All Security Group Rules
885     [Arguments]    ${sg_name}
886     [Documentation]    Delete all security rules from a specified security group
887     ${devstack_conn_id}=    Get ControlNode Connection
888     Switch Connection    ${devstack_conn_id}
889     ${sg_rules_output}=    Write Commands Until Prompt    openstack security group rule list ${sg_name} -cID -fvalue
890     Log    ${sg_rules_output}
891     @{sg_rules}=    Split String    ${sg_rules_output}    \n
892     : FOR    ${rule}    IN    @{sg_rules}
893     \    ${output}=    Write Commands Until Prompt    openstack security group rule delete ${rule}
894     \    Log    ${output}
895     Close Connection
896
897 Create Neutron Port With Additional Params
898     [Arguments]    ${network_name}    ${port_name}    ${additional_args}=${EMPTY}
899     [Documentation]    Create Port With given additional parameters
900     ${devstack_conn_id}=    Get ControlNode Connection
901     Switch Connection    ${devstack_conn_id}
902     ${cmd}=    Set Variable    neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
903     Log    ${cmd}
904     ${OUTPUT}=    Write Commands Until Prompt    ${cmd}    30s
905     Log    ${OUTPUT}
906     Should Contain    ${output}    ${OS_CMD_SUCCESS}
907     ${port_id}=    Should Match Regexp    ${OUTPUT}    [0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}
908     Log    ${port_id}
909     Close Connection
910     [Return]    ${OUTPUT}    ${port_id}
911
912 Get Ports MacAddr
913     [Arguments]    ${portName_list}
914     [Documentation]    Retrieve the port MacAddr for the given list of port name and return the MAC address list.
915     ${devstack_conn_id}=    Get ControlNode Connection
916     Switch Connection    ${devstack_conn_id}
917     ${MacAddr-list}    Create List
918     : FOR    ${portName}    IN    @{portName_list}
919     \    ${macAddr}=    OpenStackOperations.Get Port Mac    ${portName}    ${devstack_conn_id}
920     \    Append To List    ${MacAddr-list}    ${macAddr}
921     [Return]    ${MacAddr-list}
922
923 Get Port Ip
924     [Arguments]    ${port_name}
925     [Documentation]    Keyword would return the IP of the ${port_name} received.
926     Switch Connection    ${devstack_conn_id}
927     ${output}=    Write Commands Until Prompt    neutron port-list | grep "${port_name}" | awk '{print $11}' | awk -F "\\"" '{print $2}'    30s
928     Log    ${output}
929     ${splitted_output}=    Split String    ${output}    ${EMPTY}
930     ${port_ip}=    Get from List    ${splitted_output}    0
931     Log    ${port_ip}
932     [Return]    ${port_ip}
933
934 Get Port Mac
935     [Arguments]    ${port_name}    ${conn_id}=${devstack_conn_id}
936     [Documentation]    Keyword would return the MAC ID of the ${port_name} received.
937     Switch Connection    ${conn_id}
938     ${output}=    Write Commands Until Prompt    openstack port show ${port_name} | grep mac_address | awk '{print $4}'    30s
939     Log    ${output}
940     ${splitted_output}=    Split String    ${output}    ${EMPTY}
941     ${port_mac}=    Get from List    ${splitted_output}    0
942     Log    ${port_mac}
943     [Return]    ${port_mac}
944
945 Create L2Gateway
946     [Arguments]    ${bridge_name}    ${intf_name}    ${gw_name}
947     [Documentation]    Keyword to create an L2 Gateway ${gw_name} for bridge ${bridge_name} connected to interface ${intf_name} (Using Neutron CLI).
948     Switch Connection    ${devstack_conn_id}
949     ${l2gw_output}=    Write Commands Until Prompt    ${L2GW_CREATE} name=${bridge_name},interface_names=${intf_name} ${gw_name}    30s
950     Log    ${l2gw_output}
951     [Return]    ${l2gw_output}
952
953 Create L2Gateway Connection
954     [Arguments]    ${gw_name}    ${net_name}
955     [Documentation]    Keyword would create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI).
956     Switch Connection    ${devstack_conn_id}
957     ${l2gw_output}=    Write Commands Until Prompt    ${L2GW_CONN_CREATE} ${gw_name} ${net_name}    30s
958     Log    ${l2gw_output}
959     [Return]    ${l2gw_output}
960
961 Get All L2Gateway
962     [Documentation]    Keyword to return all the L2 Gateways available (Using Neutron CLI).
963     Switch Connection    ${devstack_conn_id}
964     ${output}=    Write Commands Until Prompt    ${L2GW_GET_YAML}    30s
965     [Return]    ${output}
966
967 Get All L2Gateway Connection
968     [Documentation]    Keyword to return all the L2 Gateway connections available (Using Neutron CLI).
969     Switch Connection    ${devstack_conn_id}
970     ${output}=    Write Commands Until Prompt    ${L2GW_GET_CONN_YAML}    30s
971     [Return]    ${output}
972
973 Get L2Gateway
974     [Arguments]    ${gw_id}
975     [Documentation]    Keyword to check if the ${gw_id} is available in the L2 Gateway list (Using Neutron CLI).
976     Switch Connection    ${devstack_conn_id}
977     ${output}=    Write Commands Until Prompt    ${L2GW_SHOW} ${gw_id}    30s
978     Log    ${output}
979     [Return]    ${output}
980
981 Get L2gw Id
982     [Arguments]    ${l2gw_name}
983     [Documentation]    Keyword to retrieve the L2 Gateway ID for the ${l2gw_name} (Using Neutron CLI).
984     Switch Connection    ${devstack_conn_id}
985     ${output}=    Write Commands Until Prompt    ${L2GW_GET} | grep "${l2gw_name}" | awk '{print $2}'    30s
986     Log    ${output}
987     ${splitted_output}=    Split String    ${output}    ${EMPTY}
988     ${l2gw_id}=    Get from List    ${splitted_output}    0
989     Log    ${l2gw_id}
990     [Return]    ${l2gw_id}
991
992 Get L2gw Connection Id
993     [Arguments]    ${l2gw_name}
994     [Documentation]    Keyword to retrieve the L2 Gateway Connection ID for the ${l2gw_name} (Using Neutron CLI).
995     Switch Connection    ${devstack_conn_id}
996     ${l2gw_id}=    OpenStackOperations.Get L2gw Id    ${l2gw_name}
997     ${output}=    Write Commands Until Prompt    ${L2GW_GET_CONN} | grep "${l2gw_id}" | awk '{print $2}'    30s
998     Log    ${output}
999     ${splitted_output}=    Split String    ${output}    ${EMPTY}
1000     ${l2gw_conn_id}=    Get from List    ${splitted_output}    0
1001     Log    ${l2gw_conn_id}
1002     [Return]    ${l2gw_conn_id}
1003
1004 Neutron Port List Rest
1005     [Documentation]    Keyword to get all ports details in Neutron (Using REST).
1006     ${resp} =    RequestsLibrary.Get Request    session    ${PORT_URL}
1007     Log    ${resp.content}
1008     Should Be Equal As Strings    ${resp.status_code}    200
1009     [Return]    ${resp.content}
1010
1011 Get Neutron Port Rest
1012     [Arguments]    ${port_id}
1013     [Documentation]    Keyword to get the specific port details in Neutron (Using REST).
1014     ${resp} =    RequestsLibrary.Get Request    session    ${CONFIG_API}/${GET_PORT_URL}/${port_id}
1015     Log    ${resp.content}
1016     Should Be Equal As Strings    ${resp.status_code}    200
1017     [Return]    ${resp.content}
1018
1019 Update Port Rest
1020     [Arguments]    ${port_id}    ${json_data}
1021     [Documentation]    Keyword to update ${port_id} with json data received in ${json_data} (Using REST).
1022     Log    ${json_data}
1023     ${resp} =    RequestsLibrary.Put Request    session    ${CONFIG_API}/${GET_PORT_URL}/${port_id}    ${json_data}
1024     Log    ${resp.content}
1025     Should Be Equal As Strings    ${resp.status_code}    200
1026     [Return]    ${resp.content}
1027
1028 Create And Configure Security Group
1029     [Arguments]    ${sg-name}
1030     [Documentation]    Create Security Group with given name, and default allow rules for TCP/UDP/ICMP protocols.
1031     Neutron Security Group Create    ${sg-name}
1032     Neutron Security Group Rule Create    ${sg-name}    direction=ingress    port_range_max=65535    port_range_min=1    protocol=tcp    remote_ip_prefix=0.0.0.0/0
1033     Neutron Security Group Rule Create    ${sg-name}    direction=egress    port_range_max=65535    port_range_min=1    protocol=tcp    remote_ip_prefix=0.0.0.0/0
1034     Neutron Security Group Rule Create    ${sg-name}    direction=ingress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
1035     Neutron Security Group Rule Create    ${sg-name}    direction=egress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
1036     Neutron Security Group Rule Create    ${sg-name}    direction=ingress    port_range_max=65535    port_range_min=1    protocol=udp    remote_ip_prefix=0.0.0.0/0
1037     Neutron Security Group Rule Create    ${sg-name}    direction=egress    port_range_max=65535    port_range_min=1    protocol=udp    remote_ip_prefix=0.0.0.0/0
1038
1039 Add Security Group To VM
1040     [Arguments]    ${vm}    ${sg}
1041     [Documentation]    Add the security group provided to the given VM.
1042     ${devstack_conn_id}=    Get ControlNode Connection
1043     Switch Connection    ${devstack_conn_id}
1044     ${output}=    Write Commands Until Prompt    openstack server add security group ${vm} ${sg}
1045     Log    ${output}
1046     Close Connection
1047
1048 Create SFC Flow Classifier
1049     [Arguments]    ${name}    ${src_ip}    ${dest_ip}    ${protocol}    ${dest_port}    ${neutron_src_port}
1050     [Documentation]    Create a flow classifier for SFC
1051     ${devstack_conn_id}=    Get ControlNode Connection
1052     Switch Connection    ${devstack_conn_id}
1053     ${cmd}=    Set Variable    neutron flow-classifier-create --ethertype IPv4 --source-ip-prefix ${src_ip}/32 --destination-ip-prefix ${dest_ip}/32 --protocol ${protocol} --destination-port ${dest_port}:${dest_port} --logical-source-port ${neutron_src_port} ${name}
1054     Log    ${cmd}
1055     ${output}=    Write Commands Until Prompt    ${cmd}    30s
1056     Log    ${output}
1057     Close Connection
1058     Should Contain    ${output}    Created a new flow_classifier
1059     [Return]    ${output}
1060
1061 Delete SFC Flow Classifier
1062     [Arguments]    ${name}
1063     [Documentation]    Delete a SFC flow classifier
1064     ${devstack_conn_id}=    Get ControlNode Connection
1065     Switch Connection    ${devstack_conn_id}
1066     ${cmd}=    Set Variable    neutron flow-classifier-delete ${name}
1067     Log    ${cmd}
1068     ${output}=    Write Commands Until Prompt    ${cmd}    30s
1069     Log    ${output}
1070     Close Connection
1071     Should Contain    ${output}    Deleted flow_classifier
1072     [Return]    ${output}
1073
1074 Create SFC Port Pair
1075     [Arguments]    ${name}    ${port_in}    ${port_out}
1076     [Documentation]    Creates a neutron port pair for SFC
1077     ${devstack_conn_id}=    Get ControlNode Connection
1078     Switch Connection    ${devstack_conn_id}
1079     ${cmd}=    Set Variable    neutron port-pair-create --ingress=${port_in} --egress=${port_out} ${name}
1080     Log    ${cmd}
1081     ${output}=    Write Commands Until Prompt    ${cmd}    30s
1082     Log    ${output}
1083     Close Connection
1084     Should Contain    ${output}    Created a new port_pair
1085     [Return]    ${output}
1086
1087 Delete SFC Port Pair
1088     [Arguments]    ${name}
1089     [Documentation]    Delete a SFC port pair
1090     ${devstack_conn_id}=    Get ControlNode Connection
1091     Switch Connection    ${devstack_conn_id}
1092     ${cmd}=    Set Variable    neutron port-pair-delete ${name}
1093     Log    ${cmd}
1094     ${output}=    Write Commands Until Prompt    ${cmd}    30s
1095     Log    ${output}
1096     Close Connection
1097     Should Contain    ${output}    Deleted port_pair
1098     [Return]    ${output}
1099
1100 Create SFC Port Pair Group
1101     [Arguments]    ${name}    ${port_pair}
1102     [Documentation]    Creates a port pair group with a single port pair for SFC
1103     ${devstack_conn_id}=    Get ControlNode Connection
1104     Switch Connection    ${devstack_conn_id}
1105     ${cmd}=    Set Variable    neutron port-pair-group-create --port-pair ${port_pair} ${name}
1106     Log    ${cmd}
1107     ${output}=    Write Commands Until Prompt    ${cmd}    30s
1108     Log    ${output}
1109     Close Connection
1110     Should Contain    ${output}    Created a new port_pair_group
1111     [Return]    ${output}
1112
1113 Create SFC Port Pair Group With Two Pairs
1114     [Arguments]    ${name}    ${port_pair1}    ${port_pair2}
1115     [Documentation]    Creates a port pair group with two port pairs for SFC
1116     ${devstack_conn_id}=    Get ControlNode Connection
1117     Switch Connection    ${devstack_conn_id}
1118     ${cmd}=    Set Variable    neutron port-pair-group-create --port-pair ${port_pair1} --port-pair ${port_pair2} ${name}
1119     Log    ${cmd}
1120     ${output}=    Write Commands Until Prompt    ${cmd}    30s
1121     Log    ${output}
1122     Close Connection
1123     Should Contain    ${output}    Created a new port_pair_group
1124     [Return]    ${output}
1125
1126 Delete SFC Port Pair Group
1127     [Arguments]    ${name}
1128     [Documentation]    Delete a SFC port pair group
1129     ${devstack_conn_id}=    Get ControlNode Connection
1130     Switch Connection    ${devstack_conn_id}
1131     ${cmd}=    Set Variable    neutron port-pair-group-delete ${name}
1132     Log    ${cmd}
1133     ${output}=    Write Commands Until Prompt    ${cmd}    30s
1134     Log    ${output}
1135     Close Connection
1136     Should Contain    ${output}    Deleted port_pair_group
1137     [Return]    ${output}
1138
1139 Create SFC Port Chain
1140     [Arguments]    ${name}    ${pg1}    ${pg2}    ${fc}
1141     [Documentation]    Creates a port pair chain with two port groups and a singel classifier.
1142     ${devstack_conn_id}=    Get ControlNode Connection
1143     Switch Connection    ${devstack_conn_id}
1144     ${cmd}=    Set Variable    neutron port-chain-create --port-pair-group ${pg1} --port-pair-group ${pg2} --flow-classifier ${fc} ${name}
1145     Log    ${cmd}
1146     ${output}=    Write Commands Until Prompt    ${cmd}    30s
1147     Log    ${output}
1148     Close Connection
1149     Should Contain    ${output}    Created a new port_chain
1150     [Return]    ${output}
1151
1152 Delete SFC Port Chain
1153     [Arguments]    ${name}
1154     [Documentation]    Delete a SFC port chain
1155     ${devstack_conn_id}=    Get ControlNode Connection
1156     Switch Connection    ${devstack_conn_id}
1157     ${cmd}=    Set Variable    neutron port-chain-delete ${name}
1158     Log    ${cmd}
1159     ${output}=    Write Commands Until Prompt    ${cmd}    30s
1160     Log    ${output}
1161     Close Connection
1162     Should Contain    ${output}    Deleted port_chain
1163     [Return]    ${output}
1164
1165 Reboot Nova VM
1166     [Arguments]    ${vm_name}
1167     [Documentation]    Reboot NOVA VM
1168     ${devstack_conn_id}=    Get ControlNode Connection
1169     Switch Connection    ${devstack_conn_id}
1170     ${output}=    Write Commands Until Prompt    openstack server reboot --wait ${vm_name}    30s
1171     Log    ${output}
1172     Wait Until Keyword Succeeds    35s    10s    Verify VM Is ACTIVE    ${vm_name}
1173     Close Connection
1174
1175 Remove RSA Key From KnowHosts
1176     [Arguments]    ${vm_ip}
1177     [Documentation]    Remove RSA
1178     ${devstack_conn_id}=    Get ControlNode Connection
1179     Switch Connection    ${devstack_conn_id}
1180     ${output}=    Write Commands Until Prompt    sudo cat /root/.ssh/known_hosts    30s
1181     Log    ${output}
1182     ${output}=    Write Commands Until Prompt    sudo ssh-keygen -f "/root/.ssh/known_hosts" -R ${vm_ip}    30s
1183     Log    ${output}
1184     ${output}=    Write Commands Until Prompt    sudo cat "/root/.ssh/known_hosts"    30s
1185
1186 Wait For Routes To Propogate
1187     [Arguments]    ${networks}    ${subnets}
1188     [Documentation]    Check propagated routes
1189     ${devstack_conn_id} =    Get ControlNode Connection
1190     Switch Connection    ${devstack_conn_id}
1191     : FOR    ${INDEX}    IN RANGE    0    1
1192     \    ${net_id}=    Get Net Id    @{networks}[${INDEX}]    ${devstack_conn_id}
1193     \    ${is_ipv6}=    Get Regexp Matches    @{subnets}[${INDEX}]    ${IP6_REGEX}
1194     \    ${length}=    Get Length    ${is_ipv6}
1195     \    ${cmd}=    Set Variable If    ${length} == 0    ip route    ip -6 route
1196     \    ${output}=    Write Commands Until Expected Prompt    sudo ip netns exec qdhcp-${net_id} ${cmd}    ]>
1197     \    Should Contain    ${output}    @{subnets}[${INDEX}]