Refactor #14699

Katello needs foreman's os_selected method to submit all form data

Added by Partha Aji about 1 year ago. Updated about 1 month ago.

Status:Closed
Priority:Normal
Assigned To:Partha Aji
Category:Host creation
Target version:-
Difficulty: Bugzilla link:
Found in release: Pull request:https://github.com/theforeman/foreman/pull/4444
Story points-
Velocity based estimate-
Release1.15.1Release relationshipAuto

Description

Foreman's os_selected method. Last seen at -> https://github.com/theforeman/foreman/blob/develop/app/assets/javascripts/host_edit.js#L358
has code that looks like this
attrs = attribute_hash(['operatingsystem_id', 'organization_id', 'location_id']) limiting the number of attributes to the server for media selection to 4 parameters. This makes it very hard for Katello and Other foreman plugin apps to have control over that section of the medium even with facilities like Deface.
We need to make os_selected call actually send the full form as part of the hash, so that this can be used by the backend controllers.

We need os_selected to do something along the lines of

function os_selected(element){
  update_form(element);
  update_provisioning_image();
}

Related issues

Related to Katello - Bug #16063: Autoprovisioning fails with Katello plugin installed Closed 08/11/2016
Blocks Katello - Bug #19226: Katello needs to update os_selected method to submit all ... Closed 04/18/2016

Associated revisions

Revision 40eca4c4
Added by Partha Aji about 1 month ago

fixes #14699 - Enable host edit to accept new params

Prior to this commit:
Foreman plugins like Katello/Discovery extended the Host edit page
and added fields of their own.
For example
Katello adds things like Content Views, enviroments etc.

However they were unable to get their attibutes passed to the backend
because the os_selected and other "*_selected" methods do something
like
attrs = attribute_hash(['operatingsystem_id', 'organization_id',
'location_id']);
sending a hard coded list. This makes it impossible for plugins to send
more data when things like OS or Medium or image get selected.

This commit does the following:

Updates the Host edit js's os_select and other functions
to use a globally available map to figure out which attributes to
send to the server when one calls "medium_selected" "os_selected" etc.

This will help plugins like Katello and foreman-discovery extend the
global map and add their parameters.

For example all katello would have to do now is to say something like
window.tfm.hosts.registerPluginAttributes('os', ["content_view_id"])
and when os gets selected these attributes will be automatically
get sent to server.

History

#1 Updated by Eric Helms about 1 year ago

  • Release set to Katello Backlog

#2 Updated by Partha Aji 3 months ago

  • Project changed from Katello to Foreman

#3 Updated by The Foreman Bot 3 months ago

  • Status changed from New to Ready For Testing
  • Pull request https://github.com/theforeman/foreman/pull/4444 added

#4 Updated by Partha Aji 3 months ago

  • Copied to Bug #19226: Katello needs to update os_selected method to submit all form data added

#5 Updated by Partha Aji 3 months ago

  • Copied to deleted (Bug #19226: Katello needs to update os_selected method to submit all form data)

#6 Updated by Partha Aji 3 months ago

  • Blocks Bug #19226: Katello needs to update os_selected method to submit all form data added

#7 Updated by Lukas Zapletal 2 months ago

  • Related to Bug #16063: Autoprovisioning fails with Katello plugin installed added

#8 Updated by Dominic Cleal 2 months ago

  • Release deleted (Katello Backlog)

#9 Updated by Daniel Lobato Garcia about 1 month ago

  • Release set to 1.15.1

Setting release to 1.15.1 as it's 3.4.1 on the PR that requires this change in Katello

#10 Updated by Partha Aji about 1 month ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#11 Updated by Dominic Cleal about 1 month ago

  • Tracker changed from Bug to Refactor
  • Category set to Host creation

Release should probably be re-evaluated for a refactoring/new API.

Also available in: Atom PDF