Jack Lucas | bad7720 | 2020-02-03 18:21:29 -0500 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # ================================================================================ |
| 3 | # Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. |
| 4 | # ================================================================================ |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | # ============LICENSE_END========================================================= |
| 17 | |
| 18 | # Clean up DCAE during ONAP uninstall |
| 19 | |
| 20 | set -x |
| 21 | set +e |
| 22 | |
Jack Lucas | a25c923 | 2020-03-02 11:07:31 -0500 | [diff] [blame] | 23 | # TLS setup |
| 24 | CACERT="/certs/cacert.pem" |
| 25 | CURLTLS="" |
| 26 | if [ $CMPROTO = "https" ] |
| 27 | then |
| 28 | CURLTLS="--cacert $CACERT" |
| 29 | fi |
| 30 | |
Jack Lucas | bad7720 | 2020-02-03 18:21:29 -0500 | [diff] [blame] | 31 | # Leave the Consul cluster |
| 32 | /opt/consul/bin/consul leave |
| 33 | |
| 34 | # Uninstall components managed by Cloudify |
| 35 | # Get the list of deployment ids known to Cloudify via curl to Cloudify API. |
| 36 | # The output of the curl is JSON that looks like {"items" :[{"id": "config_binding_service"}, ...], "metadata" :{...}} |
| 37 | # |
| 38 | # jq gives us the just the deployment ids (e.g., "config_binding_service"), one per line |
| 39 | # |
| 40 | # xargs -I lets us run the cfy uninstall command once for each deployment id extracted by jq |
Jack Lucas | a25c923 | 2020-03-02 11:07:31 -0500 | [diff] [blame] | 41 | curl -Ss --user admin:$CMPASS -H "Tenant: default_tenant" ${CURLTLS} "$CMPROTO://$CMADDR:$CMPORT/api/v3.1/deployments?_include=id" \ |
Jack Lucas | bad7720 | 2020-02-03 18:21:29 -0500 | [diff] [blame] | 42 | | /bin/jq .items[].id \ |
| 43 | | xargs -I % sh -c 'cfy uninstall %' |
Jack Lucas | a25c923 | 2020-03-02 11:07:31 -0500 | [diff] [blame] | 44 | |
| 45 | # Delete blueprints (in case the uninstall didn't get them) |
| 46 | curl -Ss --user admin:$CMPASS -H "Tenant: default_tenant" ${CURLTLS} "$CMPROTO://$CMADDR:$CMPORT/api/v3.1/blueprints?_include=id" \ |
| 47 | | /bin/jq .items[].id \ |
| 48 | | xargs -I % sh -c 'cfy blueprints delete %' |
| 49 | |
| 50 | # Delete plugins |
| 51 | curl -Ss --user admin:$CMPASS -H "Tenant: default_tenant" ${CURLTLS} "$CMPROTO://$CMADDR:$CMPORT/api/v3.1/plugins?_include=id" \ |
| 52 | | /bin/jq .items[].id \ |
| 53 | | xargs -I % sh -c 'cfy plugins delete %' |
| 54 | |