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 s created. Same as … #9653

Merged
merged 7 commits into from
Aug 31, 2020

Conversation

paginabianca
Copy link
Contributor

…in PR #9055

Allows the mounting of additional ISOs when the VM is created. The config option was taken from PR #9055 and slightly changed. Users can specify an array of bus names, bus numbers and filenames.

"cd_drive":[
{
"bus": "ide",
"bus_number": 3,
"filename": "isos:iso/virtio-win-0.1.187.iso"
},
{
"bus": "sata",
"bus_number": 3,
"filename": "isos:iso/someother.iso"
}
]

Closes: #7950

@paginabianca paginabianca requested a review from carlpett as a code owner July 27, 2020 09:36
@hashicorp-cla
Copy link

hashicorp-cla commented Jul 27, 2020

CLA assistant check
All committers have signed the CLA.

@paginabianca
Copy link
Contributor Author

Sorry that I created that many commits for PR. I was trying to get all tests to pass but somehow make generate does not generate the definitions for FlatstorageConfig as it does with FlatnicConfig, FlatdiskConfig and FlatvgaConfig.

I did add the definition of FlatstorageConfig manually but that is not allowed in autogenerated files.
I'm probably missing something here but don't really know what exactly. Can someone point me in the right direction?

I have tested the build after manually adding the definitions of FlatstorageConfig on my Proxmox host and it works.

@codecov
Copy link

codecov bot commented Jul 28, 2020

Codecov Report

Merging #9653 into master will decrease coverage by 0.05%.
The diff coverage is 0.00%.

Impacted Files Coverage Δ
builder/proxmox/builder.go 2.58% <0.00%> (-0.36%) ⬇️
builder/proxmox/config.go 56.52% <0.00%> (-18.48%) ⬇️
builder/proxmox/step_finalize_template_config.go 68.53% <0.00%> (-21.17%) ⬇️
builder/proxmox/step_start_vm.go 16.33% <0.00%> (-1.27%) ⬇️
builder/proxmox/step_upload_additional_isos.go 0.00% <0.00%> (ø)
builder/proxmox/step_upload_iso.go 100.00% <ø> (ø)
helper/multistep/basic_runner.go 88.57% <0.00%> (-5.72%) ⬇️
packer/communicator.go 75.53% <0.00%> (-1.07%) ⬇️
command/build.go 71.74% <0.00%> (-0.96%) ⬇️

@paginabianca paginabianca changed the title [WIP] Allows for the mounting of ISOs when a Proxmox VM s created. Same as … Allows for the mounting of ISOs when a Proxmox VM s created. Same as … Jul 28, 2020
@SwampDragons
Copy link
Contributor

I'm a big fan of squashing if you have a ton of little tweak commits.

…in PR 9055 but working

Fixed check-lint errors

Fixed bus_number check

Fixed check-genereate error

Revert "Fixed bus_number check"

This reverts commit ac8dc15.

fmt

Naming

Fixed hcl2 autogenerated code issue

fmt

less than is not greater than
@paginabianca paginabianca changed the title Allows for the mounting of ISOs when a Proxmox VM s created. Same as … [WIP]Allows for the mounting of ISOs when a Proxmox VM s created. Same as … Aug 3, 2020
Fixed Template Finalization Error

fmt

Documentation and fixes
Copy link
Collaborator

@carlpett carlpett left a comment

Choose a reason for hiding this comment

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

Thanks @paginabianca!
I've left a couple of comments below. Additionally, as was discussed in the previous PR, we probably need to tackle uploads of ISOs as well.

