Bug 2327 fix to verify ipaddress in sol003_02 testsuite
[osm/tests.git] / robot-systest / lib / juju_lib.resource
1 *** Comments ***
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
14
15 *** Settings ***
16 Documentation   Library providing keywords to read objects from Juju using juju client.
17 Library   String
18 Resource   ssh_lib.resource
19
20
21 *** Variables ***
22 ${SUCCESS_RETURN_CODE}   0
23
24
25 *** Keywords ***
26 Get Scale Number
27     [Documentation]   Get from Juju the number of units (scale) of a juju application and return it.
28     [Arguments]   ${endpoint}   ${username}   ${password}   ${privatekey}   ${application_name}   ${model_name}
29     Should Not Be Empty   ${application_name}   ${model_name}
30     ${host}=   Remove String Using Regexp   ${endpoint}   :([0-9]+)$
31     ${stdout}=   Execute Remote Command Check Rc Return Output   ${host}   ${username}   ${password}   ${privatekey}   juju show-status ${application_name} --format yaml -m ${model_name} | grep scale | awk -F ': ' '{print $2}'
32     Log   ${stdout}
33     RETURN   ${stdout}
34
35 Get Model Name
36     [Documentation]   Get from Juju the model from a KDU name and a NS id.
37     [Arguments]   ${endpoint}   ${username}   ${password}   ${privatekey}   ${ns_id}   ${kdu_name}
38     Should Not Be Empty   ${ns_id}   ${kdu_name}
39     ${host}=   Remove String Using Regexp   ${endpoint}   :([0-9]+)$
40     ${stdout}=   Execute Remote Command Check Rc Return Output   ${host}   ${username}   ${password}   ${privatekey}   juju models | grep -i ${kdu_name} | grep -i ${ns_id} | cut -f1 -d " "
41     Log   ${stdout}
42     ${model_name}=   Set Variable   ${kdu_name}-${ns_id}
43     Should Be Equal As Strings   ${model_name}   ${stdout}
44     RETURN   ${stdout}
45
46 Get Application Name VDU Level Charm
47     [Documentation]   Get from Juju the application name matching a model and a VDU profile id passed as arguments. The application name must contain the EE passed as argument.
48     [Arguments]   ${endpoint}   ${username}   ${password}   ${privatekey}   ${model_name}   ${vdu_profile_id}   ${ee_name}
49     Should Not Be Empty   ${model_name}
50     ${host}=   Remove String Using Regexp   ${endpoint}   :([0-9]+)$
51     ${stdout}=   Execute Remote Command Check Rc Return Output   ${host}   ${username}   ${password}   ${privatekey}   juju status -m ${model_name} | grep "\\-vdu" | grep -v "*" | grep -i ${vdu_profile_id} | cut -f1 -d " "
52     Log   ${stdout}
53     Should Not Be Empty   ${stdout}
54     Should Contain   ${stdout}   ${ee_name}
55     RETURN   ${stdout}
56
57 Get Application Name NS Level Charm
58     [Documentation]   Get from Juju the application name matching a model and a NS charm passed as arguments.
59     [Arguments]   ${endpoint}   ${username}   ${password}   ${privatekey}   ${model_name}   ${charm_name}
60     Should Not Be Empty   ${model_name}
61     ${host}=   Remove String Using Regexp   ${endpoint}   :([0-9]+)$
62     ${stdout}=   Execute Remote Command Check Rc Return Output   ${host}   ${username}   ${password}   ${privatekey}   juju status -m ${model_name} | grep "\\-ns" | grep -v "*" | grep -i ${charm_name} | cut -f1 -d " "
63     Log   ${stdout}
64     Should Not Be Empty   ${stdout}
65     RETURN   ${stdout}
66
67 Get Application Name VNF Level Charm
68     [Documentation]   Get from Juju the application name matching a model and a VNF profile id passed as arguments. The application name must contain the EE passed as argument.
69     [Arguments]   ${endpoint}   ${username}   ${password}   ${privatekey}   ${model_name}   ${vnf_profile_id}   ${ee_name}
70     Should Not Be Empty   ${model_name}
71     ${host}=   Remove String Using Regexp   ${endpoint}   :([0-9]+)$
72     ${stdout}=   Execute Remote Command Check Rc Return Output   ${host}   ${username}   ${password}   ${privatekey}   juju status -m ${model_name} | grep "\\-vnf" | grep -v "*" | grep -i ${vnf_profile_id} | cut -f1 -d " "
73     Log   ${stdout}
74     Should Not Be Empty   ${stdout}
75     Should Contain   ${stdout}   ${ee_name}
76     RETURN   ${stdout}