Bug #30839

Creation of compute_profile with compute_attributes set failed

Added by Christian Meißner about 2 years ago. Updated about 2 years ago.

Target version:
Bugzilla link:
Fixed in Releases:
Found in Releases:
Red Hat JIRA:



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:"}

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 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.

Associated revisions

Revision d00fc37a (diff)
Added by Ondřej Ezr about 2 years ago

Fixes #30839 - accept Arrays of nested compute attributes

API should be able to handle interfaces_attributes: [{attrs1},{attrs2}],
Until now it only handled hashes with numbered keys.


#1 Updated by Christian Meißner about 2 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:

    type: VirtualE1000
    network: dvportgroup-107
    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`.

#3 Updated by Timo Goebel about 2 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?

#4 Updated by The Foreman Bot about 2 years ago

  • Assignee set to Ondřej Ezr
  • Status changed from New to Ready For Testing
  • Pull request added

#5 Updated by The Foreman Bot about 2 years ago

  • Fixed in Releases 2.3.0 added

#6 Updated by Ondřej Ezr about 2 years ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF