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
6 # http://www.apache.org/licenses/LICENSE-2.0
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.
16 Documentation Library providing keywords to read objects from Juju using juju client.
18 Resource ssh_lib.resource
22 ${SUCCESS_RETURN_CODE} 0
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}'
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 " "
42 ${model_name}= Set Variable ${kdu_name}-${ns_id}
43 Should Be Equal As Strings ${model_name} ${stdout}
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 " "
53 Should Not Be Empty ${stdout}
54 Should Contain ${stdout} ${ee_name}
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 " "
64 Should Not Be Empty ${stdout}
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 " "
74 Should Not Be Empty ${stdout}
75 Should Contain ${stdout} ${ee_name}