2 Documentation Create VNFC in AAI
4 Resource aai_interface.robot
5 Library OperatingSystem
7 Library ONAPLibrary.Templating
10 ${VNFC_ROOT_PATH} /network/vnfcs/vnfc
12 ${AAI_ADD_VNFC_BODY}= aai/add_vnfc_body.jinja
15 Create VNFC If Not Exists
16 [Documentation] Creates VNFC in A&AI if it doesn't exist
17 [Arguments] ${vnfc_name} ${vnfc_nc} ${vnfc_func}
18 ${get_resp}= Run A&AI Get Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name}
19 Return From Keyword If '${get_resp.status_code}' == '200'
20 Create VNFC ${vnfc_name} ${vnfc_nc} ${vnfc_func}
23 [Documentation] Creates VNFC in A&AI
24 [Arguments] ${vnfc_name} ${vnfc_nc} ${vnfc_func}
25 ${arguments}= Create Dictionary vnfc_name=${vnfc_name} vnfc_nc=${vnfc_nc} vnfc_func=${vnfc_func}
26 Create Environment aai ${GLOBAL_TEMPLATE_FOLDER}
27 ${data}= Apply Template aai ${AAI_ADD_VNFC_BODY} ${arguments}
28 ${put_resp}= Run A&AI Put Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name} ${data}
29 ${status_string}= Convert To String ${put_resp.status_code}
30 Should Match Regexp ${status_string} ^(201|200)$
33 [Documentation] Removes VNFC from AAI if it exists
34 [Arguments] ${vnfc_name}
35 ${get_resp}= Run A&AI Get Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name}
36 Run Keyword If '${get_resp.status_code}' == '200' Delete VNFC ${vnfc_name} ${get_resp.json()}
39 [Documentation] Removes VNFC from AAI
40 [Arguments] ${vnfc_name} ${json}
41 ${resource_version}= Catenate ${json['resource-version']}
42 ${put_resp}= Run A&AI Delete Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name} ${resource_version}
43 Should Be Equal As Strings ${put_resp.status_code} 204
46 [Documentation] Return VNFC
47 [Arguments] ${vnfc_name}
48 ${resp}= Run A&AI Get Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name}
49 Should Be Equal As Strings ${resp.status_code} 200
50 [Return] ${resp.json()}