Skip to content

Commit

Permalink
PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mkanoor committed Feb 13, 2017
1 parent e5da2b3 commit 59ec117
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
6 changes: 2 additions & 4 deletions app/models/service_ansible_playbook.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
class ServiceAnsiblePlaybook < ServiceGeneric
delegate :job_template, :to => :service_template, :allow_nil => true

# A chance for taking options from automate script to override options from a service dialog
def preprocess(action, add_options = {})
save_job_options(action, add_options)
Expand Down Expand Up @@ -38,10 +40,6 @@ def job(action)

private

def job_template(action)
service_template.resource_actions.find_by!(:action => action).configuration_template
end

def get_job_options(action)
job_opts = options["#{action.downcase}_job_options".to_sym].deep_dup
credential_id = job_opts.delete(:credential_id)
Expand Down
5 changes: 2 additions & 3 deletions app/models/service_template_ansible_playbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ def self.default_retirement_entry_point
'/Service/Generic/StateMachines/GenericLifecycle/retire'
end

def job_template(service_action)
item = resource_actions.detect { |ra| ra.action == service_action }
item.configuration_template if item
def job_template(action)
resource_actions.find_by!(:action => action).configuration_template
end

# create ServiceTemplate and supporting ServiceResources and ResourceActions
Expand Down
2 changes: 1 addition & 1 deletion spec/models/service_ansible_playbook_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
let(:action) { ResourceAction::PROVISION }

let(:loaded_service) do
service_template = FactoryGirl.create(:service_template)
service_template = FactoryGirl.create(:service_template_ansible_playbook)
service_template.resource_actions.build(:action => action, :configuration_template => tower_job_temp)
service_template.save!
FactoryGirl.create(:service_ansible_playbook, :options => provision_options, :service_template => service_template)
Expand Down

0 comments on commit 59ec117

Please sign in to comment.