Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing AppendConfigItem #8

Open
dcramer opened this issue Sep 26, 2014 · 3 comments
Open

Missing AppendConfigItem #8

dcramer opened this issue Sep 26, 2014 · 3 comments
Labels
Easy Good for new contributors Feature New feature, not a bug

Comments

@dcramer
Copy link
Contributor

dcramer commented Sep 26, 2014

Per the Python API, there should be an "append_config_item". Without it I can't see a reliable way to set things like lxc.cgroup.devices.allow which accept multiple values.

@caglar10ur
Copy link
Member

Makes sense to me. Let me see what I can do.

P.S: Please don't hesitate to report any other problems/inconsistencies/difficulties that you are having with go-lxc. I would like to hear them even if I cannot address them right away.

@caglar10ur
Copy link
Member

By the way forgot to mention, you can achieve the same by just calling SetConfigItem multiple times.

package main

import (
    "flag"
    "log"

    "github.com/lxc/go-lxc"
)

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 container")
    flag.Parse()
}

func main() {
    c, err := lxc.NewContainer(name, lxcpath)
    if err != nil {
        log.Fatalf("ERROR: %s\n", err.Error())
    }
    defer lxc.PutContainer(c)

    log.Printf("%s", c.ConfigItem("lxc.cgroup.devices.allow"))
    if err := c.SetConfigItem("lxc.cgroup.devices.allow", "b 7:* rwm"); err != nil {
        log.Fatalf("ERROR: %s\n", err.Error())
    }
    log.Printf("%s", c.ConfigItem("lxc.cgroup.devices.allow"))
}
[caglar@qop:~/go/src/github.com/lxc/go-lxc/examples] sudo ./8
2014/09/28 16:01:10 [c *:* m b *:* m c 1:3 rwm c 1:5 rwm c 5:0 rwm c 5:1 rwm c 1:8 rwm c 1:9 rwm c 5:2 rwm c 136:* rwm c 254:0 rm c 10:229 rwm c 10:200 rwm c 1:7 rwm c 10:228 rwm c 10:232 rwm]
2014/09/28 16:01:10 [c *:* m b *:* m c 1:3 rwm c 1:5 rwm c 5:0 rwm c 5:1 rwm c 1:8 rwm c 1:9 rwm c 5:2 rwm c 136:* rwm c 254:0 rm c 10:229 rwm c 10:200 rwm c 1:7 rwm c 10:228 rwm c 10:232 rwm b 7:* rwm]
[caglar@qop:~/go/src/github.com/lxc/go-lxc/examples]

@caglar10ur caglar10ur self-assigned this Sep 29, 2014
@dcramer
Copy link
Contributor Author

dcramer commented Sep 29, 2014

@caglar10ur ah didn't realize that. Will do that for now, thanks!

@stgraber stgraber added Easy Good for new contributors Feature New feature, not a bug and removed enhancement labels Apr 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Easy Good for new contributors Feature New feature, not a bug
Development

No branches or pull requests

3 participants