Note: This is a beta release of Red Hat Bugzilla 5.0. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Also email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback here.
Bug 1360186 - Accessing the tags method of an MiqAeServiceLan object results in a NoMethodError exception
Summary: Accessing the tags method of an MiqAeServiceLan object results in a NoMethodE...
Alias: None
Product: Red Hat CloudForms Management Engine
Classification: Red Hat
Component: Automate
Version: 5.6.0
Hardware: All
OS: All
Target Milestone: GA
: 5.7.0
Assignee: Patrik Kománek
QA Contact: Dmitry Misharov
Whiteboard: tag:automate
Depends On:
Blocks: 1364222
TreeView+ depends on / blocked
Reported: 2016-07-26 07:47 UTC by Peter McGowan
Modified: 2018-06-25 14:09 UTC (History)
9 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1364222 (view as bug list)
Last Closed: 2017-01-11 20:17:59 UTC
Category: ---
Cloudforms Team: ---
Target Upstream Version:

Attachments (Terms of Use)

Description Peter McGowan 2016-07-26 07:47:47 UTC
Description of problem:
Accessing the tags method of an MiqAeServiceLan object results in a NoMethodError exception, undefined method 'tag_list'

Version-Release number of selected component (if applicable):

How reproducible:
Every Time

Steps to Reproduce:
1. Using $evm.vmdb, find a MiqAeServiceLan object
2. Call the tags method

Actual results:
NoMethodError exception

Expected results:
No error

Additional info:
This error results from the fact that the lans model is not taggable, but the tag-related classes are in MiqAeServiceModelBase.

It would be great to have two outcomes: having the lans model as taggable would be extremely useful so that lan tagging could be used to make placement decisions during provisioning. On a wider scope, it would be good to either move the tag-related methods out of ServiceModelBase, or provide a taggable? method that we could use to establish whether calling the tag-related methods was a valid operation.

Comment 2 Greg McCullough 2016-07-27 00:22:06 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?

def self.taggable?

We will need rspec tests, but to test in the rails console you can do this once you have the methods created:

  $evm =

  # Test class methods:
  => true
  vm = $evm.vmdb(:lan).taggable?
  => false

  # Test instance methods:
  => 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:

Related talk topic:

Comment 3 Patrik Kománek 2016-08-04 11:56:54 UTC
Solved in PR

Comment 5 Milan Falešník 2016-09-16 11:28:50 UTC
Verified in

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.

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