blob: de79f468e873e96da460fda4f623aa4929125a7c [file] [log] [blame]
Marco Platania992832a2019-02-08 15:25:19 -08001*** Settings ***
2Documentation Create VNFC in AAI
3
Marco Platania992832a2019-02-08 15:25:19 -08004Resource aai_interface.robot
5Library OperatingSystem
6Library Collections
DR695H3bb6cf42019-06-20 15:04:04 -04007Library ONAPLibrary.Templating
Marco Platania992832a2019-02-08 15:25:19 -08008
9*** Variables ***
Brian Freemana44f3ee2019-02-19 13:47:04 -050010${VNFC_ROOT_PATH} /network/vnfcs/vnfc
Marco Platania992832a2019-02-08 15:25:19 -080011
DR695H3bb6cf42019-06-20 15:04:04 -040012${AAI_ADD_VNFC_BODY}= aai/add_vnfc_body.jinja
Marco Platania992832a2019-02-08 15:25:19 -080013
14*** Keywords ***
15Create VNFC If Not Exists
16 [Documentation] Creates VNFC in A&AI if it doesn't exist
17 [Arguments] ${vnfc_name} ${vnfc_nc} ${vnfc_func}
Brian Freemana44f3ee2019-02-19 13:47:04 -050018 ${get_resp}= Run A&AI Get Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name}
Marco Platania992832a2019-02-08 15:25:19 -080019 Return From Keyword If '${get_resp.status_code}' == '200'
20 Create VNFC ${vnfc_name} ${vnfc_nc} ${vnfc_func}
21
22Create VNFC
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}
DR695H3bb6cf42019-06-20 15:04:04 -040026 Create Environment aai ${GLOBAL_TEMPLATE_FOLDER}
27 ${data}= Apply Template aai ${AAI_ADD_VNFC_BODY} ${arguments}
Brian Freemana44f3ee2019-02-19 13:47:04 -050028 ${put_resp}= Run A&AI Put Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name} ${data}
Marco Platania992832a2019-02-08 15:25:19 -080029 ${status_string}= Convert To String ${put_resp.status_code}
30 Should Match Regexp ${status_string} ^(201|200)$
31
32Delete VNFC If Exists
33 [Documentation] Removes VNFC from AAI if it exists
34 [Arguments] ${vnfc_name}
Brian Freemana44f3ee2019-02-19 13:47:04 -050035 ${get_resp}= Run A&AI Get Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name}
Marco Platania992832a2019-02-08 15:25:19 -080036 Run Keyword If '${get_resp.status_code}' == '200' Delete VNFC ${vnfc_name} ${get_resp.json()}
37
38Delete VNFC
39 [Documentation] Removes VNFC from AAI
40 [Arguments] ${vnfc_name} ${json}
41 ${resource_version}= Catenate ${json['resource-version']}
Brian Freemana44f3ee2019-02-19 13:47:04 -050042 ${put_resp}= Run A&AI Delete Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name} ${resource_version}
Marco Platania992832a2019-02-08 15:25:19 -080043 Should Be Equal As Strings ${put_resp.status_code} 204
44
45Get VNFC
46 [Documentation] Return VNFC
47 [Arguments] ${vnfc_name}
Brian Freemana44f3ee2019-02-19 13:47:04 -050048 ${resp}= Run A&AI Get Request ${GLOBAL_AAI_INDEX_PATH}${VNFC_ROOT_PATH}/${vnfc_name}
Marco Platania992832a2019-02-08 15:25:19 -080049 Should Be Equal As Strings ${resp.status_code} 200
Brian Freemana44f3ee2019-02-19 13:47:04 -050050 [Return] ${resp.json()}