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

Parameter verification failed when created Host in foreman Web UI #166

Closed gmalfray closed 3 years ago

gmalfray commented 3 years ago

Describe

When I want to create a new host from the foreman interface the provisioning failed with the message:

Actual (400 Bad Request) excon.error.response: body => "{\" errors \ ": {\" id \ ": \" property is not defined in schema and the schema does not allow additional properties \ ", \ "net0 \": \ "invalid format - missing key in comma-separated list property \\ n \"}, \ "data \": null} ": cookies => []: headers => {" Cache-Control " => "max-age = 0" "Connection" => "close" "Content-Length" => "190" "Content-Type" => "application / json; charset = UTF-8" "Date" => "Wed, 23 Sep 2020 09:38:04 GMT" "Expires" => "Wed, 23 Sep 2020 09:38:04 GMT" "Pragma" => "no-cache" "Server" => "pve-api -daemon / 3.0 "}: host =>" 172.xx.xx.xx ": local_address =>" 192.168.xx.xx ": local_port => 49694: path =>" / api2 / json / nodes / xxx-proxmox1 / qemu ": port => 8006: reason_phrase => "Parameter verification failed." : remote_ip => "172.xx.xx.xx": status => 400: status_line => "HTTP / 1.1 400 Parameter verification failed. \ r \ n"

In a foreman log :

2020-09-23T17:20:23 [I|app|add736ec] Started POST "/hosts" for 192.168.xx.xx at 2020-09-23 17:20:23 +0200
2020-09-23T17:20:23 [I|app|add736ec] Processing by HostsController#create as */*
2020-09-23T17:20:23 [I|app|add736ec]   Parameters: {"utf8"=>"✓", "authenticity_token"=>"NP6JaSlsBiK2/FJWaf1GO9QtS1seQjatsSOG8wUFMl6btGt2apjOpvjTRX6ZX9ZSY8RjTh1P3QilU3hpQXCPfQ==", "host"=>{"name"=>"petra-steinman", "organization_id"=>"2", "location_id"=>"1", "hostgroup_id"=>"", "compute_resource_id"=>"3", "compute_profile_id"=>"", "environment_id"=>"", "puppet_proxy_id"=>"", "puppet_ca_proxy_id"=>"", "managed"=>"true", "progress_report_id"=>"[FILTERED]", "type"=>"Host::Managed", "interfaces_attributes"=>{"0"=>{"_destroy"=>"0", "type"=>"Nic::Managed", "identifier"=>"net0", "name"=>"petra-steinman", "domain_id"=>"2", "subnet_id"=>"2", "ip"=>"xxx.xx.xxx.xx", "ip6"=>"", "managed"=>"1", "primary"=>"1", "provision"=>"1", "virtual"=>"0", "tag"=>"", "attached_to"=>""}}, "compute_attributes"=>{"type"=>"qemu", "vmid"=>"101", "node_id"=>"kosmos-it-proxmox1", "start_after_create"=>"0", "pool"=>"", "config_attributes"=>{"description"=>"", "boot"=>"", "onboot"=>"0", "agent"=>"0", "kvm"=>"1", "keyboard"=>"en-us", "vga"=>"std", "scsihw"=>"virtio-scsi-pci", "bios"=>"seabios", "cpu_type"=>"kvm64", "sockets"=>"1", "cores"=>"1", "vcpus"=>"", "cpulimit"=>"", "cpuunits"=>"", "numa"=>"0", "pcid"=>"0", "spectre"=>"0", "memory"=>"536870912", "balloon"=>"0", "shares"=>"0", "cdrom"=>"none", "cdrom_storage"=>"", "cdrom_iso"=>"", "ostype"=>"l26"}, "volumes_attributes"=>{"0"=>{"_delete"=>"", "storage"=>"localhdd", "controller"=>"scsi", "device"=>"0", "cache"=>"none", "size"=>"8589934592", "id"=>"scsi0"}}}, "architecture_id"=>"1", "operatingsystem_id"=>"12", "provision_method"=>"build", "build"=>"1", "medium_id"=>"10", "ptable_id"=>"201", "pxe_loader"=>"PXELinux BIOS", "disk"=>"", "root_pass"=>"[FILTERED]", "is_owned_by"=>"5-Users", "enabled"=>"1", "comment"=>"", "overwrite"=>"false"}, "fakepassword"=>"[FILTERED]"}
2020-09-23T17:20:24 [I|app|add736ec] Adding Compute instance for petra-steinman.fqdn.fr
2020-09-23T17:20:25 [I|app|ffe543e5] Started GET "/notification_recipients" for 192.168.xx.xx at 2020-09-23 17:20:25 +0200
2020-09-23T17:20:25 [I|app|ffe543e5] Processing by NotificationRecipientsController#index as JSON
2020-09-23T17:20:25 [I|app|ffe543e5] Completed 200 OK in 13ms (Views: 0.2ms | ActiveRecord: 1.4ms | Allocations: 2170)
2020-09-23T17:20:25 [W|app|add736ec] failed to create vm: Expected([200]) <=> Actual(400 Bad Request)
 | excon.error.response
 |   :body          => "{\"data\":null,\"errors\":{\"net0\":\"invalid format - missing key in comma-separated list property\\n\"}}"
 |   :cookies       => [
 |   ]
 |   :headers       => {
 |     "Cache-Control"  => "max-age=0"
 |     "Connection"     => "close"
 |     "Content-Length" => "97"
 |     "Content-Type"   => "application/json;charset=UTF-8"
 |     "Date"           => "Wed, 23 Sep 2020 15:20:29 GMT"
 |     "Expires"        => "Wed, 23 Sep 2020 15:20:29 GMT"
 |     "Pragma"         => "no-cache"
 |     "Server"         => "pve-api-daemon/3.0"
 |   }
 |   :host          => "172.16.106.2"
 |   :local_address => "192.168.xx.xx"
 |   :local_port    => 53480
 |   :path          => "/api2/json/nodes/proxmox1/qemu"
 |   :port          => 8006
 |   :reason_phrase => "Parameter verification failed."
 |   :remote_ip     => "xx.xx.xx.xx"
 |   :status        => 400
 |   :status_line   => "HTTP/1.1 400 Parameter verification failed.\r\n"
 | 

When editing the network interface, you cannot choose the card model in the proxmox section the fields do not appear

Used components Foreman 2.1.2 Foreman_fog_proxmox v0.12.4 Promox 6.2-10

Screenshots

image

gmalfray commented 3 years ago

It seems to be missing 'model' => 'virtio' in parameters

techy2493 commented 3 years ago

I am also seeing this with proxmox 6.2-4

techy2493 commented 3 years ago

Seems similar to #137 unfortunately I don't see a PR to try to replicate with the new value.

gmalfray commented 3 years ago

workaround: Use hammer CLI to provisionning Host --> https://github.com/theforeman/hammer-cli 1: create Compute Profile and configure it 2: create Host group 3: in Host group configure "Deploy on" and" Compute profile" 4: find manually next id in proxmox 5: use hammer CLI exemple: #> hammer -d host create --name "plop" --hostgroup-id 25 --compute-attributes "vmid=124" --location-id 1 --organization-id 2

tristanrobert commented 3 years ago

Indeed when you create a host without a host group selected the interface form does not enable proxmox compute specific fields. I am gonna see if I can enhance it and if it is not a foreman feature only. You just need to create a host group first associated with a proxmox profile (server vm or container vm), then when you create a host you just have to select the right proxmox host group.

tristanrobert commented 3 years ago

I know where is the bug: when you create host, select compute proxmox and go to VM tab you change type (lxc or server), proxmox specific nic form will then appears. The bug is in this file: https://github.com/theforeman/foreman_fog_proxmox/blob/80a82e6efd9ac7fbe00d0b9bd083a7e5968fa55d/app/assets/javascripts/foreman_fog_proxmox/proxmox_vm.js#L30. I am still investigating.