Change arguments to fs.GetStats to be map[string]string

Allows us to remove systemd.GetPaths later

Signed-off-by: Donald Huang <don.hcd@gmail.com>
This commit is contained in:
Donald Huang 2014-11-14 23:51:29 +00:00 committed by Michael Crosby
parent 05661b16b2
commit 6c6808e5bf
3 changed files with 6 additions and 46 deletions

View File

@ -21,7 +21,7 @@ func GetStats(container *Config, state *State) (*ContainerStats, error) {
if systemd.UseSystemd() {
stats.CgroupStats, err = systemd.GetStats(container.Cgroups)
} else {
stats.CgroupStats, err = fs.GetStats(container.Cgroups)
stats.CgroupStats, err = fs.GetStats(state.CgroupPaths)
}
if err != nil {

View File

@ -34,16 +34,6 @@ var destroyCommand = cli.Command{
Action: destroyAction,
}
var statsCommand = cli.Command{
Name: "stats",
Usage: "Get stats for cgroup",
Flags: []cli.Flag{
cli.StringFlag{Name: "name, n", Value: "", Usage: "container name"},
cli.StringFlag{Name: "parent, p", Value: "", Usage: "container parent"},
},
Action: statsAction,
}
var pauseCommand = cli.Command{
Name: "pause",
Usage: "Pause cgroup",
@ -196,23 +186,6 @@ func destroyAction(context *cli.Context) {
}
}
func statsAction(context *cli.Context) {
config, err := getConfig(context)
if err != nil {
log.Fatal(err)
}
stats, err := fs.GetStats(config)
if err != nil {
log.Fatal(err)
}
out, err := json.MarshalIndent(stats, "", "\t")
if err != nil {
log.Fatal(err)
}
fmt.Printf("Usage stats for '%s':\n %v\n", config.Name, string(out))
}
func pauseAction(context *cli.Context) {
setFreezerState(context, cgroups.Frozen)
}
@ -252,7 +225,6 @@ func main() {
app.Commands = []cli.Command{
createCommand,
destroyCommand,
statsCommand,
pauseCommand,
resumeCommand,
psCommand,

View File

@ -94,25 +94,13 @@ func Cleanup(c *cgroups.Cgroup) error {
return d.Cleanup()
}
func GetStats(c *cgroups.Cgroup) (*cgroups.Stats, error) {
func GetStats(systemPaths map[string]string) (*cgroups.Stats, error) {
stats := cgroups.NewStats()
d, err := getCgroupData(c, 0)
if err != nil {
return nil, fmt.Errorf("getting CgroupData %s", err)
}
for sysname, sys := range subsystems {
path, err := d.path(sysname)
if err != nil {
// Don't fail if a cgroup hierarchy was not found, just skip this subsystem
if cgroups.IsNotFound(err) {
continue
}
return nil, err
for name, path := range systemPaths {
sys, ok := subsystems[name]
if !ok {
continue
}
if err := sys.GetStats(path, stats); err != nil {
return nil, err
}