blob: 3f4dc0b2b33793a52aea82e2b3e40365be9f565b [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
Keong Limeff1eab2019-03-19 15:44:35 +11007Resource add-relationship-list.robot
Keong Lim3a5d9472019-03-04 17:15:06 +11008Library OperatingSystem
9Library Collections
10
11
12*** Variables ***
13${AAI_CONN_ROOT_PATH} /network/connectivities/connectivity
14${AAI_CONN_EXAMPLES_PATH} /examples/connectivities
15${AAI_CONN_NODES_PATH} /nodes/connectivities
16${AAI_ADD_CONNECTIVITY_BODY}= robot/assets/templates/aai/add-connectivity.template
17${AAI_CONN_API_NA_INDEX_PATH}= ${AAI_BEIJING_INDEX_PATH}
18${AAI_CONN_API_IMPL_INDEX_PATH}= ${AAI_CASABLANCA_INDEX_PATH}
19
20*** Keywords ***
21Create Connectivity If Not Exists
22 [Documentation] Creates Connectivity in AAI if it doesn't exist
23 [Arguments] ${connectivity_id}
24 ${get_resp}= Run A&AI Get Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id}
25 Return From Keyword If '${get_resp.status_code}' == '200'
26 Create Connectivity ${connectivity_id}
27
28Create Connectivity
29 [Documentation] Creates Connectivity in AAI
30 [Arguments] ${connectivity_id}
31 ${arguments}= Create Dictionary connectivity_id=${connectivity_id}
32 ${data}= Fill JSON Template File ${AAI_ADD_CONNECTIVITY_BODY} ${arguments}
33 ${put_resp}= Run A&AI Put Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id} ${data}
34 ${status_string}= Convert To String ${put_resp.status_code}
35 Should Match Regexp ${status_string} ^(201|200)$
36
37Delete Connectivity If Exists
38 [Documentation] Removes Connectivity from AAI if it exists
39 [Arguments] ${connectivity_id}
40 ${get_resp}= Run A&AI Get Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id}
41 Run Keyword If '${get_resp.status_code}' == '200' Delete Connectivity ${connectivity_id} ${get_resp.json()}
42
43Delete Connectivity
44 [Documentation] Removes Connectivity from AAI
45 [Arguments] ${connectivity_id} ${json}
46 ${resource_version}= Catenate ${json['resource-version']}
47 ${put_resp}= Run A&AI Delete Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id} ${resource_version}
48 Should Be Equal As Strings ${put_resp.status_code} 204
49
50Get Connectivity
51 [Documentation] Return Connectivity
52 [Arguments] ${connectivity_id}
53 ${resp}= Run A&AI Get Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id}
54 Should Be Equal As Strings ${resp.status_code} 200
55 [Return] ${resp.json()}
56
Keong Limeff1eab2019-03-19 15:44:35 +110057Get Valid Connectivity URL
58 [Documentation] Return Valid Connectivity URL
59 [Arguments] ${connectivity_id}
60 ${resp}= Run A&AI Get Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id}
61 Should Be Equal As Strings ${resp.status_code} 200
62 [Return] ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id}
63
Keong Lim3a5d9472019-03-04 17:15:06 +110064Get Nodes Query Connectivity
65 [Documentation] Return Nodes query Connectivity
66 [Arguments] ${connectivity_id}
67 ${resp}= Run A&AI Get Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_NODES_PATH}?connectivity-id=${connectivity_id}
68 Should Be Equal As Strings ${resp.status_code} 200
69 [Return] ${resp.json()}
70
71Get Example Connectivity
72 [Documentation] Return Example Connectivity
73 ${resp}= Run A&AI Get Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_EXAMPLES_PATH}
74 Should Be Equal As Strings ${resp.status_code} 200
75 [Return] ${resp.json()}
76
77Confirm No Connectivity
78 [Documentation] Confirm No Connectivity
79 [Arguments] ${connectivity_id}
80 ${resp}= Run A&AI Get Request ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id}
81 Should Be Equal As Strings ${resp.status_code} 404
82
83Confirm API Not Implemented Connectivity
84 [Documentation] Confirm latest API version where Connectivity is not implemented
85 [Arguments] ${connectivity_id}
86 ${resp}= Run A&AI Get Request ${AAI_CONN_API_NA_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id}
87 Should Be Equal As Strings ${resp.status_code} 400
88
Keong Limeff1eab2019-03-19 15:44:35 +110089Add Connectivity Relationship
90 [Documentation] Adds Relationship to existing Connectivity in AAI
91 [Arguments] ${connectivity_id} ${related_class_name} ${related_object_url}
92 ${put_resp}= Add Relationship ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id} ${related_class_name} ${related_object_url}
93
94Get Connectivity RelationshipList
95 [Documentation] Return relationship-list from Connectivity
96 [Arguments] ${connectivity_id}
97 ${resp}= Get RelationshipList ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id}
98 [Return] ${resp}
99
100Get Connectivity With RelationshipList
101 [Documentation] Return Connectivity with relationship-list
102 [Arguments] ${connectivity_id}
103 ${resp}= Get Object With Depth ${AAI_CONN_API_IMPL_INDEX_PATH}${AAI_CONN_ROOT_PATH}/${connectivity_id}
104 [Return] ${resp}
105