blob: 30dc2bf1134b08f6ade4d7b23b5f99ea8359cc8e [file] [log] [blame]
Jack Lucasbad77202020-02-03 18:21:29 -05001#!/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
20set -x
21set +e
22
Jack Lucasa25c9232020-03-02 11:07:31 -050023# TLS setup
24CACERT="/certs/cacert.pem"
25CURLTLS=""
26if [ $CMPROTO = "https" ]
27then
28 CURLTLS="--cacert $CACERT"
29fi
30
Jack Lucasbad77202020-02-03 18:21:29 -050031# 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 Lucasa25c9232020-03-02 11:07:31 -050041curl -Ss --user admin:$CMPASS -H "Tenant: default_tenant" ${CURLTLS} "$CMPROTO://$CMADDR:$CMPORT/api/v3.1/deployments?_include=id" \
Jack Lucasbad77202020-02-03 18:21:29 -050042| /bin/jq .items[].id \
43| xargs -I % sh -c 'cfy uninstall %'
Jack Lucasa25c9232020-03-02 11:07:31 -050044
45# Delete blueprints (in case the uninstall didn't get them)
46curl -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
51curl -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