| 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 | |
| 25 | |
| 26 | *** Variables *** |
| 27 | ${success_return_code} 0 |
| 28 | ${name} "helloworld-os" |
| 29 | ${user} "robottest" |
| 30 | ${password} "fred" |
| 31 | ${authurl} "https://169.254.169.245/" |
| 32 | ${type} "openstack" |
| 33 | ${desc} "a test vim" |
| 34 | ${tenant} "robottest2" |
| 35 | |
| 36 | |
| 37 | *** Keywords *** |
| 38 | Create Vim Account |
| 39 | [Documentation] Create a new vim account |
| 40 | |
| 41 | ${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} |
| 42 | log ${stdout} |
| 43 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 44 | |
| 45 | |
| 46 | Get Vim List |
| 47 | [Documentation] Get a vim account list |
| 48 | |
| 49 | ${rc} ${stdout}= Run and Return RC and Output osm vim-list |
| 50 | log ${stdout} |
| 51 | Log To Console ${stdout} |
| 52 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 53 | |
| 54 | |
| 55 | Delete Vim Account |
| 56 | [Documentation] delete vim account details |
| 57 | |
| 58 | ${rc} ${stdout}= Run and Return RC and Output osm vim-delete ${name} |
| 59 | log ${stdout} |
| 60 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 61 | |
| 62 | |
| 63 | VIM Setup To Launch Network Services |
| 64 | [Documentation] Setup a VIM to launch network services |
| 65 | |
| 66 | ${vmware_url}= Get Environment Variable VCD_AUTH_URL ${EMPTY} |
| 67 | ${openstack_url}= Get Environment Variable OS_AUTH_URL ${EMPTY} |
| 68 | ${vmware_vim}= Run Keyword And Return If '${vmware_url}'!='${EMPTY}' Setup Vmware Vim ${vmware_url} 'vmware' 'pytest system test' |
| 69 | ${openstack_vim}= Run Keyword And Return If '${openstack_url}'!='${EMPTY}' Setup Openstack Vim ${openstack_url} 'openstack' 'pytest system test' |
| 70 | |
| 71 | Log Many @{vim} |
| 72 | |
| 73 | |
| 74 | Setup Openstack Vim |
| 75 | [Documentation] Openstack Vim Account Setup |
| 76 | [Arguments] ${authurl} ${type} ${desc} |
| 77 | |
| 78 | ${user}= Get Environment Variable OS_USERNAME '' |
| 79 | ${password}= Get Environment Variable OS_PASSWORD '' |
| 80 | ${tenant}= Get Environment Variable OS_PROJECT_NAME '' |
| 81 | ${vim-config}= Get Environment Variable OS_VIM_CONFIG '' |
| 82 | ${vim_name}= GENERATE NAME |
| 83 | |
| 84 | ${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} |
| 85 | log ${stdout} |
| 86 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 87 | Append To List ${vim} ${stdout} |
| 88 | [Return] ${stdout} |
| 89 | |
| 90 | |
| 91 | Setup Vmware Vim |
| 92 | [Documentation] Vmware Vim Account Setup |
| 93 | [Arguments] ${authurl} ${type} ${desc} |
| 94 | |
| 95 | ${user}= Get Environment Variable VCD_USERNAME '' |
| 96 | ${password}= Get Environment Variable VCD_PASSWORD '' |
| 97 | ${tenant}= Get Environment Variable VCD_TENANT_NAME '' |
| 98 | ${vcd-org}= Get Environment Variable VCD_ORGANIZATION '' |
| 99 | ${vim-config}= Get Environment Variable VCD_VIM_CONFIG '' |
| 100 | ${vim_name}= GENERATE NAME |
| 101 | |
| 102 | ${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} |
| 103 | log ${stdout} |
| 104 | Should Be Equal As Integers ${rc} ${success_return_code} |
| 105 | Append To List ${vim} ${stdout} |
| 106 | [Return] ${stdout} |
| 107 | |
| 108 | |
| 109 | Force Delete Vim Account |
| 110 | [Documentation] delete vim account details |
| 111 | [Arguments] ${vim_name} |
| 112 | |
| 113 | ${rc} ${stdout}= Run and Return RC and Output osm vim-delete ${vim_name} |
| 114 | log ${stdout} |
| 115 | Should Be Equal As Integers ${rc} ${success_return_code} |