[Solved] Dynamic Resource Objects

providers

#1

I’d like to have some insight on the new feature called Dynamic Resource Objects. This looks to be very interesting for managing unsupported infrastructure elements like firewalls etc.

Any sample code or further docs I can read on the topic?


#2

Found something useful: https://www.slideshare.net/ManageIQ/generic-objects-bill-wei-manageiq-design-summit-2016 and https://www.youtube.com/watch?v=h4YblOmIJjM


#3

I created a simple Generic Object LBpool on Gapri-1-RC1 GUI with the following result:

@object=#<GenericObjectDefinition id: 1, name: "LBpool", description: "Load Balancer Pool", properties: {:attributes=>{"poolname"=>:string}, :associations=>{"member"=>"Service"}, :methods=>[]}, created_at: "2018-01-11 20:21:05", updated_at: "2018-01-11 20:40:07">, @virtual_columns=["generic_objects_count", "href_slug", "region_description", "region_number"], @associations=[]>

Then I created an instance and tried to add it to a service (in Rails console):

lbpool_def = $evm.vmdb('generic_object_definition').find_by(:name => 'LBpool')
myLBpool = lbpool_def.create_object(:name => 'uatweb', :poolname => 'demo')
service = Service.where(:name => "Dummy").first
service.add_resource(myLBpool)

At this point I receive an error message: NoMethodError: undefined method 'primary_key' for MiqAeMethodService::MiqAeServiceGenericObject:Class

What am I doing wrong? I can see the new object in the GUI:

generic_object


#4

I managed to fix the code based on a bugzilla comment:

lbpool_def = GenericObjectDefinition.where(:name => "LBpool").first
myLBpool = lbpool_def.create_object(:name => 'prdweb', :poolname => 'live')
service = Service.where(:name => "Dummy").first
service.add_resource(myLBpool)
service.save!

Now it is linked to the service (clickable):

generic_object_service

Also visible on the self-service UI: