forked from lxc/go-lxc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterfaces.go
41 lines (33 loc) · 826 Bytes
/
interfaces.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Copyright © 2013, 2014, The Go-LXC Authors. All rights reserved.
// Use of this source code is governed by a LGPLv2.1
// license that can be found in the LICENSE file.
// +build linux,cgo
package main
import (
"flag"
"log"
"gopkg.in/lxc/go-lxc.v2"
)
var (
lxcpath string
name string
)
func init() {
flag.StringVar(&lxcpath, "lxcpath", lxc.DefaultConfigPath(), "Use specified container path")
flag.StringVar(&name, "name", "rubik", "Name of the original container")
flag.Parse()
}
func main() {
c, err := lxc.NewContainer(name, lxcpath)
if err != nil {
log.Fatalf("ERROR: %s\n", err.Error())
}
log.Printf("Interfaces\n")
if interfaces, err := c.Interfaces(); err != nil {
log.Fatalf("ERROR: %s\n", err.Error())
} else {
for i, v := range interfaces {
log.Printf("%d) %s\n", i, v)
}
}
}