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 | # Uninstall components managed by Cloudify |
| 32 | # Get the list of deployment ids known to Cloudify via curl to Cloudify API. |
| 33 | # The output of the curl is JSON that looks like {"items" :[{"id": "config_binding_service"}, ...], "metadata" :{...}} |
| 34 | # |
| 35 | # jq gives us the just the deployment ids (e.g., "config_binding_service"), one per line |
| 36 | # |
| 37 | # 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] | 38 | 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] | 39 | | /bin/jq .items[].id \ |
| 40 | | xargs -I % sh -c 'cfy uninstall %' |
Jack Lucas | a25c923 | 2020-03-02 11:07:31 -0500 | [diff] [blame] | 41 | |
| 42 | # Delete blueprints (in case the uninstall didn't get them) |
| 43 | curl -Ss --user admin:$CMPASS -H "Tenant: default_tenant" ${CURLTLS} "$CMPROTO://$CMADDR:$CMPORT/api/v3.1/blueprints?_include=id" \ |
| 44 | | /bin/jq .items[].id \ |
| 45 | | xargs -I % sh -c 'cfy blueprints delete %' |
| 46 | |
| 47 | # Delete plugins |
| 48 | curl -Ss --user admin:$CMPASS -H "Tenant: default_tenant" ${CURLTLS} "$CMPROTO://$CMADDR:$CMPORT/api/v3.1/plugins?_include=id" \ |
| 49 | | /bin/jq .items[].id \ |
| 50 | | xargs -I % sh -c 'cfy plugins delete %' |