Delete Dynamic Resource Object form CloudForms

If you are in the situation where you cannot delete a DRO from the UI you can go and delete it from the rails console.

I had the following Dynamic Resource Object Definition:

 

As you can see I have 2 instances. How do you delete these instances? With both the API calls as well as the UI it seems that it only allows you to delete the object definition. If you have 2 instances in the DRO definition it cannot be deleted! Here are the 2 objects:

But when I tried to delete them or the object definition i got.

And

So how do you delete the DRO’s if you can’t delete them? The fallback option is always IRB.

Run

# vmdb
# bin/rails c
irb> $evm = MiqAeMethodService::MiqAeService.new(MiqAeEngine::MiqAeWorkspaceRuntime.new)
irb> $evm.vmdb(:generic_object).where(:generic_object_definition => 99000000000001).each {|dro| dro.remove_from_vmdb}

The 99000000000001 is the dro’s object id.

If you need to delete only one definiton

 $evm.vmdb(:generic_object).where(:generic_object_definition => 99000000000002, :id => 99000000000205).each {|dro| dro.remove_from_vmdb}

 

Once executed you can validate in the UI that the DRO is gone.