Adds Robot QUOTAS-01 test
[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 With Quotas
19     [Arguments]   ${project_name}   ${project_quotas}
20
21     Should Not Be Empty   ${project_name}
22     Should Not Be Empty   ${project_quotas}
23     ${rc}   ${stdout}=   Run and Return RC and Output   osm project-create ${project_name} --quotas ${project_quotas}
24     Log   ${stdout}
25     Should Be Equal As Integers   ${rc}   ${success_return_code}
26     [Return]  ${stdout}
27
28
29 Get Project Quotas
30     [Arguments]   ${project_name}   ${quotas_name}
31
32     Should Not Be Empty   ${project_name}
33     Should Not Be Empty   ${quotas_name}
34     ${rc}   ${stdout}=   Run and Return RC and Output   osm project-show ${project_name} | grep '${quotas_name}' | awk -F ',|: ' '{print $2}' | awk '{print $1}'
35     Log   ${stdout}
36     Should Be Equal As Integers   ${rc}   ${success_return_code}
37     [Return]  ${stdout}
38
39
40 Update Project Quotas
41     [Arguments]   ${project_name}   ${project_quotas}
42
43     Should Not Be Empty   ${project_name}
44     Should Not Be Empty   ${project_quotas}
45     ${rc}   ${stdout}=   Run and Return RC and Output   osm project-update ${project_name} --quotas ${project_quotas}
46     Log   ${stdout}
47     Should Be Equal As Integers   ${rc}   ${success_return_code}
48
49
50 Update Project Name
51     [Arguments]   ${project_name}   ${new_name}
52
53     Should Not Be Empty   ${project_name}
54     Should Not Be Empty   ${new_name}
55     ${rc}   ${stdout}=   Run and Return RC and Output   osm project-update ${project_name} --name ${new_name}
56     log   ${stdout}
57     Should Be Equal As Integers   ${rc}   ${success_return_code}
58
59
60 Check If User Is Assigned To Project
61     [Arguments]  ${user_name}  ${project_name}
62
63     Should Not Be Empty   ${user_name}
64     Should Not Be Empty   ${project_name}
65     ${rc}   ${stdout}=   Run And Return RC And Output   osm user-show ${user_name} | grep "project_name" | grep "${project_name}"
66     Log   ${stdout}
67     Should Be Equal As Integers   ${rc}   ${success_return_code}
68
69
70 Create VNFD In Project
71     [Documentation]     Onboards a VNFD package into an OSM project.
72     ...                 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
73
74     [Arguments]   ${project_name}   ${vnfd_pkg}   ${project_user}   ${user_password}   @{optional_parameters}
75
76     Should Not Be Empty   ${project_name}
77     Should Not Be Empty   ${vnfd_pkg}
78     Should Not Be Empty   ${project_user}
79     Should Not Be Empty   ${user_password}
80
81     ${osm_pkg_create_command}=  Set Variable  osm --project ${project_name} --user ${project_user} --password ${user_password} vnfpkg-create ${vnfd_pkg}
82     FOR  ${param}  IN  @{optional_parameters}
83         ${match}  ${param_name}  ${param_value} =  Should Match Regexp  ${param}  (.+)=(.+)  msg=Syntax error in optional parameters
84         ${osm_pkg_create_command}=  Catenate  ${osm_pkg_create_command}  --${param_name}=${param_value}
85     END
86
87     ${rc}   ${stdout}=   Run and Return RC and Output   ${osm_pkg_create_command}
88     Log   ${stdout}
89     Should Be Equal As Integers   ${rc}   ${success_return_code}
90     [Return]  ${stdout}
91
92
93 Delete VNFD In Project
94     [Arguments]   ${project_name}   ${vnfd_pkg}   ${project_user}   ${user_password}
95
96     Should Not Be Empty   ${project_name}
97     Should Not Be Empty   ${vnfd_pkg}
98     Should Not Be Empty   ${project_user}
99     Should Not Be Empty   ${user_password}
100     ${rc}   ${stdout}=   Run and Return RC and Output   osm --project ${project_name} --user ${project_user} --password ${user_password} vnfpkg-delete ${vnfd_pkg}
101     Log   ${stdout}
102     Should Be Equal As Integers   ${rc}   ${success_return_code}
103
104
105 Remove User From Project
106     [Arguments]  ${user_name}  ${project_name}
107
108     Should Not Be Empty   ${user_name}
109     Should Not Be Empty   ${project_name}
110     ${rc}   ${stdout}=   Run And Return RC And Output   osm user-update ${user_name} --remove-project ${project_name}
111     Log   ${stdout}
112     Should Be Equal As Integers   ${rc}   ${success_return_code}
113
114
115 Delete Project
116     [Arguments]  ${project_name}
117
118     ${rc}   ${stdout}=   Run and Return RC and Output   osm project-delete ${project_name}
119     Log   ${stdout}
120     Should Be Equal As Integers   ${rc}   ${success_return_code}