Debian Codegraph @

examples/list/list.go

raw symbols SCIP
1 // Copyright © 2013, 2014, The Go-LXC Authors. All rights reserved.
2 // Use of this source code is governed by a LGPLv2.1
3 // license that can be found in the LICENSE file.
4
5 //go:build linux && cgo
6 // +build linux,cgo
7
8 package main
9
10 import (
11 "flag"
12 "log"
13
14 "github.com/lxc/go-lxc"
15 )
16
17 var (
18 lxcpath string
19 )
20
21 func init() {
22 flag.StringVar(&lxcpath, "lxcpath", lxc.DefaultConfigPath(), "Use specified container path")
23 flag.Parse()
24 }
25
26 func main() {
27 log.Printf("Defined containers:\n")
28 c := lxc.DefinedContainers(lxcpath)
29 for i := range c {
30 log.Printf("%s (%s)\n", c[i].Name(), c[i].State())
31 c[i].Release()
32 }
33
34 log.Println()
35
36 log.Printf("Active containers:\n")
37 c = lxc.ActiveContainers(lxcpath)
38 for i := range c {
39 log.Printf("%s (%s)\n", c[i].Name(), c[i].State())
40 c[i].Release()
41 }
42
43 log.Println()
44
45 log.Printf("Active and Defined containers:\n")
46 c = lxc.ActiveContainers(lxcpath)
47 for i := range c {
48 log.Printf("%s (%s)\n", c[i].Name(), c[i].State())
49 c[i].Release()
50 }
51 }