Align suite/test teardown/setup
[csit.git] / resources / libraries / robot / shared / qemu.robot
1 # Copyright (c) 2019 Cisco and/or its affiliates.
2 # Licensed under the Apache License, Version 2.0 (the "License");
3 # you may not use this file except in compliance with the License.
4 # You may obtain a copy of the License at:
5 #
6 #     http://www.apache.org/licenses/LICENSE-2.0
7 #
8 # Unless required by applicable law or agreed to in writing, software
9 # distributed under the License is distributed on an "AS IS" BASIS,
10 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11 # See the License for the specific language governing permissions and
12 # limitations under the License.
13 *** Settings ***
14 | Library | resources.libraries.python.L2Util
15 | Library | resources.libraries.python.InterfaceUtil
16
17 *** Keywords ***
18 | Configure VM for vhost L2BD forwarding
19 | | [Documentation] | Setup QEMU and start VM with two vhost interfaces.
20 | | ...
21 | | ... | *Arguments:*
22 | | ... | - ${dut_node} - DUT node to start VM on. Type: dictionary
23 | | ... | - ${sock1} - Socket path for first Vhost-User interface. Type: string
24 | | ... | - ${sock2} - Socket path for second Vhost-User interface. Type: string
25 | | ... | - ${qemu_name} - Qemu instance name by which the object will be
26 | | ... | accessed (Optional). Type: string
27 | | ...
28 | | ... | _NOTE:_ This KW sets following test case variable:
29 | | ... | - ${${qemu_name}} - VM node info. Type: dictionary
30 | | ...
31 | | ... | *Example:*
32 | | ...
33 | | ... | \| Configure VM for vhost L2BD forwarding \| ${nodes['DUT1']} \
34 | | ... | \| /tmp/sock1 \| /tmp/sock2 \|
35 | | ... | \| Configure VM for vhost L2BD forwarding \| ${nodes['DUT2']} \
36 | | ... | \| /tmp/sock1 \| /tmp/sock2 \| qemu_instance_2 \|
37 | | [Arguments] | ${dut_node} | ${sock1} | ${sock2} | ${qemu_name}=vm_node
38 | | Import Library | resources.libraries.python.QemuUtils | node=${dut_node} |
39 | | ... | WITH NAME | ${qemu_name}
40 | | Set Test Variable | ${${qemu_name}} | ${None}
41 | | Run Keyword  | ${qemu_name}.Qemu Add Vhost User If | ${sock1}
42 | | Run Keyword  | ${qemu_name}.Qemu Add Vhost User If | ${sock2}
43 | | ${vm}= | Run keyword | ${qemu_name}.Qemu Start
44 | | ${br}= | Set Variable | br0
45 | | ${vhost1}= | Get Vhost User If Name By Sock | ${vm} | ${sock1}
46 | | ${vhost2}= | Get Vhost User If Name By Sock | ${vm} | ${sock2}
47 | | Linux Add Bridge | ${vm} | ${br} | ${vhost1} | ${vhost2}
48 | | Set Interface State | ${vm} | ${vhost1} | up | if_type=name
49 | | Set Interface State | ${vm} | ${vhost2} | up | if_type=name
50 | | Set Interface State | ${vm} | ${br} | up | if_type=name
51 | | Set Test Variable | ${${qemu_name}} | ${vm}