Skip to content
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

UI for targeted Embedded Ansible refresh #1083

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions app/controllers/ansible_credential_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,6 @@ def edit
@id = auth.id
end

def credential_refresh
# Targeted refresh for embedded ansible hasn't been implemented yet
embedded_ansible_refresh
end

private

def textual_group_list
Expand Down
8 changes: 6 additions & 2 deletions app/controllers/ansible_repository_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,12 @@ def display_playbooks
end

def repository_refresh
# Targeted refresh for embedded ansible hasn't been implemented yet
embedded_ansible_refresh
assert_privileges("embedded_configuration_script_source_refresh")
checked = find_checked_items
checked[0] = params[:id] if checked.blank? && params[:id]
objects = AnsibleRepositoryController.model.find(checked)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mzazrivec while debugging https://bugzilla.redhat.com/show_bug.cgi?id=1442170 I added this line here

$log.info("durandom: #{checked}")

and it logged this for 1 checked item and 2 checked items

[root@dhcp-8-198-79 vmdb]# tail -f log/evm.log | grep durandom
[----] I, [2017-04-27T03:05:31.539498 #34572:1772dc8]  INFO -- : durandom: []
[----] I, [2017-04-27T03:06:04.361611 #34581:17729a4]  INFO -- : durandom: []

looks like find_checked_items does not work for the repo list view?

embedded_ansible_refresh(objects)
javascript_flash
end

private
Expand Down
12 changes: 5 additions & 7 deletions app/controllers/mixins/embedded_ansible_refresh_mixin.rb
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
module Mixins
module EmbeddedAnsibleRefreshMixin
def embedded_ansible_refresh
def embedded_ansible_refresh(objects = nil)
objects = [ManageIQ::Providers::EmbeddedAnsible::AutomationManager.first] if objects.nil?
begin
embedded_ansible = ManageIQ::Providers::EmbeddedAnsible::AutomationManager.first
ManageIQ::Providers::EmbeddedAnsible::AutomationManager.refresh_ems([embedded_ansible.id])
add_flash(_("Embedded Ansible Provider refresh has been successfully initiated"))
EmsRefresh.queue_refresh_task(objects)
add_flash(_("Embedded Ansible refresh has been successfully initiated"))
rescue => ex
add_flash(_("An error occurred while initiating Embedded Ansible Provider refresh: %{error}") % {:error => ex}, :error)
add_flash(_("An error occurred while initiating Embedded Ansible refresh: %{error}") % {:error => ex}, :error)
end
session[:flash_msgs] = @flash_array
javascript_redirect :action => 'show_list'
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,6 @@ class ApplicationHelper::Toolbar::AnsibleCredentialsCenter < ApplicationHelper::
t = N_('Configuration'),
t,
:items => [
button(
:embedded_automation_manager_credentials_refresh,
'fa fa-refresh fa-lg',
N_('Refresh Embedded Ansible Provider'),
N_('Refresh Embedded Ansible Provider'),
:klass => ApplicationHelper::Button::EmbeddedAnsible,
:url => "credential_refresh",
:url_parms => "main_div",
:confirm => N_("Refresh relationships for all items from Embedded Ansible Provider?")),
separator,
button(
:embedded_automation_manager_credentials_add,
'pficon pficon-edit fa-lg',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ class ApplicationHelper::Toolbar::AnsibleRepositoriesCenter < ApplicationHelper:
button(
:embedded_configuration_script_source_refresh,
'fa fa-refresh fa-lg',
N_('Refresh Embedded Ansible Provider'),
N_('Refresh Embedded Ansible Provider'),
N_('Refresh Selected Ansible Repositories'),
N_('Refresh Selected Ansible Repositories'),
:klass => ApplicationHelper::Button::EmbeddedAnsible,
:url => "repository_refresh",
:url_parms => "main_div",
:confirm => N_("Refresh relationships for all items from Embedded Ansible Provider?")),
:confirm => N_("Refresh selected Ansible Repositories?"),
:enabled => false,
:onwhen => "1+"),
separator,
button(
:embedded_configuration_script_source_add,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@ class ApplicationHelper::Toolbar::AnsibleRepositoryCenter < ApplicationHelper::T
t = N_('Configuration'),
t,
:items => [
button(
:embedded_configuration_script_source_refresh,
'fa fa-refresh fa-lg',
N_('Refresh this Repository'),
N_('Refresh this Repository'),
:klass => ApplicationHelper::Button::EmbeddedAnsible,
:url => "repository_refresh",
:confirm => N_("Refresh this Repository?"),
:enabled => true,
:onwhen => "1"),
separator,
button(
:embedded_configuration_script_source_edit,
'pficon pficon-edit fa-lg',
Expand Down
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2026,7 +2026,6 @@
),
:post => %w(
button
credential_refresh
show_list
)
},
Expand Down