finish runtime
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
package network
|
||||
|
||||
import (
|
||||
"floares/lib/http/containers"
|
||||
"floares/lib/http/network"
|
||||
"floares/lib/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func ListConnect(c *gin.Context) {
|
||||
@@ -15,6 +18,31 @@ func ListConnect(c *gin.Context) {
|
||||
})
|
||||
}
|
||||
inspect := network.GetInspect(ns)
|
||||
c.JSON(http.StatusOK, inspect)
|
||||
var res model.NetworkInspect
|
||||
res.Name = inspect.Name
|
||||
res.Id = inspect.Id
|
||||
res.Ipam = model.Config{
|
||||
Subnet: inspect.IPAM.Config[0].Subnet,
|
||||
Gateway: inspect.IPAM.Config[0].Gateway,
|
||||
}
|
||||
res.Containers = make([]model.NetConnect, 0)
|
||||
res.Driver = inspect.Driver
|
||||
res.Created = inspect.Created.Format(time.DateTime)
|
||||
for k, v := range inspect.Containers {
|
||||
container := containers.InspectContainer(k)
|
||||
res.Containers = append(res.Containers, model.NetConnect{
|
||||
Name: v.Name,
|
||||
Id: k,
|
||||
Gateway: container.NetworkSettings.Networks[ns].Gateway,
|
||||
Alias: container.NetworkSettings.Networks[ns].Aliases,
|
||||
Ip: v.IPv4Address,
|
||||
Mac: v.MacAddress,
|
||||
})
|
||||
}
|
||||
c.JSON(http.StatusOK, gin.H{
|
||||
"data": res,
|
||||
"code": http.StatusOK,
|
||||
"err": "",
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user