Add Puppet environment bulk actions - #443
Conversation
7b47350 to
b3a99a0
Compare
3c788d1 to
6e4a70a
Compare
Co-Authored-By: OpenAI Codex <codex@openai.com>
6e4a70a to
a6a902f
Compare
|
|
||
| const handleError = response => { | ||
| handleModalClose(); | ||
| dispatch( |
There was a problem hiding this comment.
is it possible to re-use https://github.com/theforeman/foreman/pull/11045/changes ?
| ForemanPuppet::Engine.routes.draw do | ||
| namespace :api, defaults: { format: 'json' } do | ||
| scope '(:apiv)', module: :v2, defaults: { apiv: 'v2' }, apiv: /v1|v2/, constraints: ApiConstraints.new(version: 2, default: true) do | ||
| match 'hosts/bulk/change_environment', to: 'hosts_bulk_actions#change_environment', via: [:put] |
There was a problem hiding this comment.
wouldn't it be better to move this route to the bulk action area in line 5?
There was a problem hiding this comment.
I agree, at the moment the path of the endpoint is evaluated to /api/foreman_puppet/api/v2/hosts/bulk/change_environment, while the change_puppet_proxy host bulk-action's path is /api/hosts/bulk/change_puppet_proxy.
The latter seems more correct to me.
| def get_environment_for(host, id) | ||
| if id == 'inherit' && host.hostgroup.present? | ||
| host.hostgroup.environment | ||
| host.hostgroup.puppet&.environment |
There was a problem hiding this comment.
I guess, this is a issues which is solved within this PR?
| p.actions << 'foreman_puppet/api/v2/hosts_bulk_actions/change_environment' | ||
| p.actions << 'foreman_puppet/api/v2/hosts_bulk_actions/change_puppet_proxy' | ||
| p.actions << 'foreman_puppet/api/v2/hosts_bulk_actions/remove_puppet_proxy' |
There was a problem hiding this comment.
These might need changing based on the result in the above comment.
|
|
||
| def put_change_environment(params:, session: nil) | ||
| original_routes = @routes | ||
| @routes = ForemanPuppet::Engine.routes |
There was a problem hiding this comment.
This would also be obsolete, when api_routes is changed.
| inherited_environment = FactoryBot.create(:environment, organizations: [organization], locations: [location]) | ||
| hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, | ||
| environment: inherited_environment, | ||
| organizations: [organization], | ||
| locations: [location]) | ||
| inherited_hosts = FactoryBot.create_list(:host, 2, :with_puppet_enc, | ||
| environment: inherited_environment, | ||
| hostgroup: hostgroup, | ||
| organization: organization, | ||
| location: location) |
There was a problem hiding this comment.
The test setup should not already fulfill the test-assertion.
| inherited_environment = FactoryBot.create(:environment, organizations: [organization], locations: [location]) | |
| hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, | |
| environment: inherited_environment, | |
| organizations: [organization], | |
| locations: [location]) | |
| inherited_hosts = FactoryBot.create_list(:host, 2, :with_puppet_enc, | |
| environment: inherited_environment, | |
| hostgroup: hostgroup, | |
| organization: organization, | |
| location: location) | |
| inherited_environment = FactoryBot.create(:environment, organizations: [organization], locations: [location]) | |
| host_environment = FactoryBot.create(:environment, organizations: [organization], locations: [location]) | |
| hostgroup = FactoryBot.create(:hostgroup, :with_puppet_enc, | |
| environment: inherited_environment, | |
| organizations: [organization], | |
| locations: [location]) | |
| inherited_hosts = FactoryBot.create_list(:host, 2, :with_puppet_enc, | |
| environment: host_environment, | |
| hostgroup: hostgroup, | |
| organization: organization, | |
| location: location) | |
| assert_not_equal host_environment, inherited_environment |
Generated-by: OpenAI Codex codex@openai.com