Reformat Robot files to follow best practices
[osm/tests.git] / robot-systest / lib / project_lib.robot
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
4 #
5 #       http://www.apache.org/licenses/LICENSE-2.0
6 #
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.
12
13 *** Variables ***
14 ${success_return_code}   0
15
16
17 *** Keywords ***
18 Create Project
19     [Arguments]   ${project_name}
20
21     Should Not Be Empty   ${project_name}
22     ${rc}   ${stdout}=   Run and Return RC and Output   osm project-create ${project_name}
23     Log   ${stdout}
24     Should Be Equal As Integers   ${rc}   ${success_return_code}
25     [Return]   ${stdout}
26
27
28 Create Project With Quotas
29     [Arguments]   ${project_name}   ${project_quotas}
30
31     Should Not Be Empty   ${project_name}
32     Should Not Be Empty   ${project_quotas}
33     ${rc}   ${stdout}=   Run and Return RC and Output   osm project-create ${project_name} --quotas ${project_quotas}
34     Log   ${stdout}
35     Should Be Equal As Integers   ${rc}   ${success_return_code}
36     [Return]   ${stdout}
37
38
39 Get Project Quotas
40     [Arguments]   ${project_name}   ${quotas_name}
41
42     Should Not Be Empty   ${project_name}
43     Should Not Be Empty   ${quotas_name}
44     ${rc}   ${stdout}=   Run and Return RC and Output   osm project-show ${project_name} | grep '${quotas_name}' | awk -F ',|: ' '{print $2}' | awk '{print $1}'
45     Log   ${stdout}
46     Should Be Equal As Integers   ${rc}   ${success_return_code}
47     [Return]   ${stdout}
48
49
50 Update Project Quotas
51     [Arguments]   ${project_name}   ${project_quotas}
52
53     Should Not Be Empty   ${project_name}
54     Should Not Be Empty   ${project_quotas}
55     ${rc}   ${stdout}=   Run and Return RC and Output   osm project-update ${project_name} --quotas ${project_quotas}
56     Log   ${stdout}
57     Should Be Equal As Integers   ${rc}   ${success_return_code}
58
59
60 Update Project Name
61     [Arguments]   ${project_name}   ${new_name}
62
63     Should Not Be Empty   ${project_name}
64     Should Not Be Empty   ${new_name}
65     ${rc}   ${stdout}=   Run and Return RC and Output   osm project-update ${project_name} --name ${new_name}
66     log   ${stdout}
67     Should Be Equal As Integers   ${rc}   ${success_return_code}
68
69
70 Check If User Is Assigned To Project
71     [Arguments]   ${user_name}   ${project_name}
72
73     Should Not Be Empty   ${user_name}
74     Should Not Be Empty   ${project_name}
75     ${rc}   ${stdout}=   Run And Return RC And Output   osm user-show ${user_name} | grep "project_name" | grep "${project_name}"
76     Log   ${stdout}
77     Should Be Equal As Integers   ${rc}   ${success_return_code}
78
79
80 Create VNFD In Project
81     [Documentation]   Onboards a VNFD package into an OSM project.
82     ...                 Extra parameters (such as 'override') are given to this function in name=value format. These parameters will be appended to the 'osm vnfpkg-create' command with the next syntax: --param_name=param_value
83
84     [Arguments]   ${project_name}   ${vnfd_pkg}   ${project_user}   ${user_password}   @{optional_parameters}
85
86     Should Not Be Empty   ${project_name}
87     Should Not Be Empty   ${vnfd_pkg}
88     Should Not Be Empty   ${project_user}
89     Should Not Be Empty   ${user_password}
90
91     ${osm_pkg_create_command}=   Set Variable   osm --project ${project_name} --user ${project_user} --password ${user_password} vnfpkg-create ${vnfd_pkg}
92     FOR   ${param}   IN   @{optional_parameters}
93         ${match}   ${param_name}   ${param_value} =   Should Match Regexp   ${param}   (.+)=(.+)   msg=Syntax error in optional parameters
94         ${osm_pkg_create_command}=   Catenate   ${osm_pkg_create_command}   --${param_name}=${param_value}
95     END
96
97     ${rc}   ${stdout}=   Run and Return RC and Output   ${osm_pkg_create_command}
98     Log   ${stdout}
99     Should Be Equal As Integers   ${rc}   ${success_return_code}
100     [Return]   ${stdout}
101
102
103 Delete VNFD In Project
104     [Arguments]   ${project_name}   ${vnfd_pkg}   ${project_user}   ${user_password}
105
106     Should Not Be Empty   ${project_name}
107     Should Not Be Empty   ${vnfd_pkg}
108     Should Not Be Empty   ${project_user}
109     Should Not Be Empty   ${user_password}
110     ${rc}   ${stdout}=   Run and Return RC and Output   osm --project ${project_name} --user ${project_user} --password ${user_password} vnfpkg-delete ${vnfd_pkg}
111     Log   ${stdout}
112     Should Be Equal As Integers   ${rc}   ${success_return_code}
113
114
115 Remove User From Project
116     [Arguments]   ${user_name}   ${project_name}
117
118     Should Not Be Empty   ${user_name}
119     Should Not Be Empty   ${project_name}
120     ${rc}   ${stdout}=   Run And Return RC And Output   osm user-update ${user_name} --remove-project ${project_name}
121     Log   ${stdout}
122     Should Be Equal As Integers   ${rc}   ${success_return_code}
123
124
125 Delete Project
126     [Arguments]   ${project_name}
127
128     ${rc}   ${stdout}=   Run and Return RC and Output   osm project-delete ${project_name}
129     Log   ${stdout}
130     Should Be Equal As Integers   ${rc}   ${success_return_code}