2016年11月9日水曜日

Ambari APIでサービスを特定ホストにインストールする

Grafanaを例に

curl -u admin:admin -H "X-Requested-By:ambari" -i -X POST http://localhost:8080/api/v1/clusters/${_CLS}/services/AMBARI_METRICS/components/METRICS_GRAFANA
curl -u admin:admin -H "X-Requested-By:ambari" -i -X POST -d '{"host_components":[{"HostRoles":{"component_name":"METRICS_GRAFANA"}}]}' \
http://localhost:8080/api/v1/clusters/${_CLS}/hosts?Hosts/host_name=${_HOST}

PostgreSQL log:
LOG:  execute <unnamed>: INSERT INTO servicecomponentdesiredstate (component_name, desired_state, service_name, cluster_id, desired_stack_id) VALUES ($1, $2, $3, $4, $5)
DETAIL:  parameters: $1 = 'METRICS_GRAFANA', $2 = 'INSTALLED', $3 = 'AMBARI_METRICS', $4 = '2', $5 = '4'
LOG:  execute <unnamed>: INSERT INTO hostcomponentdesiredstate (admin_state, desired_state, maintenance_state, restart_required, security_state, host_id, desired_stack_id, service_name, cluster_id, component_name) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
DETAIL:  parameters: $1 = NULL, $2 = 'INIT', $3 = 'OFF', $4 = '0', $5 = 'UNSECURED', $6 = '4', $7 = '4', $8 = 'AMBARI_METRICS', $9 = '2', $10 = 'METRICS_GRAFANA'
LOG:  execute <unnamed>: INSERT INTO hostcomponentstate (id, current_state, security_state, upgrade_state, version, host_id, service_name, cluster_id, component_name, current_stack_id) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
DETAIL:  parameters: $1 = '453', $2 = 'INIT', $3 = 'UNSECURED', $4 = 'NONE', $5 = 'UNKNOWN', $6 = '4', $7 = 'AMBARI_METRICS', $8 = '2', $9 = 'METRICS_GRAFANA', $10 = '4'

インストール:
curl -u admin:admin -H "X-Requested-By:ambari" -X PUT -d '{"RequestInfo":{"context":"Install Grafana","operation_level":{"level":"HOST_COMPONENT","cluster_name":"'${_CLS}'","host_name":"'${_HOST}'","service_name":"AMBARI_METRICS"}},"Body":{"HostRoles":{"state":"INSTALLED"}}}' http://localhost:8080/api/v1/clusters/bne_c1/hosts/node1.localdomain/host_components/METRICS_GRAFANA


削除してみる:
curl -u admin:admin -H "X-Requested-By: ambari" -X DELETE  http://localhost:8080/api/v1/clusters/${_CLS}/services/AMBARI_METRICS/components/METRICS_GRAFANA

LOG:  execute <unnamed>: DELETE FROM hostcomponentdesiredstate WHERE ((((host_id = $1) AND (cluster_id = $2)) AND (component_name = $3)) AND (service_name = $4))
DETAIL:  parameters: $1 = '4', $2 = '2', $3 = 'METRICS_GRAFANA', $4 = 'AMBARI_METRICS'
LOG:  execute <unnamed>: DELETE FROM hostcomponentstate WHERE (id = $1)
DETAIL:  parameters: $1 = '453'
LOG:  execute <unnamed>: DELETE FROM servicecomponentdesiredstate WHERE (((cluster_id = $1) AND (component_name = $2)) AND (service_name = $3))
DETAIL:  parameters: $1 = '2', $2 = 'METRICS_GRAFANA', $3 = 'AMBARI_METRICS'

0 件のコメント:

コメントを投稿