Skip to content

Instantly share code, notes, and snippets.

@psachin
Last active Jan 27, 2018
Embed
What would you like to do?
Demo DRO
irb(main):024:0> dro_class = $evm.vmdb(:generic_object_definition).find_by(:name => "demo_dro")
PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0
PostgreSQLAdapter#log_after_checkin, connection_pool: size: 5, connections: 1, in use: 0, waiting_in_queue: 0
PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0
PostgreSQLAdapter#log_after_checkin, connection_pool: size: 5, connections: 1, in use: 0, waiting_in_queue: 0
=> #<MiqAeServiceGenericObjectDefinition:0x1b5f38c @object=#<GenericObjectDefinition id: 6, name: "demo_dro", description: "Used for enablement", properties: {:attributes=>{"name"=>:string, "is_tired"=>:boolean, "created"=>:datetime, "retirement"=>:datetime}, :associations=>{}, :methods=>["kick", "laugh_at", "punch", "buy_a_drink"]}, created_at: "2017-12-04 19:57:17", updated_at: "2017-12-06 16:43:42">, @virtual_columns=["generic_objects_count", "href_slug", "region_description", "region_number"], @associations=[]>
irb(main):026:0> dro = dro_class.create_object(:name => "My demo DRO object", :is_tired => false, :created => Time.new, :retirement => nil)
PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0
PostgreSQLAdapter#log_after_checkin, connection_pool: size: 5, connections: 1, in use: 0, waiting_in_queue: 0
PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0
PostgreSQLAdapter#log_after_checkin, connection_pool: size: 5, connections: 1, in use: 0, waiting_in_queue: 0
PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0
PostgreSQLAdapter#log_after_checkin, connection_pool: size: 5, connections: 1, in use: 0, waiting_in_queue: 0
=> #<MiqAeServiceGenericObject:0x1469780 @object=#<GenericObject:0x000000030578e8 id: 12, name: "My demo DRO object", uid: nil, generic_object_definition_id: 6, created_at: "2018-01-27 16:17:53", updated_at: "2018-01-27 16:17:53", attributes: {"is_tired"=>false, "created"=>2018-01-27 16:17:53 UTC, "retirement"=>nil}, associations: [], methods: ["kick", "laugh_at", "punch", "buy_a_drink"]>, @virtual_columns=["generic_object_definition_name", "href_slug", "region_description", "region_number"], @associations=[]>
irb(main):027:0> $evm.log(:info, "dro object: #{dro.inspect}")
PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0
PostgreSQLAdapter#log_after_checkin, connection_pool: size: 5, connections: 1, in use: 0, waiting_in_queue: 0
=> true
irb(main):031:0> dro.attributes
=> {"id"=>12, "name"=>"My demo DRO object", "uid"=>nil, "generic_object_definition_id"=>6, "created_at"=>Sat, 27 Jan 2018 16:17:53 UTC +00:00, "updated_at"=>Sat, 27 Jan 2018 16:17:53 UTC +00:00, "properties"=>{"is_tired"=>false, "created"=>"2018-01-27T11:17:53.437-05:00", "retirement"=>nil}}
irb(main):033:0> dro.retirement=Time.now+7.days
RuntimeError: Workspace not found when running generic object
from /opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-ef744f1aa985/lib/miq_automation_engine/service_models/miq_ae_service_generic_object.rb:23:in `ae_user_identity'
from /opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-ef744f1aa985/lib/miq_automation_engine/service_models/miq_ae_service_generic_object.rb:29:in `method_missing'
from (irb):33
from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands/console.rb:65:in `start'
from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands/console_helper.rb:9:in `start'
from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:78:in `console'
from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
irb(main):034:0> dro.retirement
RuntimeError: Workspace not found when running generic object
from /opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-ef744f1aa985/lib/miq_automation_engine/service_models/miq_ae_service_generic_object.rb:23:in `ae_user_identity'
from /opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-ef744f1aa985/lib/miq_automation_engine/service_models/miq_ae_service_generic_object.rb:29:in `method_missing'
from (irb):34
from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands/console.rb:65:in `start'
from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands/console_helper.rb:9:in `start'
from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:78:in `console'
from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
irb(main):035:0> mydro = $evm.vmdb(:generic_object).find(12)
PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0
PostgreSQLAdapter#log_after_checkin, connection_pool: size: 5, connections: 1, in use: 0, waiting_in_queue: 0
PostgreSQLAdapter#log_after_checkout, connection_pool: size: 5, connections: 1, in use: 1, waiting_in_queue: 0
PostgreSQLAdapter#log_after_checkin, connection_pool: size: 5, connections: 1, in use: 0, waiting_in_queue: 0
=> #<MiqAeServiceGenericObject:0x47b6098 @object=#<GenericObject:0x00000008f6c630 id: 12, name: "My demo DRO object", uid: nil, generic_object_definition_id: 6, created_at: "2018-01-27 16:17:53", updated_at: "2018-01-27 16:17:53", attributes: {"created"=>2018-01-27 16:17:53 UTC, "is_tired"=>false, "retirement"=>nil}, associations: [], methods: ["kick", "laugh_at", "punch", "buy_a_drink"]>, @virtual_columns=["generic_object_definition_name", "href_slug", "region_description", "region_number"], @associations=[]>
irb(main):039:0> mydro.retirement
RuntimeError: Workspace not found when running generic object
from /opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-ef744f1aa985/lib/miq_automation_engine/service_models/miq_ae_service_generic_object.rb:23:in `ae_user_identity'
from /opt/rh/cfme-gemset/bundler/gems/manageiq-automation_engine-ef744f1aa985/lib/miq_automation_engine/service_models/miq_ae_service_generic_object.rb:29:in `method_missing'
from (irb):39
from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands/console.rb:65:in `start'
from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands/console_helper.rb:9:in `start'
from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:78:in `console'
from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
from /opt/rh/cfme-gemset/gems/railties-5.0.6/lib/rails/commands.rb:18:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
irb(main):040:0>
irb(main):064:0> mydro.attributes["properties"]["is_tired"]
=> false
irb(main):065:0> mydro.attributes["properties"]["created"]
=> "2018-01-27T11:17:53.437-05:00"
irb(main):066:0> mydro.attributes["properties"]["retirement"]
=> nil
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment