Bug 1337261
Summary: | [RFE] "NoMethodError: undefined method `where' for MiqAeMethodService::MiqAeServiceClassification:Class" | ||||||
---|---|---|---|---|---|---|---|
Product: | Red Hat CloudForms Management Engine | Reporter: | John Prause <jprause> | ||||
Component: | Automate | Assignee: | mkanoor | ||||
Status: | CLOSED ERRATA | QA Contact: | Matouš Mojžíš <mmojzis> | ||||
Severity: | medium | Docs Contact: | |||||
Priority: | unspecified | ||||||
Version: | 5.5.0 | CC: | cpelland, gmccullo, jhardy, mfeifer, mkanoor, obarenbo, tfitzger | ||||
Target Milestone: | GA | Keywords: | FutureFeature, ZStream | ||||
Target Release: | 5.5.5 | ||||||
Hardware: | Unspecified | ||||||
OS: | Unspecified | ||||||
Whiteboard: | automate | ||||||
Fixed In Version: | 5.5.5.2 | Doc Type: | Enhancement | ||||
Doc Text: | Story Points: | --- | |||||
Clone Of: | 1295927 | Environment: | |||||
Last Closed: | 2016-07-26 15:34:35 UTC | Type: | --- | ||||
Regression: | --- | Mount Type: | --- | ||||
Documentation: | --- | CRM: | |||||
Verified Versions: | Category: | --- | |||||
oVirt Team: | --- | RHEL 7.3 requirements from Atomic Host: | |||||
Cloudforms Team: | --- | Target Upstream Version: | |||||
Embargoed: | |||||||
Bug Depends On: | 1295927 | ||||||
Bug Blocks: | |||||||
Attachments: |
|
Comment 2
mkanoor
2016-06-14 15:11:38 UTC
New commit detected on cfme/5.5.z: https://code.engineering.redhat.com/gerrit/gitweb?p=cfme.git;a=commitdiff;h=5c117ffa2387cadf1fe099b3007e69021a2e5569 commit 5c117ffa2387cadf1fe099b3007e69021a2e5569 Merge: 7a4f936 db5c139 Author: Greg McCullough <gmccullo> AuthorDate: Tue Jun 14 12:29:52 2016 -0400 Commit: Greg McCullough <gmccullo> CommitDate: Tue Jun 14 12:29:52 2016 -0400 Merge branch 'bugzilla_1337261_5_5_z' into '5.5.z' Support where method for service models https://bugzilla.redhat.com/show_bug.cgi?id=1337261 Starting in Rails 4 the where method should be used instead of find when accessing ActiveRecord Objects. The Automate Service Model wraps the ActiveRecord objects and wasn't exposing the class method where. Clean Cherry Pick From https://github.com/ManageIQ/manageiq/pull/6046 See merge request !968 lib/miq_automation_engine/engine/miq_ae_service_model_base.rb | 2 +- spec/lib/miq_automation_engine/miq_ae_service_model_spec.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) Created attachment 1179839 [details]
automation.log
Tried this code: vm_id = '1234' query = $evm.vmdb(:vm).where(:vendor => "redhat") query = query.where(:id => vm_id) if vm_id query.first and didn't work. Error is in automation.log This is not supposed to work, we don't support chaining of where clauses. We don't support the full Rails where clause, the reason for this is the Automate methods run as a client/server with the Engine acting as the server and the method acting as the client. The entire query is evaluated on the Engine side and it sends the result back to the client. When we chain where clauses we have temp chained queries being sent back as opposed to the result. You can try this instead vm_id = '1234' query = if vm_id $evm.vmdb(:vm).where("vendor = ? and id = ?", "redhat", vm_id) else $evm.vmdb{:vm).where("vendor = ?", "redhat") end query.first Okay, it works. Verified in 5.5.5.2. No error after simulation. Since the problem described in this bug report should be resolved in a recent advisory, it has been closed with a resolution of ERRATA. For information on the advisory, and where to find the updated files, follow the link below. If the solution does not work for you, open a new bug report. https://rhn.redhat.com/errata/RHBA-2016-1488.html |