blob: 9588527c88f8878e5fd4e5664ef50b6511bb467e [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-aug-2019 : Improvement to the code, robot framework initial seed code.
23##
24
25
26*** Variables ***
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
32
33
34*** Keywords ***
35Get NS List
36 [Documentation] Get ns instance list
37
yadavmrf21d9da2019-11-05 11:42:57 +053038 ${rc} ${stdout}= Run and Return RC and Output osm ns-list
yadavmr58af6b12019-09-18 15:33:25 +053039 log ${stdout}
yadavmrf21d9da2019-11-05 11:42:57 +053040 Should Be Equal As Integers ${rc} ${success_return_code}
yadavmr58af6b12019-09-18 15:33:25 +053041
42
43Launch Network Services and Return
44 [Arguments] ${vim_name}
yadavmrf21d9da2019-11-05 11:42:57 +053045
46 Should Not Be Empty ${nsd_ids} There are no NS descriptors to launch the NS
yadavmr58af6b12019-09-18 15:33:25 +053047 :FOR ${nsd} IN @{nsd_ids}
48 \ ${ns_name}= GENERATE NAME
49 \ Append To List ${ns_ids} ${ns_name}
50 \ Create Network Service ${nsd} ${vim_name} ${ns_name}
yadavmr58af6b12019-09-18 15:33:25 +053051
yadavmrf21d9da2019-11-05 11:42:57 +053052
yadavmr58af6b12019-09-18 15:33:25 +053053Create Network Service
54 [Documentation] Create ns at osm
55 [Arguments] ${nsd} ${vim_name} ${ns_name}
56
yadavmrf21d9da2019-11-05 11:42:57 +053057 ${ns_config}= Get Environment Variable NS_CONFIG ''
58 Run Keyword If ${ns_config}!='' Create Network Service With Config ${nsd} ${vim_name} ${ns_name} ${ns_config}
59 ... ELSE Create Network Service Without Config ${nsd} ${vim_name} ${ns_name}
60
yadavmr58af6b12019-09-18 15:33:25 +053061 WAIT UNTIL KEYWORD SUCCEEDS ${ns_launch_max_wait_time} ${ns_launch_pol_time} Check For NS Instance To Configured ${ns_name}
62 Check For NS Instance For Failure ${ns_name}
yadavmrf21d9da2019-11-05 11:42:57 +053063
yadavmr58af6b12019-09-18 15:33:25 +053064
65Create Network Service Without Config
66 [Documentation] Create ns at osm
67 [Arguments] ${nsd} ${vim_name} ${ns_name}
68
yadavmrf21d9da2019-11-05 11:42:57 +053069 ${rc} ${stdout}= Run and Return RC and Output osm ns-create --ns_name ${ns_name} --nsd_name ${nsd} --vim_account ${vim_name}
yadavmr58af6b12019-09-18 15:33:25 +053070 log ${stdout}
yadavmrf21d9da2019-11-05 11:42:57 +053071 Should Be Equal As Integers ${rc} ${success_return_code}
yadavmr58af6b12019-09-18 15:33:25 +053072
73
74Create Network Service With Config
75 [Documentation] Create ns at osm
76 [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config}
77
yadavmrf21d9da2019-11-05 11:42:57 +053078 ${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}
yadavmr58af6b12019-09-18 15:33:25 +053079 log ${stdout}
yadavmrf21d9da2019-11-05 11:42:57 +053080 Should Be Equal As Integers ${rc} ${success_return_code}
yadavmr58af6b12019-09-18 15:33:25 +053081
yadavmrf21d9da2019-11-05 11:42:57 +053082
yadavmr58af6b12019-09-18 15:33:25 +053083Delete NS
84 [Documentation] Delete ns
85 [Arguments] ${ns}
86
yadavmrf21d9da2019-11-05 11:42:57 +053087 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
yadavmr58af6b12019-09-18 15:33:25 +053088 log ${stdout}
yadavmrf21d9da2019-11-05 11:42:57 +053089 Should Be Equal As Integers ${rc} ${success_return_code}
yadavmr58af6b12019-09-18 15:33:25 +053090
91 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Delete ${ns}
92
93
94Check For NS Instance To Configured
95 [Arguments] ${ns_name}
96
yadavmrf21d9da2019-11-05 11:42:57 +053097 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
yadavmr58af6b12019-09-18 15:33:25 +053098 log ${stdout}
yadavmrf21d9da2019-11-05 11:42:57 +053099 Should Be Equal As Integers ${rc} ${success_return_code}
yadavmr58af6b12019-09-18 15:33:25 +0530100 Should Contain Any ${stdout} configured failed
101
102
103Check For NS Instance For Failure
104 [Arguments] ${ns_name}
105
yadavmrf21d9da2019-11-05 11:42:57 +0530106 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
yadavmr58af6b12019-09-18 15:33:25 +0530107 log ${stdout}
yadavmrf21d9da2019-11-05 11:42:57 +0530108 Should Be Equal As Integers ${rc} ${success_return_code}
yadavmr58af6b12019-09-18 15:33:25 +0530109 Should Not Contain ${stdout} failed
110
111
112Check For NS Instance To Be Delete
113 [Arguments] ${ns}
114
yadavmrf21d9da2019-11-05 11:42:57 +0530115 ${rc} ${stdout}= Run and Return RC and Output osm ns-list
yadavmr58af6b12019-09-18 15:33:25 +0530116 log ${stdout}
yadavmrf21d9da2019-11-05 11:42:57 +0530117 Should Be Equal As Integers ${rc} ${success_return_code}
yadavmr58af6b12019-09-18 15:33:25 +0530118 Should Not Contain ${stdout} ${ns}
119
120
121Force Delete NS
122 [Documentation] Forcely Delete ns
123 [Arguments] ${ns}
124
yadavmrf21d9da2019-11-05 11:42:57 +0530125 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
yadavmr58af6b12019-09-18 15:33:25 +0530126 log ${stdout}
yadavmrf21d9da2019-11-05 11:42:57 +0530127 Should Be Equal As Integers ${rc} ${success_return_code}
yadavmr58af6b12019-09-18 15:33:25 +0530128 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Delete ${ns}