1 # -*- coding: utf-8 -*-
4 # Copyright 2019 Tech Mahindra Limited
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
12 # http://www.apache.org/licenses/LICENSE-2.0
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
22 # 1. Feature 7829: Jayant Madavi, Mrityunjay Yadav : MY00514913@techmahindra.com : 06-aug-2019 : Improvement to the code, robot framework initial seed code.
27 ${success_return_code} 0
28 ${ns_launch_max_wait_time} 5min
29 ${ns_launch_pol_time} 30sec
30 ${ns_delete_max_wait_time} 1min
31 ${ns_delete_pol_time} 15sec
36 [Documentation] Get ns instance list
38 ${rc} ${stdout}= Run and Return RC and Output osm ns-list
40 Should Be Equal As Integers ${rc} ${success_return_code}
44 [Arguments] ${ns_name}
46 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}" | awk 'NR==4{print $4}'
51 Verify All JUJU Applications Status
52 [Arguments] ${ns} ${api_ip} ${api_port} ${username} ${password} ${api_cert_path}
54 ${juju_model}= Get NS Instance ID ${ns}
56 Import Library robot_juju.JujuLibrary ${api_ip} ${api_port} ${juju_model} ${username} ${password} ${api_cert_path}
57 Assert status of applications is ${status_active}
60 Launch Network Services and Return
61 [Arguments] ${vim_name} ${ns_config}=''
62 [Documentation] Get Configuration parameter to create Newtork service
64 Run Keyword If ${ns_config}=='' Get NS Config
65 ... ELSE Set NS Config ${ns_config}
66 Log To Console \n${nsconfig}
67 Should Not Be Empty ${nsd_ids} There are no NS descriptors to launch the NS
68 :FOR ${nsd} IN @{nsd_ids}
69 \ ${ns_name}= GENERATE NAME
70 \ Append To List ${ns_ids} ${ns_name}
71 \ Create Network Service ${nsd} ${vim_name} ${ns_name} ${nsconfig}
75 [Arguments] ${ns_config}
76 [Documentation] Set NS Configuration variable
78 ${nsconfig}= Get Variable Value ${ns_config} ''
79 Set Test Variable ${nsconfig}
83 [Documentation] Get NS Configuration from Environment Variable
85 ${nsconfig}= Get Environment Variable NS_CONFIG ''
86 Set Test Variable ${nsconfig}
89 Create Network Service
90 [Documentation] Create ns at osm
91 [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config}
93 Run Keyword If ${ns_config}!='' Create Network Service With Config ${nsd} ${vim_name} ${ns_name} ${ns_config}
94 ... ELSE Create Network Service Without Config ${nsd} ${vim_name} ${ns_name}
96 WAIT UNTIL KEYWORD SUCCEEDS ${ns_launch_max_wait_time} ${ns_launch_pol_time} Check For NS Instance To Configured ${ns_name}
97 Check For NS Instance For Failure ${ns_name}
100 Create Network Service Without Config
101 [Documentation] Create ns at osm
102 [Arguments] ${nsd} ${vim_name} ${ns_name}
104 ${rc} ${stdout}= Run and Return RC and Output osm ns-create --ns_name ${ns_name} --nsd_name ${nsd} --vim_account ${vim_name}
106 Should Be Equal As Integers ${rc} ${success_return_code}
109 Create Network Service With Config
110 [Documentation] Create ns at osm
111 [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config}
113 ${rc} ${stdout}= Run and Return RC and Output osm ns-create --ns_name ${ns_name} --nsd_name ${nsd} --vim_account ${vim_name} --config ${ns_config}
115 Should Be Equal As Integers ${rc} ${success_return_code}
119 [Documentation] Delete ns
122 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
124 Should Be Equal As Integers ${rc} ${success_return_code}
126 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Delete ${ns}
129 Check For NS Instance To Configured
130 [Arguments] ${ns_name}
132 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
134 Should Be Equal As Integers ${rc} ${success_return_code}
135 Should Contain Any ${stdout} READY BROKEN
138 Check For NS Instance For Failure
139 [Arguments] ${ns_name}
141 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
143 Should Be Equal As Integers ${rc} ${success_return_code}
144 Should Not Contain ${stdout} BROKEN
147 Check For NS Instance To Be Delete
150 ${rc} ${stdout}= Run and Return RC and Output osm ns-list
152 Should Be Equal As Integers ${rc} ${success_return_code}
153 Should Not Contain ${stdout} ${ns}
157 [Documentation] Forcely Delete ns
160 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
162 Should Be Equal As Integers ${rc} ${success_return_code}
163 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Delete ${ns}
166 Perform VNF Scale-in Operation
167 [Arguments] ${ns} ${vnf_member} ${scaling_group}
169 ${rc} ${nsr}= Run and Return RC and Output osm ns-show ${ns} --literal
170 ${scaled_vnf}= Get Scaled Vnf ${nsr}
171 log to console Scaled VNF befor scale-in operation is ${scaled_vnf}
172 ${rc} ${stdout}= Run and Return RC and Output osm vnf-scale --scale-in --scaling-group ${scaling_group} ${ns} ${vnf_member}
173 Should Be Equal As Integers ${rc} ${success_return_code}
175 Sleep 1m Waiting for scale-in operation to complete
176 ${rc} ${nsr}= Run and Return RC and Output osm ns-show ${ns} --literal
177 ${scaled_vnf}= Get Scaled Vnf ${nsr}
178 log to console Scaled VNF after scale-in operation is ${scaled_vnf}
181 Perform VNF Scale-out Operation
182 [Arguments] ${ns} ${vnf_member} ${scaling_group}
184 ${rc} ${nsr}= Run and Return RC and Output osm ns-show ${ns} --literal
185 ${scaled_vnf}= Get Scaled Vnf ${nsr}
186 log to console Scaled VNF befor scale-out operation is ${scaled_vnf}
187 ${rc} ${stdout}= Run and Return RC and Output osm vnf-scale --scale-out --scaling-group ${scaling_group} ${ns} ${vnf_member}
188 Should Be Equal As Integers ${rc} ${success_return_code}
190 Sleep 1m Waiting for scale-out operation to complete
191 ${rc} ${nsr}= Run and Return RC and Output osm ns-show ${ns} --literal
192 ${scaled_vnf}= Get Scaled Vnf ${nsr}
193 log to console Scaled VNF befor scale-out operation is ${scaled_vnf}