mirror of https://github.com/docker/docs.git
add Node back to inspect
Signed-off-by: Victor Vieux <vieux@docker.com>
This commit is contained in:
parent
e3e7ddb616
commit
0fca58b069
|
|
@ -32,18 +32,10 @@ DELETE "/images/{name:.*}"
|
||||||
|
|
||||||
```json
|
```json
|
||||||
"Node": {
|
"Node": {
|
||||||
"ID": "ODAI:IC6Q:MSBL:TPB5:HIEE:6IKC:VCAM:QRNH:PRGX:ERZT:OK46:PMFX",
|
"Id": "ODAI:IC6Q:MSBL:TPB5:HIEE:6IKC:VCAM:QRNH:PRGX:ERZT:OK46:PMFX",
|
||||||
"IP": "0.0.0.0",
|
"Ip": "0.0.0.0",
|
||||||
"Addr": "http://0.0.0.0:4243",
|
"Addr": "http://0.0.0.0:4243",
|
||||||
"Name": "vagrant-ubuntu-saucy-64",
|
"Name": "vagrant-ubuntu-saucy-64",
|
||||||
"Cpus": 1,
|
|
||||||
"Memory": 2099654656,
|
|
||||||
"Labels": {
|
|
||||||
"executiondriver": "native-0.2",
|
|
||||||
"kernelversion": "3.11.0-15-generic",
|
|
||||||
"operatingsystem": "Ubuntu 13.10",
|
|
||||||
"storagedriver": "aufs"
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
```
|
```
|
||||||
* `GET "/containers/{name:.*}/json"`: `HostIP` replaced by the the actual Node's IP if `HostIP` is `0.0.0.0`
|
* `GET "/containers/{name:.*}/json"`: `HostIP` replaced by the the actual Node's IP if `HostIP` is `0.0.0.0`
|
||||||
|
|
|
||||||
|
|
@ -180,14 +180,8 @@ func getContainerJSON(c *context, w http.ResponseWriter, r *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
n, err := json.Marshal(container.Node)
|
|
||||||
if err != nil {
|
|
||||||
httpError(w, err.Error(), http.StatusInternalServerError)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// insert Node field
|
// insert Node field
|
||||||
data = bytes.Replace(data, []byte("\"Name\":\"/"), []byte(fmt.Sprintf("\"Node\":%s,\"Name\":\"/", n)), -1)
|
data = bytes.Replace(data, []byte("\"Name\":\"/"), []byte(fmt.Sprintf("\"Node\":%s,\"Name\":\"/", cluster.SerializeNode(container.Node))), -1)
|
||||||
|
|
||||||
// insert node IP
|
// insert node IP
|
||||||
data = bytes.Replace(data, []byte("\"HostIp\":\"0.0.0.0\""), []byte(fmt.Sprintf("\"HostIp\":%q", container.Node.IP())), -1)
|
data = bytes.Replace(data, []byte("\"HostIp\":\"0.0.0.0\""), []byte(fmt.Sprintf("\"HostIp\":%q", container.Node.IP())), -1)
|
||||||
|
|
|
||||||
|
|
@ -36,15 +36,12 @@ func (eh *eventsHandler) Wait(remoteAddr string) {
|
||||||
func (eh *eventsHandler) Handle(e *cluster.Event) error {
|
func (eh *eventsHandler) Handle(e *cluster.Event) error {
|
||||||
eh.RLock()
|
eh.RLock()
|
||||||
|
|
||||||
str := fmt.Sprintf("{%q:%q,%q:%q,%q:%q,%q:%d,%q:%q,%q:%q,%q:%q,%q:%q}",
|
str := fmt.Sprintf("{%q:%q,%q:%q,%q:%q,%q:%d,%q:%s}",
|
||||||
"status", e.Status,
|
"status", e.Status,
|
||||||
"id", e.Id,
|
"id", e.Id,
|
||||||
"from", e.From+" node:"+e.Node.Name(),
|
"from", e.From+" node:"+e.Node.Name(),
|
||||||
"time", e.Time,
|
"time", e.Time,
|
||||||
"node_name", e.Node.Name(),
|
"node", cluster.SerializeNode(e.Node))
|
||||||
"node_id", e.Node.ID(),
|
|
||||||
"node_addr", e.Node.Addr(),
|
|
||||||
"node_ip", e.Node.IP())
|
|
||||||
|
|
||||||
for key, w := range eh.ws {
|
for key, w := range eh.ws {
|
||||||
if _, err := fmt.Fprintf(w, str); err != nil {
|
if _, err := fmt.Fprintf(w, str); err != nil {
|
||||||
|
|
|
||||||
|
|
@ -54,15 +54,16 @@ func TestHandle(t *testing.T) {
|
||||||
|
|
||||||
assert.NoError(t, eh.Handle(event))
|
assert.NoError(t, eh.Handle(event))
|
||||||
|
|
||||||
str := fmt.Sprintf("{%q:%q,%q:%q,%q:%q,%q:%d,%q:%q,%q:%q,%q:%q,%q:%q}",
|
str := fmt.Sprintf("{%q:%q,%q:%q,%q:%q,%q:%d,%q:{%q:%q,%q:%q,%q:%q,%q:%q}}",
|
||||||
"status", "status",
|
"status", "status",
|
||||||
"id", "id",
|
"id", "id",
|
||||||
"from", "from node:node_name",
|
"from", "from node:node_name",
|
||||||
"time", 0,
|
"time", 0,
|
||||||
"node_name", "node_name",
|
"node",
|
||||||
"node_id", "node_id",
|
"Name", "node_name",
|
||||||
"node_addr", "node_addr",
|
"Id", "node_id",
|
||||||
"node_ip", "node_ip")
|
"Addr", "node_addr",
|
||||||
|
"Ip", "node_ip")
|
||||||
|
|
||||||
assert.Equal(t, str, string(fw.Tmp))
|
assert.Equal(t, str, string(fw.Tmp))
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
package cluster
|
package cluster
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
type Node interface {
|
type Node interface {
|
||||||
ID() string
|
ID() string
|
||||||
Name() string
|
Name() string
|
||||||
|
|
@ -21,3 +23,11 @@ type Node interface {
|
||||||
|
|
||||||
IsHealthy() bool
|
IsHealthy() bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func SerializeNode(node Node) string {
|
||||||
|
return fmt.Sprintf("{%q:%q,%q:%q,%q:%q,%q:%q}",
|
||||||
|
"Name", node.Name(),
|
||||||
|
"Id", node.ID(),
|
||||||
|
"Addr", node.Addr(),
|
||||||
|
"Ip", node.IP())
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue