-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdelete_component.sh
35 lines (24 loc) · 1.85 KB
/
delete_component.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
ambari_server=127.0.0.1
ambari_user=admin
ambari_password=admin
cluster_name=test
component=$1
hostname=$2
service_name=$3
function stop_component(){
#stop a Service
[ -n "$service_name" ] && [ -z "$component" ] && curl -i -$ambari_user:$ambari_password -H 'X-Requested-By: ambari' -H 'Content-Type: application/json' -X PUT -d '{"RequestInfo":{"context":"Stop Service"},"Body":{"ServiceInfo":{"state":"INSTALLED"}}}' http://$ambari_server:8080/api/v1/clusters/$cluster_name/services/$service_name
#Stop one host components
[ -n "$hostname" ] && curl -i -$ambari_user:$ambari_password -H 'X-Requested-By: ambari' -H 'Content-Type: application/json' -X PUT -d '{"RequestInfo":{"context":"Stop Component"},"Body":{"HostRoles":{"state":"INSTALLED"}}}' http://$ambari_server:8080/api/v1/clusters/$cluster_name/hosts/$hostname/host_components/$component
#Stop all host component
[ -n "$component" ] && [ -n "$service_name" ] && curl -i -$ambari_user:$ambari_password -H 'X-Requested-By: ambari' -H 'Content-Type: application/json' -X PUT -d '{"RequestInfo":{"context":"Stop All Components"},"Body":{"ServiceComponentInfo":{"state":"INSTALLED"}}}' http://$ambari_server:8080/api/v1/clusters/$cluster_name/services/$service_name/components/$component
}
function delete_component() {
#delete host component
[ -n "$hostname" ] && curl -i -$ambari_user:$ambari_password -H 'X-Requested-By: ambari' -H 'Content-Type: application/json' -X DELETE http://$ambari_server:8080/api/v1/clusters/$cluster_name/hosts/$hostname/host_components/$component
#delete service
[ -n "$service_name" ] && [ -z "$component" ] && curl -i -$ambari_user:$ambari_password -H 'X-Requested-By: ambari' -H 'Content-Type: application/json' -X DELETE http://$ambari_server:8080/api/v1/clusters/$cluster_name/services/$service_name
}
stop_component
delete_component