Moving robot-systests deprecated to tests
[osm/tests.git] / robot-systest / deprecated / lib / cli / network_slicing_lib.robot
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. Jayant Madavi, Mrityunjay Yadav : MY00514913@techmahindra.com : 08-nov-2019
23 ##
24
25 *** Variables ***
26 ${success_return_code}    0
27 ${delete_max_wait_time}    1min
28 ${delete_pol_time}    15sec
29 ${ns_launch_max_wait_time}    5min
30 ${ns_launch_pol_time}    30sec
31
32
33 *** Keywords ***
34 Create NST
35     [Documentation]  Create nst at osm
36     [Arguments]  ${nst_pkg}
37
38     ${rc}   ${stdout}=      Run and Return RC and Output            osm nst-create ${nst_pkg}
39     log     ${stdout}
40     Should Be Equal As Integers         ${rc}     ${success_return_code}
41     [Return]  ${stdout}
42
43
44 Delete NST
45     [Documentation]  delete nst at osm
46     [Arguments]  ${nst}
47
48     ${rc}   ${stdout}=      Run and Return RC and Output            osm nst-delete ${nst}
49     log     ${stdout}
50     Should Be Equal As Integers         ${rc}     ${success_return_code}
51     [Return]  ${stdout}
52
53
54 Launch Network Slice Instance
55     [Arguments]  ${vim_name}    ${nst_name}    ${ns_config}=''
56
57     ${nsi_name}=    GENERATE NAME
58     Run Keyword If   ${ns_config}!=''   Create Network Slice With Config    ${nsi_name}    ${nst_name}    ${vim_name}    ${ns_config}
59     ...    ELSE    Create Network Slice Without Config    ${nsi_name}    ${nst_name}    ${vim_name}
60
61     WAIT UNTIL KEYWORD SUCCEEDS     ${ns_launch_max_wait_time}   ${ns_launch_pol_time}   Check For Network Slice Instance To Configured   ${nsi_name}
62     Check For Network Slice Instance For Failure    ${nsi_name}
63
64
65 Create Network Slice With Config
66     [Arguments]  ${nsi_name}    ${nst_name}    ${vim}    ${config}
67
68     ${rc}   ${stdout}=      Run and Return RC and Output    osm nsi-create --nsi_name ${nsi_name} --nst_name ${nst_name} --vim_account ${vim} --config ${config}
69     log     ${stdout}
70     Should Be Equal As Integers    ${rc}    ${success_return_code}
71     Append To List     ${nsi_list}       ${nsi_name}
72
73
74 Create Network Slice Without Config
75     [Arguments]  ${nsi_name}    ${nst_name}    ${vim}
76
77     ${rc}   ${stdout}=      Run and Return RC and Output    osm nsi-create --nsi_name ${nsi_name} --nst_name ${nst_name} --vim_account ${vim}
78     log     ${stdout}
79     Should Be Equal As Integers    ${rc}    ${success_return_code}
80     Append To List     ${nsi_list}       ${nsi_name}
81
82
83 Check For Network Slice Instance For Failure
84     [Arguments]  ${nsi_name}
85
86     ${rc}   ${stdout}=      Run and Return RC and Output    osm nsi-list --filter name="${nsi_name}"
87     log     ${stdout}
88     Should Be Equal As Integers    ${rc}    ${success_return_code}
89     Should Not Contain      ${stdout}   failed
90
91
92 Check For Network Slice Instance To Configured
93     [Arguments]  ${nsi_name}
94
95     ${rc}   ${stdout}=      Run and Return RC and Output    osm nsi-list --filter name="${nsi_name}"
96     log     ${stdout}
97     Should Be Equal As Integers    ${rc}    ${success_return_code}
98     Should Contain Any      ${stdout}   configured    failed
99
100
101 Delete Network Slice Instance
102     [Documentation]  Delete ns
103     [Arguments]  ${nsi}
104
105     ${rc}   ${stdout}=      Run and Return RC and Output    osm nsi-delete ${nsi}
106     log     ${stdout}
107     Should Be Equal As Integers    ${rc}    ${success_return_code}
108
109     WAIT UNTIL KEYWORD SUCCEEDS  ${delete_max_wait_time}   ${delete_pol_time}   Check For NSI Instance To Be Delete   ${nsi}
110
111
112 Check For NSI Instance To Be Delete
113     [Arguments]  ${nsi}
114
115     ${rc}   ${stdout}=      Run and Return RC and Output    osm nsi-list
116     log     ${stdout}
117     Should Be Equal As Integers    ${rc}    ${success_return_code}
118     Should Not Contain      ${stdout}   ${nsi}