Refactor packages_lib into package_lib
[osm/tests.git] / robot-systest / lib / package_lib.robot
1 # -*- coding: utf-8 -*-
2
3 ##
4 # Copyright ETSI Contributors and Others.
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 *** Settings ***
22 Library   String
23 Library   OperatingSystem
24
25
26 *** Variables ***
27 ${success_return_code}   0
28 ${delete_max_wait_time}   1min
29 ${delete_pol_time}   15sec
30
31
32 *** Keywords ***
33 Upload Package
34     [Documentation]   Onboards ("creates") a NF Package into OSM.
35     ...               - Parameters:
36     ...                 - pkg: Name (and location) of the NF Package
37
38     [Arguments]   ${pkg}
39
40     # Proceedes with the onboarding with the appropriate arguments
41     ${rc}   ${stdout}=   Run and Return RC and Output   tar -czf ${pkg}.tar.gz -C ${pkg} .
42     ${rc}   ${stdout}=   Run and Return RC and Output   osm upload-package ${pkg}.tar.gz
43     log   ${stdout}
44     Should Be Equal As Integers   ${rc}   ${success_return_code}
45     [Return]   ${stdout}
46
47
48 Delete Package
49     [Arguments]   ${pkg}
50
51     # Proceedes with the onboarding with the appropriate arguments
52     ${rc}   ${stdout}=   Run and Return RC and Output   rm ${pkg}.tar.gz
53
54
55 Package Build
56     [Documentation]   Build the package NS, VNF given the package_folder
57
58     [Arguments]   ${pkg_folder}   ${skip_charm_build}=${EMPTY}
59
60     ${skip_charm}   Set Variable If   '${skip_charm_build}'!='${EMPTY}'   --skip-charm-build   \
61     ${rc}   ${stdout}=   Run and Return RC and Output   osm package-build ${pkg_folder} ${skip_charm}
62     Should Be Equal As Integers   ${rc}   ${success_return_code}
63     Should Contain   ${stdout}   Package created
64     ${package}=   Get Line   ${stdout}   -1
65
66     [Return]   ${package}
67
68
69 Package Validate
70     [Documentation]   Validate descriptors given a base directory
71
72     [Arguments]   ${pkg_folder}
73     ${rc}   ${stdout}=   Run and Return RC and Output   osm package-validate ${pkg_folder} | awk -F\| '$2 !~ /-/ && $4 ~ /OK|ERROR/ {print $4}'
74     Should Be Equal As Integers   ${rc}   ${success_return_code}
75     Should Contain   ${stdout}   'OK'
76     ${package}=   Get Line   ${stdout}   -1
77
78     [Return]   ${package}
79