<?xml version="1.0" encoding="UTF-8" standalone="yes"?><oembed><version><![CDATA[1.0]]></version><provider_name><![CDATA[CloudForms Now]]></provider_name><provider_url><![CDATA[http://cloudformsblog.redhat.com]]></provider_url><author_name><![CDATA[johnhardy36]]></author_name><author_url><![CDATA[https://cloudformsblog.redhat.com/author/johnhardy36/]]></author_url><title><![CDATA[Delete Template from Disk&nbsp;(RHEV)]]></title><type><![CDATA[link]]></type><html><![CDATA[<p>You want to delete a Template in RHEV from the CloudFORMS UI, but how?</p>
<p>This is easy, because the ReST API&#8217;s are so lovely in RHEV. Here is how;</p>
<p>Create a custom button that will execute your method, remember this is for <strong>VM Template</strong> and not just <strong>VM</strong>.</p>
<p>Now create the Automate parts, (if you need assistance on the general wiring of automate, <a href="http://cloudformsnow.com/2013/05/08/create-template-from-vm-rhev/">try here first)</a><!--more--></p>
<ol>
<li>Instance for button to call.</li>
<li>Button instance link to your automate instance (system/request/buttoninstance &#8211;&gt; sample/methods/delete_template)</li>
<li>create your delete_template instance and method.</li>
<li>The method code is as follows;</li>
</ol>
<pre class="brush: ruby; title: ; notranslate" title="">&lt;/pre&gt;
#

#            Automate Method

#

$evm.log(&quot;info&quot;, &quot;Automate Method Started&quot;)

#

#            Method Code Goes here

#

#!/usr/bin/ruby

require 'rubygems'

require 'rest_client'

vm = $evm.root['vm']

ext_management_system = vm.ext_management_system

$evm.log(&quot;info&quot;, &quot;Template Name - #{vm.name}&quot;)

$evm.log(&quot;info&quot;, &quot;Template UID - #{vm.uid_ems}&quot;)

$evm.log(&quot;info&quot;, &quot;RHEVM Name - #{ext_management_system.name}&quot;)

rhevm = &quot;https://#{ext_management_system.ipaddress}/api/templates&quot;

rhevadmin = 'admin@internal'

rhevadminpass = 'monster'

resource = RestClient::Resource.new(rhevm, :user =&gt; rhevadmin, :password =&gt; rhevadminpass)

deleteTemplate = resource.delete

$evm.log(&quot;info&quot;, &quot;Result - #{deleteTemplate}&quot;)

#

#

#

$evm.log(&quot;info&quot;, &quot;Automate Method Ended&quot;)

exit MIQ_OK
&lt;pre&gt;
</pre>
<p>And the method code you can get here&#8230;.<a href="https://github.com/jonnyfiveiq/CloudFORMSNOW/blob/master/RHEV/Templates/deleteTemplate.rb">https://github.com/jonnyfiveiq/CloudFORMSNOW/blob/master/RHEV/Templates/deleteTemplate.rb</a></p>
<p>You may want to add a dialog to confirm the action, for this POC it was not required though I think its a good idea, even get the administrator to confirm there name so we have some trace to the action.</p>
<h3>Credit</h3>
<p><strong>Matteo Bernacchi</strong> &#8211; We do like these ReST API&#8217;s for RHEV!</p>
]]></html><thumbnail_url><![CDATA[https://i1.wp.com/s2.wp.com/wp-content/themes/vip/rh-parent/img/og_shadowman.png?ssl=1&fit=440%2C330]]></thumbnail_url><thumbnail_width><![CDATA[200]]></thumbnail_width><thumbnail_height><![CDATA[200]]></thumbnail_height></oembed>