Provision VM with a specific template


I want to deploy a VM from a catalog using a specific template.
I have a drop-down list that lists my templates but I can’t overwrite the default one in the catalog.

In my dialog, i use the Name “customization_template_id”

My method :

     vm_template = {}

     vm_template['!'] = '-- select from list --'
     $evm.vmdb(:vm_or_template).where(:template => true).each do |vm|
           vm_template[] =
     list_values = {
     'sort_by'    => :value,
     'data_type'  => :integer,
     'required'   => true,
     'values'     => vm_template
     list_values.each { |key, value| $evm.object[key] = value }

     rescue => err
     $evm.log(:error, "[#{err}]\n#{err.backtrace.join("\n")}")
     exit MIQ_STOP

In my vmware_PreProvision i got this :

    #`Get information from the template platform
   template = prov.vm_template
   ems = template.ext_management_system
   product  = template.operating_system['product_name'].downcase
   bitness = template.operating_system['bitness']
   log(:info, "Template:<#{}> Provider:<#{}> Vendor:<# 
   {template.vendor}> Product:<#{product}> Bitness:<#{bitness}>")

Can you help me ?

Thank you

Hi there @Alsta

Unfortunately the template is fairly fundamental to the catalog item definition and is “baked in” when you create a catalog item. This can’t be changed once the service catalog item is created.

If you need to be able to select a template at catalog order time then the only way is to create a ‘Generic’ catalog item type and use the service dialog to collect and assemble the parameters for a call to $evm.execute(‘create_provision_request’). There are some examples around of how to do this, but it’s not that trivial.

@jcutter has a useful helper method called build_vm_provision_request.rb in his repo here

An easier option is to create multiple service catalog items, one for each template that you want your users to be able to provision from.

Hope this helps,