Bug 1360186
| Summary: | Accessing the tags method of an MiqAeServiceLan object results in a NoMethodError exception | |||
|---|---|---|---|---|
| Product: | Red Hat CloudForms Management Engine | Reporter: | Peter McGowan <pmcgowan> | |
| Component: | Automate | Assignee: | Patrik Kománek <pkomanek> | |
| Status: | CLOSED CURRENTRELEASE | QA Contact: | Dmitry Misharov <dmisharo> | |
| Severity: | high | Docs Contact: | ||
| Priority: | medium | |||
| Version: | 5.6.0 | CC: | cpelland, dajohnso, gmccullo, jhardy, mfalesni, mkanoor, obarenbo, simaishi, tfitzger | |
| Target Milestone: | GA | Keywords: | TestOnly, ZStream | |
| Target Release: | 5.7.0 | |||
| Hardware: | All | |||
| OS: | All | |||
| Whiteboard: | tag:automate | |||
| Fixed In Version: | 5.7.0.0 | Doc Type: | If docs needed, set a value | |
| Doc Text: | Story Points: | --- | ||
| Clone Of: | ||||
| : | 1364222 (view as bug list) | Environment: | ||
| Last Closed: | 2017-01-11 20:17:59 UTC | Type: | Bug | |
| 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: | ||||
| Bug Blocks: | 1364222 | |||
|
Description
Peter McGowan
2016-07-26 07:47:47 UTC
Patrik - Since we support tagging on so many objects (but not all) the tagging methods exposed to the automate service model were implemented at the base object. We never dealt with properly handling active_record objects that do not include tagging. The suggested approach here is to add two new methods (one class/one instance) both called "taggable?" to the base automate service model (lib/miq_automation_engine/engine/miq_ae_service_model_base.rb) which would return true/false if the class or instance supports tagging. I'm thinking it would look like this: def taggable? self.class.taggable? end def self.taggable? model.respond_to?(:tags) end We will need rspec tests, but to test in the rails console you can do this once you have the methods created: $evm = MiqAeMethodService::MiqAeService.new(MiqAeEngine::MiqAeWorkspaceRuntime.new) # Test class methods: $evm.vmdb(:vm).taggable? => true vm = $evm.vmdb(:lan).taggable? => false # Test instance methods: $evm.vmdb(:vm).first.taggable? => true vm = $evm.vmdb(:lan).first.taggable? => false Then we need to update the tagging methods in miq_ae_service_model_base.rb (tagged_with?, tags, tag_assign, tag_unassign) to verify that tagging is supported on the current object and raise an error if not. We should add a new error class here for this error here: lib/miq_automation_engine/miq_ae_exception.rb Related talk topic: http://talk.manageiq.org/t/should-all-models-be-taggable/1613 Solved in PR https://github.com/ManageIQ/manageiq/pull/10230 Verified in 5.7.0.0 irb(main):007:0> $evm.vmdb(:Lan).all.last.taggable? => true irb(main):008:0> $evm.vmdb(:Lan).all.last.tags => [] irb(main):015:0> $evm.vmdb(:Lan).all.last.tag_assign 'location/chicago' => true irb(main):016:0> $evm.vmdb(:Lan).all.last.tags => ["location/chicago"] Works as expected. |