Skip to content

Commit

Permalink
enhance: add more field in 'pouch info' command
Browse files Browse the repository at this point in the history
Signed-off-by: Zou Rui <[email protected]>
  • Loading branch information
ZouRui89 committed Apr 27, 2018
1 parent 01c4164 commit a6dced7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
7 changes: 7 additions & 0 deletions daemon/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"strings"
"sync"

"github.com/alibaba/pouch/apis/types"
"github.com/alibaba/pouch/client"
"github.com/alibaba/pouch/cri"
"github.com/alibaba/pouch/network"
Expand Down Expand Up @@ -97,6 +98,12 @@ type Config struct {

// Pidfile keeps daemon pid
Pidfile string `json:"pidfile,omitempty"`

// Default log configuration
DefaultLogConfig types.HostConfigAO0LogConfig `json:"default-log-config, omitempty"`

// RegistryService
RegistryService types.RegistryServiceConfig `json:"registry-service, omitempty" `
}

// Validate validates the user input config.
Expand Down
18 changes: 13 additions & 5 deletions daemon/mgr/system.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mgr

import (
"context"
"fmt"
"os"
"runtime"
Expand Down Expand Up @@ -33,16 +34,18 @@ type SystemManager struct {
name string
registry *registry.Client
config *config.Config
imageMgr ImageMgr

store *meta.Store
}

// NewSystemManager creates a brand new system manager.
func NewSystemManager(cfg *config.Config, store *meta.Store) (*SystemManager, error) {
func NewSystemManager(cfg *config.Config, store *meta.Store, imageManager ImageMgr) (*SystemManager, error) {
return &SystemManager{
name: "system_manager",
registry: &registry.Client{},
config: cfg,
imageMgr: imageManager,
store: store,
}, nil
}
Expand Down Expand Up @@ -96,8 +99,13 @@ func (mgr *SystemManager) Info() (types.SystemInfo, error) {
OSName = osName
}

images, err := mgr.imageMgr.ListImages(context.Background(), "")
if err != nil {
logrus.Warnf("failed to get image info")
}

info := types.SystemInfo{
// architecture: ,
Architecture: runtime.GOARCH,
// CgroupDriver: ,
// ContainerdCommit: ,
Containers: cRunning + cPaused + cStopped,
Expand All @@ -113,21 +121,21 @@ func (mgr *SystemManager) Info() (types.SystemInfo, error) {
HTTPProxy: mgr.config.ImageProxy,
// HTTPSProxy: ,
// ID: ,
// Images: ,
Images: int64(len(images)),
IndexServerAddress: "https://index.docker.io/v1/",
DefaultRegistry: mgr.config.DefaultRegistry,
KernelVersion: kernelVersion,
Labels: mgr.config.Labels,
// LiveRestoreEnabled: ,
// LoggingDriver: ,
LoggingDriver: mgr.config.DefaultLogConfig.Type,
LxcfsEnabled: mgr.config.IsLxcfsEnabled,
MemTotal: totalMem,
Name: hostname,
NCPU: int64(runtime.NumCPU()),
OperatingSystem: OSName,
OSType: runtime.GOOS,
PouchRootDir: mgr.config.HomeDir,
// RegistryConfig: ,
RegistryConfig: &mgr.config.RegistryService,
// RuncCommit: ,
// Runtimes: ,
// SecurityOptions: ,
Expand Down
2 changes: 1 addition & 1 deletion internal/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func GenContainerMgr(ctx context.Context, d DaemonProvider) (mgr.ContainerMgr, e

// GenSystemMgr generates a SystemMgr instance according to config cfg.
func GenSystemMgr(cfg *config.Config, d DaemonProvider) (mgr.SystemMgr, error) {
return mgr.NewSystemManager(cfg, d.MetaStore())
return mgr.NewSystemManager(cfg, d.MetaStore(), d.ImgMgr())
}

// GenImageMgr generates a ImageMgr instance according to config cfg.
Expand Down

0 comments on commit a6dced7

Please sign in to comment.