Skip to content

Commit

Permalink
Add automate engine support for array elements containing text values.
Browse files Browse the repository at this point in the history
  • Loading branch information
syncrou committed Mar 17, 2017
1 parent 2b4518d commit 04e2437
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/miq_automation_engine/engine/miq_ae_object.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 04e2437

Please sign in to comment.