mirror of
https://github.com/rancher/os.git
synced 2025-05-10 17:16:21 +00:00
Added cloudinitsave case for proxmox
This commit is contained in:
parent
8ad6b10446
commit
67599f352c
cmd/cloudinitsave
config/cloudinit/datasource/proxmox
pkg/init/cloudinit
@ -40,6 +40,7 @@ import (
|
||||
"github.com/rancher/os/config/cloudinit/datasource/metadata/gce"
|
||||
"github.com/rancher/os/config/cloudinit/datasource/metadata/packet"
|
||||
"github.com/rancher/os/config/cloudinit/datasource/proccmdline"
|
||||
"github.com/rancher/os/config/cloudinit/datasource/proxmox"
|
||||
"github.com/rancher/os/config/cloudinit/datasource/tftp"
|
||||
"github.com/rancher/os/config/cloudinit/datasource/url"
|
||||
"github.com/rancher/os/config/cloudinit/datasource/vmware"
|
||||
@ -229,7 +230,12 @@ func getDatasources(datasources []string) []datasource.Datasource {
|
||||
|
||||
switch parts[0] {
|
||||
case "*":
|
||||
dss = append(dss, getDatasources([]string{"configdrive", "vmware", "ec2", "digitalocean", "packet", "gce", "cloudstack", "exoscale"})...)
|
||||
dss = append(dss, getDatasources([]string{"configdrive", "vmware", "ec2", "digitalocean", "packet", "gce", "cloudstack", "exoscale", "proxmox"})...)
|
||||
case "proxmox":
|
||||
if root == "" {
|
||||
root = "/media/pve-config"
|
||||
}
|
||||
dss = append(dss, proxmox.NewDataSource(root))
|
||||
case "exoscale":
|
||||
dss = append(dss, exoscale.NewDatasource(root))
|
||||
case "cloudstack":
|
||||
|
@ -15,7 +15,7 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
configDev = "/dev/sr0"
|
||||
configDev = "/dev/sr0"
|
||||
configDevMountPoint = "/media/pve-config"
|
||||
)
|
||||
|
||||
@ -105,6 +105,7 @@ func MountConfigDrive() error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return mount.Mount(configDev, configDevMountPoint, fsType, "ro")
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,10 @@
|
||||
package proxmox
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/rancher/os/config/cloudinit/datasource/test"
|
||||
)
|
||||
|
||||
func TestFetchUserdata(t *testing.T) {
|
||||
for _, tt := range []struct {
|
||||
@ -14,15 +18,15 @@ func TestFetchUserdata(t *testing.T) {
|
||||
userdata: "",
|
||||
},
|
||||
{
|
||||
root: "/media/pve-config",
|
||||
files: test.NewMockFilesystem(test.File{Path: "/media/pve-config/user-data", Contents: "userdata"}),
|
||||
root: "/media/config",
|
||||
files: test.NewMockFilesystem(test.File{Path: "/media/config/user-data", Contents: "userdata"}),
|
||||
userdata: "userdata",
|
||||
},
|
||||
} {
|
||||
pve := Proxmox{tt.root, tt.files.ReadFile, nil, true}
|
||||
userdata, err := pve.FetchUserdata()
|
||||
if err != nil {
|
||||
t.Fatalf("bad error for %+v: want %v, get %q", tt, nil, err)
|
||||
t.Fatalf("bad error for %+v: want %v, got %q", tt, nil, err)
|
||||
}
|
||||
if string(userdata) != tt.userdata {
|
||||
t.Fatalf("bad userdata for %+v: want %q, got %q", tt, tt.userdata, userdata)
|
||||
|
@ -41,7 +41,7 @@ func CloudInit(cfg *config.CloudConfig) (*config.CloudConfig, error) {
|
||||
log.Error(err)
|
||||
}
|
||||
if proxmox {
|
||||
cfg.Rancher.CloudInit.Datasources = append([]string{"proxmox"}, cfg.Rancher.CloutInit.Datasources...)
|
||||
cfg.Rancher.CloudInit.Datasources = append([]string{"proxmox"}, cfg.Rancher.CloudInit.Datasources...)
|
||||
}
|
||||
|
||||
if len(cfg.Rancher.CloudInit.Datasources) == 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user