theforeman / foreman_fog_proxmox

Foreman plugin to add Proxmox compute resource based on fog-proxmox gem
GNU General Public License v3.0
106 stars 31 forks source link

ERF42-8295 [Foreman::Exception]: invalid vmid=0 with foreman ansible modules #160

Closed FlatKey closed 4 years ago

FlatKey commented 4 years ago

Description If I try to create a VM within the foreman ansible modules (theforeman.foreman.host) I got the exception ERF42-8295 [Foreman::Exception]: invalid vmid=0.

Used components Foreman 2.1 Foreman_fog_proxmox 0.11.1 Foreman_ansible_modules 1.0.1 Ansible 2.9

Expected behavior It would be nice if the foreman_fog_proxmox plugin determines and uses the next free valid vmid. As an alternative, the vmid can also be specified as a host parameter and these can be read by the plugin.

tristanrobert commented 4 years ago

Next_vmid is computed when you use the foreman forms and create a new VM: https://github.com/theforeman/foreman_fog_proxmox/blob/c112ba30e275feb8b0694869c9c2f5fdb4507216/app/models/foreman_fog_proxmox/proxmox_vm_new.rb#L110 But if you create the VM without these forms, like ansible playbooks, it will not be executed. So you need an enhancement which is suitable with both forms and ansible playbooks.

FlatKey commented 4 years ago

Exactly, that's why I created theforeman/foreman_fog_proxmox#161 , in which next_vmid is also used if the vmid is 0. Does it fit?

tristanrobert commented 4 years ago

It needs tests. 0 is an invalid vmid so this test should be changed: https://github.com/theforeman/foreman_fog_proxmox/blob/c112ba30e275feb8b0694869c9c2f5fdb4507216/test/unit/foreman_fog_proxmox/proxmox_vm_commands_server_create_test.rb#L34 because it tests only vmid = 100 that fails and not vmid = 0 that is invalid too. Another tests should be written. Why vmid==0? I am working on it and thinking about it.

tristanrobert commented 4 years ago

I have added tests and a specific case vmid == 0.

FlatKey commented 4 years ago

Thank you for your support with the added feature and test, but it's a littlebit sad that my pull request was not used or time for improvement was given.