本文整理汇总了Golang中github.com/docker/engine-api/types.Info类的典型用法代码示例。如果您正苦于以下问题:Golang Info类的具体用法?Golang Info怎么用?Golang Info使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Info类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: getInfo
// GET /info
func getInfo(c *context, w http.ResponseWriter, r *http.Request) {
info := apitypes.Info{
Images: len(c.cluster.Images().Filter(cluster.ImageFilterOptions{})),
DriverStatus: c.statusHandler.Status(),
NEventsListener: c.eventsHandler.Size(),
Debug: c.debug,
MemoryLimit: true,
SwapLimit: true,
CPUCfsPeriod: true,
CPUCfsQuota: true,
CPUShares: true,
CPUSet: true,
IPv4Forwarding: true,
BridgeNfIptables: true,
BridgeNfIP6tables: true,
OomKillDisable: true,
OperatingSystem: runtime.GOOS,
Architecture: runtime.GOARCH,
NCPU: int(c.cluster.TotalCpus()),
MemTotal: c.cluster.TotalMemory(),
HTTPProxy: os.Getenv("http_proxy"),
HTTPSProxy: os.Getenv("https_proxy"),
NoProxy: os.Getenv("no_proxy"),
SystemTime: time.Now().Format(time.RFC3339Nano),
ExperimentalBuild: experimental.ENABLED,
}
if kernelVersion, err := kernel.GetKernelVersion(); err == nil {
info.KernelVersion = kernelVersion.String()
}
for _, c := range c.cluster.Containers() {
info.Containers++
if c.Info.State.Paused {
info.ContainersPaused++
} else if c.Info.State.Running {
info.ContainersRunning++
} else {
info.ContainersStopped++
}
}
if hostname, err := os.Hostname(); err == nil {
info.Name = hostname
}
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(info)
}
开发者ID:cloudvision,项目名称:swarm,代码行数:50,代码来源:handlers.go
示例2: getInfo
// GET /info
func getInfo(c *context, w http.ResponseWriter, r *http.Request) {
info := apitypes.Info{
Images: len(c.cluster.Images().Filter(cluster.ImageFilterOptions{})),
NEventsListener: c.eventsHandler.Size(),
Debug: c.debug,
MemoryLimit: true,
SwapLimit: true,
CPUCfsPeriod: true,
CPUCfsQuota: true,
CPUShares: true,
CPUSet: true,
IPv4Forwarding: true,
BridgeNfIptables: true,
BridgeNfIP6tables: true,
OomKillDisable: true,
ServerVersion: "swarm/" + version.VERSION,
OperatingSystem: runtime.GOOS,
Architecture: runtime.GOARCH,
NCPU: int(c.cluster.TotalCpus()),
MemTotal: c.cluster.TotalMemory(),
HTTPProxy: os.Getenv("http_proxy"),
HTTPSProxy: os.Getenv("https_proxy"),
NoProxy: os.Getenv("no_proxy"),
SystemTime: time.Now().Format(time.RFC3339Nano),
ExperimentalBuild: experimental.ENABLED,
}
// API versions older than 1.22 use DriverStatus and return \b characters in the output
status := c.statusHandler.Status()
if c.apiVersion != "" && versionpkg.Version(c.apiVersion).LessThan("1.22") {
for i := range status {
if status[i][0][:1] == " " {
status[i][0] = status[i][0][1:]
} else {
status[i][0] = "\b" + status[i][0]
}
}
info.DriverStatus = status
} else {
info.SystemStatus = status
}
kernelVersion := "<unknown>"
if kv, err := kernel.GetKernelVersion(); err != nil {
log.Warnf("Could not get kernel version: %v", err)
} else {
kernelVersion = kv.String()
}
info.KernelVersion = kernelVersion
for _, c := range c.cluster.Containers() {
info.Containers++
if c.Info.State.Paused {
info.ContainersPaused++
} else if c.Info.State.Running {
info.ContainersRunning++
} else {
info.ContainersStopped++
}
}
hostname := "<unknown>"
if hn, err := os.Hostname(); err != nil {
log.Warnf("Could not get hostname: %v", err)
} else {
hostname = hn
}
info.Name = hostname
w.Header().Set("Content-Type", "application/json")
json.NewEncoder(w).Encode(info)
}
开发者ID:yehohanan7,项目名称:swarm,代码行数:73,代码来源:handlers.go
注:本文中的github.com/docker/engine-api/types.Info类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论