| calvinosanc1 | 2582fbd | 2020-06-12 10:52:29 +0200 | [diff] [blame] | 1 | # Copyright 2020 Canonical Ltd. |
| 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 | *** Variables *** |
| 16 | ${success_return_code} 0 |
| 17 | ${k8scluster_launch_max_wait_time} 2min |
| 18 | ${k8scluster_launch_pol_time} 30sec |
| 19 | ${k8scluster_delete_max_wait_time} 2min |
| 20 | ${k8scluster_delete_pol_time} 15sec |
| 21 | |
| 22 | *** Keywords *** |
| 23 | Create K8s Cluster |
| 24 | [Arguments] ${k8scluster_creds} ${k8scluster_version} ${k8scluster_vim} ${k8scluster_net} ${k8scluster_name} |
| 25 | ${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" |
| 26 | log ${stdout} |
| 27 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 28 | WAIT UNTIL KEYWORD SUCCEEDS ${k8scluster_launch_max_wait_time} ${k8scluster_launch_pol_time} Check For K8s Cluster To Be Ready ${k8scluster_name} |
| 29 | [Return] ${stdout} |
| 30 | |
| 31 | Delete K8s Cluster |
| 32 | [Arguments] ${k8scluster_name} |
| 33 | ${rc} ${stdout}= Run and Return RC and Output osm k8scluster-delete ${k8scluster_name} |
| 34 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 35 | WAIT UNTIL KEYWORD SUCCEEDS ${k8scluster_delete_max_wait_time} ${k8scluster_delete_pol_time} Check For K8s Cluster To Be Deleted ${k8scluster_name} |
| 36 | |
| 37 | Get K8s Cluster |
| 38 | ${rc} ${stdout}= Run and Return RC and Output osm k8scluster-list |
| 39 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 40 | log ${stdout} |
| 41 | [Return] ${stdout} |
| 42 | |
| 43 | Check for K8s Cluster |
| 44 | [Arguments] ${k8scluster_name} |
| 45 | ${rc} ${stdout}= Run and Return RC and Output osm k8scluster-list --filter name="${k8scluster_name}" |
| 46 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 47 | [Return] ${stdout} |
| 48 | |
| 49 | Check For K8s Cluster To Be Deleted |
| 50 | [Arguments] ${k8scluster_name} |
| 51 | ${rc} ${stdout}= Run and Return RC and Output osm k8scluster-list --filter name="${k8scluster_name}" | awk '{print $2}' | grep ${k8scluster_name} |
| 52 | Should Be Empty ${stdout} |
| 53 | |
| 54 | Check For K8s Cluster To Be Ready |
| 55 | [Arguments] ${k8scluster_name} |
| 56 | ${rc} ${stdout}= Run and Return RC and Output osm k8scluster-list --filter name="${k8scluster_name}" --filter _admin.operationalState="ENABLED" | awk '{print $2}' | grep ${k8scluster_name} |
| 57 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 58 | Should Be Equal As Strings ${stdout} ${k8scluster_name} |