| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| 3 | ## |
| 4 | # Copyright 2019 Tech Mahindra Limited |
| 5 | # |
| 6 | # All Rights Reserved. |
| 7 | # |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 9 | # not use this file except in compliance with the License. You may obtain |
| 10 | # a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 16 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 17 | # License for the specific language governing permissions and limitations |
| 18 | # under the License. |
| 19 | ## |
| 20 | |
| 21 | ## Change log: |
| 22 | # 1. Feature 7829: Jayant Madavi, Mrityunjay Yadav : MY00514913@techmahindra.com : 06-sep-2019 |
| 23 | ## |
| 24 | |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 25 | *** Settings *** |
| 26 | Library OperatingSystem |
| 27 | Library String |
| 28 | Library Collections |
| 29 | Library ../custom_lib.py |
| 30 | |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 31 | |
| 32 | *** Variables *** |
| 33 | ${success_return_code} 0 |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 34 | ${user} "robottest" |
| 35 | ${password} "fred" |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 36 | ${authurl} "https://127.0.0.1/" |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 37 | ${type} "openstack" |
| 38 | ${desc} "a test vim" |
| 39 | ${tenant} "robottest2" |
| 40 | |
| 41 | |
| 42 | *** Keywords *** |
| 43 | Create Vim Account |
| 44 | [Documentation] Create a new vim account |
| 45 | |
| lavado | d5f6aa6 | 2019-11-21 18:57:36 +0100 | [diff] [blame] | 46 | ${vim-name}= Generate Random String 8 [NUMBERS] |
| 47 | ${vim-name}= Catenate SEPARATOR= vim_ ${vim-name} |
| 48 | set global variable ${vim-name} |
| 49 | |
| 50 | ${rc} ${stdout}= Run and Return RC and Output osm vim-create --name ${vim-name} --user ${user} --password ${password} --auth_url ${authurl} --tenant ${tenant} --account_type ${type} --description ${desc} |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 51 | log ${stdout} |
| 52 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 53 | |
| 54 | |
| 55 | Get Vim List |
| 56 | [Documentation] Get a vim account list |
| 57 | |
| 58 | ${rc} ${stdout}= Run and Return RC and Output osm vim-list |
| 59 | log ${stdout} |
| 60 | Log To Console ${stdout} |
| 61 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 62 | |
| 63 | |
| 64 | Delete Vim Account |
| 65 | [Documentation] delete vim account details |
| 66 | |
| lavado | d5f6aa6 | 2019-11-21 18:57:36 +0100 | [diff] [blame] | 67 | ${rc} ${stdout}= Run and Return RC and Output osm vim-delete ${vim-name} |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 68 | log ${stdout} |
| 69 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 70 | |
| 71 | |
| 72 | VIM Setup To Launch Network Services |
| 73 | [Documentation] Setup a VIM to launch network services |
| 74 | |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 75 | set global variable @{vim} |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 76 | ${vmware_url}= Get Environment Variable VCD_AUTH_URL ${EMPTY} |
| 77 | ${openstack_url}= Get Environment Variable OS_AUTH_URL ${EMPTY} |
| 78 | ${vmware_vim}= Run Keyword And Return If '${vmware_url}'!='${EMPTY}' Setup Vmware Vim ${vmware_url} 'vmware' 'pytest system test' |
| 79 | ${openstack_vim}= Run Keyword And Return If '${openstack_url}'!='${EMPTY}' Setup Openstack Vim ${openstack_url} 'openstack' 'pytest system test' |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 80 | Should Not Be Empty ${vim} VIM details not provided |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 81 | Log Many @{vim} |
| 82 | |
| 83 | |
| 84 | Setup Openstack Vim |
| 85 | [Documentation] Openstack Vim Account Setup |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 86 | [Tags] vim-setup |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 87 | [Arguments] ${authurl} ${type} ${desc} |
| 88 | |
| 89 | ${user}= Get Environment Variable OS_USERNAME '' |
| 90 | ${password}= Get Environment Variable OS_PASSWORD '' |
| 91 | ${tenant}= Get Environment Variable OS_PROJECT_NAME '' |
| 92 | ${vim-config}= Get Environment Variable OS_VIM_CONFIG '' |
| 93 | ${vim_name}= GENERATE NAME |
| 94 | |
| 95 | ${rc} ${stdout}= Run and Return RC and Output osm vim-create --name ${vim_name} --user ${user} --password ${password} --auth_url ${authurl} --tenant ${tenant} --account_type ${type} --description ${desc} --config ${vim-config} |
| 96 | log ${stdout} |
| 97 | Should Be Equal As Integers ${rc} ${success_return_code} |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 98 | Sleep 30s Wait for to get vim ready |
| 99 | ${rc} ${vim_detail}= Run and Return RC and Output osm vim-show ${vim_name} |
| 100 | Should Contain ${vim_detail} "operationalState": "ENABLED" msg=Openstack vim is not available values=False |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 101 | Append To List ${vim} ${stdout} |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 102 | |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 103 | [Return] ${stdout} |
| 104 | |
| 105 | |
| 106 | Setup Vmware Vim |
| 107 | [Documentation] Vmware Vim Account Setup |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 108 | [Tags] vim-setup |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 109 | [Arguments] ${authurl} ${type} ${desc} |
| 110 | |
| 111 | ${user}= Get Environment Variable VCD_USERNAME '' |
| 112 | ${password}= Get Environment Variable VCD_PASSWORD '' |
| 113 | ${tenant}= Get Environment Variable VCD_TENANT_NAME '' |
| 114 | ${vcd-org}= Get Environment Variable VCD_ORGANIZATION '' |
| 115 | ${vim-config}= Get Environment Variable VCD_VIM_CONFIG '' |
| 116 | ${vim_name}= GENERATE NAME |
| 117 | |
| 118 | ${rc} ${stdout}= Run and Return RC and Output osm vim-create --name ${vim_name} --user ${user} --password ${password} --auth_url ${authurl} --tenant ${tenant} --account_type ${type} --description ${desc} --config ${vim-config} |
| 119 | log ${stdout} |
| 120 | Should Be Equal As Integers ${rc} ${success_return_code} |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 121 | Sleep 30s Wait for to get vim ready |
| 122 | ${rc} ${vim_detail}= Run and Return RC and Output osm vim-show ${vim_name} |
| 123 | Should Contain ${vim_detail} "operationalState": "ENABLED" msg=VMWare VCD vim is not available values=False |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 124 | Append To List ${vim} ${stdout} |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 125 | |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 126 | [Return] ${stdout} |
| 127 | |
| 128 | |
| 129 | Force Delete Vim Account |
| 130 | [Documentation] delete vim account details |
| 131 | [Arguments] ${vim_name} |
| 132 | |
| 133 | ${rc} ${stdout}= Run and Return RC and Output osm vim-delete ${vim_name} |
| 134 | log ${stdout} |
| 135 | Should Be Equal As Integers ${rc} ${success_return_code} |