How can I get Customization Templates to work while using a Generic Service Catalog Item?


I’m trying to use a cloud-init script within the context of a Generic Service Catalog Item to set the root password for a VM.

<% # Global variables
    root_password = MiqPassword.decrypt(evm[:"password::dialog_root_password"]) %>
ssh_pwauth: True
disable_root: False
    list: |
    expire: False

When I associate a Customization Template with an OpenStack Service Catalog Item, the root password get populated as I expected.

How can I achieve the same effect in a Generic Service context?


I figured out how to do this by looking at a few sources. In a nutshell:

  1. I used a custom BuildRequest method (credit to @bhelgeson and @claudiol for introducing me to this method). In this method I do a duplication of the dialog-specific options from the Service Template Provision Task object as follows:

stp_task = $evm.root[“service_template_provision_task”]

duplicate all options from the dialog.

ws_options = stp_task.options[:dialog].dup
ws_values[:customization_template_id] = 1000000000001

build_request(template_options, vm_options, tag_options, ws_options)

2 . In my openstack_CustomizeRequest, I have the following code:

prov = $evm.root[“miq_provision”]
ws_values = prov.get_option(:ws_values)

Get customization template for cloud-init

customization_template = $evm.vmdb(:CustomizationTemplate).find(ws_values[:customization_template_id])

copy everything blind at first, customize later

ws_values.each { |k, v| prov.set_option(k, v) }

prov.set_customization_template(customization_template) rescue nil

Following the above steps allowed me to populate the customization template cloud-init script with values I entered in my service catalog dialog successfully.