Comment on lines 115 to 117
} else {
changes[cdrom] = c.AdditionalISOFiles[idx].Filename + ",media=cdrom"
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This wouldn't be a change, right? It is what you set already in the StartVM step.

@@ -213,6 +213,29 @@ builder.
- `cloud_init_storage_pool` - (string) - Name of the Proxmox storage pool
to store the Cloud-Init CDROM on. If not given, the storage pool of the boot device will be used.

- `additional_iso_files` (array of objects) - Additional ISO filess attached to the virtual machine.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo

Suggested change
- `additional_iso_files` (array of objects) - Additional ISO filess attached to the virtual machine.
- `additional_iso_files` (array of objects) - Additional ISO files attached to the virtual machine.

}
]
```
- `device` (string) - Bus type that the ISO will be mountet on. Can be `ide`,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo

Suggested change
- `device` (string) - Bus type that the ISO will be mountet on. Can be `ide`,
- `device` (string) - Bus type that the ISO will be mounted on. Can be `ide`,

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also, wouldn't it semantically be a device_type or similar, since a device would include the number as well?

Comment on lines 195 to 205
if c.AdditionalISOFiles[idx].Device == "" {
log.Printf("AdditionalISOFile %d Device not set, using default 'ide'", idx)
c.AdditionalISOFiles[idx].Device = "ide"
}
if !contains([]string{"ide", "sata", "scsi"}, c.AdditionalISOFiles[idx].Device) {
errs = packer.MultiErrorAppend(errs, fmt.Errorf("%q is not a valid AdditionalISOFile Device", c.AdditionalISOFiles[idx].Device))
}
if c.AdditionalISOFiles[idx].BusNumber == 0 {
log.Printf("AdditionalISOFile %d number not set, using default: '3'", idx)
c.AdditionalISOFiles[idx].BusNumber = 3
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I leave multiple additional isos without a bus number, they will overwrite each other this way. I can see three options:

  1. Make bus_number mandatory (and in that case, maybe merge it with device_type so you'd specify the entire device like device="ide3")
  2. Keep track of what device numbers we've used and use the next unused one. This will probably get tricky.
  3. Error out if there's more than one element without a set number.

I'd lean towards option 1 because it will more obvious, although it does sacrifice a small amount of convenience when just adding a single additional iso.

{
"device": "scsi",
"bus_number": "3",
"filemane": "local:iso/virtio-win-0.1.185.iso",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo

Suggested change
"filemane": "local:iso/virtio-win-0.1.185.iso",
"filename": "local:iso/virtio-win-0.1.185.iso",


- `bus_number` (string) - Number of the device. Can be 0 to 3 for `ide`, 0 to 5
for `sata` and 0 to 30 for `scsi`.
Defaults to 3 sice `ide` bus 2 is generally the boot drive.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Typo

Suggested change
Defaults to 3 sice `ide` bus 2 is generally the boot drive.
Defaults to 3 since `ide` bus 2 is generally the boot drive.

@paginabianca
Copy link
Contributor Author

Thanks for the feedback and sorry for the typos. I'll fix those and the naming eather today or tomorrow.

I've looked into uploads of ISOs but I'm not sure where and how it would be best to implement that.
Do you have anything specific in mind? Otherwise I'll try to figure out a solution.

Fixed Template Finalization Error

fmt

Documentation and fixes

Finalize Fix

Description

fix

Typos

Finalize Fix

Prepared ISO upload feature

Preparations for ISO upload

More preparations

Even more preparations

Hopefully Final preparation

removed
@paginabianca paginabianca changed the title [WIP]Allows for the mounting of ISOs when a Proxmox VM s created. Same as … Allows for the mounting of ISOs when a Proxmox VM s created. Same as … Aug 13, 2020
Copy link
Collaborator

@carlpett carlpett left a comment

Choose a reason for hiding this comment

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

This notification apparently drowned in a bunch of other email, sorry for taking so long! Nice work on the upload part, looks good 🎉 Ideally we could merge the main/additional iso uploads, but this works.

Other than that, one final naming nit and I think a minor bug, otherwise 👍

for idx := range c.AdditionalISOFiles {
if !c.AdditionalISOFiles[idx].shouldUploadISO {
state.Put("additional_iso_files", c.AdditionalISOFiles)
return multistep.ActionContinue
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 continue, right? Otherwise we'll skip uploading any iso:s later in the list

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah you're right. Thanks for the heads up 👍

@@ -87,6 +90,15 @@ type vgaConfig struct {
Type string `mapstructure:"type"`
Memory int `mapstructure:"memory"`
}
type storageConfig struct {
common.ISOConfig `mapstructure:",squash"`
DeviceType string `mapstructure:"device_type"`
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think I had a couple of comments around this last time round, which addressed the naming here in different ways and we got a bit of a mix of all now 😄 I think it's great that we no longer have the number as a separate field, but now it should probably be called device rather than device_type.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense. Will change it shortly.

Copy link
Collaborator

@carlpett carlpett left a comment

Choose a reason for hiding this comment

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

Nice! Just one small typo, apart from that LGTM!

builder/proxmox/config.go Outdated Show resolved Hide resolved
fix typo

Co-authored-by: Calle Pettersson <carlpett@users.noreply.github.com>
Copy link
Contributor

@azr azr left a comment

Choose a reason for hiding this comment

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

Code LGTM, nice work @paginabianca. I applied your last suggestion @carlpett awesome reviewing 😄 , I'm also trusting your review as the owner of this builder on this and I think this can be merged. ( just waiting for the tests to be green )

🎉

@azr azr merged commit e4f975f into hashicorp:master Aug 31, 2020
@paginabianca
Copy link
Contributor Author

Awesome 😄 thanks @carlpett for providing all the feedback.

@rgevaert
Copy link

rgevaert commented Aug 31, 2020 via email

@carlpett
Copy link
Collaborator

🎉 Nice work!

@paginabianca paginabianca deleted the proxmox-add-devices branch August 31, 2020 14:30
@SwampDragons SwampDragons added this to the 1.6.3 milestone Sep 9, 2020
@ghost
Copy link

ghost commented Oct 13, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked as resolved and limited conversation to collaborators Oct 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Proxmox: Add multiple ISOs (CD/DVD Drives)
6 participants