Skip to content

Instantly share code, notes, and snippets.

@fsouza
Created March 4, 2012 00:52
Show Gist options
  • Save fsouza/1969549 to your computer and use it in GitHub Desktop.
Save fsouza/1969549 to your computer and use it in GitHub Desktop.
package lxc
import (
"bytes"
"os/exec"
)
func LxcCreate(containerName, config string) error {
if err := exec.Command("sudo", "lxc-start", "--daemon", "-n", containerName).Start(); err != nil {
return err
}
return nil
}
func LxcDestroy(containerName string) {
exec.Command("sudo", "lxc-destroy", "-n", containerName).Start()
}
func LxcLs() string {
var out bytes.Buffer
cmd := exec.Command("sudo", "lxc-ls")
cmd.Stdout = &out
cmd.Run()
return out.String()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment