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

Allows for the mounting of ISOs when a Proxmox VM is created. Useful … #9055

Closed
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
6 changes: 6 additions & 0 deletions builder/proxmox/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ type Config struct {

shouldUploadISO bool

CDDrive []storageConfig `mapstructure:"cd_drive"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we rename this something like additional_iso_files?


ctx interpolate.Context
}

Expand All @@ -81,6 +83,10 @@ type vgaConfig struct {
Type string `mapstructure:"type"`
Memory int `mapstructure:"memory"`
}
type storageConfig struct {
BUS string `mapstructure:"bus"`
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a device, not a bus

Filename string `mapstructure:"filename"`
}

func (c *Config) Prepare(raws ...interface{}) ([]string, error) {
// Agent defaults to true
Expand Down
174 changes: 88 additions & 86 deletions builder/proxmox/config.hcl2spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion builder/proxmox/step_start_vm.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func (s *stepStartVM) Run(ctx context.Context, state multistep.StateBag) multist
}

isoFile := state.Get("iso_file").(string)

ui.Say("Creating VM")
config := proxmox.ConfigQemu{
Name: c.VMName,
Expand Down Expand Up @@ -84,6 +83,12 @@ func (s *stepStartVM) Run(ctx context.Context, state multistep.StateBag) multist
// instance id inside of the provisioners, used in step_provision.
state.Put("instance_id", vmRef)

for idx := range c.CDDrive{
params := map[string]interface{}{
c.CDDrive[idx].BUS : c.CDDrive[idx].Filename+",media=cdrom",
}
client.SetVmConfig(vmRef,params)
}
ui.Say("Starting VM")
_, err = client.StartVm(vmRef)
if err != nil {
Expand Down