3 * ============LICENSE_START=======================================================
5 * ================================================================================
6 * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
7 * ================================================================================
8 * Copyright (C) 2017 Amdocs
9 * =============================================================================
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
22 * ============LICENSE_END=========================================================
32 sudo apt-get install python2.7
33 sudo apt-get install python-pip
38 sudo apt-get install software-properties-common
39 sudo apt-add-repository ppa:ansible/ansible
41 sudo apt-get install ansible
43 ++ SQL db: The new version REST API code does not need sql db in ansible server
48 1. Start RestServer: python RestServer.py
50 2. Try curl commands (case no secured REST: http & no authentication):
51 (we will need more samples for testing -Taka@att)
53 - curl -H "Content-type:application/json" -X POST -d '{"Id": "ap3929_1548451746", "PlaybookName": "ctpx/R7.0.1/ansible/healthcheck/site.yml", "Timeout": "10", "InventoryNames": "VM", "EnvParameters": {"vnf_instance": "ctpx5000v"}}' http://0.0.0.0:8000/Dispatch
55 response: {"StatusMessage": "PLAYBOOK INVENTORY FILE NOT FOUND", "StatusCode": 101}
57 - Request to execute playbook:
58 curl -H "Content-type: application/json" -X POST -d '{"Id": "10", "PlaybookName": "ansible_sleep", "NodeList": ["host"], "Timeout": "60", "EnvParameters": {"Sleep": "10"}}' http://0.0.0.0:8000/Dispatch
60 response: {"ExpectedDuration": "60sec", "StatusMessage": "PENDING", "StatusCode": 100}
62 - Get results (blocked until test finished):
63 curl --cacert ~/SshKey/fusion_eric-vm_cert.pem --user "appc:abc123" -H "Content-type: application/json" -X GET "http://0.0.0.0:8000/Dispatch/?Id=10&Type=GetResult"
65 response: {"Results": {"localhost": {"GroupName": "host", "StatusMessage": "SUCCESS", "StatusCode": 200}}, "PlaybookName": "ansible_sleep", "Version": "0.00", "Duration": "11.261794", "StatusMessage": "FINISHED", "StatusCode": 200}
67 - Delete playbook execution information
68 curl --cacert ~/SshKey/fusion_eric-vm_cert.pem --user "appc:abc123" -H "Content-type: application/json" -X DELETE http://0.0.0.0:8000/Dispatch/?Id=10
70 response: {"StatusMessage": "PLAYBOOK EXECUTION RECORDS DELETED", "StatusCode": 200}