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 add profiles to list of system options #188

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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: 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,11 @@ func (p *lxdProvider) Allocate(ctx context.Context, system *System) (Server, err
if !p.options.Reuse {
args = append(args, "--ephemeral")
}
if system != nil {
for _, profile := range system.Profiles {
args = append(args, "-p", profile)
}
}
output, err := exec.Command("lxc", args...).CombinedOutput()
if err != nil {
err = outputErr(output, err)
Expand Down Expand Up @@ -482,6 +488,7 @@ func (p *lxdProvider) serverJSON(name string) (*lxdServerJSON, error) {
func (p *lxdProvider) tuneSSH(name string) error {
cmds := [][]string{
{"sed", "-i", `s/^\s*#\?\s*\(PermitRootLogin\|PasswordAuthentication\)\>.*/\1 yes/`, "/etc/ssh/sshd_config"},
{"bash", "-c", `sed -i "s/^\s*#\?\s*\(PermitRootLogin\|PasswordAuthentication\)\>.*/\1 yes/" /etc/ssh/sshd_config.d/* || :`},
{"/bin/bash", "-c", fmt.Sprintf("echo root:'%s' | chpasswd", p.options.Password)},
{"killall", "-HUP", "sshd"},
}
Expand Down
3 changes: 3 additions & 0 deletions spread/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,9 @@ type System struct {
// Only for Google so far.
SecureBoot bool `yaml:"secure-boot"`

// List of profiles, only for LXD
Profiles []string

// Supported are {"uefi",""}, only for qemu so far.
Bios string
// Request a specific CPU family, e.g. "Intel Skylake" The
Expand Down
2 changes: 1 addition & 1 deletion tests/lxd/spread.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ project: spread
backends:
lxd:
systems:
- ubuntu-16.04
- ubuntu-24.04

path: /home/test

Expand Down
Loading