blob: c3c8242fe1fc1aeed10839a1c78614e0c898296d [file] [log] [blame]
yadavmr58af6b12019-09-18 15:33:25 +05301# -*- 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
yadavmrf21d9da2019-11-05 11:42:57 +053025*** Settings ***
26Library OperatingSystem
27Library String
28Library Collections
29Library ../custom_lib.py
30
yadavmr58af6b12019-09-18 15:33:25 +053031
32*** Variables ***
33${success_return_code} 0
yadavmr58af6b12019-09-18 15:33:25 +053034${user} "robottest"
35${password} "fred"
yadavmrf21d9da2019-11-05 11:42:57 +053036${authurl} "https://127.0.0.1/"
yadavmr58af6b12019-09-18 15:33:25 +053037${type} "openstack"
38${desc} "a test vim"
39${tenant} "robottest2"
40
41
42*** Keywords ***
43Create Vim Account
44 [Documentation] Create a new vim account
45
lavadod5f6aa62019-11-21 18:57:36 +010046 ${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}
yadavmr58af6b12019-09-18 15:33:25 +053051 log ${stdout}
52 Should Be Equal As Integers ${rc} ${success_return_code}
53
54
55Get 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
64Delete Vim Account
65 [Documentation] delete vim account details
yadavmrf3ec8f42020-01-30 16:07:59 +053066 [Arguments] ${vim_name}=${vim-name}
yadavmr58af6b12019-09-18 15:33:25 +053067
yadavmrf3ec8f42020-01-30 16:07:59 +053068 ${rc} ${stdout}= Run and Return RC and Output osm vim-delete ${vim_name}
yadavmr58af6b12019-09-18 15:33:25 +053069 log ${stdout}
70 Should Be Equal As Integers ${rc} ${success_return_code}
71
72
73VIM Setup To Launch Network Services
74 [Documentation] Setup a VIM to launch network services
75
yadavmrf21d9da2019-11-05 11:42:57 +053076 set global variable @{vim}
yadavmr58af6b12019-09-18 15:33:25 +053077 ${vmware_url}= Get Environment Variable VCD_AUTH_URL ${EMPTY}
78 ${openstack_url}= Get Environment Variable OS_AUTH_URL ${EMPTY}
79 ${vmware_vim}= Run Keyword And Return If '${vmware_url}'!='${EMPTY}' Setup Vmware Vim ${vmware_url} 'vmware' 'pytest system test'
80 ${openstack_vim}= Run Keyword And Return If '${openstack_url}'!='${EMPTY}' Setup Openstack Vim ${openstack_url} 'openstack' 'pytest system test'
yadavmrf21d9da2019-11-05 11:42:57 +053081 Should Not Be Empty ${vim} VIM details not provided
yadavmr58af6b12019-09-18 15:33:25 +053082 Log Many @{vim}
83
84
85Setup Openstack Vim
86 [Documentation] Openstack Vim Account Setup
yadavmrf21d9da2019-11-05 11:42:57 +053087 [Tags] vim-setup
yadavmr58af6b12019-09-18 15:33:25 +053088 [Arguments] ${authurl} ${type} ${desc}
89
90 ${user}= Get Environment Variable OS_USERNAME ''
91 ${password}= Get Environment Variable OS_PASSWORD ''
92 ${tenant}= Get Environment Variable OS_PROJECT_NAME ''
93 ${vim-config}= Get Environment Variable OS_VIM_CONFIG ''
94 ${vim_name}= GENERATE NAME
95
96 ${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}
97 log ${stdout}
98 Should Be Equal As Integers ${rc} ${success_return_code}
yadavmrf21d9da2019-11-05 11:42:57 +053099 Sleep 30s Wait for to get vim ready
100 ${rc} ${vim_detail}= Run and Return RC and Output osm vim-show ${vim_name}
101 Should Contain ${vim_detail} "operationalState": "ENABLED" msg=Openstack vim is not available values=False
yadavmr58af6b12019-09-18 15:33:25 +0530102 Append To List ${vim} ${stdout}
yadavmrf21d9da2019-11-05 11:42:57 +0530103
yadavmr58af6b12019-09-18 15:33:25 +0530104 [Return] ${stdout}
105
106
107Setup Vmware Vim
108 [Documentation] Vmware Vim Account Setup
yadavmrf21d9da2019-11-05 11:42:57 +0530109 [Tags] vim-setup
yadavmr58af6b12019-09-18 15:33:25 +0530110 [Arguments] ${authurl} ${type} ${desc}
111
112 ${user}= Get Environment Variable VCD_USERNAME ''
113 ${password}= Get Environment Variable VCD_PASSWORD ''
114 ${tenant}= Get Environment Variable VCD_TENANT_NAME ''
115 ${vcd-org}= Get Environment Variable VCD_ORGANIZATION ''
116 ${vim-config}= Get Environment Variable VCD_VIM_CONFIG ''
117 ${vim_name}= GENERATE NAME
118
119 ${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}
120 log ${stdout}
121 Should Be Equal As Integers ${rc} ${success_return_code}
yadavmrf21d9da2019-11-05 11:42:57 +0530122 Sleep 30s Wait for to get vim ready
123 ${rc} ${vim_detail}= Run and Return RC and Output osm vim-show ${vim_name}
124 Should Contain ${vim_detail} "operationalState": "ENABLED" msg=VMWare VCD vim is not available values=False
yadavmr58af6b12019-09-18 15:33:25 +0530125 Append To List ${vim} ${stdout}
yadavmrf21d9da2019-11-05 11:42:57 +0530126
yadavmr58af6b12019-09-18 15:33:25 +0530127 [Return] ${stdout}
128
129
130Force Delete Vim Account
131 [Documentation] delete vim account details
132 [Arguments] ${vim_name}
133
134 ${rc} ${stdout}= Run and Return RC and Output osm vim-delete ${vim_name}
135 log ${stdout}
136 Should Be Equal As Integers ${rc} ${success_return_code}