-
Notifications
You must be signed in to change notification settings - Fork 74
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
Support for expression methods #49
Support for expression methods #49
Conversation
@gmcculloug Travis failure is pending for this PR ManageIQ/manageiq#15537 to get merged. |
:ae_class => 'ASTERIX', :instance_name => 'DOGMATIX', | ||
:method_name => 'OBELIX', :method_params => m_params, | ||
:method_loc => 'expression', | ||
:method_script => vm_search) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This same create_ae_model_with_method
method and parameters are repeated for all but 2 tests. Please move into either a let
block or method so it can be shared.
allow(User).to receive(:server_timezone).and_return("UTC") | ||
end | ||
|
||
it "expression_method" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggest moving these tests into something like a describe "expression_method" do
block to better group and reduce the duplication in each test title.
@@ -0,0 +1,169 @@ | |||
module MiqAeExpressionMethodSpec | |||
include MiqAeEngine | |||
describe MiqAeExpressionMethod do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we come up with a way to test this class without having to build an automate model and instantiate it each time? Seems very expensive to run each test and it would be better to focus the tests on the class. Thoughts?
@mkanoor The PR description has great documentation for the feature but I think it could use a few updates/enhancements that would be really useful.
|
58e9c0b
to
23d3509
Compare
Checked commits mkanoor/manageiq-automation_engine@49575af~...23d3509 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_expression_method.rb
lib/miq_automation_engine/engine/miq_ae_engine/miq_ae_object.rb
|
Expression Methods
https://www.pivotaltracker.com/n/projects/1613499/stories/148625717
Expression Methods allow you to use Advance Search Filters as Automate Methods, substituting the user_input from Automate Objects. The advantages of this approach is that the methods run directly in the worker and don't have the overhead of forking a DRb process to run the Automate Methods.
Related PR #50
Steps
Create a new Automate Method and set the Location to expression
Select the Expression object to use for the expression builder from the drop down list
Create an expression using the expression editor controls and any values that need to be set at runtime from automate, mark then as user input. These are positional arguments.
In the input parameters section create arg1,arg2,arg3... for each of the user input fields from Step 3. When specifying the default value for arg1,arg2,... you can use substitution. e.g. ${/#vm_suffix}
Create a field called attributes with the list of attributes that you would like to collect from the search objects. e.g (name, id)
Input Parameters
Optional Input Parameters
or
This should me marked as an Array Type in the Input Parameters field.
If attributes and distinct are not specified we try to store the result in a variable called
values with a hash consisting of id and name. This makes it compatible with our existing dynamic dialog result set.
result_obj The object where the result data should be stored (default: current object)
result_attr The name of the attribute which stores the result (default: values)
result_type The result type hash or array (default: dialog_hash which matches to our dynamic dialog hash. Valid values are 'hash', 'dialog_hash', 'array', 'simple'
on_empty The method behavior when the search returns an empty list
warn | error | abort (default: error)
default The default value in case the result is empty and you select warn
UI PR Expression method ui changes manageiq-ui-classic#1668
ManageIQ PR: Added support for expression methods manageiq#15537
The Expression Method in Edit Mode
The Expression Method in Display Mode
Dynamic Dialog Instance
The instance below shows how to setup for Dynamic Dialogs, the default properties can be set in the instance and the method will fill in the values field. In the examples below the AvailableVMsInternal is an expression method.
If trying to get data into a text box e.g ID of a VMDB object the arguments would look like