| 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 |
| 34 | ${name} "helloworld-os" |
| 35 | ${user} "robottest" |
| 36 | ${password} "fred" |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 37 | ${authurl} "https://127.0.0.1/" |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 38 | ${type} "openstack" |
| 39 | ${desc} "a test vim" |
| 40 | ${tenant} "robottest2" |
| 41 | |
| 42 | |
| 43 | *** Keywords *** |
| 44 | Create Vim Account |
| 45 | [Documentation] Create a new vim account |
| 46 | |
| 47 | ${rc} ${stdout}= Run and Return RC and Output osm vim-create --name ${name} --user ${user} --password ${password} --auth_url ${authurl} --tenant ${tenant} --account_type ${type} --description ${desc} |
| 48 | log ${stdout} |
| 49 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 50 | |
| 51 | |
| 52 | Get Vim List |
| 53 | [Documentation] Get a vim account list |
| 54 | |
| 55 | ${rc} ${stdout}= Run and Return RC and Output osm vim-list |
| 56 | log ${stdout} |
| 57 | Log To Console ${stdout} |
| 58 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 59 | |
| 60 | |
| 61 | Delete Vim Account |
| 62 | [Documentation] delete vim account details |
| 63 | |
| 64 | ${rc} ${stdout}= Run and Return RC and Output osm vim-delete ${name} |
| 65 | log ${stdout} |
| 66 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 67 | |
| 68 | |
| 69 | VIM Setup To Launch Network Services |
| 70 | [Documentation] Setup a VIM to launch network services |
| 71 | |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 72 | set global variable @{vim} |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 73 | ${vmware_url}= Get Environment Variable VCD_AUTH_URL ${EMPTY} |
| 74 | ${openstack_url}= Get Environment Variable OS_AUTH_URL ${EMPTY} |
| 75 | ${vmware_vim}= Run Keyword And Return If '${vmware_url}'!='${EMPTY}' Setup Vmware Vim ${vmware_url} 'vmware' 'pytest system test' |
| 76 | ${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] | 77 | Should Not Be Empty ${vim} VIM details not provided |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 78 | Log Many @{vim} |
| 79 | |
| 80 | |
| 81 | Setup Openstack Vim |
| 82 | [Documentation] Openstack Vim Account Setup |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 83 | [Tags] vim-setup |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 84 | [Arguments] ${authurl} ${type} ${desc} |
| 85 | |
| 86 | ${user}= Get Environment Variable OS_USERNAME '' |
| 87 | ${password}= Get Environment Variable OS_PASSWORD '' |
| 88 | ${tenant}= Get Environment Variable OS_PROJECT_NAME '' |
| 89 | ${vim-config}= Get Environment Variable OS_VIM_CONFIG '' |
| 90 | ${vim_name}= GENERATE NAME |
| 91 | |
| 92 | ${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} |
| 93 | log ${stdout} |
| 94 | Should Be Equal As Integers ${rc} ${success_return_code} |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 95 | Sleep 30s Wait for to get vim ready |
| 96 | ${rc} ${vim_detail}= Run and Return RC and Output osm vim-show ${vim_name} |
| 97 | 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] | 98 | Append To List ${vim} ${stdout} |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 99 | |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 100 | [Return] ${stdout} |
| 101 | |
| 102 | |
| 103 | Setup Vmware Vim |
| 104 | [Documentation] Vmware Vim Account Setup |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 105 | [Tags] vim-setup |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 106 | [Arguments] ${authurl} ${type} ${desc} |
| 107 | |
| 108 | ${user}= Get Environment Variable VCD_USERNAME '' |
| 109 | ${password}= Get Environment Variable VCD_PASSWORD '' |
| 110 | ${tenant}= Get Environment Variable VCD_TENANT_NAME '' |
| 111 | ${vcd-org}= Get Environment Variable VCD_ORGANIZATION '' |
| 112 | ${vim-config}= Get Environment Variable VCD_VIM_CONFIG '' |
| 113 | ${vim_name}= GENERATE NAME |
| 114 | |
| 115 | ${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} |
| 116 | log ${stdout} |
| 117 | Should Be Equal As Integers ${rc} ${success_return_code} |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 118 | Sleep 30s Wait for to get vim ready |
| 119 | ${rc} ${vim_detail}= Run and Return RC and Output osm vim-show ${vim_name} |
| 120 | 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] | 121 | Append To List ${vim} ${stdout} |
| yadavmr | f21d9da | 2019-11-05 11:42:57 +0530 | [diff] [blame] | 122 | |
| yadavmr | 58af6b1 | 2019-09-18 15:33:25 +0530 | [diff] [blame] | 123 | [Return] ${stdout} |
| 124 | |
| 125 | |
| 126 | Force Delete Vim Account |
| 127 | [Documentation] delete vim account details |
| 128 | [Arguments] ${vim_name} |
| 129 | |
| 130 | ${rc} ${stdout}= Run and Return RC and Output osm vim-delete ${vim_name} |
| 131 | log ${stdout} |
| 132 | Should Be Equal As Integers ${rc} ${success_return_code} |