mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 18:35:44 +03:00
HTTP and API
This commit is contained in:
committed by
Michael Schurter
parent
dcafa8b460
commit
0fb9ba7732
@@ -44,6 +44,9 @@ func (s *HTTPServer) NodeSpecificRequest(resp http.ResponseWriter, req *http.Req
|
||||
case strings.HasSuffix(path, "/drain"):
|
||||
nodeName := strings.TrimSuffix(path, "/drain")
|
||||
return s.nodeToggleDrain(resp, req, nodeName)
|
||||
case strings.HasSuffix(path, "/eligibility"):
|
||||
nodeName := strings.TrimSuffix(path, "/eligibility")
|
||||
return s.nodeToggleEligibility(resp, req, nodeName)
|
||||
case strings.HasSuffix(path, "/purge"):
|
||||
nodeName := strings.TrimSuffix(path, "/purge")
|
||||
return s.nodePurge(resp, req, nodeName)
|
||||
@@ -149,6 +152,26 @@ func (s *HTTPServer) nodeToggleDrain(resp http.ResponseWriter, req *http.Request
|
||||
return out, nil
|
||||
}
|
||||
|
||||
func (s *HTTPServer) nodeToggleEligibility(resp http.ResponseWriter, req *http.Request,
|
||||
nodeID string) (interface{}, error) {
|
||||
if req.Method != "PUT" && req.Method != "POST" {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
|
||||
var drainRequest structs.NodeUpdateEligibilityRequest
|
||||
if err := decodeBody(req, &drainRequest); err != nil {
|
||||
return nil, CodedError(400, err.Error())
|
||||
}
|
||||
s.parseWriteRequest(req, &drainRequest.WriteRequest)
|
||||
|
||||
var out structs.GenericResponse
|
||||
if err := s.agent.RPC("Node.UpdateEligibility", &drainRequest, &out); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
setIndex(resp, out.Index)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (s *HTTPServer) nodeQuery(resp http.ResponseWriter, req *http.Request,
|
||||
nodeID string) (interface{}, error) {
|
||||
if req.Method != "GET" {
|
||||
|
||||
Reference in New Issue
Block a user