Bug 2327 fix to verify ipaddress in sol003_02 testsuite
[osm/tests.git] / robot-systest / lib / k8scluster_lib.resource
1 *** Comments ***
2 # Copyright 2020 Canonical Ltd.
3 #
4 #   Licensed under the Apache License, Version 2.0 (the "License");
5 #   you may not use this file except in compliance with the License.
6 #   You may obtain a copy of the License at
7 #
8 #       http://www.apache.org/licenses/LICENSE-2.0
9 #
10 #   Unless required by applicable law or agreed to in writing, software
11 #   distributed under the License is distributed on an "AS IS" BASIS,
12 #   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 #   See the License for the specific language governing permissions and
14 #   limitations under the License.
15
16
17 *** Settings ***
18 Documentation   Library providing keywords for CRUD operations over Kubernetes clusters with OSM client.
19 Library   OperatingSystem
20
21
22 *** Variables ***
23 ${SUCCESS_RETURN_CODE}   0
24 ${K8SCLUSTER_LAUNCH_MAX_WAIT_TIME}   6min
25 ${K8SCLUSTER_LAUNCH_POL_TIME}   30sec
26 ${K8SCLUSTER_DELETE_MAX_WAIT_TIME}   2min
27 ${K8SCLUSTER_DELETE_POL_TIME}   15sec
28
29
30 *** Keywords ***
31 Create K8s Cluster
32     [Documentation]   Register a Kubernetes cluster in OSM using the name, version and credentials passed as arguments.
33     [Arguments]   ${k8scluster_creds}   ${k8scluster_version}   ${k8scluster_vim}   ${k8scluster_net}   ${k8scluster_name}
34     ${rc}   ${stdout}=   Run And Return Rc And Output   osm k8scluster-add --creds ${k8scluster_creds} --version ${k8scluster_version} --vim ${k8scluster_vim} --k8s-nets '{"net1": "${k8scluster_net}"}' ${k8scluster_name} --description "Robot cluster"
35     Log   ${stdout}
36     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
37     Wait Until Keyword Succeeds   ${K8SCLUSTER_LAUNCH_MAX_WAIT_TIME}   ${K8SCLUSTER_LAUNCH_POL_TIME}   Check For K8s Cluster To Be Ready   ${k8scluster_name}
38     RETURN   ${stdout}
39
40 Delete K8s Cluster
41     [Documentation]   Unregister/delete a Kubernetes cluster from OSM.
42     [Arguments]   ${k8scluster_name}
43     ${rc}   ${stdout}=   Run And Return Rc And Output   osm k8scluster-delete ${k8scluster_name}
44     Log   ${stdout}
45     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
46     Wait Until Keyword Succeeds   ${K8SCLUSTER_DELETE_MAX_WAIT_TIME}   ${K8SCLUSTER_DELETE_POL_TIME}   Check For K8s Cluster To Be Deleted   ${k8scluster_name}
47
48 Get K8s Cluster
49     [Documentation]   Get the list of Kubernetes clusters in OSM, and return it.
50     ${rc}   ${stdout}=   Run And Return Rc And Output   osm k8scluster-list
51     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
52     Log   ${stdout}
53     RETURN   ${stdout}
54
55 Check For K8s Cluster
56     [Documentation]   Check if a Kubernetes cluster identified by name exists in OSM, and return it.
57     [Arguments]   ${k8scluster_name}
58     ${rc}   ${stdout}=   Run And Return Rc And Output   osm k8scluster-list --filter name="${k8scluster_name}"
59     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
60     RETURN   ${stdout}
61
62 Check For K8s Cluster To Be Deleted
63     [Documentation]   Check if a Kubernetes cluster identified by name is not present in OSM.
64     [Arguments]   ${k8scluster_name}
65     ${rc}   ${stdout}=   Run And Return Rc And Output   osm k8scluster-list --filter name="${k8scluster_name}" | awk '{print $2}' | grep ${k8scluster_name}
66     Log   ${rc},${stdout}
67     Should Be Empty   ${stdout}
68
69 Check For K8s Cluster To Be Ready
70     [Documentation]   Check if a Kubernetes cluster registered in OSM is ready (the state must be ENABLED or DEGRADED).
71     [Arguments]   ${k8scluster_name}
72     ${rc}   ${stdout}=   Run And Return Rc And Output   osm k8scluster-list --filter name="${k8scluster_name}" --filter _admin.operationalState="ENABLED,DEGRADED"
73     Log   ${rc},${stdout}
74     ${rc}   ${stdout}=   Run And Return Rc And Output   echo "${stdout}" | awk '{print $2}' | grep ${k8scluster_name}
75     Log   ${rc},${stdout}
76     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
77     Should Be Equal As Strings   ${stdout}   ${k8scluster_name}
78
79 Check For K8s Cluster To Be Enabled
80     [Documentation]   Check if the state of Kubernetes cluster registered in OSM is ENABLED.
81     [Arguments]   ${k8scluster_name}
82     ${rc}   ${stdout}=   Run And Return Rc And Output   osm k8scluster-show ${k8scluster_name}
83     Log   ${rc},${stdout}
84     ${rc}   ${stdout}=   Run And Return Rc And Output   osm k8scluster-list --filter name="${k8scluster_name}" --filter _admin.operationalState="ENABLED"
85     Log   ${rc},${stdout}
86     ${rc}   ${stdout}=   Run And Return Rc And Output   echo "${stdout}" | awk '{print $2}' | grep ${k8scluster_name}
87     Log   ${rc},${stdout}
88     Should Be Equal As Integers   ${rc}   ${SUCCESS_RETURN_CODE}
89     Should Be Equal As Strings   ${stdout}   ${k8scluster_name}