Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for expression methods #15537

Merged
merged 3 commits into from
Jul 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 = MiqSyntaxChecker.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