Get Tags Applied to Service Object in Post Provision

I am in CF 3.1. I have copied the redhat_PostProvision method to my own domain and I have verified that it is the one that is being called during the post provision process.

How can I access the tags that were applied to a catalog_item before it was provisioned? Using the InspectMe method on the Service Catalog Item object I can see the tags under the service_template attribute. However, I cannot actually access the service template object.

Through experimentation, I have found that I have access to $evm.root[‘miq_provision’] (and therefore the vm and everything it can access).

Is it possible to get the service_template object in post_provision? Is this the best way to get the tags associated with a catalog item after it is provisioned? Or is there a way to get the tags on a catalog item directly?


Instead of using redhat_PostProvision, would check_provisioned be the better route?

You would want to do this in post-provisioning. If you have an handle to the VM you can get to the service through 2 relationships:

  1. service - The top-level service if you are using Catalog Bundles, otherwise it is the service the VM is attached to.
  2. direct_service - The service the VM is attached to.

Then the service has a relationship to the catalog item through the service_template relationship.

The code would look something like this:

    prov = $evm.root['miq_provision']
    vm = prov.vm
    service = vm.direct_service
    service_template = service.service_template  

Hi there, thanks for the response. It doesn’t look like you can access the service_template from a service object?

I wasn’t able to figure out how to get the tags to a service in redhat_PostProvision.

However, I was able to get around this by changing the service dialog that is used to order the service. I changed it so that it had 2 elements that would tell me if the vm had provisioned using a certain service. This probably won’t work for everyone, but it worked in my case.

Hi, when I use Service Provisionning and I need to do some tagging I am using Post Provisionning step at Service Level and not VM level, you should connect your Provision Entry Point in your Catatog item to /ManageIQ/Service/Provisioning/StateMachines/ServiceProvision_Template/CatalogBundleInitialization and then you call a post method (post1) below, then you can call the method references above by Gregg.