From 8ea1f8db2c1a3e6db0c3779d2183fe671fd2b976 Mon Sep 17 00:00:00 2001 From: Bill Wei Date: Tue, 7 Mar 2017 19:20:37 -0500 Subject: [PATCH] Require EmbeddedAnsible playbook to create playbook service --- app/models/service_template_ansible_playbook.rb | 4 ++-- spec/factories/configuration_script.rb | 4 ++++ spec/models/service_template_ansible_playbook_spec.rb | 10 ++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/app/models/service_template_ansible_playbook.rb b/app/models/service_template_ansible_playbook.rb index 37f0468d037..0de089bb147 100644 --- a/app/models/service_template_ansible_playbook.rb +++ b/app/models/service_template_ansible_playbook.rb @@ -74,7 +74,7 @@ def self.create_job_templates(service_name, description, config_info, auth_user) def self.create_job_template(name, description, info, auth_user) tower, params = build_parameter_list(name, description, info) - task_id = ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript.create_in_provider_queue(tower.id, params, auth_user) + task_id = ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScript.create_in_provider_queue(tower.id, params, auth_user) task = MiqTask.wait_for_taskid(task_id) raise task.message unless task.status == "Ok" task.task_results @@ -82,7 +82,7 @@ def self.create_job_template(name, description, info, auth_user) private_class_method :create_job_template def self.build_parameter_list(name, description, info) - playbook = ManageIQ::Providers::AnsibleTower::AutomationManager::Playbook.find(info[:playbook_id]) + playbook = ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook.find(info[:playbook_id]) tower = playbook.manager params = { :name => name, diff --git a/spec/factories/configuration_script.rb b/spec/factories/configuration_script.rb index 6780a20e4f0..d6f00a09de4 100644 --- a/spec/factories/configuration_script.rb +++ b/spec/factories/configuration_script.rb @@ -14,4 +14,8 @@ factory :ansible_configuration_script, :class => "ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript", :parent => :configuration_script + + factory :embedded_playbook, + :class => "ManageIQ::Providers::EmbeddedAnsible::AutomationManager::Playbook", + :parent => :configuration_script_payload end diff --git a/spec/models/service_template_ansible_playbook_spec.rb b/spec/models/service_template_ansible_playbook_spec.rb index 5829b7bf596..9fcd7eddd01 100644 --- a/spec/models/service_template_ansible_playbook_spec.rb +++ b/spec/models/service_template_ansible_playbook_spec.rb @@ -3,7 +3,6 @@ let(:auth_one) { FactoryGirl.create(:authentication, :manager_ref => 6) } let(:auth_two) { FactoryGirl.create(:authentication, :manager_ref => 10) } - let(:config_script) { FactoryGirl.create(:configuration_script) } let(:script_source) { FactoryGirl.create(:configuration_script_source, :manager => ems) } let(:inventory_root_group) { FactoryGirl.create(:inventory_root_group, :name => 'Demo Inventory') } @@ -13,11 +12,10 @@ end let(:playbook) do - FactoryGirl.create(:configuration_script_payload, + FactoryGirl.create(:embedded_playbook, :configuration_script_source => script_source, :manager => ems, - :inventory_root_group => inventory_root_group, - :type => 'ManageIQ::Providers::AnsibleTower::AutomationManager::Playbook') + :inventory_root_group => inventory_root_group) end let(:job_template) do @@ -74,7 +72,7 @@ it '#create_job_template' do expect(described_class).to receive(:build_parameter_list).and_return([ems, {}]) - expect(ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript) + expect(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScript) .to receive(:create_in_provider_queue).once.with(ems.id, {}, 'system') expect(MiqTask).to receive(:wait_for_taskid).with(any_args).once.and_return( instance_double('MiqTask', :task_results => {}, :status => 'Ok') @@ -89,7 +87,7 @@ it 'create_job_template exception' do expect(described_class).to receive(:build_parameter_list).and_return([ems, {}]) - expect(ManageIQ::Providers::AnsibleTower::AutomationManager::ConfigurationScript) + expect(ManageIQ::Providers::EmbeddedAnsible::AutomationManager::ConfigurationScript) .to receive(:create_in_provider_queue).once.with(ems.id, {}, 'system') expect(MiqTask).to receive(:wait_for_taskid).with(any_args).once.and_raise(Exception, 'bad job template')