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

Inconsistent attribute names inside Automate Engine #13440

Merged
merged 3 commits into from
Jan 12, 2017

Conversation

mkanoor
Copy link
Contributor

@mkanoor mkanoor commented Jan 10, 2017

Inside the Automate Engine we convert the attribute name for
simple data types to lowercase, but for Array types we dont
convert the attribute name to lowercase.

This PR converts all attribute names to lowercase.

This is inconsistent.
e.g. Array::VM=VM::100&Name=fred

would yield 2 attribute names VM and name. The "name" got converted to
lowercase but VM didn't.

When the methods access these variables using $evm.root we internally
convert it to lowercase at access time

$evm.root['VM'] gets converted to $evm.root['vm']
$evm.root['vm'] gets converted to $evm.root['vm']
$evm.root['Name'] gets converted to $evm.root['name']

If the caller passed in Array::VM=VM::100&Name=fred
$evm.root['VM'] fails because the method layer converts it to lowercase
and internally it has preserved its original case

This is not that prevalent since most of the attribute names that embed
the class type are generated internally and they always lowercase the
name. We have seen this manifest itself when using Tag controls using
dialogs and the user names the tag with mixed case e.g.
TagControl would be stored in the engine as dialog_TagControl but when
the methods try to access $evm.root['dialog_TagControl'] the method
layer would lowercase it and not find the attribute.

Links

Steps for Testing/QA

  • Create Dialog with TagControl and use mixed case name e.g. TagControl
  • Write an Automate Method which can be called from the Dialog to access the TagControl
     desc = $evm.root['dialog_TagControl'].first.description
     $evm.log(:info, "Description #{desc}")

Screen Shot attached
screen shot 2017-01-10 at 5 53 36 pm

@mkanoor
Copy link
Contributor Author

mkanoor commented Jan 10, 2017

@tinaafitz @gmcculloug
Please review

@mkanoor mkanoor closed this Jan 11, 2017
@mkanoor mkanoor reopened this Jan 11, 2017
https://bugzilla.redhat.com/show_bug.cgi?id=1408482

Inside the Automate Engine we convert the attribute name for
 simple data types to lowercase, but for vmdb or Array types we dont
 convert the attribute name to lowercase.

This PR converts all attribute names to lowercase.

This is inconsistent.
e.g. VM::VM=100&Name=fred

would yield 2 attribute names VM and name. The "name" got converted to
lowercase but VM didn't.

When the methods access these variables using $evm.root we internally
convert it to lowercase at access time

$evm.root['VM']        gets converted to $evm.root['vm']
$evm.root['vm']        gets converted to $evm.root['vm']
$evm.root['Name']      gets converted to $evm.root['Name']

If the caller passed in VM::VM=100&Name=fred
$evm.root['VM'] fails because the method layer converts it to lowercase
and internally it has preserved its original case

This is not that prevalent since most of the attribute names that embed
the class type are generated internally and they always lowercase the
name. We have seen this manifest itself when using Tag controls using
dialogs and the user names the tag with mixed case e.g.
TagControl would be stored in the engine as dialog_TagControl but when
the methods try to access $evm.root['dialog_TagControl'] the method
layer would lowercase it and not find the attribute.
expect(result["vms"].length).to eq(1)
expect(result["name"]).to eq("fred")
expect(result["Name"]).to be_nil
expect(result["VMs"]).to be_nil
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor, but can you move this check for VMs next to the vms tests so they are grouped together. Makes it clearer what you are testing.

@gmcculloug
Copy link
Member

One minor comment on the spec both otherwise this looks good.

@@ -273,7 +273,7 @@ def process_args_attribute(args, args_key)
key, klass = get_key_name_and_klass_from_key(args_key)
value = args.delete(args_key)
args["#{key}_id"] = value unless @attributes.key?(key)
args[key] = MiqAeObject.convert_value_based_on_datatype(value, klass)
args[key.downcase] = MiqAeObject.convert_value_based_on_datatype(value, klass)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mkanoor The key is already lower case here.

@miq-bot
Copy link
Member

miq-bot commented Jan 11, 2017

Checked commits mkanoor/manageiq@c3379ae~...18c82f1 with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1
2 files checked, 0 offenses detected
Everything looks good. ⭐

@gmcculloug gmcculloug merged commit df1e645 into ManageIQ:master Jan 12, 2017
@gmcculloug gmcculloug added this to the Sprint 52 Ending Jan 16, 2017 milestone Jan 12, 2017
@simaishi
Copy link
Contributor

Backported to Euwe via #13545

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants