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 |
| 7 | Library OperatingSystem |
| 8 | Library 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 *** |
| 20 | Create 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 | |
| 27 | Create 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 | |
| 36 | Delete 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 | |
| 42 | Delete 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 | |
| 49 | Get 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 | |
| 56 | Get 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 | |
| 63 | Get 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 | |
| 69 | Confirm 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 | |
| 75 | Confirm 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 | |