blob: 3d02901c751bead3c16e60556753ade2a0a8f47c [file] [log] [blame]
garciadeblas7a9e0312023-12-11 22:24:46 +01001*** Comments ***
aktasf47542b2021-05-26 10:32:32 +03002# 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
garciadeblas7a9e0312023-12-11 22:24:46 +010014
15*** Settings ***
16Documentation Library providing keywords to read objects from Juju using juju client.
17Library String
18Resource ssh_lib.resource
19
20
aktasf47542b2021-05-26 10:32:32 +030021*** Variables ***
garciadeblas7a9e0312023-12-11 22:24:46 +010022${SUCCESS_RETURN_CODE} 0
aktasf47542b2021-05-26 10:32:32 +030023
24
25*** Keywords ***
26Get Scale Number
garciadeblas7a9e0312023-12-11 22:24:46 +010027 [Documentation] Get from Juju the number of units (scale) of a juju application and return it.
Guillermo Calvino01b29472022-11-18 16:52:50 +010028 [Arguments] ${endpoint} ${username} ${password} ${privatekey} ${application_name} ${model_name}
aktasf47542b2021-05-26 10:32:32 +030029 Should Not Be Empty ${application_name} ${model_name}
Guillermo Calvino01b29472022-11-18 16:52:50 +010030 ${host}= Remove String Using Regexp ${endpoint} :([0-9]+)$
aguilard71e24ea2021-08-12 10:44:17 +020031 ${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}'
garciadeblas321726f2022-12-21 11:43:06 +010032 Log ${stdout}
garciadeblas7a9e0312023-12-11 22:24:46 +010033 RETURN ${stdout}
aktasf47542b2021-05-26 10:32:32 +030034
35Get Model Name
garciadeblas7a9e0312023-12-11 22:24:46 +010036 [Documentation] Get from Juju the model from a KDU name and a NS id.
Guillermo Calvino01b29472022-11-18 16:52:50 +010037 [Arguments] ${endpoint} ${username} ${password} ${privatekey} ${ns_id} ${kdu_name}
aktasf47542b2021-05-26 10:32:32 +030038 Should Not Be Empty ${ns_id} ${kdu_name}
Guillermo Calvino01b29472022-11-18 16:52:50 +010039 ${host}= Remove String Using Regexp ${endpoint} :([0-9]+)$
aguilard71e24ea2021-08-12 10:44:17 +020040 ${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 " "
garciadeblas321726f2022-12-21 11:43:06 +010041 Log ${stdout}
aktasf47542b2021-05-26 10:32:32 +030042 ${model_name}= Set Variable ${kdu_name}-${ns_id}
43 Should Be Equal As Strings ${model_name} ${stdout}
garciadeblas7a9e0312023-12-11 22:24:46 +010044 RETURN ${stdout}
aticiga131bf02022-08-25 13:10:14 +030045
46Get Application Name VDU Level Charm
garciadeblas7a9e0312023-12-11 22:24:46 +010047 [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.
Guillermo Calvino01b29472022-11-18 16:52:50 +010048 [Arguments] ${endpoint} ${username} ${password} ${privatekey} ${model_name} ${vdu_profile_id} ${ee_name}
aticiga131bf02022-08-25 13:10:14 +030049 Should Not Be Empty ${model_name}
Guillermo Calvino01b29472022-11-18 16:52:50 +010050 ${host}= Remove String Using Regexp ${endpoint} :([0-9]+)$
aticiga131bf02022-08-25 13:10:14 +030051 ${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 " "
garciadeblas321726f2022-12-21 11:43:06 +010052 Log ${stdout}
aticiga131bf02022-08-25 13:10:14 +030053 Should Not Be Empty ${stdout}
54 Should Contain ${stdout} ${ee_name}
garciadeblas7a9e0312023-12-11 22:24:46 +010055 RETURN ${stdout}
aticiga131bf02022-08-25 13:10:14 +030056
57Get Application Name NS Level Charm
garciadeblas7a9e0312023-12-11 22:24:46 +010058 [Documentation] Get from Juju the application name matching a model and a NS charm passed as arguments.
Guillermo Calvino01b29472022-11-18 16:52:50 +010059 [Arguments] ${endpoint} ${username} ${password} ${privatekey} ${model_name} ${charm_name}
aticiga131bf02022-08-25 13:10:14 +030060 Should Not Be Empty ${model_name}
Guillermo Calvino01b29472022-11-18 16:52:50 +010061 ${host}= Remove String Using Regexp ${endpoint} :([0-9]+)$
aticiga131bf02022-08-25 13:10:14 +030062 ${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 " "
garciadeblas321726f2022-12-21 11:43:06 +010063 Log ${stdout}
aticiga131bf02022-08-25 13:10:14 +030064 Should Not Be Empty ${stdout}
garciadeblas7a9e0312023-12-11 22:24:46 +010065 RETURN ${stdout}
aticiga131bf02022-08-25 13:10:14 +030066
67Get Application Name VNF Level Charm
garciadeblas7a9e0312023-12-11 22:24:46 +010068 [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.
Guillermo Calvino01b29472022-11-18 16:52:50 +010069 [Arguments] ${endpoint} ${username} ${password} ${privatekey} ${model_name} ${vnf_profile_id} ${ee_name}
aticiga131bf02022-08-25 13:10:14 +030070 Should Not Be Empty ${model_name}
Guillermo Calvino01b29472022-11-18 16:52:50 +010071 ${host}= Remove String Using Regexp ${endpoint} :([0-9]+)$
aticiga131bf02022-08-25 13:10:14 +030072 ${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 " "
garciadeblas321726f2022-12-21 11:43:06 +010073 Log ${stdout}
aticiga131bf02022-08-25 13:10:14 +030074 Should Not Be Empty ${stdout}
75 Should Contain ${stdout} ${ee_name}
garciadeblas7a9e0312023-12-11 22:24:46 +010076 RETURN ${stdout}