Bug #30839
closedCreation of compute_profile with compute_attributes set failed
Description
Problem:¶
We try to create compute_profiles with the given ansible module. If we simply provide name parameter all work well. But if we add data to compute_attributes parameter we get the following output from ansible:
fatal: [localhost]: FAILED! => {"changed": false, "error": {"message": "odd number of arguments for Hash"}, "msg": "Error while performing create on compute_attributes: 500 Server Error: Internal Server Error for url: https://foreman.prod.spock.bmwgroup.net/api/compute_profiles/17/compute_resources/7/compute_attributes"}
The corresponding message in server logs are:
2020-09-14T12:35:54 [I|app|db44c3e7] Started POST "/api/compute_profiles/17/compute_resources/7/compute_attributes" for 44.128.0.6 at 2020-09-14 12:35:54 +0000
2020-09-14T12:35:54 [I|app|db44c3e7] Processing by Api::V2::ComputeAttributesController#create as JSON
2020-09-14T12:35:54 [I|app|db44c3e7] Parameters: {"compute_attribute"=>{"vm_attrs"=>{"cores"=>1, "sockets"=>1, "memory_mb"=>"2048", "firmware"=>"automatic", "cluster"=>"ASH", "resource_pool"=>"Resources", "path"=>"/Datacenters/ASH_i4/vm/ASH_VM", "guest_id"=>"otherGuest64", "hardware_version"=>"Default", "memoryHotAddEnabled"=>"0", "cpuHotAddEnabled"=>"0", "add_cdrom"=>"0", "boot_order"=>["network", "disk"], "annotation"=>"", "scsi_controllers"=>[{"type"=>"VirtualLsiLogicController", "key"=>1000}], "interfaces_attributes"=>[{"type"=>"VirtualE1000", "network"=>"dvportgroup-106"}], "volumes_attributes"=>[{"name"=>"Hard disk", "thin"=>true, "mode"=>"persistent", "controller_key"=>1000, "size_gb"=>10, "datastore"=>"DS_ASH01"}]}}, "apiv"=>"v2", "compute_profile_id"=>"17", "compute_resource_id"=>"7"}
2020-09-14T12:35:54 [W|app|db44c3e7] Action failed
Expected outcome:¶
The resource should be created or the error message should lead us to a configuration failure.
Foreman and Proxy versions:¶
Foreman server version: 2.1.2
Foreman ansible modules version: 1.2.0
Other relevant data:¶
Currently we test with vmware compute resource.
Updated by Christian Meißner over 4 years ago
- Priority changed from High to Low
We found out that the problem was located in `interfaces_attributes` and `volumes_attributes` dicts. These are really dicts in form of:
interfaces_attributes:
'0':
type: VirtualE1000
network: dvportgroup-107
'1':
type: VirtualE1000
network: dvportgroup-106
It's a bit ugly and strange. Maybe it's a good idea to:
1. Document the correct format and possible parameters of `vm_attrs` dict
2. Make the nested parameters a bit more convenient and provide the both data structures as lists instead of dicts.
Maybe this issue should be converted to `feature` or `refactor`.
Updated by Ondřej Ezr over 4 years ago
Updated by Timo Goebel over 4 years ago
I believe this is actually an issue in our API. We should probably add some kind of processing in the controller so it also accepts an array. WDYT?
Updated by The Foreman Bot over 4 years ago
- Status changed from New to Ready For Testing
- Assignee set to Ondřej Ezr
- Pull request https://github.com/theforeman/foreman/pull/8006 added
Updated by Ondřej Ezr about 4 years ago
- Status changed from Ready For Testing to Closed
Applied in changeset foreman|d00fc37a68839f8bf823969880339c9343eacd4c.