...
Add the Service to the Cluster.
Code Block POST /api/v1/clusters/MyCluster/services { "ServiceInfo": { "service_name":"TESTSRV" } }
Add the Components to the Service. In this case, add TEST_CLIENT to TESTSRV.
Code Block POST /api/v1/clusters/MyCluster/services/TESTSRV/components/TEST_CLIENT
Install the component on a hostall target hosts. For example, on the to install on
c6402.ambari.apache.org
andc6403.ambari.apache.org
host, first create the component resource, then have Ambari install the component. This will end up calling host_component resource on the hosts using POST.Code Block POST /api/v1/clusters/MyCluster/hosts/c6402.ambari.apache.org/host_components/TEST_CLIENT POST /api/v1/clusters/MyCluster/hosts/c6403.ambari.apache.org/host_components/TEST_CLIENT
Now have Ambari install the components on all hosts. In this single command, you are instructing Ambari to install all components related to the service. This call the
install()
method in the command script on each host.Code Block POSTPUT /api/v1/clusters/MyCluster/hosts/c6403services/TESTSRV { "RequestInfo": { "context": "Install Test Srv Client" }, "Body": { "ServiceInfo": { "state": "INSTALLED" } } }
Alternatively, instead of installing all components at the same time, you can explicitly install each host component. In this example, we will explicitly install the TEST_CLIENT on
/host_components/TEST_CLIENTc6402.ambari.apache.org
:
Code Block PUT /api/v1/clusters/MyCluster/hosts/c6403c6402.ambari.apache.org/host_components/TEST_CLIENT { "RequestInfo": { "context":"Install Test Srv Client" }, "Body": { "HostRoles": { "state":"INSTALLED" } } }
Use the following to configure the client on the host. This will end up calling the
configure()
method in the command script.Code Block POST /api/v1/clusters/MyCluster/requests { "RequestInfo" : { "command" : "CONFIGURE", "context" : "Config Test Srv Client" }, "Requests/resource_filters": [{ "service_name" : "TESTSRV", "component_name" : "TEST_CLIENT", "hosts" : "c6403.ambari.apache.org" }] }
If you want to see which hosts the component is installed.
Code Block GET /api/v1/clusters/MyCluster/components/TEST_CLIENT