{"id":2401,"date":"2018-04-08T18:00:42","date_gmt":"2018-04-08T22:00:42","guid":{"rendered":"http:\/\/blog.domb.net\/?p=2401"},"modified":"2018-05-08T11:07:16","modified_gmt":"2018-05-08T15:07:16","slug":"delete-dynamic-resource-object-form-cloudforms","status":"publish","type":"post","link":"https:\/\/blog.domb.net\/?p=2401","title":{"rendered":"Delete Dynamic Resource Object form CloudForms"},"content":{"rendered":"<p>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.<\/p>\n<p>I had the following Dynamic Resource Object Definition:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2402\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2018-04-08-at-8.15.10-AM.png\" alt=\"\" width=\"928\" height=\"743\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2018-04-08-at-8.15.10-AM.png 928w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2018-04-08-at-8.15.10-AM-300x240.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2018-04-08-at-8.15.10-AM-768x615.png 768w\" sizes=\"auto, (max-width: 928px) 100vw, 928px\" \/><\/p>\n<p>&nbsp;<\/p>\n<p>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\u00a0object definition. If you have 2 instances in the DRO definition it cannot be deleted! Here are the 2 objects:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2403\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2018-04-08-at-8.15.20-AM.png\" alt=\"\" width=\"1450\" height=\"210\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2018-04-08-at-8.15.20-AM.png 1450w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2018-04-08-at-8.15.20-AM-300x43.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2018-04-08-at-8.15.20-AM-768x111.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2018-04-08-at-8.15.20-AM-1024x148.png 1024w\" sizes=\"auto, (max-width: 1450px) 100vw, 1450px\" \/><\/p>\n<p>But when I tried to delete them or the object definition i got.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2404\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2018-04-07-at-7.56.26-PM.png\" alt=\"\" width=\"604\" height=\"278\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2018-04-07-at-7.56.26-PM.png 604w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2018-04-07-at-7.56.26-PM-300x138.png 300w\" sizes=\"auto, (max-width: 604px) 100vw, 604px\" \/><\/p>\n<p>And<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-2405\" src=\"http:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2018-04-07-at-7.56.34-PM.png\" alt=\"\" width=\"1289\" height=\"233\" srcset=\"https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2018-04-07-at-7.56.34-PM.png 1289w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2018-04-07-at-7.56.34-PM-300x54.png 300w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2018-04-07-at-7.56.34-PM-768x139.png 768w, https:\/\/blog.domb.net\/wp-content\/uploads\/Screen-Shot-2018-04-07-at-7.56.34-PM-1024x185.png 1024w\" sizes=\"auto, (max-width: 1289px) 100vw, 1289px\" \/><\/p>\n<p>So how do you delete the DRO&#8217;s if you can&#8217;t delete them? The fallback option is always IRB.<\/p>\n<p>Run<\/p>\n<pre class=\"lang:default decode:true\"># vmdb\r\n# bin\/rails c\r\nirb&gt; $evm = MiqAeMethodService::MiqAeService.new(MiqAeEngine::MiqAeWorkspaceRuntime.new)\r\nirb&gt; $evm.vmdb(:generic_object).where(:generic_object_definition =&gt; 99000000000001).each {|dro| dro.remove_from_vmdb}<\/pre>\n<p>The\u00a099000000000001 is the dro&#8217;s object id.<\/p>\n<p>If you need to delete only one definiton<\/p>\n<pre class=\"lang:default decode:true \"> $evm.vmdb(:generic_object).where(:generic_object_definition =&gt; 99000000000002, :id =&gt; 99000000000205).each {|dro| dro.remove_from_vmdb}<\/pre>\n<p>&nbsp;<\/p>\n<p>Once executed\u00a0you can validate in the UI that the DRO is gone.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>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: &nbsp; As you can see I have 2 instances. How do you delete these instances? With both the API calls as well&#8230;<\/p>\n","protected":false},"author":2,"featured_media":2048,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_themeisle_gutenberg_block_has_review":false,"footnotes":""},"categories":[37],"tags":[29,146],"class_list":["post-2401","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-cloudforms","tag-cloudforms","tag-dynamic-resource-objects"],"_links":{"self":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/2401","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2401"}],"version-history":[{"count":2,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/2401\/revisions"}],"predecessor-version":[{"id":2434,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/posts\/2401\/revisions\/2434"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=\/wp\/v2\/media\/2048"}],"wp:attachment":[{"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2401"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2401"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.domb.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2401"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}