Keong Lim | 3a5d947 | 2019-03-04 17:15:06 +1100 | [diff] [blame] | 1 | *** Settings *** |
| 2 | Documentation 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 | |
| 4 | Resource ../json_templater.robot |
| 5 | Resource aai_interface.robot |
| 6 | Resource api_version_properties.robot |
Keong Lim | eff1eab | 2019-03-19 15:44:35 +1100 | [diff] [blame] | 7 | Resource add-relationship-list.robot |
Keong Lim | 3a5d947 | 2019-03-04 17:15:06 +1100 | [diff] [blame] | 8 | Library OperatingSystem |
| 9 | Library 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 *** |
| 21 | Create 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 | |
| 28 | Create 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 | |
| 37 | Delete 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 | |
| 43 | Delete 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 | |
| 50 | Get 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 Lim | eff1eab | 2019-03-19 15:44:35 +1100 | [diff] [blame] | 57 | Get 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 Lim | 3a5d947 | 2019-03-04 17:15:06 +1100 | [diff] [blame] | 64 | Get 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 | |
| 71 | Get 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 | |
| 77 | Confirm 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 | |
| 83 | Confirm 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 Lim | eff1eab | 2019-03-19 15:44:35 +1100 | [diff] [blame] | 89 | Add 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 | |
| 94 | Get 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 | |
| 100 | Get 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 | |