2014-05-16 22:49:17 +00:00
|
|
|
package agent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"net/http"
|
|
|
|
"strings"
|
2014-05-19 20:12:15 +00:00
|
|
|
"time"
|
2014-12-13 03:17:04 +00:00
|
|
|
|
pkg refactor
command/agent/* -> agent/*
command/consul/* -> agent/consul/*
command/agent/command{,_test}.go -> command/agent{,_test}.go
command/base/command.go -> command/base.go
command/base/* -> command/*
commands.go -> command/commands.go
The script which did the refactor is:
(
cd $GOPATH/src/github.com/hashicorp/consul
git mv command/agent/command.go command/agent.go
git mv command/agent/command_test.go command/agent_test.go
git mv command/agent/flag_slice_value{,_test}.go command/
git mv command/agent .
git mv command/base/command.go command/base.go
git mv command/base/config_util{,_test}.go command/
git mv commands.go command/
git mv consul agent
rmdir command/base/
gsed -i -e 's|package agent|package command|' command/agent{,_test}.go
gsed -i -e 's|package agent|package command|' command/flag_slice_value{,_test}.go
gsed -i -e 's|package base|package command|' command/base.go command/config_util{,_test}.go
gsed -i -e 's|package main|package command|' command/commands.go
gsed -i -e 's|base.Command|BaseCommand|' command/commands.go
gsed -i -e 's|agent.Command|AgentCommand|' command/commands.go
gsed -i -e 's|\tCommand:|\tBaseCommand:|' command/commands.go
gsed -i -e 's|base\.||' command/commands.go
gsed -i -e 's|command\.||' command/commands.go
gsed -i -e 's|command|c|' main.go
gsed -i -e 's|range Commands|range command.Commands|' main.go
gsed -i -e 's|Commands: Commands|Commands: command.Commands|' main.go
gsed -i -e 's|base\.BoolValue|BoolValue|' command/operator_autopilot_set.go
gsed -i -e 's|base\.DurationValue|DurationValue|' command/operator_autopilot_set.go
gsed -i -e 's|base\.StringValue|StringValue|' command/operator_autopilot_set.go
gsed -i -e 's|base\.UintValue|UintValue|' command/operator_autopilot_set.go
gsed -i -e 's|\bCommand\b|BaseCommand|' command/base.go
gsed -i -e 's|BaseCommand Options|Command Options|' command/base.go
gsed -i -e 's|base.Command|BaseCommand|' command/*.go
gsed -i -e 's|c\.Command|c.BaseCommand|g' command/*.go
gsed -i -e 's|\tCommand:|\tBaseCommand:|' command/*_test.go
gsed -i -e 's|base\.||' command/*_test.go
gsed -i -e 's|\bCommand\b|AgentCommand|' command/agent{,_test}.go
gsed -i -e 's|cmd.AgentCommand|cmd.BaseCommand|' command/agent.go
gsed -i -e 's|cli.AgentCommand = new(Command)|cli.Command = new(AgentCommand)|' command/agent_test.go
gsed -i -e 's|exec.AgentCommand|exec.Command|' command/agent_test.go
gsed -i -e 's|exec.BaseCommand|exec.Command|' command/agent_test.go
gsed -i -e 's|NewTestAgent|agent.NewTestAgent|' command/agent_test.go
gsed -i -e 's|= TestConfig|= agent.TestConfig|' command/agent_test.go
gsed -i -e 's|: RetryJoin|: agent.RetryJoin|' command/agent_test.go
gsed -i -e 's|\.\./\.\./|../|' command/config_util_test.go
gsed -i -e 's|\bverifyUniqueListeners|VerifyUniqueListeners|' agent/config{,_test}.go command/agent.go
gsed -i -e 's|\bserfLANKeyring\b|SerfLANKeyring|g' agent/{agent,keyring,testagent}.go command/agent.go
gsed -i -e 's|\bserfWANKeyring\b|SerfWANKeyring|g' agent/{agent,keyring,testagent}.go command/agent.go
gsed -i -e 's|\bNewAgent\b|agent.New|g' command/agent{,_test}.go
gsed -i -e 's|\bNewAgent|New|' agent/{acl_test,agent,testagent}.go
gsed -i -e 's|\bAgent\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bBool\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bConfig\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bDefaultConfig\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bDevConfig\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bMergeConfig\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bReadConfigPaths\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bParseMetaPair\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bSerfLANKeyring\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|\bSerfWANKeyring\b|agent.&|g' command/agent{,_test}.go
gsed -i -e 's|circonus\.agent|circonus|g' command/agent{,_test}.go
gsed -i -e 's|logger\.agent|logger|g' command/agent{,_test}.go
gsed -i -e 's|metrics\.agent|metrics|g' command/agent{,_test}.go
gsed -i -e 's|// agent.Agent|// agent|' command/agent{,_test}.go
gsed -i -e 's|a\.agent\.Config|a.Config|' command/agent{,_test}.go
gsed -i -e 's|agent\.AppendSliceValue|AppendSliceValue|' command/{configtest,validate}.go
gsed -i -e 's|consul/consul|agent/consul|' GNUmakefile
gsed -i -e 's|\.\./test|../../test|' agent/consul/server_test.go
# fix imports
f=$(grep -rl 'github.com/hashicorp/consul/command/agent' * | grep '\.go')
gsed -i -e 's|github.com/hashicorp/consul/command/agent|github.com/hashicorp/consul/agent|' $f
goimports -w $f
f=$(grep -rl 'github.com/hashicorp/consul/consul' * | grep '\.go')
gsed -i -e 's|github.com/hashicorp/consul/consul|github.com/hashicorp/consul/agent/consul|' $f
goimports -w $f
goimports -w command/*.go main.go
)
2017-06-09 22:28:28 +00:00
|
|
|
"github.com/hashicorp/consul/agent/consul/structs"
|
2016-06-07 20:24:51 +00:00
|
|
|
"github.com/hashicorp/consul/types"
|
2014-05-19 20:12:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
// lockDelayMinThreshold is used to convert a numeric lock
|
|
|
|
// delay value from nanoseconds to seconds if it is below this
|
|
|
|
// threshold. Users often send a value like 5, which they assume
|
|
|
|
// is seconds, but because Go uses nanosecond granularity, ends
|
|
|
|
// up being very small. If we see a value below this threshold,
|
2015-09-15 12:22:08 +00:00
|
|
|
// we multiply by time.Second
|
2014-05-19 20:12:15 +00:00
|
|
|
lockDelayMinThreshold = 1000
|
2014-05-16 22:49:17 +00:00
|
|
|
)
|
|
|
|
|
2014-05-19 18:29:50 +00:00
|
|
|
// sessionCreateResponse is used to wrap the session ID
|
|
|
|
type sessionCreateResponse struct {
|
|
|
|
ID string
|
|
|
|
}
|
|
|
|
|
2014-05-16 22:49:17 +00:00
|
|
|
// SessionCreate is used to create a new session
|
|
|
|
func (s *HTTPServer) SessionCreate(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
2014-05-16 22:58:07 +00:00
|
|
|
// Mandate a PUT request
|
|
|
|
if req.Method != "PUT" {
|
|
|
|
resp.WriteHeader(405)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2014-11-20 02:11:41 +00:00
|
|
|
// Default the session to our node + serf check + release session invalidate behavior
|
2014-05-16 22:49:17 +00:00
|
|
|
args := structs.SessionRequest{
|
|
|
|
Op: structs.SessionCreate,
|
|
|
|
Session: structs.Session{
|
2014-05-19 20:12:15 +00:00
|
|
|
Node: s.agent.config.NodeName,
|
2017-07-14 05:33:47 +00:00
|
|
|
Checks: []types.CheckID{structs.SerfCheckID},
|
2014-05-19 20:12:15 +00:00
|
|
|
LockDelay: 15 * time.Second,
|
2014-11-20 02:11:41 +00:00
|
|
|
Behavior: structs.SessionKeysRelease,
|
2014-11-25 16:06:14 +00:00
|
|
|
TTL: "",
|
2014-05-16 22:49:17 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
s.parseDC(req, &args.Datacenter)
|
2016-12-13 05:59:22 +00:00
|
|
|
s.parseToken(req, &args.Token)
|
2014-05-16 22:49:17 +00:00
|
|
|
|
|
|
|
// Handle optional request body
|
|
|
|
if req.ContentLength > 0 {
|
2014-05-19 20:12:15 +00:00
|
|
|
if err := decodeBody(req, &args.Session, FixupLockDelay); err != nil {
|
2014-05-16 22:49:17 +00:00
|
|
|
resp.WriteHeader(400)
|
Use fmt.Fprint/Fprintf/Fprintln
Used the following rewrite rules:
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b, c, d))) -> fmt.Fprintf(resp, a, b, c, d)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b, c))) -> fmt.Fprintf(resp, a, b, c)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b))) -> fmt.Fprintf(resp, a, b)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a))) -> fmt.Fprint(resp, a)' *.go
gofmt -w -r 'resp.Write([]byte(a + "\n")) -> fmt.Fprintln(resp, a)' *.go
gofmt -w -r 'resp.Write([]byte(a)) -> fmt.Fprint(resp, a)' *.go
2017-04-20 14:07:42 +00:00
|
|
|
fmt.Fprintf(resp, "Request decode failed: %v", err)
|
2014-05-16 22:49:17 +00:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the session, get the ID
|
|
|
|
var out string
|
|
|
|
if err := s.agent.RPC("Session.Apply", &args, &out); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
// Format the response as a JSON object
|
2014-05-19 18:29:50 +00:00
|
|
|
return sessionCreateResponse{out}, nil
|
2014-05-16 22:49:17 +00:00
|
|
|
}
|
|
|
|
|
2014-05-19 20:12:15 +00:00
|
|
|
// FixupLockDelay is used to handle parsing the JSON body to session/create
|
|
|
|
// and properly parsing out the lock delay duration value.
|
|
|
|
func FixupLockDelay(raw interface{}) error {
|
|
|
|
rawMap, ok := raw.(map[string]interface{})
|
|
|
|
if !ok {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
var key string
|
2017-04-20 18:42:22 +00:00
|
|
|
for k := range rawMap {
|
2014-05-19 20:12:15 +00:00
|
|
|
if strings.ToLower(k) == "lockdelay" {
|
|
|
|
key = k
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if key != "" {
|
|
|
|
val := rawMap[key]
|
|
|
|
// Convert a string value into an integer
|
|
|
|
if vStr, ok := val.(string); ok {
|
|
|
|
dur, err := time.ParseDuration(vStr)
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
if dur < lockDelayMinThreshold {
|
|
|
|
dur = dur * time.Second
|
|
|
|
}
|
|
|
|
rawMap[key] = dur
|
|
|
|
}
|
|
|
|
// Convert low value integers into seconds
|
|
|
|
if vNum, ok := val.(float64); ok {
|
|
|
|
dur := time.Duration(vNum)
|
|
|
|
if dur < lockDelayMinThreshold {
|
|
|
|
dur = dur * time.Second
|
|
|
|
}
|
|
|
|
rawMap[key] = dur
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2014-05-16 22:49:17 +00:00
|
|
|
// SessionDestroy is used to destroy an existing session
|
|
|
|
func (s *HTTPServer) SessionDestroy(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
2014-08-19 17:53:25 +00:00
|
|
|
// Mandate a PUT request
|
|
|
|
if req.Method != "PUT" {
|
|
|
|
resp.WriteHeader(405)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
2014-05-16 22:49:17 +00:00
|
|
|
args := structs.SessionRequest{
|
|
|
|
Op: structs.SessionDestroy,
|
|
|
|
}
|
|
|
|
s.parseDC(req, &args.Datacenter)
|
2016-12-13 05:59:22 +00:00
|
|
|
s.parseToken(req, &args.Token)
|
2014-05-16 22:49:17 +00:00
|
|
|
|
|
|
|
// Pull out the session id
|
|
|
|
args.Session.ID = strings.TrimPrefix(req.URL.Path, "/v1/session/destroy/")
|
|
|
|
if args.Session.ID == "" {
|
|
|
|
resp.WriteHeader(400)
|
Use fmt.Fprint/Fprintf/Fprintln
Used the following rewrite rules:
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b, c, d))) -> fmt.Fprintf(resp, a, b, c, d)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b, c))) -> fmt.Fprintf(resp, a, b, c)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b))) -> fmt.Fprintf(resp, a, b)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a))) -> fmt.Fprint(resp, a)' *.go
gofmt -w -r 'resp.Write([]byte(a + "\n")) -> fmt.Fprintln(resp, a)' *.go
gofmt -w -r 'resp.Write([]byte(a)) -> fmt.Fprint(resp, a)' *.go
2017-04-20 14:07:42 +00:00
|
|
|
fmt.Fprint(resp, "Missing session")
|
2014-05-16 22:49:17 +00:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var out string
|
|
|
|
if err := s.agent.RPC("Session.Apply", &args, &out); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return true, nil
|
|
|
|
}
|
|
|
|
|
2014-11-25 16:06:14 +00:00
|
|
|
// SessionRenew is used to renew the TTL on an existing TTL session
|
|
|
|
func (s *HTTPServer) SessionRenew(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
|
|
|
// Mandate a PUT request
|
|
|
|
if req.Method != "PUT" {
|
|
|
|
resp.WriteHeader(405)
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
args := structs.SessionSpecificRequest{}
|
|
|
|
if done := s.parse(resp, req, &args.Datacenter, &args.QueryOptions); done {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pull out the session id
|
|
|
|
args.Session = strings.TrimPrefix(req.URL.Path, "/v1/session/renew/")
|
|
|
|
if args.Session == "" {
|
|
|
|
resp.WriteHeader(400)
|
Use fmt.Fprint/Fprintf/Fprintln
Used the following rewrite rules:
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b, c, d))) -> fmt.Fprintf(resp, a, b, c, d)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b, c))) -> fmt.Fprintf(resp, a, b, c)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b))) -> fmt.Fprintf(resp, a, b)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a))) -> fmt.Fprint(resp, a)' *.go
gofmt -w -r 'resp.Write([]byte(a + "\n")) -> fmt.Fprintln(resp, a)' *.go
gofmt -w -r 'resp.Write([]byte(a)) -> fmt.Fprint(resp, a)' *.go
2017-04-20 14:07:42 +00:00
|
|
|
fmt.Fprint(resp, "Missing session")
|
2014-11-25 16:06:14 +00:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var out structs.IndexedSessions
|
|
|
|
if err := s.agent.RPC("Session.Renew", &args, &out); err != nil {
|
|
|
|
return nil, err
|
2014-12-10 15:02:23 +00:00
|
|
|
} else if out.Sessions == nil {
|
|
|
|
resp.WriteHeader(404)
|
Use fmt.Fprint/Fprintf/Fprintln
Used the following rewrite rules:
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b, c, d))) -> fmt.Fprintf(resp, a, b, c, d)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b, c))) -> fmt.Fprintf(resp, a, b, c)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b))) -> fmt.Fprintf(resp, a, b)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a))) -> fmt.Fprint(resp, a)' *.go
gofmt -w -r 'resp.Write([]byte(a + "\n")) -> fmt.Fprintln(resp, a)' *.go
gofmt -w -r 'resp.Write([]byte(a)) -> fmt.Fprint(resp, a)' *.go
2017-04-20 14:07:42 +00:00
|
|
|
fmt.Fprintf(resp, "Session id '%s' not found", args.Session)
|
2014-12-10 15:02:23 +00:00
|
|
|
return nil, nil
|
2014-11-25 16:06:14 +00:00
|
|
|
}
|
2014-12-10 15:02:23 +00:00
|
|
|
|
2014-11-25 16:06:14 +00:00
|
|
|
return out.Sessions, nil
|
|
|
|
}
|
|
|
|
|
2014-05-16 22:49:17 +00:00
|
|
|
// SessionGet is used to get info for a particular session
|
|
|
|
func (s *HTTPServer) SessionGet(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
|
|
|
args := structs.SessionSpecificRequest{}
|
|
|
|
if done := s.parse(resp, req, &args.Datacenter, &args.QueryOptions); done {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pull out the session id
|
|
|
|
args.Session = strings.TrimPrefix(req.URL.Path, "/v1/session/info/")
|
|
|
|
if args.Session == "" {
|
|
|
|
resp.WriteHeader(400)
|
Use fmt.Fprint/Fprintf/Fprintln
Used the following rewrite rules:
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b, c, d))) -> fmt.Fprintf(resp, a, b, c, d)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b, c))) -> fmt.Fprintf(resp, a, b, c)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b))) -> fmt.Fprintf(resp, a, b)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a))) -> fmt.Fprint(resp, a)' *.go
gofmt -w -r 'resp.Write([]byte(a + "\n")) -> fmt.Fprintln(resp, a)' *.go
gofmt -w -r 'resp.Write([]byte(a)) -> fmt.Fprint(resp, a)' *.go
2017-04-20 14:07:42 +00:00
|
|
|
fmt.Fprint(resp, "Missing session")
|
2014-05-16 22:49:17 +00:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var out structs.IndexedSessions
|
|
|
|
defer setMeta(resp, &out.QueryMeta)
|
|
|
|
if err := s.agent.RPC("Session.Get", &args, &out); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2015-11-15 05:05:37 +00:00
|
|
|
|
|
|
|
// Use empty list instead of nil
|
|
|
|
if out.Sessions == nil {
|
|
|
|
out.Sessions = make(structs.Sessions, 0)
|
|
|
|
}
|
2014-05-16 22:49:17 +00:00
|
|
|
return out.Sessions, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SessionList is used to list all the sessions
|
|
|
|
func (s *HTTPServer) SessionList(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
|
|
|
args := structs.DCSpecificRequest{}
|
|
|
|
if done := s.parse(resp, req, &args.Datacenter, &args.QueryOptions); done {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var out structs.IndexedSessions
|
|
|
|
defer setMeta(resp, &out.QueryMeta)
|
|
|
|
if err := s.agent.RPC("Session.List", &args, &out); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2015-11-15 05:05:37 +00:00
|
|
|
|
|
|
|
// Use empty list instead of nil
|
|
|
|
if out.Sessions == nil {
|
|
|
|
out.Sessions = make(structs.Sessions, 0)
|
|
|
|
}
|
2014-05-16 22:49:17 +00:00
|
|
|
return out.Sessions, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// SessionsForNode returns all the nodes belonging to a node
|
|
|
|
func (s *HTTPServer) SessionsForNode(resp http.ResponseWriter, req *http.Request) (interface{}, error) {
|
|
|
|
args := structs.NodeSpecificRequest{}
|
|
|
|
if done := s.parse(resp, req, &args.Datacenter, &args.QueryOptions); done {
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pull out the node name
|
|
|
|
args.Node = strings.TrimPrefix(req.URL.Path, "/v1/session/node/")
|
|
|
|
if args.Node == "" {
|
|
|
|
resp.WriteHeader(400)
|
Use fmt.Fprint/Fprintf/Fprintln
Used the following rewrite rules:
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b, c, d))) -> fmt.Fprintf(resp, a, b, c, d)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b, c))) -> fmt.Fprintf(resp, a, b, c)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a, b))) -> fmt.Fprintf(resp, a, b)' *.go
gofmt -w -r 'resp.Write([]byte(fmt.Sprintf(a))) -> fmt.Fprint(resp, a)' *.go
gofmt -w -r 'resp.Write([]byte(a + "\n")) -> fmt.Fprintln(resp, a)' *.go
gofmt -w -r 'resp.Write([]byte(a)) -> fmt.Fprint(resp, a)' *.go
2017-04-20 14:07:42 +00:00
|
|
|
fmt.Fprint(resp, "Missing node name")
|
2014-05-16 22:49:17 +00:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
var out structs.IndexedSessions
|
|
|
|
defer setMeta(resp, &out.QueryMeta)
|
|
|
|
if err := s.agent.RPC("Session.NodeSessions", &args, &out); err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2015-11-15 05:05:37 +00:00
|
|
|
|
|
|
|
// Use empty list instead of nil
|
|
|
|
if out.Sessions == nil {
|
|
|
|
out.Sessions = make(structs.Sessions, 0)
|
|
|
|
}
|
2014-05-16 22:49:17 +00:00
|
|
|
return out.Sessions, nil
|
|
|
|
}
|