From 8cd6d8faac04f37da50e7ed220df7d957d5047e2 Mon Sep 17 00:00:00 2001 From: Tina Fitzgerald Date: Thu, 16 Feb 2017 17:11:52 -0500 Subject: [PATCH] Add service object to deliver to automate. The generic service state machine uses the service object. We're currently getting the service object from the task which causes a problem in retirement because we don't have a task. --- app/models/service_template_provision_task.rb | 2 ++ spec/models/service_template_provision_task_spec.rb | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/service_template_provision_task.rb b/app/models/service_template_provision_task.rb index 28708fb8f86..ce1ac9e1e86 100644 --- a/app/models/service_template_provision_task.rb +++ b/app/models/service_template_provision_task.rb @@ -136,6 +136,8 @@ def deliver_to_automate(req_type = request_type, _zone = nil) args[:automate_message] = ra.ae_message unless ra.ae_message.blank? args[:attrs].merge!(ra.ae_attributes) end + + args[:attrs].merge!(MiqAeEngine.create_automation_attributes(destination.class.base_model.name => destination)) args[:user_id] = get_user.id args[:miq_group_id] = get_user.current_group.id args[:tenant_id] = get_user.current_tenant.id diff --git a/spec/models/service_template_provision_task_spec.rb b/spec/models/service_template_provision_task_spec.rb index 11075b2e36e..8b81e5859b9 100644 --- a/spec/models/service_template_provision_task_spec.rb +++ b/spec/models/service_template_provision_task_spec.rb @@ -75,6 +75,8 @@ def service_resource_id(index, scaling_max) describe "#deliver_to_automate" do it "delivers to the queue when the state is not active" do + @service = FactoryGirl.create(:service, :name => 'Test Service') + @task_0.destination = @service @task_0.state = 'pending' zone = FactoryGirl.create(:zone, :name => "special") orchestration_manager = FactoryGirl.create(:ext_management_system, :zone => zone) @@ -86,7 +88,7 @@ def service_resource_id(index, scaling_max) :class_name => 'ServiceProvision_Template', :instance_name => 'clone_to_service', :automate_message => 'create', - :attrs => {'request' => 'clone_to_service'}, + :attrs => {'request' => 'clone_to_service', 'Service::Service' => @service.id}, :user_id => @admin.id, :miq_group_id => @admin.current_group_id, :tenant_id => @admin.current_tenant.id,