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): 5.6.0.13 How reproducible: Every Time Steps to Reproduce: 1. Using $evm.vmdb, find a MiqAeServiceLan object 2. Call the tags method 3. 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.
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.