From bb86d413c8e902e25b327196a7d28f9af9993098 Mon Sep 17 00:00:00 2001 From: Lucy Fu Date: Fri, 6 Jul 2018 16:11:32 -0400 Subject: [PATCH] The vm_id coming in from API is a string. --- app/models/service_template_transformation_plan.rb | 8 ++++---- spec/models/service_template_transformation_plan_spec.rb | 4 ++-- .../service_template_transformation_plan_task_spec.rb | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/models/service_template_transformation_plan.rb b/app/models/service_template_transformation_plan.rb index c7dce1fc3c0..fa2deb70584 100644 --- a/app/models/service_template_transformation_plan.rb +++ b/app/models/service_template_transformation_plan.rb @@ -41,8 +41,8 @@ def self.default_reconfiguration_entry_point # :pre_service_id # :post_service_id # :actions => [ - # {:vm_id => 1, :pre_service => true, :post_service => false}, - # {:vm_id => 2, :pre_service => true, :post_service => true}, + # {:vm_id => "1", :pre_service => true, :post_service => false}, + # {:vm_id => "2", :pre_service => true, :post_service => true}, # ] # def self.create_catalog_item(options, _auth_user = nil) @@ -83,9 +83,9 @@ def self.validate_config_info(options) vms = [] if config_info[:actions] - vm_objects = VmOrTemplate.where(:id => config_info[:actions].collect { |vm_hash| vm_hash[:vm_id] }.compact).group_by(&:id) + vm_objects = VmOrTemplate.where(:id => config_info[:actions].collect { |vm_hash| vm_hash[:vm_id] }.compact).index_by(&:id).stringify_keys config_info[:actions].each do |vm_hash| - vm_obj = vm_objects[vm_hash[:vm_id]].try(:first) || vm_hash[:vm] + vm_obj = vm_objects[vm_hash[:vm_id]] || vm_hash[:vm] next if vm_obj.nil? vm_options = {} diff --git a/spec/models/service_template_transformation_plan_spec.rb b/spec/models/service_template_transformation_plan_spec.rb index f05b5d99a90..a072f9334f4 100644 --- a/spec/models/service_template_transformation_plan_spec.rb +++ b/spec/models/service_template_transformation_plan_spec.rb @@ -30,8 +30,8 @@ :pre_service_id => apst.id, :post_service_id => apst.id, :actions => [ - {:vm_id => vm1.id, :pre_service => true, :post_service => false}, - {:vm_id => vm2.id, :pre_service => true, :post_service => true} + {:vm_id => vm1.id.to_s, :pre_service => true, :post_service => false}, + {:vm_id => vm2.id.to_s, :pre_service => true, :post_service => true} ], } } diff --git a/spec/models/service_template_transformation_plan_task_spec.rb b/spec/models/service_template_transformation_plan_task_spec.rb index 430cf69d4b0..12130dcdf10 100644 --- a/spec/models/service_template_transformation_plan_task_spec.rb +++ b/spec/models/service_template_transformation_plan_task_spec.rb @@ -34,8 +34,8 @@ :pre_service_id => apst.id, :post_service_id => apst.id, :actions => [ - {:vm_id => vm.id, :pre_service => true, :post_service => true}, - {:vm_id => vm2.id, :pre_service => false, :post_service => false}, + {:vm_id => vm.id.to_s, :pre_service => true, :post_service => true}, + {:vm_id => vm2.id.to_s, :pre_service => false, :post_service => false}, ], } }