Skip to content

Commit

Permalink
Merge pull request #15537 from mkanoor/exp_method_manageiq_changes
Browse files Browse the repository at this point in the history
Added support for expression methods
  • Loading branch information
gmcculloug authored Jul 26, 2017
2 parents 9a58921 + aa07b39 commit 470292c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion app/models/miq_ae_method.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class MiqAeMethod < ApplicationRecord

AVAILABLE_LANGUAGES = ["ruby", "perl"] # someday, add sh, perl, python, tcl and any other scripting language
validates_inclusion_of :language, :in => AVAILABLE_LANGUAGES
AVAILABLE_LOCATIONS = ["builtin", "inline", "uri"]
AVAILABLE_LOCATIONS = %w(builtin inline uri expression).freeze
validates_inclusion_of :location, :in => AVAILABLE_LOCATIONS
AVAILABLE_SCOPES = ["class", "instance"]
validates_inclusion_of :scope, :in => AVAILABLE_SCOPES
Expand All @@ -33,6 +33,10 @@ def self.available_scopes
AVAILABLE_SCOPES
end

def self.available_expression_objects
MiqExpression.base_tables
end

# Validate the syntax of the passed in inline ruby code
def self.validate_syntax(code_text)
result = ManageIQ::AutomationEngine::SyntaxChecker.check(code_text)
Expand Down
3 changes: 2 additions & 1 deletion spec/support/automation_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ def create_ae_model_with_method(attrs = {})
attrs = default_ae_model_attributes(attrs)
method_script = attrs.delete(:method_script)
method_params = attrs.delete(:method_params) || {}
method_loc = attrs.delete(:method_loc) || "inline"
instance_name = attrs.delete(:instance_name)
method_name = attrs.delete(:method_name)
ae_fields = {'execute' => {:aetype => 'method', :datatype => 'string'}}
ae_instances = {instance_name => {'execute' => {:value => method_name}}}
ae_methods = {method_name => {:scope => 'instance', :location => 'inline',
ae_methods = {method_name => {:scope => 'instance', :location => method_loc,
:data => method_script,
:language => 'ruby', 'params' => method_params}}

Expand Down

0 comments on commit 470292c

Please sign in to comment.