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}
43 Launch Network Services and Return
44 [Arguments] ${vim_name} ${ns_config}=''
45 [Documentation] Get Configuration parameter to create Newtork service
47 Run Keyword If ${ns_config}=='' Get NS Config
48 ... ELSE Set NS Config ${ns_config}
49 Log To Console \n${nsconfig}
50 Should Not Be Empty ${nsd_ids} There are no NS descriptors to launch the NS
51 :FOR ${nsd} IN @{nsd_ids}
52 \ ${ns_name}= GENERATE NAME
53 \ Append To List ${ns_ids} ${ns_name}
54 \ Create Network Service ${nsd} ${vim_name} ${ns_name} ${nsconfig}
58 [Arguments] ${ns_config}
59 [Documentation] Set NS Configuration variable
61 ${nsconfig}= Get Variable Value ${ns_config} ''
62 Set Test Variable ${nsconfig}
66 [Documentation] Get NS Configuration from Environment Variable
68 ${nsconfig}= Get Environment Variable NS_CONFIG ''
69 Set Test Variable ${nsconfig}
72 Create Network Service
73 [Documentation] Create ns at osm
74 [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config}
76 Run Keyword If ${ns_config}!='' Create Network Service With Config ${nsd} ${vim_name} ${ns_name} ${ns_config}
77 ... ELSE Create Network Service Without Config ${nsd} ${vim_name} ${ns_name}
79 WAIT UNTIL KEYWORD SUCCEEDS ${ns_launch_max_wait_time} ${ns_launch_pol_time} Check For NS Instance To Configured ${ns_name}
80 Check For NS Instance For Failure ${ns_name}
83 Create Network Service Without Config
84 [Documentation] Create ns at osm
85 [Arguments] ${nsd} ${vim_name} ${ns_name}
87 ${rc} ${stdout}= Run and Return RC and Output osm ns-create --ns_name ${ns_name} --nsd_name ${nsd} --vim_account ${vim_name}
89 Should Be Equal As Integers ${rc} ${success_return_code}
92 Create Network Service With Config
93 [Documentation] Create ns at osm
94 [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config}
96 ${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}
98 Should Be Equal As Integers ${rc} ${success_return_code}
102 [Documentation] Delete ns
105 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
107 Should Be Equal As Integers ${rc} ${success_return_code}
109 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Delete ${ns}
112 Check For NS Instance To Configured
113 [Arguments] ${ns_name}
115 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
117 Should Be Equal As Integers ${rc} ${success_return_code}
118 Should Contain Any ${stdout} READY BROKEN
121 Check For NS Instance For Failure
122 [Arguments] ${ns_name}
124 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
126 Should Be Equal As Integers ${rc} ${success_return_code}
127 Should Not Contain ${stdout} BROKEN
130 Check For NS Instance To Be Delete
133 ${rc} ${stdout}= Run and Return RC and Output osm ns-list
135 Should Be Equal As Integers ${rc} ${success_return_code}
136 Should Not Contain ${stdout} ${ns}
140 [Documentation] Forcely Delete ns
143 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
145 Should Be Equal As Integers ${rc} ${success_return_code}
146 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Delete ${ns}