Merge "Fix error in REC-13"
[ta/cloudtaf.git] / resources / ssh.robot
1 # Copyright 2019 Nokia
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 *** Settings ***
16 Documentation     Defines targets to RemoteSession - library
17 ...               'default' points to the active master via infra_external like
18 ...               the connections to the caas_master - nodes.
19 ...               Connection to the other nodes(caas_worker, storage) are done infra_internal
20 ...               via the active master. (in case the controller is also a storage the
21 ...               direct connection is used instead).
22
23 Library        crl.remotesession.remotesession.RemoteSession
24 ...            WITH NAME    RemoteSession
25 Library        cluster.cluster.Cluster
26 ...   WITH NAME  Cluster
27
28 *** Variables ***
29 @{ALL_MASTERS_IN_SYSTEM}              @{EMPTY}
30 @{ALL_PURE_WORKERS_IN_SYSTEM}         @{EMPTY}
31 @{ALL_PURE_STORAGES_IN_SYSTEM}        @{EMPTY}
32 ${IS_DPDK_IN_USE}                     ${False}
33
34 *** Keywords ***
35
36 Setup Connections
37     [Documentation]     Setup targets for the RemoteSession Library for
38     ...                 for all nodes.
39
40     Cluster.Initialize  host=${RFCLI_TARGET_1.IP}
41     ...                 user=${RFCLI_TARGET_1.USER}
42     ...                 password=${RFCLI_TARGET_1.PASS}
43
44     ${remotesession}=  Get Library Instance    RemoteSession
45
46     Cluster.Initialize RemoteSession   ${remotesession}
47     ${master}=    Get Variable Value    ${RFCLI_TARGET_1.MASTER_PROFILE}    caas_master
48     ${worker}=    Get Variable Value    ${RFCLI_TARGET_1.WORKER_PROFILE}    caas_worker
49
50     ${masters}=    Cluster.Get Hosts Containing   ${master}
51     Set Global Variable     ${ALL_MASTERS_IN_SYSTEM}     ${masters}
52
53     ${pure_storages}=    Cluster.Get Hosts With Profiles    storage
54     Set Global Variable     ${ALL_PURE_STORAGES_IN_SYSTEM}     ${pure_storages}
55
56     ${pure_workers}=    Cluster.Get Hosts With Profiles    ${worker}
57     Set Global Variable     ${ALL_PURE_WORKERS_IN_SYSTEM}     ${pure_workers}
58
59     ${is_dpdk_in_use}=  Cluster.Is Dpdk
60     Set Global Variable  ${IS_DPDK_IN_USE}  ${is_dpdk_in_use}
61
62
63 Execute Command
64     [Arguments]     ${CMD}      ${NODE_NAME}=default    ${CHECK_STDERR}=${True}
65     ${result}=     RemoteSession.Execute Command In Target     ${CMD}  target=${NODE_NAME}
66     Should Be Equal As Integers     ${result.status}       0    ${result.stderr}
67     Run Keyword If    ${CHECK_STDERR}    Should Be Empty    ${result.stderr}
68     [Return]    ${result.stdout}
69