blob: ba198e598a046a5bd259b2e4d804e74cd81f3ded [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# 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 Lucasa25c9232020-03-02 11:07:31 -050038curl -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 -050039| /bin/jq .items[].id \
40| xargs -I % sh -c 'cfy uninstall %'
Jack Lucasa25c9232020-03-02 11:07:31 -050041
42# Delete blueprints (in case the uninstall didn't get them)
43curl -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
48curl -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 %'