1 # Licensed under the Apache License, Version 2.0 (the "License");
2 # you may not use this file except in compliance with the License.
3 # You may obtain a copy of the License at
5 # http://www.apache.org/licenses/LICENSE-2.0
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS,
9 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10 # See the License for the specific language governing permissions and
11 # limitations under the License.
14 ${success_return_code} 0
15 ${ns_launch_max_wait_time} 5min
16 ${ns_launch_pol_time} 30sec
17 ${ns_delete_max_wait_time} 1min
18 ${ns_delete_pol_time} 15sec
19 ${ns_action_max_wait_time} 1min
20 ${ns_action_pol_time} 15sec
21 ${vnf_scale_max_wait_time} 5min
22 ${vnf_scale_pol_time} 30sec
26 Create Network Service
27 [Arguments] ${nsd} ${vim_name} ${ns_name} ${ns_config} ${publickey}
29 ${config_attr} Set Variable If '${ns_config}'!='${EMPTY}' --config '${ns_config}' \
30 ${sshkeys_attr} Set Variable If '${publickey}'!='${EMPTY}' --ssh_keys ${publickey} \
32 ${ns_id}= Instantiate Network Service ${ns_name} ${nsd} ${vim_name} ${config_attr} ${sshkeys_attr}
35 WAIT UNTIL KEYWORD SUCCEEDS ${ns_launch_max_wait_time} ${ns_launch_pol_time} Check For NS Instance To Configured ${ns_name}
36 Check For NS Instance For Failure ${ns_name}
39 Instantiate Network Service
40 [Arguments] ${ns_name} ${nsd} ${vim_name} ${ns_extra_args}
42 ${rc} ${stdout}= Run and Return RC and Output osm ns-create --ns_name ${ns_name} --nsd_name ${nsd} --vim_account ${vim_name} ${ns_extra_args}
44 Should Be Equal As Integers ${rc} ${success_return_code}
47 Get Vnf Management Ip Address
48 [Arguments] ${ns_id} ${vnf_member_index}
50 Should Not Be Empty ${ns_id}
51 Should Not Be Empty ${vnf_member_index}
52 ${rc} ${stdout}= Run and Return RC and Output osm vnf-list --filter member-vnf-index-ref=${vnf_member_index} | grep ${ns_id} | awk '{print $14}' 2>&1
54 Should Be Equal As Integers ${rc} ${success_return_code}
57 Check For NS Instance To Configured
58 [Arguments] ${ns_name}
60 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
62 Should Be Equal As Integers ${rc} ${success_return_code}
63 Should Contain Any ${stdout} READY BROKEN
65 Check For NS Instance For Failure
66 [Arguments] ${ns_name}
68 ${rc} ${stdout}= Run and Return RC and Output osm ns-list --filter name="${ns_name}"
70 Should Be Equal As Integers ${rc} ${success_return_code}
71 Should Not Contain ${stdout} BROKEN
73 Check For NS Instance To Be Deleted
76 ${rc} ${stdout}= Run and Return RC and Output osm ns-list | awk '{print $2}' | grep ${ns}
77 Should Not Be Equal As Strings ${stdout} ${ns}
80 [Documentation] Delete ns
83 ${rc} ${stdout}= Run and Return RC and Output osm ns-delete ${ns}
85 Should Be Equal As Integers ${rc} ${success_return_code}
87 WAIT UNTIL KEYWORD SUCCEEDS ${ns_delete_max_wait_time} ${ns_delete_pol_time} Check For NS Instance To Be Deleted ${ns}
90 [Documentation] Execute an action over the desired NS.
91 ... Parameters are given to this function in key=value format (one argument per key/value pair).
92 ... Return the ID of the operation associated to the executed action.
93 ... Examples of execution:
94 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index}
95 ... \${ns_op_id}= Execute NS Action \${ns_name} \${ns_action} \${vnf_member_index} \${param1}=\${value1} \${param2}=\${value2}
97 [Arguments] ${ns_name} ${ns_action} ${vnf_member_index} @{action_params}
99 ${params}= Set Variable ${EMPTY}
100 FOR ${param} IN @{action_params}
101 ${match} ${param_name} ${param_value} = Should Match Regexp ${param} (.+)=(.+) msg=Syntax error in parameters
102 ${params}= Catenate SEPARATOR= ${params} "${param_name}":"${param_value}",
104 ${osm_ns_action_command}= Set Variable osm ns-action --action_name ${ns_action} --vnf_name ${vnf_member_index}
105 ${osm_ns_action_command}= Run Keyword If '${params}'!='${EMPTY}' Catenate ${osm_ns_action_command} --params '{${params}}'
106 ... ELSE Set Variable ${osm_ns_action_command}
107 ${osm_ns_action_command}= Catenate ${osm_ns_action_command} ${ns_name}
108 ${rc} ${stdout}= Run and Return RC and Output ${osm_ns_action_command}
109 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
110 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
114 Execute Manual VNF Scale
115 [Documentation] Execute a manual VNF Scale action.
116 ... The parameter 'scale_type' must be SCALE_IN or SCALE_OUT.
117 ... Return the ID of the operation associated to the executed scale action.
119 [Arguments] ${ns_name} ${vnf_member_index} ${scaling_group} ${scale_type}
121 Should Contain Any ${scale_type} SCALE_IN SCALE_OUT msg=Unknown scale type: ${scale_type} values=False
122 ${osm_vnf_scale_command}= Set Variable osm vnf-scale --scaling-group ${scaling_group}
123 ${osm_vnf_scale_command}= Run Keyword If '${scale_type}'=='SCALE_IN' Catenate ${osm_vnf_scale_command} --scale-in
124 ... ELSE Catenate ${osm_vnf_scale_command} --scale-out
125 ${osm_vnf_scale_command}= Catenate ${osm_vnf_scale_command} ${ns_name} ${vnf_member_index}
126 ${rc} ${stdout}= Run and Return RC and Output ${osm_vnf_scale_command}
127 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
128 Wait Until Keyword Succeeds ${ns_action_max_wait_time} ${ns_action_pol_time} Check For NS Operation Completed ${stdout}
133 [Arguments] ${ns_name}
135 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-list ${ns_name}
138 Should Be Equal As Integers ${rc} ${success_return_code}
141 Check For NS Operation Completed
142 [Documentation] Check wheter the status of the desired operation is "COMPLETED" or not.
144 [Arguments] ${ns_operation_id}
146 ${rc} ${stdout}= Run and Return RC and Output osm ns-op-show ${ns_operation_id} --literal | yq r - operationState
148 Should Be Equal As Integers ${rc} ${success_return_code}
149 Should Contain ${stdout} COMPLETED msg=Timeout waiting for ns-action with id ${ns_operation_id} values=False
153 [Documentation] Return a list with the IDs of the VNF records of a NS instance.
157 ${rc} ${stdout}= Run and Return RC and Output osm vnf-list | grep ${ns_id} | awk '{print $2}' 2>&1
158 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
159 @{vdur} = Split String ${stdout}
164 [Documentation] Return a list with the names of the VDU records of a VNF instance.
166 [Arguments] ${vnf_id}
168 ${rc} ${stdout}= Run and Return RC and Output osm vnf-show ${vnf_id} --literal | yq r - vdur.*.name
169 Should Be Equal As Integers ${rc} ${success_return_code} msg=${stdout} values=False
170 @{vdur} = Split String ${stdout}