mirror of https://github.com/docker/docs.git
use ID and names
This commit is contained in:
parent
725c03d799
commit
20319a5049
|
|
@ -32,8 +32,8 @@ type handler func(c *context, w http.ResponseWriter, r *http.Request)
|
||||||
func getInfo(c *context, w http.ResponseWriter, r *http.Request) {
|
func getInfo(c *context, w http.ResponseWriter, r *http.Request) {
|
||||||
driverStatus := [][2]string{{"\bNodes", fmt.Sprintf("%d", len(c.cluster.Nodes()))}}
|
driverStatus := [][2]string{{"\bNodes", fmt.Sprintf("%d", len(c.cluster.Nodes()))}}
|
||||||
|
|
||||||
for ID, node := range c.cluster.Nodes() {
|
for _, node := range c.cluster.Nodes() {
|
||||||
driverStatus = append(driverStatus, [2]string{ID, node.Addr})
|
driverStatus = append(driverStatus, [2]string{node.Name, node.Addr})
|
||||||
}
|
}
|
||||||
info := struct {
|
info := struct {
|
||||||
Containers int
|
Containers int
|
||||||
|
|
@ -70,7 +70,7 @@ func getContainersJSON(c *context, w http.ResponseWriter, r *http.Request) {
|
||||||
// TODO remove the Node ID in the name when we have a good solution
|
// TODO remove the Node ID in the name when we have a good solution
|
||||||
tmp.Names = make([]string, len(container.Names))
|
tmp.Names = make([]string, len(container.Names))
|
||||||
for i, name := range container.Names {
|
for i, name := range container.Names {
|
||||||
tmp.Names[i] = "/" + container.Node().ID + name
|
tmp.Names[i] = "/" + container.Node().Name + name
|
||||||
}
|
}
|
||||||
tmp.Ports = make([]dockerclient.Port, len(container.Ports))
|
tmp.Ports = make([]dockerclient.Port, len(container.Ports))
|
||||||
for i, port := range container.Ports {
|
for i, port := range container.Ports {
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,8 @@ const (
|
||||||
stateRefreshPeriod = 30 * time.Second
|
stateRefreshPeriod = 30 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewNode(id string, addr string) *Node {
|
func NewNode(addr string) *Node {
|
||||||
e := &Node{
|
e := &Node{
|
||||||
ID: id,
|
|
||||||
Addr: addr,
|
Addr: addr,
|
||||||
Labels: make(map[string]string),
|
Labels: make(map[string]string),
|
||||||
ch: make(chan bool),
|
ch: make(chan bool),
|
||||||
|
|
@ -34,6 +33,7 @@ type Node struct {
|
||||||
ID string
|
ID string
|
||||||
IP string
|
IP string
|
||||||
Addr string
|
Addr string
|
||||||
|
Name string
|
||||||
Cpus int64
|
Cpus int64
|
||||||
Memory int64
|
Memory int64
|
||||||
Labels map[string]string
|
Labels map[string]string
|
||||||
|
|
@ -96,6 +96,8 @@ func (n *Node) updateSpecs() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
n.ID = info.ID
|
||||||
|
n.Name = info.Name
|
||||||
n.Cpus = info.NCPU
|
n.Cpus = info.NCPU
|
||||||
n.Memory = info.MemTotal
|
n.Memory = info.MemTotal
|
||||||
n.Labels = map[string]string{
|
n.Labels = map[string]string{
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ func manage(c *cli.Context) {
|
||||||
refresh := func(c *cluster.Cluster, nodes []string) error {
|
refresh := func(c *cluster.Cluster, nodes []string) error {
|
||||||
for _, addr := range nodes {
|
for _, addr := range nodes {
|
||||||
if c.Node(addr) == nil {
|
if c.Node(addr) == nil {
|
||||||
n := cluster.NewNode(addr, addr)
|
n := cluster.NewNode(addr)
|
||||||
if err := n.Connect(nil); err != nil {
|
if err := n.Connect(nil); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue