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

lxd: support for container profiles #136

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -792,6 +792,15 @@ backends:
image: ubuntu:16.04.1
```

Additionally, you can provide a comma-seperated list of LXD profiles to use:
```
backends:
lxd:
profiles: my-profile
Meulengracht marked this conversation as resolved.
Show resolved Hide resolved
systems:
- ubuntu-16.04
```

That's it. Have fun with your self-contained multi-system task runner.


Expand Down
9 changes: 8 additions & 1 deletion spread/lxd.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"gopkg.in/yaml.v2"
"io/ioutil"
"os"
"os/exec"
Expand All @@ -15,6 +14,8 @@ import (
"syscall"
"time"

"gopkg.in/yaml.v2"

"golang.org/x/net/context"
)

Expand Down Expand Up @@ -111,6 +112,12 @@ func (p *lxdProvider) Allocate(ctx context.Context, system *System) (Server, err
if !p.options.Reuse {
args = append(args, "--ephemeral")
}
if p.backend.Profiles != "" {
profiles := strings.Split(p.backend.Profiles, ",")
for _, profile := range profiles {
args = append(args, "--profile", profile)
}
}
output, err := exec.Command("lxc", args...).CombinedOutput()
if err != nil {
err = outputErr(output, err)
Expand Down
3 changes: 3 additions & 0 deletions spread/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ type Backend struct {
// Only for qemu so far.
Memory Size

// Only for LXD so far.
Profiles string

// Only for Linode and Google so far.
Plan string
Location string
Expand Down