mirror of
https://github.com/kemko/nomad.git
synced 2026-01-05 18:05:42 +03:00
Add additional API endpoint for requesting client specific node allocations.
This commit is contained in:
@@ -36,6 +36,9 @@ func (s *HTTPServer) NodeSpecificRequest(resp http.ResponseWriter, req *http.Req
|
||||
case strings.HasSuffix(path, "/evaluate"):
|
||||
nodeName := strings.TrimSuffix(path, "/evaluate")
|
||||
return s.nodeForceEvaluate(resp, req, nodeName)
|
||||
case strings.HasSuffix(path, "/clientallocations"):
|
||||
nodeName := strings.TrimSuffix(path, "/clientallocations")
|
||||
return s.nodeClientAllocations(resp, req, nodeName)
|
||||
case strings.HasSuffix(path, "/allocations"):
|
||||
nodeName := strings.TrimSuffix(path, "/allocations")
|
||||
return s.nodeAllocations(resp, req, nodeName)
|
||||
@@ -89,6 +92,27 @@ func (s *HTTPServer) nodeAllocations(resp http.ResponseWriter, req *http.Request
|
||||
return out.Allocs, nil
|
||||
}
|
||||
|
||||
func (s *HTTPServer) nodeClientAllocations(resp http.ResponseWriter, req *http.Request,
|
||||
nodeID string) (interface{}, error) {
|
||||
if req.Method != "GET" {
|
||||
return nil, CodedError(405, ErrInvalidMethod)
|
||||
}
|
||||
args := structs.NodeSpecificRequest{
|
||||
NodeID: nodeID,
|
||||
}
|
||||
if s.parse(resp, req, &args.Region, &args.QueryOptions) {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var out structs.NodeClientAllocsResponse
|
||||
if err := s.agent.RPC("Node.GetClientAllocs", &args, &out); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
setMeta(resp, &out.QueryMeta)
|
||||
return out.Allocs, nil
|
||||
}
|
||||
|
||||
func (s *HTTPServer) nodeToggleDrain(resp http.ResponseWriter, req *http.Request,
|
||||
nodeID string) (interface{}, error) {
|
||||
if req.Method != "PUT" && req.Method != "POST" {
|
||||
|
||||
Reference in New Issue
Block a user