diff --git a/command/agent/agent_endpoint.go b/command/agent/agent_endpoint.go index f5eeda8d47..2edee0c09d 100644 --- a/command/agent/agent_endpoint.go +++ b/command/agent/agent_endpoint.go @@ -3,12 +3,21 @@ package agent import ( "fmt" "github.com/hashicorp/consul/consul/structs" + "github.com/hashicorp/serf/serf" "net/http" "strings" ) +type AgentSelf struct { + Config *Config + Member serf.Member +} + func (s *HTTPServer) AgentSelf(resp http.ResponseWriter, req *http.Request) (interface{}, error) { - return s.agent.LocalMember(), nil + return AgentSelf{ + Config: s.agent.config, + Member: s.agent.LocalMember(), + }, nil } func (s *HTTPServer) AgentServices(resp http.ResponseWriter, req *http.Request) (interface{}, error) { diff --git a/command/agent/agent_endpoint_test.go b/command/agent/agent_endpoint_test.go index 71bc9c3055..73682a9cc4 100644 --- a/command/agent/agent_endpoint_test.go +++ b/command/agent/agent_endpoint_test.go @@ -82,8 +82,12 @@ func TestHTTPAgentSelf(t *testing.T) { t.Fatalf("Err: %v", err) } - val := obj.(serf.Member) - if int(val.Port) != srv.agent.config.Ports.SerfLan { + val := obj.(AgentSelf) + if int(val.Member.Port) != srv.agent.config.Ports.SerfLan { + t.Fatalf("incorrect port: %v", obj) + } + + if int(val.Config.Ports.SerfLan) != srv.agent.config.Ports.SerfLan { t.Fatalf("incorrect port: %v", obj) } } diff --git a/website/source/docs/agent/http.html.markdown b/website/source/docs/agent/http.html.markdown index db375b8e91..34a45f4731 100644 --- a/website/source/docs/agent/http.html.markdown +++ b/website/source/docs/agent/http.html.markdown @@ -200,10 +200,10 @@ msgpack RPC protocol. The following endpoints are supported: -* /v1/agent/self : Returns the local node configuration * /v1/agent/checks : Returns the checks the local agent is managing * /v1/agent/services : Returns the services local agent is managing * /v1/agent/members : Returns the members as seen by the local serf agent +* /v1/agent/self : Returns the local node configuration * /v1/agent/join/\ : Trigger local agent to join a node * /v1/agent/force-leave/\: Force remove node * /v1/agent/check/register : Registers a new local check @@ -214,34 +214,6 @@ The following endpoints are supported: * /v1/agent/service/register : Registers a new local service * /v1/agent/service/deregister/\ : Deregister a local service -### /v1/agent/self - -This endpoint is used to return configuration of the local agent. - -It returns a JSON body like this: - - { - "Name": "foobar", - "Addr": "10.1.10.12", - "Port": 8301, - "Tags": { - "bootstrap": "1", - "dc": "dc1", - "port": "8300", - "role": "consul", - "vsn": "1", - "vsn_max": "1", - "vsn_min":"1" - }, - "Status": 1, - "ProtocolMin": 1, - "ProtocolMax": 2, - "ProtocolCur": 2, - "DelegateMin": 2, - "DelegateMax": 4, - "DelegateCur": 4 - } - ### /v1/agent/checks This endpoint is used to return the all the checks that are registered with @@ -319,6 +291,77 @@ This endpoint returns a JSON body like: } ] +### /v1/agent/self + +This endpoint is used to return configuration of the local agent and member information. + +It returns a JSON body like this: + + { + "Config": { + "Bootstrap": true, + "Server": true, + "Datacenter": "dc1", + "DataDir": "/tmp/consul", + "DNSRecursor": "", + "Domain": "consul.", + "EncryptKey": "", + "LogLevel": "INFO", + "NodeName": "foobar", + "ClientAddr": "127.0.0.1", + "BindAddr": "0.0.0.0", + "AdvertiseAddr": "10.1.10.12", + "Ports": { + "DNS": 8600, + "HTTP": 8500, + "RPC": 8400, + "SerfLan": 8301, + "SerfWan": 8302, + "Server": 8300 + }, + "LeaveOnTerm": false, + "SkipLeaveOnInt": false, + "StatsiteAddr": "", + "Protocol": 1, + "EnableDebug": false, + "VerifyIncoming": false, + "VerifyOutgoing": false, + "CAFile": "", + "CertFile": "", + "KeyFile": "", + "StartJoin": [], + "UiDir": "", + "PidFile": "", + "EnableSyslog": false, + "RejoinAfterLeave": false, + "AEInterval": 60000000000, + "Checks": null, + "Services": null, + "ConsulConfig": null + }, + "Member": { + "Name": "foobar", + "Addr": "10.1.10.12", + "Port": 8301, + "Tags": { + "bootstrap": "1", + "dc": "dc1", + "port": "8300", + "role": "consul", + "vsn": "1", + "vsn_max": "1", + "vsn_min": "1" + }, + "Status": 1, + "ProtocolMin": 1, + "ProtocolMax": 2, + "ProtocolCur": 2, + "DelegateMin": 2, + "DelegateMax": 4, + "DelegateCur": 4 + } + } + ### /v1/agent/join/\ This endpoint is hit with a GET and is used to instruct the agent to attempt to