-
Notifications
You must be signed in to change notification settings - Fork 991
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #37640 - Apply Loc/Org filter to Host Registration form #10240
Conversation
@jeremylenz Interested to review this? |
Would it be possible to add a tests for this? |
If you only allow a single value, would it make more sense to hide the fields completely? |
The way it is implemented now, you can still choose 'Not specified' as the second option. |
As far as I can see, there are no tests at all for the Host Registration page (yet). |
6e18d20
to
5ac8bba
Compare
Test added. |
But not specified results in the same, right? The selected org/loc is used |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @nadjaheitmann
Wasn't it possible to use this in Foreman with nested organizations? I know those aren't a thing in Katello but they are in vanilla Foreman. I also wonder about the case where the user has selected an organization but not a location. Can't you still end up in the situation where the combination is invalid? |
You mean that you would select a parent organization at the top and then see the child organizations in the selection? The way it was is that you did not have any restrictions to the selection at all.
Actually yes: If you have a smart-proxy which is under a given organization and you have a location selected at the top which does not match. Not sure what is the best way to prevent this. This is executed before the command is generated: I suppose that the upper level location is used for finding the proxy. And if we want to generate a registration command for a proxy that is not found, there is an error. |
I think it might be needed to update the list of available proxies when you change the organization and/or location. |
At the moment, the list is updated according to what you select in the registration form but not according to what is selected outside of the form. |
This is done. I'm currently debugging it. This method https://github.com/theforeman/foreman/blob/develop/app/controllers/registration_commands_controller.rb#L55 returns smart_proxies which can be used for the selected HostRegistartion Formular -> Organization / Location If you then press "Generate" this method is used to find the SmartProxy with a given ID but it validates if the SmartProxy is available at the Page Organization/Location: Update:
If I select organization 1 and location 2 in the HostRegistartion from, I get the following debug output:
So, the HostRegistration formular data changes the org/loc. To actually find the SmartProxy which will be used to generate the curl command, the page Org/Loc is used: |
Created https://projects.theforeman.org/issues/37682 for this issue. |
Thanks, I think that properly summarizes the issues. I left a comment that when working on that we should consider reverting the behavior introduced here. |
Select organization A. Then go to Register Host page and Select organization B in the Host Registration form and choose a smart-proxy that belongs to B. Choose activation key and click generate. That gives you an error because organizations are not matching. The curl command fails to render.
Fixed it by not allowing to choose other locations/organizations than the one selected for Foreman previously. If no location/organization is selected in Foreman, any organization can be selected in the Host Registration form.