Project

General

Profile

Actions

Refactor #4541

open

Non-ActiveRecord nested attributes forms

Added by Daniel Lobato Garcia about 10 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
-
Target version:
-
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

At the moment, Foreman simulates Openstack blocks as if they were in ActiveRecord, just to get the form to send several blocks in a "block_device_mapping" hash to the Openstack hypervisor.
However, this generates a Hash that needs to be post-processed Foreman::Model::Openstack.
The hash looks like this:

{"name"=>"foreman_1393931003", "flavor_ref"=>"1", "image_ref"=>"", "tenant_id"=>"b799ab2737774be1a0aa6dde330450de", "security_group"=>"", "network"=>"", 

"block_device_mapping_attributes"=>
  {
   "new_block_device_mapping"=>{"device_name"=>"", "_destroy"=>"", "delete_on_termination"=>"0", "volume_id"=>"b58e229c-01a6-45f8-ae44-898e524f73a5", "id"=>"0"}, 
   "0"=>{"device_name"=>"adasdasd", "_destroy"=>"", "delete_on_termination"=>"0", "volume_id"=>"b58e229c-01a6-45f8-ae44-898e524f73a5", "id"=>"0"}, 
   "new_1393931015304"=>{"device_name"=>"asdasdasd", "_destroy"=>"", "delete_on_termination"=>"1", "volume_id"=>"2b553f3a-08d2-49ca-a9fa-2c5098cbcbfc", "id"=>"0"}, 
   "new_1393931020344"=>{"device_name"=>"sdas", "_destroy"=>"", "delete_on_termination"=>"1", "volume_id"=>"b58e229c-01a6-45f8-ae44-898e524f73a5", "id"=>"0"}
  }
}

and it should look like:

{"name"=>"foreman_1393931003", "flavor_ref"=>"1", "image_ref"=>"", "tenant_id"=>"b799ab2737774be1a0aa6dde330450de", "security_group"=>"", "network"=>"", 

"block_device_mapping"=>
  [
   {"device_name"=>"", "_destroy"=>"", "delete_on_termination"=>"0", "volume_id"=>"b58e229c-01a6-45f8-ae44-898e524f73a5", "id"=>"0"}, 
   {"device_name"=>"adasdasd", "_destroy"=>"", "delete_on_termination"=>"0", "volume_id"=>"b58e229c-01a6-45f8-ae44-898e524f73a5", "id"=>"0"}, 
   {"device_name"=>"asdasdasd", "_destroy"=>"", "delete_on_termination"=>"1", "volume_id"=>"2b553f3a-08d2-49ca-a9fa-2c5098cbcbfc", "id"=>"0"}, 
   {"device_name"=>"sdas", "_destroy"=>"", "delete_on_termination"=>"1", "volume_id"=>"b58e229c-01a6-45f8-ae44-898e524f73a5", "id"=>"0"}
  ]
}

As of now, these kind of non-activerecord relations nested attributes requires post-processing of the Hash in Ovirt, Libvirt (Nics and volumes), and Openstack.
It would be highly desirable to get the forms to submit the correct hash to avoid post-processing in all of these compute resources.

No data to display

Actions

Also available in: Atom PDF