VIRL test: Replace IP probe for VXLAN test
[csit.git] / resources / libraries / robot / qemu.robot
1 # Copyright (c) 2016 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.QemuUtils
15 | Library | resources.libraries.python.ssh.SSH
16
17 *** Keywords ***
18
19 | Exist QEMU Build List
20 | | [Documentation] | Return TRUE if variable QEMU_BUILD exist, otherwise FALSE
21 | | ${ret} | ${tmp}=  | Run Keyword And Ignore Error
22 | | ... | Variable Should Exist | @{QEMU_BUILD}
23 | | Return From Keyword If | "${ret}" == "PASS" | ${TRUE}
24 | | Return From Keyword | ${FALSE}
25
26 | Is QEMU Ready on Node
27 | | [Documentation] | Check if QEMU was built on the node before
28 | | [Arguments] | ${node}
29 | | ${ret}= | Exist QEMU Build List
30 | | Return From Keyword If | ${ret} == ${FALSE} | ${FALSE}
31 | | ${ret} | ${tmp}=  | Run Keyword And Ignore Error
32 | | ... | Should Contain | ${QEMU_BUILD} | ${node['host']}
33 | | Return From Keyword If | "${ret}" == "PASS" | ${TRUE}
34 | | Return From Keyword | ${FALSE}
35
36 | Add Node to QEMU Build List
37 | | [Documentation] | Add node to the list of nodes with builded QEMU (global
38 | | ...             | variable QEMU_BUILD)
39 | | [Arguments] | ${node}
40 | | ${ret}= | Exist QEMU Build List
41 | | Run Keyword If | ${ret} == ${TRUE}
42 | | ... | Append To List | ${QEMU_BUILD} | ${node['host']}
43 | | ... | ELSE | Set Global Variable | @{QEMU_BUILD} | ${node['host']}
44
45 | Build QEMU on Node
46 | | [Documentation] | Build QEMU from sources on the Node. Nodes with successful
47 | | ...             | QEMU build are stored in global variable list QEMU_BUILD
48 | | [Arguments] | ${node}
49 | | ${ready}= | Is QEMU Ready on Node | ${node}
50 | | Return From Keyword If | ${ready} == ${TRUE}
51 | | Build QEMU | ${node}
52 | | Add Node to QEMU Build List | ${node}
53
54 | Build QEMU on all DUTs
55 | | [Documentation] | Build QEMU from sources on all DUTs. Nodes with successful
56 | | ...             | QEMU build are stored in global variable list QEMU_BUILD
57 | | ${duts}= | Get Matches | ${nodes} | DUT*
58 | | :FOR | ${dut} | IN | @{duts}
59 | | | Build QEMU on Node | ${nodes['${dut}']}
60
61 | Stop and Clear QEMU
62 | | [Documentation] | Stop QEMU, clear used sockets and close SSH connection
63 | | ...             | running on ${dut}, ${vm} is VM node info dictionary
64 | | ...             | returned by qemu_start or None.
65 | | [Arguments] | ${dut} | ${vm}
66 | | Qemu Set Node | ${dut}
67 | | Qemu Kill
68 | | Qemu Clear Socks
69 | | Run Keyword If | ${vm} is not None | Disconnect | ${vm}
70
71 | Kill Qemu on all DUTs
72 | | [Documentation] | Kill QEMU processes on all DUTs.
73 | | ${duts}= | Get Matches | ${nodes} | DUT*
74 | | :FOR | ${dut} | IN | @{duts}
75 | | | Qemu Set Node | ${nodes['${dut}']}
76 | | | Qemu Kill