Skip to content

Commit

Permalink
Make ServiceTemplateAnsiblePlaybook create_dialogs public
Browse files Browse the repository at this point in the history
This method is used in `.create_catalog_item` and should be public
rather than relying on `.send()`
  • Loading branch information
agrare committed Oct 1, 2024
1 parent 1bd9520 commit a580a91
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions app/models/service_template_ansible_playbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def self.create_catalog_item(options, _auth_user)

transaction do
create_from_options(options).tap do |service_template|
dialog_ids = service_template.send(:create_dialogs, config_info)
dialog_ids = service_template.create_dialogs(config_info)
config_info.deep_merge!(dialog_ids)
service_template.options[:config_info].deep_merge!(dialog_ids)
service_template.create_resource_actions(config_info)
Expand Down Expand Up @@ -105,6 +105,15 @@ def retirement_potential?
retirement_jt_exists && services.where(:retired => false).exists?
end

def create_dialogs(config_info)
[:provision, :retirement, :reconfigure].each_with_object({}) do |action, hash|
info = config_info[action]
next unless new_dialog_required?(info)

hash[action] = {:dialog_id => create_new_dialog(info[:new_dialog_name], info[:extra_vars], info[:hosts]).id}
end
end

private

def check_retirement_potential
Expand All @@ -115,15 +124,6 @@ def check_retirement_potential
throw :abort
end

def create_dialogs(config_info)
[:provision, :retirement, :reconfigure].each_with_object({}) do |action, hash|
info = config_info[action]
next unless new_dialog_required?(info)

hash[action] = {:dialog_id => create_new_dialog(info[:new_dialog_name], info[:extra_vars], info[:hosts]).id}
end
end

def new_dialog_required?(info)
info && info.key?(:new_dialog_name) && !info.key?(:dialog_id)
end
Expand Down

0 comments on commit a580a91

Please sign in to comment.