Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

API + restart the services that restart is required

avatar

after adding new parameter and value to the ambari cluster , we need to restart the service to take affect

from ambari GUI restart the service is required , and we can see that because restart button is colored with orange

so my question is

we need API command that restart only the services that restart is required?

Michael-Bronson
1 ACCEPTED SOLUTION

avatar
Master Mentor

@uri ben-ari

Please pardon me 😞

The URL should end with "requests" instead of "request"

.

Example:

 #  curl  -u admin:admin -H "X-Requested-By: ambari" -X POST  -d '{"RequestInfo":{"command":"RESTART","context":"Restart all required services","operation_level":"host_component"},"Requests/resource_filters":[{"hosts_predicate":"HostRoles/stale_configs=true"}]}' http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/requests

{
  "href" : "http://amb25101.example.com:8080/api/v1/clusters/plain_ambari/requests/132",
  "Requests" : {
    "id" : 132,
    "status" : "Accepted"
  }
}

.

View solution in original post

14 REPLIES 14

avatar
Master Mentor

@uri ben-ari

Please try this:

# curl -iv -u admin:admin -H "X-Requested-By: ambari" -X POST  -d '{"RequestInfo":{"command":"RESTART","context":"Restart all required services","operation_level":"host_component"},"Requests/resource_filters":[{"hosts_predicate":"HostRoles/stale_configs=true"}]}' http://$AMBARI_SERVER:8080/api/v1/clusters/$CLUSTER_NAME/reques

.

Please replace the $AMBARI_SERVER with ambari FQDN

$CLUSTER_NAME = clustername.

.

avatar

thank you very much - I will test it on my ambari cluster

Michael-Bronson

avatar

btw - regarding my previews question , how to find the config type for the parameter , can we talk about this ?

Michael-Bronson

avatar
Master Mentor

avatar

from some reason I get - HTTP/1.1 404 Not Found

Michael-Bronson

avatar
Master Mentor

@uri ben-ari

The "Restart all required services" feature is available from ambari 2.5 onwards only.

If you are getting 404 in Ambari 2.5 then you might be doing something wrong in the URL.

In my case i missed "t" at the end of th URL. The "request" became "reques" Please correct it as following:

# curl -iv -u admin:admin -H "X-Requested-By: ambari" -X POST  -d '{"RequestInfo":{"command":"RESTART","context":"Restart all required services","operation_level":"host_component"},"Requests/resource_filters":[{"hosts_predicate":"HostRoles/stale_configs=true"}]}' http://$AMBARI_SERVER:8080/api/v1/clusters/$CLUSTER_NAME/request

.

avatar

I change the hostname and the cluster name maybe something else in the syntax

Michael-Bronson

avatar

* Trying 109.164.35.62... * Connected to master.urns.com (109.164.35.62) port 8080 (#0) * Server auth using Basic with user 'admin' > POST /api/v1/clusters/HDP01/request HTTP/1.1 > Authorization: Basic YWRtaW46YWRtaW4= > User-Agent: curl/7.29.0 > Host: master.urns.com:8080 > Accept: */* > X-Requested-By: ambari > Content-Length: 195 > Content-Type: application/x-www-form-urlencoded > * upload completely sent off: 195 out of 195 bytes < HTTP/1.1 404 Not Found HTTP/1.1 404 Not Found < X-Frame-Options: DENY X-Frame-Options: DENY < X-XSS-Protection: 1; mode=block X-XSS-Protection: 1; mode=block < X-Content-Type-Options: nosniff X-Content-Type-Options: nosniff < Cache-Control: no-store Cache-Control: no-store < Pragma: no-cache Pragma: no-cache < Set-Cookie: AMBARISESSIONID=1kmyjqsidore28zeh3nxu88c5;Path=/;HttpOnly Set-Cookie: AMBARISESSIONID=1kmyjqsidore28zeh3nxu88c5;Path=/;HttpOnly < Expires: Thu, 01 Jan 1970 00:00:00 GMT Expires: Thu, 01 Jan 1970 00:00:00 GMT < User: admin User: admin < Content-Length: 0 Content-Length: 0 < Server: Jetty(8.1.19.v20160209) Server: Jetty(8.1.19.v20160209)

Michael-Bronson

avatar

as you can see from the log hostname is ok ans the cluster name

Michael-Bronson