在ambari rest API中设置变量

时间:2020-04-27 10:44:30

标签: json rest api ambari

以下ambari API将仅停止工作计算机上的数据节点

# curl -s -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop DataNodes","operation_level":{"level":"SERVICE","cluster_name":"$CLUSTER_NAME"},"query":"HostRoles/component_name=DATANODE&HostRoles/host_name.in(dn1.example.com,dn2.example.com,dn3.example.com)&HostRoles/maintenance_state=OFF"},"Body":{"HostRoles":{"state":"INSTALLED"}}}' "h ttp://$AMBARI_FQDN:8080/api/v1/clusters/$CLUSTER_NAME/host_components"

现在我们要替换列表-n1.example.com,dn2.example.com,dn3.example.com

带有变量-DATANODES=n1.example.com,dn2.example.com,dn3.example.com

因此$DATANODES将替换API中的列表,如下所示

# curl -s -u admin:admin -H "X-Requested-By: ambari" -X PUT -d '{"RequestInfo":{"context":"Stop DataNodes","operation_level":{"level":"SERVICE","cluster_name":"$CLUSTER_NAME"},"query":"HostRoles/component_name=DATANODE&HostRoles/host_name.in($DATANODES)&HostRoles/maintenance_state=OFF"},"Body":{"HostRoles":{"state":"INSTALLED"}}}' "h ttp://$AMBARI_FQDN:8080/api/v1/clusters/$CLUSTER_NAME/host_components"

但这不起作用,关于如何正确设置它的任何建议吗?

0 个答案:

没有答案