Skip to content

Commit

Permalink
Update resource_action immediately after job template is deleted
Browse files Browse the repository at this point in the history
  • Loading branch information
bzwei committed May 5, 2017
1 parent c5f755e commit 2dc391f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions app/models/service_template_ansible_playbook.rb
Expand Up @@ -132,7 +132,7 @@ def self.validate_config_info(info)


def job_template(action)
resource_actions.find_by(:action => action.to_s.capitalize).try(:configuration_template)
resource_actions.find_by(:action => action.capitalize).try(:configuration_template)
end

def update_catalog_item(options, auth_user = nil)
Expand Down Expand Up @@ -189,11 +189,12 @@ def create_dialogs(config_info)
end
end

def delete_job_templates(job_templates)
def delete_job_templates(job_templates, action = nil)
auth_user = User.current_userid || 'system'
job_templates.each do |job_template|
ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScript
.delete_in_provider_queue(job_template.manager.id, { :manager_ref => job_template.manager_ref }, auth_user)
resource_actions.find_by(:action => action.capitalize).update_attributes(:configuration_template => nil) if action
end
end

Expand All @@ -219,7 +220,7 @@ def update_job_templates(name, description, config_info, auth_user)
params[:manager_ref] = job_template(action).manager_ref
ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScript.update_in_provider_queue(tower.id, params, auth_user)
else
delete_job_templates([job_template])
delete_job_templates([job_template], action)
end
end
end
Expand Down

0 comments on commit 2dc391f

Please sign in to comment.