blob: e4d7bd51cde4cae02061628a78e608e9eef12472 [file] [log] [blame]
Keong Lim3a5d9472019-03-04 17:15:06 +11001*** Settings ***
2Documentation Operations on connectivities in AAI for CCVPN use case, using earliest API version where it is implemented and latest API version where it is not implemented
3
4Resource ../json_templater.robot
5Resource aai_interface.robot
6Resource api_version_properties.robot
7Library OperatingSystem
8Library Collections
9
10
11*** Variables ***
12${AAI_CONN_ROOT_PATH} /network/connectivities/connectivity
13${AAI_CONN_EXAMPLES_PATH} /examples/connectivities
14${AAI_CONN_NODES_PATH} /nodes/connectivities
15${AAI_ADD_CONNECTIVITY_BODY}= robot/assets/templates/aai/add-connectivity.template
16${AAI_CONN_API_NA_INDEX_PATH}= ${AAI_BEIJING_INDEX_PATH}
17${AAI_CONN_API_IMPL_INDEX_PATH}= ${AAI_CASABLANCA_INDEX_PATH}
18
19*** Keywords ***
20Create Connectivity If Not Exists
21 [Documentation] Creates Connectivity in AAI if it doesn't exist
22 [Arguments] ${connectivity_id}
23 ${get_resp}= Run A&AI Get Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id}
24 Return From Keyword If '${get_resp.status_code}' == '200'
25 Create Connectivity ${connectivity_id}
26
27Create Connectivity
28 [Documentation] Creates Connectivity in AAI
29 [Arguments] ${connectivity_id}
30 ${arguments}= Create Dictionary connectivity_id=${connectivity_id}
31 ${data}= Fill JSON Template File ${AAI_ADD_CONNECTIVITY_BODY} ${arguments}
32 ${put_resp}= Run A&AI Put Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id} ${data}
33 ${status_string}= Convert To String ${put_resp.status_code}
34 Should Match Regexp ${status_string} ^(201|200)$
35
36Delete Connectivity If Exists
37 [Documentation] Removes Connectivity from AAI if it exists
38 [Arguments] ${connectivity_id}
39 ${get_resp}= Run A&AI Get Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id}
40 Run Keyword If '${get_resp.status_code}' == '200' Delete Connectivity ${connectivity_id} ${get_resp.json()}
41
42Delete Connectivity
43 [Documentation] Removes Connectivity from AAI
44 [Arguments] ${connectivity_id} ${json}
45 ${resource_version}= Catenate ${json['resource-version']}
46 ${put_resp}= Run A&AI Delete Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id} ${resource_version}
47 Should Be Equal As Strings ${put_resp.status_code} 204
48
49Get Connectivity
50 [Documentation] Return Connectivity
51 [Arguments] ${connectivity_id}
52 ${resp}= Run A&AI Get Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id}
53 Should Be Equal As Strings ${resp.status_code} 200
54 [Return] ${resp.json()}
55
56Get Nodes Query Connectivity
57 [Documentation] Return Nodes query Connectivity
58 [Arguments] ${connectivity_id}
59 ${resp}= Run A&AI Get Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_NODES_PATH}?connectivity-id=${connectivity_id}
60 Should Be Equal As Strings ${resp.status_code} 200
61 [Return] ${resp.json()}
62
63Get Example Connectivity
64 [Documentation] Return Example Connectivity
65 ${resp}= Run A&AI Get Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_EXAMPLES_PATH}
66 Should Be Equal As Strings ${resp.status_code} 200
67 [Return] ${resp.json()}
68
69Confirm No Connectivity
70 [Documentation] Confirm No Connectivity
71 [Arguments] ${connectivity_id}
72 ${resp}= Run A&AI Get Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id}
73 Should Be Equal As Strings ${resp.status_code} 404
74
75Confirm API Not Implemented Connectivity
76 [Documentation] Confirm latest API version where Connectivity is not implemented
77 [Arguments] ${connectivity_id}
78 ${resp}= Run A&AI Get Request ${AAI_CONN_API_NA_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id}
79 Should Be Equal As Strings ${resp.status_code} 400
80