Openstack service provision

I am currently trying build a catalogue item that provisions a machine via openstack.

I can provision a machine using the cloud/instances/Lifecycle route. And I am trying to build a service item from a template provisioning request.

It seems to me that as I am adjusting the specification of the machine based on the contents of the dialog then my customizations need to be made before the machine is automatically approved ( as the customizations can change the vm that is being requested )

I have created a new state machine with an openstack customization state. And I have started work on a piece of ruby that will process the request before it is approved.

I need to adjust the tenant from the template request for example and I need to instantiate the cloud provider. The following code looks reasonable:

request = $evm.root['miq_request']
source = request.source
service_resource = source.service_resources.first
resource = service_resource.resource
openstack = ExtManagementSystem.find(resource.options[:src_ems_id][0])

However in the automation method I get:

 ERROR -- : <AutomationEngine> Method STDERR: <code: openstack = ExtManagementSystem.find(resource.options[:src_ems_id][0])>:59:in `<main>': uninitialized constant ExtManagementSystem (NameError)

Am I correct in editing the provisioning request before the approval and if so what would be the correct way of getting at the object that represents the openstack system ?

Looking at some Redhat docs it implies that a method is to create a new provisioning request without using a template request however it leaves all of the emsCustomAttributes blank with no examples so that is less than useful.

Peter’s book is more useful, is this the recommended route. I think looking at things there is enough information in Peter’s book to get me going however it would be good to know I was heading in the right direction.

Could people clarify the correct approach for creating a service catalogue item for provisioning a machine.

ptavares_rh in talk.manageiq says that the way to access the openstack object is via:

openstack = $evm.vmdb("ext_management_system" ,resource.options[:src_ems_id][0])

It is worth noting that method calls of the returned object (openstack in this instance, for example openstack.cloud_tenants ) return arrays rather than an Active Record thing eg you would have to iterate though the array with an each rather than use find_by

I am going to put my current method for provisioning a machine to one side and try creating a new provisioning request.