diff --git a/cmd/cloudinitsave/cloudinitsave.go b/cmd/cloudinitsave/cloudinitsave.go index 4e3e56c7..cb653ef9 100644 --- a/cmd/cloudinitsave/cloudinitsave.go +++ b/cmd/cloudinitsave/cloudinitsave.go @@ -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": diff --git a/config/cloudinit/datasource/proxmox/proxmox.go b/config/cloudinit/datasource/proxmox/proxmox.go index 34da7b80..c6afa664 100644 --- a/config/cloudinit/datasource/proxmox/proxmox.go +++ b/config/cloudinit/datasource/proxmox/proxmox.go @@ -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") } diff --git a/config/cloudinit/datasource/proxmox/proxmox_test.go b/config/cloudinit/datasource/proxmox/proxmox_test.go index 86486fca..d6022967 100644 --- a/config/cloudinit/datasource/proxmox/proxmox_test.go +++ b/config/cloudinit/datasource/proxmox/proxmox_test.go @@ -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) diff --git a/pkg/init/cloudinit/cloudinit.go b/pkg/init/cloudinit/cloudinit.go index 2ecf1aa2..97284050 100644 --- a/pkg/init/cloudinit/cloudinit.go +++ b/pkg/init/cloudinit/cloudinit.go @@ -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 {