Keong Lim | eff1eab | 2019-03-19 15:44:35 +1100 | [diff] [blame^] | 1 | *** Settings *** |
| 2 | Documentation Operations on vpn-bindings in AAI for CCVPN use case, |
| 3 | ... using earliest API version where changes are implemented and |
| 4 | ... latest API version where changes are not implemented |
| 5 | |
| 6 | Resource ../json_templater.robot |
| 7 | Resource aai_interface.robot |
| 8 | Resource api_version_properties.robot |
| 9 | Resource add-relationship-list.robot |
| 10 | Library OperatingSystem |
| 11 | Library Collections |
| 12 | |
| 13 | |
| 14 | *** Variables *** |
| 15 | ${AAI_VPNB_ROOT_PATH} /network/vpn-bindings/vpn-binding |
| 16 | ${AAI_VPNB_EXAMPLES_PATH} /examples/vpn-bindings |
| 17 | ${AAI_VPNB_NODES_PATH} /nodes/vpn-bindings |
| 18 | ${AAI_ADD_VPNBINDING_BODY}= robot/assets/templates/aai/add-vpn-binding.template |
| 19 | ${AAI_VPNB_API_NA_INDEX_PATH}= ${AAI_BEIJING_INDEX_PATH} |
| 20 | ${AAI_VPNB_API_IMPL_INDEX_PATH}= ${AAI_CASABLANCA_INDEX_PATH} |
| 21 | |
| 22 | *** Keywords *** |
| 23 | Create VPN Binding If Not Exists |
| 24 | [Documentation] Creates VPN Binding in AAI if it doesn't exist |
| 25 | [Arguments] ${vpn_id} |
| 26 | ${get_resp}= Run A&AI Get Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} |
| 27 | Return From Keyword If '${get_resp.status_code}' == '200' |
| 28 | Create VPN Binding ${vpn_id} |
| 29 | |
| 30 | Create VPN Binding |
| 31 | [Documentation] Creates VPN Binding in AAI |
| 32 | [Arguments] ${vpn_id} |
| 33 | ${arguments}= Create Dictionary vpn_id=${vpn_id} |
| 34 | ${data}= Fill JSON Template File ${AAI_ADD_VPNBINDING_BODY} ${arguments} |
| 35 | ${put_resp}= Run A&AI Put Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} ${data} |
| 36 | ${status_string}= Convert To String ${put_resp.status_code} |
| 37 | Should Match Regexp ${status_string} ^(201|200)$ |
| 38 | |
| 39 | Delete VPN Binding If Exists |
| 40 | [Documentation] Removes VPN Binding from AAI if it exists |
| 41 | [Arguments] ${vpn_id} |
| 42 | ${get_resp}= Run A&AI Get Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} |
| 43 | Run Keyword If '${get_resp.status_code}' == '200' Delete VPN Binding ${vpn_id} ${get_resp.json()} |
| 44 | |
| 45 | Delete VPN Binding |
| 46 | [Documentation] Removes VPN Binding from AAI |
| 47 | [Arguments] ${vpn_id} ${json} |
| 48 | ${resource_version}= Catenate ${json['resource-version']} |
| 49 | ${put_resp}= Run A&AI Delete Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} ${resource_version} |
| 50 | Should Be Equal As Strings ${put_resp.status_code} 204 |
| 51 | |
| 52 | Get VPN Binding |
| 53 | [Documentation] Return VPN Binding |
| 54 | [Arguments] ${vpn_id} |
| 55 | ${resp}= Run A&AI Get Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} |
| 56 | Should Be Equal As Strings ${resp.status_code} 200 |
| 57 | [Return] ${resp.json()} |
| 58 | |
| 59 | Get Valid VPN Binding URL |
| 60 | [Documentation] Return Valid VPN Binding URL |
| 61 | [Arguments] ${vpn_id} |
| 62 | ${resp}= Run A&AI Get Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} |
| 63 | Should Be Equal As Strings ${resp.status_code} 200 |
| 64 | [Return] ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} |
| 65 | |
| 66 | Get Nodes Query VPN Binding |
| 67 | [Documentation] Return Nodes query VPN Binding |
| 68 | [Arguments] ${vpn_id} |
| 69 | ${resp}= Run A&AI Get Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_NODES_PATH}?vpn-id=${vpn_id} |
| 70 | Should Be Equal As Strings ${resp.status_code} 200 |
| 71 | [Return] ${resp.json()} |
| 72 | |
| 73 | Get Example VPN Binding |
| 74 | [Documentation] Return Example VPN Binding |
| 75 | ${resp}= Run A&AI Get Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_EXAMPLES_PATH} |
| 76 | Should Be Equal As Strings ${resp.status_code} 200 |
| 77 | [Return] ${resp.json()} |
| 78 | |
| 79 | Confirm No VPN Binding |
| 80 | [Documentation] Confirm No VPN Binding |
| 81 | [Arguments] ${vpn_id} |
| 82 | ${resp}= Run A&AI Get Request ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} |
| 83 | Should Be Equal As Strings ${resp.status_code} 404 |
| 84 | |
| 85 | # Not applicable to VPN Binding as it appears in all known API versions |
| 86 | # Confirm API Not Implemented VPN Binding |
| 87 | # [Documentation] Confirm latest API version where VPN Binding is not implemented |
| 88 | # [Arguments] ${vpn_id} |
| 89 | # ${resp}= Run A&AI Get Request ${AAI_VPNB_API_NA_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} |
| 90 | # Should Be Equal As Strings ${resp.status_code} 400 |
| 91 | |
| 92 | Add VPN Binding Relationship |
| 93 | [Documentation] Adds Relationship to existing VPN Binding in AAI |
| 94 | [Arguments] ${vpn_id} ${related_class_name} ${related_object_url} |
| 95 | ${put_resp}= Add Relationship ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} ${related_class_name} ${related_object_url} |
| 96 | |
| 97 | Get VPN Binding RelationshipList |
| 98 | [Documentation] Return relationship-list from VPN Binding |
| 99 | [Arguments] ${vpn_id} |
| 100 | ${resp}= Get RelationshipList ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} |
| 101 | [Return] ${resp} |
| 102 | |
| 103 | Get VPN Binding With RelationshipList |
| 104 | [Documentation] Return VPN Binding with relationship-list |
| 105 | [Arguments] ${vpn_id} |
| 106 | ${resp}= Get Object With Depth ${AAI_VPNB_API_IMPL_INDEX_PATH}${AAI_VPNB_ROOT_PATH}/${vpn_id} |
| 107 | [Return] ${resp} |
| 108 | |