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