From 04e2437a6dcbf6428246b829563818ed9f4c2fc1 Mon Sep 17 00:00:00 2001 From: Drew Bomhof Date: Fri, 17 Mar 2017 17:46:02 -0400 Subject: [PATCH] Add automate engine support for array elements containing text values. PR: https://github.com/ManageIQ/manageiq/pull/11667 --- .../engine/miq_ae_object.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/miq_automation_engine/engine/miq_ae_object.rb b/lib/miq_automation_engine/engine/miq_ae_object.rb index d620539481b..4aad787af5c 100644 --- a/lib/miq_automation_engine/engine/miq_ae_object.rb +++ b/lib/miq_automation_engine/engine/miq_ae_object.rb @@ -279,11 +279,15 @@ def process_args_attribute(args, args_key) end def load_array_objects_from_string(objects_str) - objects_str.split(',').collect do |o| - klass, str_value = o.split(CLASS_SEPARATOR) - value = MiqAeObject.convert_value_based_on_datatype(str_value, klass) - value if value.kind_of?(MiqAeMethodService::MiqAeServiceModelBase) - end.compact + objects_str.split(',').collect do |element| + if element.include?(CLASS_SEPARATOR) + klass, str_value = element.split(CLASS_SEPARATOR) + MiqAeObject.convert_value_based_on_datatype(str_value.strip, klass.strip) + else + element.presence + end.compact + end + end def get_key_name_and_klass_from_key(attribute_key) @@ -531,6 +535,8 @@ def self.convert_value_based_on_datatype(value, datatype) return service_model.find(value) end + (raise MiqAeException::InvalidClass unless MiqAeField.available_datatypes.include?(datatype)) if datatype + # default datatype => 'string' value end