Overriding Service Template VM Template?


#1

Following the Cloudforms book, I am creating a service catalog item for VMware provisioning and then overriding some of the values through dialog values (i.e. src_vm_id, placement_ds_name, etc.) and then setting the customization spec selected by a dialog item. However when trying to provision a VM from a template with an OS different from that of my catalog item template, I am returned the following error:

Service Provision Error: Server [EVM] Service [Custom-20181123-042243] Step [checkprovisioned] Status [Error Creating Service] Message [[MiqException::MiqProvisionError]: Customization Specification [42] for OS type [Linux] does not match the template VM OS]

I’ve debugged this enough to identify that this happens when I pick a Windows template through my dialog but have a Linux template as the value in the Service Catalog item. Running the object walker, I can see that source.platform is equal to Linux when it should be Windows. The code that outputs the error is here:

If I pick any Windows template, the provisioning process is able to follow through. If I change the service catalog item to a Linux one, then I can only provision Linux templates.

How do I go about changing the default catalog item template value and/or source.platform to be the appropriate one?


Windows/CentOS VM provisioning using VMware cspec/template
#2

This is the use case for a Generic Catalog. Once you change the catalog backing template you may as well do the entire request.
I haven’t tested myself but do you have “guid” for the name value field of your template selection dialog?
If that doesn’t work I think you can to go to Service CatalogItemInitialization and change the guid value there. (or i guess any of the vmware pre-provision scripts also)


#3

After taking a look at @task.source since it contains all of the service dialog items, including the default source VM, I noticed a field called :sysprep_custom_spec that contained the default customization spec. I was able to override this with my dialog item, and the provisioning continued successfully.

I’d be interested to figure out how this is done via a generic catalog item at some point. There’s very little guidance out there on how to configure a generic catalog item into a VMware-like one.


#4

The original book had a description of generic services, but the example was very dependent on Kevin’s upstream code samples so I removed it from subsequent versions:

https://pemcg.gitbooks.io/introduction-to-cloudforms-automation/content/chapter17/custom_state_machines.html

pemcg


#5

Hi xyker,

The problem you describe occurs because you ran in a situation where you selected a VM template with a windows os and and a vmware customization specification for linux. If you deploy a windows vm template, you need to make sure that you select a windows customization specification template.

The vm template is set, e.g. via “guid”
The customization specification is set via “sysprep_custom_spec”

Getting the vm template and customization specification right manually is not an easy task.

It boils down to the concept of how manageiq (pre-)processes provisioning requests. You can have a look at the following documentation:

https://pemcg.gitbooks.io/mastering-automation-in-cloudforms-4-2-and-manage/content/creating_provisioning_requests_programmatically/chapter.html
http://manageiq.org/docs/reference/latest/api/appendices/provision_attributes.html
http://manageiq.org/docs/reference/latest/doc-Methods_Available_for_Automation/miq/