L2Gw Test Cases Suite1
[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           SSHLibrary
4 Resource          Netvirt.robot
5 Resource          Utils.robot
6 Resource          L2GatewayOperations.robot
7 Resource          ../variables/Variables.robot
8
9 *** Keywords ***
10 Source Password
11     [Arguments]    ${force}=no    ${source_pwd}=yes
12     [Documentation]    Sourcing the Openstack PAsswords for neutron configurations
13     Run Keyword If    '${source_pwd}' == 'yes' or '${force}' == 'yes'    Write Commands Until Prompt    cd ${DEVSTACK_DEPLOY_PATH}; source openrc admin admin
14
15 Get Tenant ID From Security Group
16     [Documentation]    Returns tenant ID by reading it from existing default security-group.
17     ${devstack_conn_id}=    Get ControlNode Connection
18     Switch Connection    ${devstack_conn_id}
19     ${output}=    Write Commands Until Prompt    neutron security-group-show default | grep "| tenant_id" | awk '{print $4}'
20     Log    ${output}
21     [Return]    ${output}
22
23 Get Tenant ID From Network
24     [Arguments]    ${network_uuid}
25     [Documentation]    Returns tenant ID by reading it from existing network.
26     ${resp}=    Get_From_Uri    uri=${CONFIG_API}/neutron:neutron/networks/network/${network_uuid}/    accept=${ACCEPT_EMPTY}    session=session
27     ${tenant_id}=    Utils.Extract Value From Content    ${resp}    /network/0/tenant-id    strip
28     [Return]    ${tenant_id}
29
30 Create Network
31     [Arguments]    ${network_name}    ${additional_args}=${EMPTY}    ${verbose}=TRUE
32     [Documentation]    Create Network with neutron request.
33     ${devstack_conn_id}=    Get ControlNode Connection
34     Switch Connection    ${devstack_conn_id}
35     ${command}    Set Variable If    "${verbose}" == "TRUE"    neutron -v net-create ${network_name} ${additional_args}    neutron net-create ${network_name} ${additional_args} | grep -w id | awk '{print $4}'
36     ${output}=    Write Commands Until Prompt    ${command}    30s
37     Log    ${output}
38     [Return]    ${output}
39
40 List Networks
41     [Documentation]    List networks and return output with neutron client.
42     ${devstack_conn_id}=    Get ControlNode Connection
43     Switch Connection    ${devstack_conn_id}
44     ${output}=    Write Commands Until Prompt    neutron net-list    30s
45     Close Connection
46     Log    ${output}
47     [Return]    ${output}
48
49 List Subnets
50     [Documentation]    List subnets and return output with neutron client.
51     ${devstack_conn_id}=    Get ControlNode Connection
52     Switch Connection    ${devstack_conn_id}
53     ${output}=    Write Commands Until Prompt    neutron subnet-list    30s
54     Close Connection
55     Log    ${output}
56     [Return]    ${output}
57
58 Delete Network
59     [Arguments]    ${network_name}
60     [Documentation]    Delete Network with neutron request.
61     ${devstack_conn_id}=    Get ControlNode Connection
62     Switch Connection    ${devstack_conn_id}
63     ${output}=    Write Commands Until Prompt    neutron -v net-delete ${network_name}    30s
64     Close Connection
65     Log    ${output}
66     Should Match Regexp    ${output}    Deleted network: ${network_name}|Deleted network\\(s\\): ${network_name}
67
68 Create SubNet
69     [Arguments]    ${network_name}    ${subnet}    ${range_ip}    ${additional_args}=${EMPTY}
70     [Documentation]    Create SubNet for the Network with neutron request.
71     ${devstack_conn_id}=    Get ControlNode Connection
72     Switch Connection    ${devstack_conn_id}
73     ${output}=    Write Commands Until Prompt    neutron -v subnet-create ${network_name} ${range_ip} --name ${subnet} ${additional_args}    30s
74     Close Connection
75     Log    ${output}
76     Should Contain    ${output}    Created a new subnet
77
78 Create Port
79     [Arguments]    ${network_name}    ${port_name}    ${sg}=default    ${additional_args}=${EMPTY}
80     [Documentation]    Create Port with neutron request.
81     ${devstack_conn_id}=    Get ControlNode Connection
82     Switch Connection    ${devstack_conn_id}
83     ${output}=    Write Commands Until Prompt    neutron -v port-create ${network_name} --name ${port_name} --security-group ${sg} ${additional_args}    30s
84     Close Connection
85     Log    ${output}
86     Should Contain    ${output}    Created a new port
87
88 Delete Port
89     [Arguments]    ${port_name}
90     [Documentation]    Delete Port with neutron request.
91     ${devstack_conn_id}=    Get ControlNode Connection
92     Switch Connection    ${devstack_conn_id}
93     ${output}=    Write Commands Until Prompt    neutron -v port-delete ${port_name}    30s
94     Close Connection
95     Log    ${output}
96     Should Match Regexp    ${output}    Deleted port: ${port_name}|Deleted port\\(s\\): ${port_name}
97
98 List Ports
99     [Documentation]    List ports and return output with neutron client.
100     ${devstack_conn_id}=    Get ControlNode Connection
101     Switch Connection    ${devstack_conn_id}
102     ${output}=    Write Commands Until Prompt    neutron port-list    30s
103     Close Connection
104     Log    ${output}
105     [Return]    ${output}
106
107 List Nova VMs
108     [Documentation]    List VMs and return output with nova client.
109     ${devstack_conn_id}=    Get ControlNode Connection
110     Switch Connection    ${devstack_conn_id}
111     ${output}=    Write Commands Until Prompt    nova list    30s
112     Close Connection
113     Log    ${output}
114     [Return]    ${output}
115
116 Create And Associate Floating IPs
117     [Arguments]    ${external_net}    @{vm_list}
118     [Documentation]    Create and associate floating IPs to VMs with nova request
119     ${devstack_conn_id}=    Get ControlNode Connection
120     Switch Connection    ${devstack_conn_id}
121     ${ip_list}=    Create List    @{EMPTY}
122     : FOR    ${vm}    IN    @{vm_list}
123     \    ${output}=    Write Commands Until Prompt    neutron floatingip-create ${external_net}    30s
124     \    Log    ${output}
125     \    @{ip}    Get Regexp Matches    ${output}    [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
126     \    ${ip_length}    Get Length    ${ip}
127     \    Run Keyword If    ${ip_length}>0    Append To List    ${ip_list}    @{ip}[0]
128     \    ...    ELSE    Append To List    ${ip_list}    None
129     \    ${output}=    Write Commands Until Prompt    nova floating-ip-associate ${vm} @{ip}[0]    30s
130     \    Log    ${output}
131     [Return]    ${ip_list}
132
133 Verify Gateway Ips
134     [Documentation]    Verifies the Gateway Ips with dump flow.
135     ${output}=    Write Commands Until Prompt    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
136     Log    ${output}
137     : FOR    ${GatewayIpElement}    IN    @{GATEWAY_IPS}
138     \    Should Contain    ${output}    ${GatewayIpElement}
139
140 Verify Dhcp Ips
141     [Documentation]    Verifies the Dhcp Ips with dump flow.
142     ${output}=    Write Commands Until Prompt    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
143     Log    ${output}
144     : FOR    ${DhcpIpElement}    IN    @{DHCP_IPS}
145     \    Should Contain    ${output}    ${DhcpIpElement}
146
147 Verify No Dhcp Ips
148     [Documentation]    Verifies the Dhcp Ips with dump flow.
149     ${output}=    Write Commands Until Prompt    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
150     Log    ${output}
151     : FOR    ${DhcpIpElement}    IN    @{DHCP_IPS}
152     \    Should Not Contain    ${output}    ${DhcpIpElement}
153
154 Delete SubNet
155     [Arguments]    ${subnet}
156     [Documentation]    Delete SubNet for the Network with neutron request.
157     Log    ${subnet}
158     ${devstack_conn_id}=    Get ControlNode Connection
159     Switch Connection    ${devstack_conn_id}
160     ${output}=    Write Commands Until Prompt    neutron -v subnet-delete ${subnet}
161     Close Connection
162     Log    ${output}
163     Should Match Regexp    ${output}    Deleted subnet: ${subnet}|Deleted subnet\\(s\\): ${subnet}
164
165 Verify No Gateway Ips
166     [Documentation]    Verifies the Gateway Ips removed with dump flow.
167     ${output}=    Write Commands Until Prompt    sudo ovs-ofctl -O OpenFlow13 dump-flows br-int
168     Log    ${output}
169     : FOR    ${GatewayIpElement}    IN    @{GATEWAY_IPS}
170     \    Should Not Contain    ${output}    ${GatewayIpElement}
171
172 Delete Vm Instance
173     [Arguments]    ${vm_name}
174     [Documentation]    Delete Vm instances using instance names.
175     ${devstack_conn_id}=    Get ControlNode Connection
176     Switch Connection    ${devstack_conn_id}
177     ${output}=    Write Commands Until Prompt    nova force-delete ${vm_name}    40s
178     Close Connection
179
180 Get Net Id
181     [Arguments]    ${network_name}    ${devstack_conn_id}
182     [Documentation]    Retrieve the net id for the given network name to create specific vm instance
183     Switch Connection    ${devstack_conn_id}
184     ${output}=    Write Commands Until Prompt    neutron net-list | grep "${network_name}" | awk '{print $2}'    30s
185     Log    ${output}
186     ${splitted_output}=    Split String    ${output}    ${EMPTY}
187     ${net_id}=    Get from List    ${splitted_output}    0
188     Log    ${net_id}
189     [Return]    ${net_id}
190
191 Get Subnet Id
192     [Arguments]    ${subnet_name}    ${devstack_conn_id}
193     [Documentation]    Retrieve the subnet id for the given subnet name
194     Switch Connection    ${devstack_conn_id}
195     ${output}=    Write Commands Until Prompt    neutron subnet-list | grep "${subnet_name}" | awk '{print $2}'    30s
196     Log    ${output}
197     ${splitted_output}=    Split String    ${output}    ${EMPTY}
198     ${subnet_id}=    Get from List    ${splitted_output}    0
199     Log    ${subnet_id}
200     [Return]    ${subnet_id}
201
202 Get Port Id
203     [Arguments]    ${port_name}    ${devstack_conn_id}
204     [Documentation]    Retrieve the port id for the given port name to attach specific vm instance to a particular port
205     Switch Connection    ${devstack_conn_id}
206     ${output}=    Write Commands Until Prompt    neutron port-list | grep "${port_name}" | awk '{print $2}'    30s
207     Log    ${output}
208     ${splitted_output}=    Split String    ${output}    ${EMPTY}
209     ${port_id}=    Get from List    ${splitted_output}    0
210     Log    ${port_id}
211     [Return]    ${port_id}
212
213 Get Router Id
214     [Arguments]    ${router1}    ${devstack_conn_id}
215     [Documentation]    Retrieve the router id for the given router name
216     Switch Connection    ${devstack_conn_id}
217     ${output}=    Write Commands Until Prompt    neutron router-list | grep "${router1}" | awk '{print $2}'    30s
218     Log    ${output}
219     ${splitted_output}=    Split String    ${output}    ${EMPTY}
220     ${router_id}=    Get from List    ${splitted_output}    0
221     Log    ${router_id}
222     [Return]    ${router_id}
223
224 Create Vm Instances
225     [Arguments]    ${net_name}    ${vm_instance_names}    ${image}=cirros-0.3.4-x86_64-uec    ${flavor}=m1.nano    ${sg}=default
226     [Documentation]    Create X Vm Instance with the net id of the Netowrk.
227     ${devstack_conn_id}=    Get ControlNode Connection
228     Switch Connection    ${devstack_conn_id}
229     ${net_id}=    Get Net Id    ${net_name}    ${devstack_conn_id}
230     : FOR    ${VmElement}    IN    @{vm_instance_names}
231     \    ${output}=    Write Commands Until Prompt    nova boot --image ${image} --flavor ${flavor} --nic net-id=${net_id} ${VmElement} --security-groups ${sg}    30s
232     \    Log    ${output}
233
234 Create Vm Instance With Port On Compute Node
235     [Arguments]    ${port_name}    ${vm_instance_name}    ${compute_node}    ${image}=cirros-0.3.4-x86_64-uec    ${flavor}=m1.nano    ${sg}=default
236     [Documentation]    Create One VM instance using given ${port_name} and for given ${compute_node}
237     ${devstack_conn_id}=    Get ControlNode Connection
238     Switch Connection    ${devstack_conn_id}
239     ${port_id}=    Get Port Id    ${port_name}    ${devstack_conn_id}
240     ${hostname_compute_node}=    Run Command On Remote System    ${compute_node}    hostname
241     ${output}=    Write Commands Until Prompt    nova boot --image ${image} --flavor ${flavor} --nic port-id=${port_id} ${vm_instance_name} --security-groups ${sg} --availability-zone nova:${hostname_compute_node}    30s
242     Log    ${output}
243
244 Verify VM Is ACTIVE
245     [Arguments]    ${vm_name}
246     [Documentation]    Run these commands to check whether the created vm instance is active or not.
247     ${devstack_conn_id}=    Get ControlNode Connection
248     Switch Connection    ${devstack_conn_id}
249     ${output}=    Write Commands Until Prompt    nova show ${vm_name} | grep OS-EXT-STS:vm_state    30s
250     Log    ${output}
251     Should Contain    ${output}    active
252
253 Verify VMs Received DHCP Lease
254     [Arguments]    @{vm_list}
255     [Documentation]    Using nova console-log on the provided ${vm_list} to search for the string "obtained" which
256     ...    correlates to the instance receiving it's IP address via DHCP. Also retrieved is the ip of the nameserver
257     ...    if available in the console-log output. The keyword will also return a list of the learned ips as it
258     ...    finds them in the console log output, and will have "None" for Vms that no ip was found.
259     ${devstack_conn_id}=    Get ControlNode Connection
260     Switch Connection    ${devstack_conn_id}
261     ${ip_list}    Create List    @{EMPTY}
262     ${dhcp_ip}    Create List    @{EMPTY}
263     : FOR    ${vm}    IN    @{vm_list}
264     \    ${vm_ip_line}=    Write Commands Until Prompt    nova console-log ${vm} | grep -i "obtained"    30s
265     \    Log    ${vm_ip_line}
266     \    @{vm_ip}    Get Regexp Matches    ${vm_ip_line}    [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
267     \    ${vm_ip_length}    Get Length    ${vm_ip}
268     \    Run Keyword If    ${vm_ip_length}>0    Append To List    ${ip_list}    @{vm_ip}[0]
269     \    ...    ELSE    Append To List    ${ip_list}    None
270     \    ${dhcp_ip_line}=    Write Commands Until Prompt    nova console-log ${vm} | grep "^nameserver"    30s
271     \    Log    ${dhcp_ip_line}
272     \    @{dhcp_ip}    Get Regexp Matches    ${dhcp_ip_line}    [0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}\\.[0-9]{1,3}
273     \    ${dhcp_ip_length}    Get Length    ${dhcp_ip}
274     \    Run Keyword If    ${dhcp_ip_length}<=0    Append To List    ${dhcp_ip}    None
275     \    Log    ${dhcp_ip}
276     ${dhcp_length}    Get Length    ${dhcp_ip}
277     Return From Keyword If    ${dhcp_length}==0    ${ip_list}    ${EMPTY}
278     [Return]    ${ip_list}    @{dhcp_ip}[0]
279
280 View Vm Console
281     [Arguments]    ${vm_instance_names}
282     [Documentation]    View Console log of the created vm instances using nova show.
283     : FOR    ${VmElement}    IN    @{vm_instance_names}
284     \    ${output}=    Write Commands Until Prompt    nova show ${VmElement}
285     \    Log    ${output}
286     \    ${output}=    Write Commands Until Prompt    nova console-log ${VmElement}
287     \    Log    ${output}
288
289 Ping Vm From DHCP Namespace
290     [Arguments]    ${net_name}    ${vm_ip}
291     [Documentation]    Reach all Vm Instance with the net id of the Netowrk.
292     Log    ${vm_ip}
293     ${devstack_conn_id}=    Get ControlNode Connection
294     Switch Connection    ${devstack_conn_id}
295     ${net_id}=    Get Net Id    ${net_name}    ${devstack_conn_id}
296     Log    ${net_id}
297     ${output}=    Write Commands Until Prompt    sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip}    20s
298     Log    ${output}
299     Close Connection
300     Should Contain    ${output}    64 bytes
301
302 Ping From DHCP Should Not Succeed
303     [Arguments]    ${net_name}    ${vm_ip}
304     [Documentation]    Should Not Reach Vm Instance with the net id of the Netowrk.
305     Log    ${vm_ip}
306     ${devstack_conn_id}=    Get ControlNode Connection
307     Switch Connection    ${devstack_conn_id}
308     ${net_id}=    Get Net Id    ${net_name}    ${devstack_conn_id}
309     Log    ${net_id}
310     ${output}=    Write Commands Until Prompt    sudo ip netns exec qdhcp-${net_id} ping -c 3 ${vm_ip}    20s
311     Close Connection
312     Log    ${output}
313     Should Not Contain    ${output}    64 bytes
314
315 Ping Vm From Control Node
316     [Arguments]    ${vm_floating_ip}
317     [Documentation]    Ping VM floating IP from control node
318     Log    ${vm_floating_ip}
319     ${devstack_conn_id}=    Get ControlNode Connection
320     Switch Connection    ${devstack_conn_id}
321     ${output}=    Write Commands Until Prompt    ping -c 3 ${vm_floating_ip}    20s
322     Log    ${output}
323     Close Connection
324     Should Contain    ${output}    64 bytes
325
326 Ping From Instance
327     [Arguments]    ${dest_vm_ip}
328     [Documentation]    Ping to the expected destination ip.
329     ${output}=    Write Commands Until Expected Prompt    ping -c 3 ${dest_vm_ip}    ${OS_SYSTEM_PROMPT}
330     Log    ${output}
331     [Return]    ${output}
332
333 Curl Metadata Server
334     [Documentation]    Ping to the expected destination ip.
335     ${output}=    Write Commands Until Expected Prompt    curl -i http://169.254.169.254    ${OS_SYSTEM_PROMPT}
336     Write Commands Until Prompt    exit
337     Should Contain    ${output}    200
338
339 Close Vm Instance
340     [Documentation]    Exit the vm instance.
341     ${output}=    Write Commands Until Prompt    exit
342     Log    ${output}
343
344 Check If Console Is VmInstance
345     [Arguments]    ${console}=cirros
346     [Documentation]    Check if the session has been able to login to the VM instance
347     ${output}=    Write Commands Until Expected Prompt    id    ${OS_SYSTEM_PROMPT}
348     Should Contain    ${output}    ${console}
349
350 Exit From Vm Console
351     [Documentation]    Check if the session has been able to login to the VM instance and exit the instance
352     ${rcode}=    Run Keyword And Return Status    Check If Console Is VmInstance    cirros
353     Run Keyword If    ${rcode}    Write Commands Until Prompt    exit
354
355 Check Ping
356     [Arguments]    ${ip_address}
357     [Documentation]    Run Ping command on the IP available as argument
358     ${output}=    Write Commands Until Expected Prompt    ping -c 3 ${ip_address}    ${OS_SYSTEM_PROMPT}
359     Should Contain    ${output}    64 bytes
360
361 Check Metadata Access
362     [Documentation]    Try curl on the Metadataurl and check if it is okay
363     ${output}=    Write Commands Until Expected Prompt    curl -i http://169.254.169.254    ${OS_SYSTEM_PROMPT}
364     Should Contain    ${output}    200
365
366 Execute Command on VM Instance
367     [Arguments]    ${net_name}    ${vm_ip}    ${cmd}    ${user}=cirros    ${password}=cubswin:)
368     [Documentation]    Login to the vm instance using ssh in the network, executes a command inside the VM and returns the ouput.
369     ${devstack_conn_id} =    Get ControlNode Connection
370     Switch Connection    ${devstack_conn_id}
371     ${net_id} =    Get Net Id    ${net_name}    ${devstack_conn_id}
372     Log    ${vm_ip}
373     ${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:
374     Log    ${output}
375     ${output} =    Write Commands Until Expected Prompt    ${password}    ${OS_SYSTEM_PROMPT}
376     Log    ${output}
377     ${rcode} =    Run Keyword And Return Status    Check If Console Is VmInstance
378     ${output} =    Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    ${cmd}    ${OS_SYSTEM_PROMPT}
379     [Teardown]    Exit From Vm Console
380     [Return]    ${output}
381
382 Test Operations From Vm Instance
383     [Arguments]    ${net_name}    ${src_ip}    ${dest_ips}    ${user}=cirros    ${password}=cubswin:)
384     [Documentation]    Login to the vm instance using ssh in the network.
385     ${devstack_conn_id}=    Get ControlNode Connection
386     Switch Connection    ${devstack_conn_id}
387     Log    ${src_ip}
388     ${net_id}=    Get Net Id    ${net_name}    ${devstack_conn_id}
389     ${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:
390     Log    ${output}
391     ${output}=    Write Commands Until Expected Prompt    ${password}    ${OS_SYSTEM_PROMPT}
392     Log    ${output}
393     ${rcode}=    Run Keyword And Return Status    Check If Console Is VmInstance
394     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    ifconfig    ${OS_SYSTEM_PROMPT}
395     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    route    ${OS_SYSTEM_PROMPT}
396     Run Keyword If    ${rcode}    Write Commands Until Expected Prompt    arp -an    ${OS_SYSTEM_PROMPT}
397     : FOR    ${dest_ip}    IN    @{dest_ips}
398     \    Log    ${dest_ip}
399     \    ${string_empty}=    Run Keyword And Return Status    Should Be Empty    ${dest_ip}
400     \    Run Keyword If    ${string_empty}    Continue For Loop
401     \    Run Keyword If    ${rcode}    Check Ping    ${dest_ip}
402     Run Keyword If    ${rcode}    Check Metadata Access
403     [Teardown]    Exit From Vm Console
404
405 Install Netcat On Controller
406     [Documentation]    Installs Netcat on the controller - this probably shouldn't be here
407     ${devstack_conn_id}=    Get ControlNode Connection
408     Switch Connection    ${devstack_conn_id}
409     ${output}=    Write Commands Until Prompt    sudo yum install -y nc
410     Log    ${output}
411     Close Connection
412
413 Test Netcat Operations From Vm Instance
414     [Arguments]    ${net_name}    ${vm_ip}    ${dest_ip}    ${additional_args}=${EMPTY}    ${port}=12345    ${user}=cirros
415     ...    ${password}=cubswin:)
416     [Documentation]    Use Netcat to test TCP/UDP connections to the controller
417     ${client_data}    Set Variable    Test Client Data
418     ${server_data}    Set Variable    Test Server Data
419     ${devstack_conn_id}=    Get ControlNode Connection
420     Switch Connection    ${devstack_conn_id}
421     Log    ${vm_ip}
422     ${output}=    Write Commands Until Prompt    ( ( echo "${server_data}" | sudo timeout 60 nc -l ${additional_args} ${port} ) & )
423     Log    ${output}
424     ${output}=    Write Commands Until Prompt    sudo netstat -nlap | grep ${port}
425     Log    ${output}
426     ${nc_output}=    Execute Command on VM Instance    ${net_name}    ${vm_ip}    sudo echo "${client_data}" | nc -v -w 5 ${additional_args} ${dest_ip} ${port}
427     Log    ${nc_output}
428     ${output}=    Execute Command on VM Instance    ${net_name}    ${vm_ip}    sudo route -n
429     Log    ${output}
430     ${output}=    Execute Command on VM Instance    ${net_name}    ${vm_ip}    sudo arp -an
431     Log    ${output}
432     Should Match Regexp    ${nc_output}    ${server_data}
433
434 Ping Other Instances
435     [Arguments]    ${list_of_external_dst_ips}
436     [Documentation]    Check reachability with other network's instances.
437     ${rcode}=    Run Keyword And Return Status    Check If Console Is VmInstance
438     : FOR    ${dest_ip}    IN    @{list_of_external_dst_ips}
439     \    Log    ${dest_ip}
440     \    Check Ping    ${dest_ip}
441
442 Create Router
443     [Arguments]    ${router_name}
444     [Documentation]    Create Router and Add Interface to the subnets.
445     ${devstack_conn_id}=    Get ControlNode Connection
446     Switch Connection    ${devstack_conn_id}
447     ${output}=    Write Commands Until Prompt    neutron -v router-create ${router_name}    30s
448     Close Connection
449     Should Contain    ${output}    Created a new router
450
451 List Router
452     [Documentation]    List Router and return output with neutron client.
453     ${devstack_conn_id}=    Get ControlNode Connection
454     Switch Connection    ${devstack_conn_id}
455     ${output}=    Write Commands Until Prompt    neutron router-list    30s
456     Close Connection
457     Log    ${output}
458     [Return]    ${output}
459
460 Add Router Interface
461     [Arguments]    ${router_name}    ${interface_name}
462     ${devstack_conn_id}=    Get ControlNode Connection
463     Switch Connection    ${devstack_conn_id}
464     ${output}=    Write Commands Until Prompt    neutron -v router-interface-add ${router_name} ${interface_name}
465     Close Connection
466     Should Contain    ${output}    Added interface
467
468 Show Router Interface
469     [Arguments]    ${router_name}
470     [Documentation]    List Router interface associated with given Router and return output with neutron client.
471     ${devstack_conn_id}=    Get ControlNode Connection
472     Switch Connection    ${devstack_conn_id}
473     ${output}=    Write Commands Until Prompt    neutron router-port-list ${router_name} -f csv    30s
474     Close Connection
475     Log    ${output}
476     [Return]    ${output}
477
478 Add Router Gateway
479     [Arguments]    ${router_name}    ${network_name}
480     ${devstack_conn_id}=    Get ControlNode Connection
481     Switch Connection    ${devstack_conn_id}
482     ${output}=    Write Commands Until Prompt    neutron -v router-gateway-set ${router_name} ${network_name}
483     Close Connection
484     Should Contain    ${output}    Set gateway
485
486 Remove Interface
487     [Arguments]    ${router_name}    ${interface_name}
488     [Documentation]    Remove Interface to the subnets.
489     ${devstack_conn_id}=    Get ControlNode Connection
490     Switch Connection    ${devstack_conn_id}
491     ${output}=    Write Commands Until Prompt    neutron -v router-interface-delete ${router_name} ${interface_name}
492     Close Connection
493     Should Contain    ${output}    Removed interface from router
494
495 Update Router
496     [Arguments]    ${router_name}    ${cmd}
497     [Documentation]    Update the router with the command. Router name and command should be passed as argument.
498     ${devstack_conn_id} =    Get ControlNode Connection
499     Switch Connection    ${devstack_conn_id}
500     ${output} =    Write Commands Until Prompt    neutron router-update ${router_name} ${cmd}    30s
501     Close Connection
502     Should Contain    ${output}    Updated
503
504 Show Router
505     [Arguments]    ${router_name}    ${options}
506     [Documentation]    Show information of a given router. Router name and optional fields should be sent as arguments.
507     ${devstack_conn_id} =    Get ControlNode Connection
508     Switch Connection    ${devstack_conn_id}
509     ${output} =    Write Commands Until Prompt    neutron router-show ${router_name} ${options}    30s
510     Log    ${output}
511     Close Connection
512
513 Delete Router
514     [Arguments]    ${router_name}
515     [Documentation]    Delete Router and Interface to the subnets.
516     ${devstack_conn_id}=    Get ControlNode Connection
517     Switch Connection    ${devstack_conn_id}
518     ${output}=    Write Commands Until Prompt    neutron -v router-delete ${router_name}    60s
519     Close Connection
520     Should Match Regexp    ${output}    Deleted router: ${router_name}|Deleted router\\(s\\): ${router_name}
521
522 Get DumpFlows And Ovsconfig
523     [Arguments]    ${openstack_node_ip}
524     [Documentation]    Get the OvsConfig and Flow entries from OVS from the Openstack Node
525     Log    ${openstack_node_ip}
526     SSHLibrary.Open Connection    ${openstack_node_ip}    prompt=${DEFAULT_LINUX_PROMPT}
527     Utils.Flexible SSH Login    ${OS_USER}    ${DEVSTACK_SYSTEM_PASSWORD}
528     SSHLibrary.Set Client Configuration    timeout=${default_devstack_prompt_timeout}
529     Write Commands Until Expected Prompt    ip -o link    ${DEFAULT_LINUX_PROMPT_STRICT}
530     Write Commands Until Expected Prompt    ip -o addr    ${DEFAULT_LINUX_PROMPT_STRICT}
531     Write Commands Until Expected Prompt    ip route    ${DEFAULT_LINUX_PROMPT_STRICT}
532     Write Commands Until Expected Prompt    arp -an    ${DEFAULT_LINUX_PROMPT_STRICT}
533     ${nslist}=    Write Commands Until Expected Prompt    ip netns list | awk '{print $1}'    ${DEFAULT_LINUX_PROMPT_STRICT}
534     @{lines}    Split To Lines    ${nslist}
535     : FOR    ${line}    IN    @{lines}
536     \    Write Commands Until Expected Prompt    sudo ip netns exec ${line} ip -o link    ${DEFAULT_LINUX_PROMPT_STRICT}
537     \    Write Commands Until Expected Prompt    sudo ip netns exec ${line} ip -o addr    ${DEFAULT_LINUX_PROMPT_STRICT}
538     \    Write Commands Until Expected Prompt    sudo ip netns exec ${line} ip route    ${DEFAULT_LINUX_PROMPT_STRICT}
539     Write Commands Until Expected Prompt    sudo ovs-vsctl show    ${DEFAULT_LINUX_PROMPT_STRICT}
540     Write Commands Until Expected Prompt    sudo ovs-vsctl list Open_vSwitch    ${DEFAULT_LINUX_PROMPT_STRICT}
541     Write Commands Until Expected Prompt    sudo ovs-ofctl show br-int -OOpenFlow13    ${DEFAULT_LINUX_PROMPT_STRICT}
542     Write Commands Until Expected Prompt    sudo ovs-ofctl dump-flows br-int -OOpenFlow13    ${DEFAULT_LINUX_PROMPT_STRICT}
543     Write Commands Until Expected Prompt    sudo ovs-ofctl dump-groups br-int -OOpenFlow13    ${DEFAULT_LINUX_PROMPT_STRICT}
544     Write Commands Until Expected Prompt    sudo ovs-ofctl dump-group-stats br-int -OOpenFlow13    ${DEFAULT_LINUX_PROMPT_STRICT}
545
546 Get Karaf Log Type From Test Start
547     [Arguments]    ${ip}    ${test_name}    ${type}    ${user}=${ODL_SYSTEM_USER}    ${password}=${ODL_SYSTEM_PASSWORD}    ${prompt}=${ODL_SYSTEM_PROMPT}
548     ...    ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
549     ${cmd}    Set Variable    sed '1,/ROBOT MESSAGE: Starting test ${test_name}/d' ${log_file} | grep '${type}'
550     ${output}    Run Command On Controller    ${ip}    ${cmd}    ${user}    ${password}    ${prompt}
551     Log    ${output}
552
553 Get Karaf Log Types From Test Start
554     [Arguments]    ${ip}    ${test_name}    ${types}    ${user}=${ODL_SYSTEM_USER}    ${password}=${ODL_SYSTEM_PASSWORD}    ${prompt}=${ODL_SYSTEM_PROMPT}
555     ...    ${log_file}=${WORKSPACE}/${BUNDLEFOLDER}/data/log/karaf.log
556     : FOR    ${type}    IN    @{types}
557     \    Get Karaf Log Type From Test Start    ${ip}    ${test_name}    ${type}    ${user}    ${password}
558     \    ...    ${prompt}    ${log_file}
559
560 Get Karaf Log Events From Test Start
561     [Arguments]    ${test_name}    ${user}=${ODL_SYSTEM_USER}    ${password}=${ODL_SYSTEM_PASSWORD}    ${prompt}=${ODL_SYSTEM_PROMPT}
562     ${log_types} =    Create List    ERROR    WARN    Exception
563     Run Keyword If    0 < ${NUM_ODL_SYSTEM}    Get Karaf Log Types From Test Start    ${ODL_SYSTEM_IP}    ${test_name}    ${log_types}
564     Run Keyword If    1 < ${NUM_ODL_SYSTEM}    Get Karaf Log Types From Test Start    ${ODL_SYSTEM_2_IP}    ${test_name}    ${log_types}
565     Run Keyword If    2 < ${NUM_ODL_SYSTEM}    Get Karaf Log Types From Test Start    ${ODL_SYSTEM_3_IP}    ${test_name}    ${log_types}
566
567 Get ControlNode Connection
568     ${control_conn_id}=    SSHLibrary.Open Connection    ${OS_CONTROL_NODE_IP}    prompt=${DEFAULT_LINUX_PROMPT_STRICT}
569     Utils.Flexible SSH Login    ${OS_USER}    ${DEVSTACK_SYSTEM_PASSWORD}
570     SSHLibrary.Set Client Configuration    timeout=30s
571     Source Password    force=yes
572     [Return]    ${control_conn_id}
573
574 Get OvsDebugInfo
575     [Documentation]    Get the OvsConfig and Flow entries from all Openstack nodes
576     Run Keyword If    0 < ${NUM_OS_SYSTEM}    Get DumpFlows And Ovsconfig    ${OS_CONTROL_NODE_IP}
577     Run Keyword If    1 < ${NUM_OS_SYSTEM}    Get DumpFlows And Ovsconfig    ${OS_COMPUTE_1_IP}
578     Run Keyword If    2 < ${NUM_OS_SYSTEM}    Get DumpFlows And Ovsconfig    ${OS_COMPUTE_2_IP}
579
580 Get Test Teardown Debugs
581     [Arguments]    ${test_name}=${TEST_NAME}
582     Get OvsDebugInfo
583     Run Keyword And Ignore Error    Get Model Dump    ${HA_PROXY_IP}
584     Get Karaf Log Events From Test Start    ${test_name}
585
586 Get Suite Teardown Debugs
587     Get OvsDebugInfo
588     Get Model Dump    ${HA_PROXY_IP}
589
590 Show Debugs
591     [Arguments]    @{vm_indices}
592     [Documentation]    Run these commands for debugging, it can list state of VM instances and ip information in control node
593     ${devstack_conn_id}=    Get ControlNode Connection
594     Switch Connection    ${devstack_conn_id}
595     ${output}=    Write Commands Until Prompt    sudo ip netns list
596     Log    ${output}
597     : FOR    ${index}    IN    @{vm_indices}
598     \    ${output}=    Write Commands Until Prompt    nova show ${index}    30s
599     \    Log    ${output}
600     Close Connection
601     List Nova VMs
602     List Networks
603     List Subnets
604     List Ports
605
606 Create Security Group
607     [Arguments]    ${sg_name}    ${desc}
608     ${devstack_conn_id}=    Get ControlNode Connection
609     Switch Connection    ${devstack_conn_id}
610     ${output}=    Write Commands Until Prompt    nova secgroup-create ${sg_name} ${desc}    40s
611     Close Connection
612
613 Create Security Rule
614     [Arguments]    ${direction}    ${protocol}    ${min_port}    ${max_port}    ${remote_ip}    ${sg_name}
615     ${devstack_conn_id}=    Get ControlNode Connection
616     Switch Connection    ${devstack_conn_id}
617     ${output}=    Write Commands Until Prompt    neutron security-group-rule-create --direction ${direction} --protocol ${protocol} --port-range-min ${min_port} --port-range-max ${max_port} --remote-ip-prefix ${remote_ip} ${sg_name}
618     Close Connection
619
620 Neutron Security Group Show
621     [Arguments]    ${SecurityGroupRuleName}    ${additional_args}=${EMPTY}
622     [Documentation]    Displays the neutron security group configurations that belongs to a given neutron security group name
623     ${devstack_conn_id}=    Get ControlNode Connection
624     Switch Connection    ${devstack_conn_id}
625     ${cmd}=    Set Variable    neutron security-group-show ${SecurityGroupRuleName} ${additional_args}
626     Log    ${cmd}
627     ${output}=    Write Commands Until Prompt    ${cmd}    30s
628     Log    ${output}
629     Close Connection
630     [Return]    ${output}
631
632 Neutron Port Show
633     [Arguments]    ${PortName}    ${additional_args}=${EMPTY}
634     [Documentation]    Display the port configuration that belong to a given neutron port
635     ${devstack_conn_id}=    Get ControlNode Connection
636     Switch Connection    ${devstack_conn_id}
637     ${cmd}=    Set Variable    neutron port-show ${PortName} ${additional_args}
638     Log    ${cmd}
639     ${output}=    Write Commands Until Prompt    ${cmd}    30s
640     Log    ${output}
641     Close Connection
642     [Return]    ${output}
643
644 Neutron Security Group Create
645     [Arguments]    ${SecurityGroupName}    ${additional_args}=${EMPTY}
646     [Documentation]    Create a security group with specified name ,description & protocol value according to security group template
647     ${devstack_conn_id}=    Get ControlNode Connection
648     Switch Connection    ${devstack_conn_id}
649     ${cmd}=    Set Variable    neutron security-group-create ${SecurityGroupName} ${additional_args}
650     Log    ${cmd}
651     ${output}=    Write Commands Until Prompt    ${cmd}    30s
652     Log    ${output}
653     Should Contain    ${output}    Created a new security_group
654     ${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}
655     Log    ${sgp_id}
656     Close Connection
657     [Return]    ${output}    ${sgp_id}
658
659 Neutron Security Group Update
660     [Arguments]    ${SecurityGroupName}    ${additional_args}=${EMPTY}
661     [Documentation]    Updating security groups
662     ${devstack_conn_id}=    Get ControlNode Connection
663     Switch Connection    ${devstack_conn_id}
664     ${cmd}=    Set Variable    neutron security-group-update ${SecurityGroupName} ${additional_args}
665     Log    ${cmd}
666     ${output}=    Write Commands Until Prompt    ${cmd}    30s
667     Log    ${output}
668     Close Connection
669     [Return]    ${output}
670
671 Delete SecurityGroup
672     [Arguments]    ${sg_name}
673     [Documentation]    Delete Security group
674     ${devstack_conn_id}=    Get ControlNode Connection
675     Switch Connection    ${devstack_conn_id}
676     ${output}=    Write Commands Until Prompt    neutron security-group-delete ${sg_name}    40s
677     Log    ${output}
678     Should Match Regexp    ${output}    Deleted security_group: ${sg_name}|Deleted security_group\\(s\\): ${sg_name}
679     Close Connection
680
681 Neutron Security Group Rule Create
682     [Arguments]    ${Security_group_name}    &{Kwargs}
683     [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]} ..."
684     ${devstack_conn_id}=    Get ControlNode Connection
685     Switch Connection    ${devstack_conn_id}
686     Run Keyword If    ${Kwargs}    Log    ${Kwargs}
687     ${description}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    description    default=${None}
688     ${direction}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    direction    default=${None}
689     ${ethertype}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    ethertype    default=${None}
690     ${port_range_max}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    port_range_max    default=${None}
691     ${port_range_min}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    port_range_min    default=${None}
692     ${protocol}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    protocol    default=${None}
693     ${remote_group_id}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    remote_group_id    default=${None}
694     ${remote_ip_prefix}    Run Keyword If    ${Kwargs}    Pop From Dictionary    ${Kwargs}    remote_ip_prefix    default=${None}
695     ${cmd}=    Set Variable    neutron security-group-rule-create ${Security_group_name}
696     ${cmd}=    Run Keyword If    '${description}'!='None'    Catenate    ${cmd}    --description ${description}
697     ...    ELSE    Catenate    ${cmd}
698     ${cmd}=    Run Keyword If    '${direction}'!='None'    Catenate    ${cmd}    --direction ${direction}
699     ...    ELSE    Catenate    ${cmd}
700     ${cmd}=    Run Keyword If    '${ethertype}'!='None'    Catenate    ${cmd}    --ethertype ${ethertype}
701     ...    ELSE    Catenate    ${cmd}
702     ${cmd}=    Run Keyword If    '${port_range_max}'!='None'    Catenate    ${cmd}    --port_range_max ${port_range_max}
703     ...    ELSE    Catenate    ${cmd}
704     ${cmd}=    Run Keyword If    '${port_range_min}'!='None'    Catenate    ${cmd}    --port_range_min ${port_range_min}
705     ...    ELSE    Catenate    ${cmd}
706     ${cmd}=    Run Keyword If    '${protocol}'!='None'    Catenate    ${cmd}    --protocol ${protocol}
707     ...    ELSE    Catenate    ${cmd}
708     ${cmd}=    Run Keyword If    '${remote_group_id}'!='None'    Catenate    ${cmd}    --remote_group_id ${remote_group_id}
709     ...    ELSE    Catenate    ${cmd}
710     ${cmd}=    Run Keyword If    '${remote_ip_prefix}'!='None'    Catenate    ${cmd}    --remote_ip_prefix ${remote_ip_prefix}
711     ...    ELSE    Catenate    ${cmd}
712     ${output}=    Write Commands Until Prompt    ${cmd}    30s
713     ${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}
714     Log    ${rule_id}
715     Should Contain    ${output}    Created a new security_group_rule
716     Close Connection
717     [Return]    ${output}    ${rule_id}
718
719 Create Neutron Port With Additional Params
720     [Arguments]    ${network_name}    ${port_name}    ${additional_args}=${EMPTY}
721     [Documentation]    Create Port With given additional parameters
722     ${devstack_conn_id}=    Get ControlNode Connection
723     Switch Connection    ${devstack_conn_id}
724     ${cmd}=    Set Variable    neutron -v port-create ${network_name} --name ${port_name} ${additional_args}
725     Log    ${cmd}
726     ${OUTPUT}=    Write Commands Until Prompt    ${cmd}    30s
727     Log    ${OUTPUT}
728     Should Contain    ${output}    Created a new port
729     ${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}
730     Log    ${port_id}
731     Close Connection
732     [Return]    ${OUTPUT}    ${port_id}
733
734 Get Ports MacAddr
735     [Arguments]    ${portName_list}
736     [Documentation]    Retrieve the port MacAddr for the given list of port name and return the MAC address list.
737     ${devstack_conn_id}=    Get ControlNode Connection
738     Switch Connection    ${devstack_conn_id}
739     ${MacAddr-list}    Create List
740     : FOR    ${portName}    IN    @{portName_list}
741     \    ${macAddr}=    OpenStackOperations.Get Port Mac    ${portName}    ${devstack_conn_id}
742     \    Append To List    ${MacAddr-list}    ${macAddr}
743     [Return]    ${MacAddr-list}
744
745 Get Port Ip
746     [Arguments]    ${port_name}
747     [Documentation]    Keyword would return the IP of the ${port_name} received.
748     Switch Connection    ${devstack_conn_id}
749     ${output}=    Write Commands Until Prompt    neutron port-list | grep "${port_name}" | awk '{print $11}' | awk -F "\\"" '{print $2}'    30s
750     Log    ${output}
751     ${splitted_output}=    Split String    ${output}    ${EMPTY}
752     ${port_ip}=    Get from List    ${splitted_output}    0
753     Log    ${port_ip}
754     [Return]    ${port_ip}
755
756 Get Port Mac
757     [Arguments]    ${port_name}    ${conn_id}=${devstack_conn_id}
758     [Documentation]    Keyword would return the MAC ID of the ${port_name} received.
759     Switch Connection    ${conn_id}
760     ${output}=    Write Commands Until Prompt    neutron port-list | grep "${port_name}" | awk '{print $6}'    30s
761     Log    ${output}
762     ${splitted_output}=    Split String    ${output}    ${EMPTY}
763     ${port_mac}=    Get from List    ${splitted_output}    0
764     Log    ${port_mac}
765     [Return]    ${port_mac}
766
767 Create L2Gateway
768     [Arguments]    ${bridge_name}    ${intf_name}    ${gw_name}
769     [Documentation]    Keyword to create an L2 Gateway ${gw_name} for bridge ${bridge_name} connected to interface ${intf_name} (Using Neutron CLI).
770     Switch Connection    ${devstack_conn_id}
771     ${l2gw_output}=    Write Commands Until Prompt    ${L2GW_CREATE} name=${bridge_name},interface_names=${intf_name} ${gw_name}    30s
772     Log    ${l2gw_output}
773     [Return]    ${l2gw_output}
774
775 Create L2Gateway Connection
776     [Arguments]    ${gw_name}    ${net_name}
777     [Documentation]    Keyword would create a new L2 Gateway Connection for ${gw_name} to ${net_name} (Using Neutron CLI).
778     Switch Connection    ${devstack_conn_id}
779     ${l2gw_output}=    Write Commands Until Prompt    ${L2GW_CONN_CREATE} ${gw_name} ${net_name}    30s
780     Log    ${l2gw_output}
781     [Return]    ${l2gw_output}
782
783 Get All L2Gateway
784     [Documentation]    Keyword to return all the L2 Gateways available (Using Neutron CLI).
785     Switch Connection    ${devstack_conn_id}
786     ${output}=    Write Commands Until Prompt    ${L2GW_GET_YAML}    30s
787     [Return]    ${output}
788
789 Get All L2Gateway Connection
790     [Documentation]    Keyword to return all the L2 Gateway connections available (Using Neutron CLI).
791     Switch Connection    ${devstack_conn_id}
792     ${output}=    Write Commands Until Prompt    ${L2GW_GET_CONN_YAML}    30s
793     [Return]    ${output}
794
795 Get L2Gateway
796     [Arguments]    ${gw_id}
797     [Documentation]    Keyword to check if the ${gw_id} is available in the L2 Gateway list (Using Neutron CLI).
798     Switch Connection    ${devstack_conn_id}
799     ${output}=    Write Commands Until Prompt    ${L2GW_SHOW} ${gw_id}    30s
800     Log    ${output}
801     [Return]    ${output}
802
803 Get L2gw Id
804     [Arguments]    ${l2gw_name}
805     [Documentation]    Keyword to retrieve the L2 Gateway ID for the ${l2gw_name} (Using Neutron CLI).
806     Switch Connection    ${devstack_conn_id}
807     ${output}=    Write Commands Until Prompt    ${L2GW_GET} | grep "${l2gw_name}" | awk '{print $2}'    30s
808     Log    ${output}
809     ${splitted_output}=    Split String    ${output}    ${EMPTY}
810     ${l2gw_id}=    Get from List    ${splitted_output}    0
811     Log    ${l2gw_id}
812     [Return]    ${l2gw_id}
813
814 Get L2gw Connection Id
815     [Arguments]    ${l2gw_name}
816     [Documentation]    Keyword to retrieve the L2 Gateway Connection ID for the ${l2gw_name} (Using Neutron CLI).
817     Switch Connection    ${devstack_conn_id}
818     ${l2gw_id}=    OpenStackOperations.Get L2gw Id    ${l2gw_name}
819     ${output}=    Write Commands Until Prompt    ${L2GW_GET_CONN} | grep "${l2gw_id}" | awk '{print $2}'    30s
820     Log    ${output}
821     ${splitted_output}=    Split String    ${output}    ${EMPTY}
822     ${l2gw_conn_id}=    Get from List    ${splitted_output}    0
823     Log    ${l2gw_conn_id}
824     [Return]    ${l2gw_conn_id}
825
826 Neutron Port List Rest
827     [Documentation]    Keyword to get all ports details in Neutron (Using REST).
828     ${resp} =    RequestsLibrary.Get Request    session    ${PORT_URL}
829     Log    ${resp.content}
830     Should Be Equal As Strings    ${resp.status_code}    200
831     [Return]    ${resp.content}
832
833 Get Neutron Port Rest
834     [Arguments]    ${port_id}
835     [Documentation]    Keyword to get the specific port details in Neutron (Using REST).
836     ${resp} =    RequestsLibrary.Get Request    session    ${CONFIG_API}/${GET_PORT_URL}/${port_id}
837     Log    ${resp.content}
838     Should Be Equal As Strings    ${resp.status_code}    200
839     [Return]    ${resp.content}
840
841 Update Port Rest
842     [Arguments]    ${port_id}    ${json_data}
843     [Documentation]    Keyword to update ${port_id} with json data received in ${json_data} (Using REST).
844     Log    ${json_data}
845     ${resp} =    RequestsLibrary.Put Request    session    ${CONFIG_API}/${GET_PORT_URL}/${port_id}    ${json_data}
846     Log    ${resp.content}
847     Should Be Equal As Strings    ${resp.status_code}    200
848     [Return]    ${resp.content}
849
850 Create And Configure Security Group
851     [Arguments]    ${sg-name}
852     Neutron Security Group Create    ${sg-name}
853     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
854     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
855     Neutron Security Group Rule Create    ${sg-name}    direction=ingress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
856     Neutron Security Group Rule Create    ${sg-name}    direction=egress    protocol=icmp    remote_ip_prefix=0.0.0.0/0
857     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
858     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