2014-04-27 19:56:06 +00:00
|
|
|
package consul
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/consul/consul/structs"
|
|
|
|
)
|
|
|
|
|
2014-04-28 21:44:36 +00:00
|
|
|
// Internal endpoint is used to query the miscellaneous info that
|
2014-04-27 19:56:06 +00:00
|
|
|
// does not necessarily fit into the other systems. It is also
|
|
|
|
// used to hold undocumented APIs that users should not rely on.
|
2014-04-28 21:44:36 +00:00
|
|
|
type Internal struct {
|
2014-04-27 19:56:06 +00:00
|
|
|
srv *Server
|
|
|
|
}
|
|
|
|
|
|
|
|
// ChecksInState is used to get all the checks in a given state
|
2014-04-28 21:44:36 +00:00
|
|
|
func (m *Internal) NodeInfo(args *structs.NodeSpecificRequest,
|
2014-04-27 19:56:06 +00:00
|
|
|
reply *structs.IndexedNodeDump) error {
|
2014-04-28 21:44:36 +00:00
|
|
|
if done, err := m.srv.forward("Internal.NodeInfo", args, args, reply); done {
|
2014-04-27 19:56:06 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the state specific checks
|
|
|
|
state := m.srv.fsm.State()
|
|
|
|
return m.srv.blockingRPC(&args.QueryOptions,
|
|
|
|
&reply.QueryMeta,
|
|
|
|
state.QueryTables("NodeInfo"),
|
|
|
|
func() error {
|
|
|
|
reply.Index, reply.Dump = state.NodeInfo(args.Node)
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
// ChecksInState is used to get all the checks in a given state
|
2014-04-28 21:44:36 +00:00
|
|
|
func (m *Internal) NodeDump(args *structs.DCSpecificRequest,
|
2014-04-27 19:56:06 +00:00
|
|
|
reply *structs.IndexedNodeDump) error {
|
2014-04-28 21:44:36 +00:00
|
|
|
if done, err := m.srv.forward("Internal.NodeDump", args, args, reply); done {
|
2014-04-27 19:56:06 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get the state specific checks
|
|
|
|
state := m.srv.fsm.State()
|
|
|
|
return m.srv.blockingRPC(&args.QueryOptions,
|
|
|
|
&reply.QueryMeta,
|
|
|
|
state.QueryTables("NodeDump"),
|
|
|
|
func() error {
|
|
|
|
reply.Index, reply.Dump = state.NodeDump()
|
|
|
|
return nil
|
|
|
|
})
|
|
|
|
}
|