Bug 1337261 - [RFE] "NoMethodError: undefined method `where' for MiqAeMethodService::MiqAeServiceClassification:Class"
Summary: [RFE] "NoMethodError: undefined method `where' for MiqAeMethodService::MiqAeS...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Automate
Version: 5.5.0
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: GA
: 5.5.5
Assignee: mkanoor
QA Contact: Matouš Mojžíš
URL:
Whiteboard: automate
Depends On: 1295927
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-05-18 16:06 UTC by John Prause
Modified: 2017-08-30 01:16 UTC (History)
7 users (show)

Fixed In Version: 5.5.5.2
Doc Type: Enhancement
Doc Text:
Clone Of: 1295927
Environment:
Last Closed: 2016-07-26 15:34:35 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:


Attachments (Terms of Use)
automation.log (2.80 KB, text/plain)
2016-07-14 13:02 UTC, Matouš Mojžíš
no flags Details


Links
System ID Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2016:1488 normal SHIPPED_LIVE CFME 5.5.5 bug fixes and enhancement update 2016-07-26 19:28:27 UTC

Comment 4 CFME Bot 2016-06-14 16:32:26 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@redhat.com>
AuthorDate: Tue Jun 14 12:29:52 2016 -0400
Commit:     Greg McCullough <gmccullo@redhat.com>
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(-)

Comment 6 Matouš Mojžíš 2016-07-14 13:02:37 UTC
Created attachment 1179839 [details]
automation.log

Comment 7 Matouš Mojžíš 2016-07-14 13:11:33 UTC
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

Comment 8 mkanoor 2016-07-18 14:26:56 UTC
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

Comment 9 Matouš Mojžíš 2016-07-19 09:57:18 UTC
Okay, it works. 
Verified in 5.5.5.2. No error after simulation.

Comment 11 errata-xmlrpc 2016-07-26 15:34:35 UTC
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


Note You need to log in before you can comment on or make changes to this bug.