Debian Codegraph @

examples/config/config.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 name string
20 hostname string
21 )
22
23 func init() {
24 flag.StringVar(&lxcpath, "lxcpath", lxc.DefaultConfigPath(), "Use specified container path")
25 flag.StringVar(&name, "name", "rubik", "Name of the container")
26 flag.StringVar(&hostname, "hostname", "rubik-host1", "Hostname of the container")
27 flag.Parse()
28 }
29
30 func main() {
31 c, err := lxc.NewContainer(name, lxcpath)
32 if err != nil {
33 log.Fatalf("ERROR: %s\n", err.Error())
34 }
35 defer c.Release()
36
37 //setting hostname
38 err = c.SetConfigItem("lxc.utsname", hostname)
39 if err != nil {
40 log.Fatalf("ERROR: %s\n", err.Error())
41 }
42
43 // fetching rootfs location
44 rootfs := c.ConfigItem("lxc.rootfs")[0]
45 log.Printf("Root FS: %s\n", rootfs)
46
47 }