Bugzilla will be upgraded to version 5.0. The upgrade date is tentatively scheduled for 2 December 2018, pending final testing and feedback.
Bug 1337261 - [RFE] "NoMethodError: undefined method `where' for MiqAeMethodService::MiqAeServiceClassification:Class"
[RFE] "NoMethodError: undefined method `where' for MiqAeMethodService::MiqAeS...
Status: CLOSED ERRATA
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Automate (Show other bugs)
5.5.0
Unspecified Unspecified
unspecified Severity medium
: GA
: 5.5.5
Assigned To: mkanoor
Matouš Mojžíš
automate
: FutureFeature, ZStream
Depends On: 1295927
Blocks:
  Show dependency treegraph
 
Reported: 2016-05-18 12:06 EDT by John Prause
Modified: 2017-08-29 21:16 EDT (History)
7 users (show)

See Also:
Fixed In Version: 5.5.5.2
Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: 1295927
Environment:
Last Closed: 2016-07-26 11:34:35 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


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


External Trackers
Tracker 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 15:28:27 EDT

  None (edit)
Comment 4 CFME Bot 2016-06-14 12:32:26 EDT
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 09:02 EDT
Created attachment 1179839 [details]
automation.log
Comment 7 Matouš Mojžíš 2016-07-14 09:11:33 EDT
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 10:26:56 EDT
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 05:57:18 EDT
Okay, it works. 
Verified in 5.5.5.2. No error after simulation.
Comment 11 errata-xmlrpc 2016-07-26 11:34:35 EDT
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.