Associate VM with generic service catalogue item

Hi everyone,

Recently I’ve been using some generic service catalogue items for provisioning OpenStack instances. However, once provisioned, the VM is not associated with the service request.

ie; the following returns an empty array:
$evm.vmdb(:service).find_by_id(<id_of_provisioning_service_object).vms.inspect

I’m using the $evm.execute('create_provision_request', *args) method to provision from my generic service catalogue item.

I thought I could be able to do this during my openstack_PostProvision method, using the following logic:

  • Get the root provisioning object (prov = $evm.root[‘miq_provision’])
  • Get the root MiqAeServiceService object (service = $evm.root[‘service’]
  • Get the VM associated with the provisioning object (vm = prov.vm)
  • Set the VM to the MiqAeServiceService (?)

Looking at the MiqAeServiceService object, it exposes direct_vms, indirect_vms and vms, however there is no method to update these. The ManageIQ source for the MiqAeServiceService object substantiates this: https://github.com/ManageIQ/manageiq/blob/master/lib/miq_automation_engine/service_models/miq_ae_service_service.rb

So, my question is - does anyone know how to associate VMs created from a generic service catalogue item with the underlying service object?

Shane

Hi @jockey10,

There is a method add_to_service on the VM:

The automate method is here:
https://github.com/ManageIQ/manageiq/blob/master/lib/miq_automation_engine/service_models/miq_ae_service_vm.rb#L3

Awesome, thanks @gmccullough!