3 Replies Latest reply on Dec 20, 2018 3:40 AM by Czernobog

    vRA 7.4 - trigger vRO workflow on VM Reprovision, but not on Destroy action

    Czernobog Hot Shot

      I want to build a service, that is triggered after a vSphere VM is destroyed. When VM Destroy is executed, I need a vRO workflow to run. The parameter values are passed using the Extensibility.Lifecycle.Properties.VMPSMasterWorklow32.Disposing property and an event subscription. However, this event subscription is triggered also, when a server is reprovisioned, since both the Disposing and Provisioning events take place. I could not find a Workflow Subscription Condition that references a reprovision action.

      What I want to achieve:

      - User executes VM Destroy action: trigger vRO Workflow

      - User executes VM Reprovision action: vRO Workflow is not triggered

      How can this be done, if at all?

        • 1. Re: vRA 7.4 - trigger vRO workflow on VM Reprovision, but not on Destroy action
          daphnissov Guru
          vExpertCommunity Warriors

          Reprovision is an action unlike a destroy, so you want to listen for VMPSMasterWorkflow32.Active.EVENT.onReprovision. Then you can write a custom property out to the payload that doesn't trigger your destroy. Look at this thread as an example.

          • 2. Re: vRA 7.4 - trigger vRO workflow on VM Reprovision, but not on Destroy action
            Czernobog Hot Shot

            My main issue is how to find the event, I've already checked the event broker but connot find the correct lifecycle event. Here's what I have available:

            • 3. Re: vRA 7.4 - trigger vRO workflow on VM Reprovision, but not on Destroy action
              Czernobog Hot Shot

              Sorry for the late edit, but there is still one issue I somehow cannot resolve.

              So on one side I have the Active event subscriptions, on the other the lifecycle subscriptions.

              What I want to achieve is, to run a workflow when the VM is disposed but not, when the disposing takes place as a result of reprovisioning. Following conditions have to be included in the event subscriptions as a result:

               

              topic ID: com.vmware.csp.iaas.blueprint.service.machine.lifecycle.provision

               

              All of the following

              Data > Lifecycle state > Lifecycle state name     Equals     VMPSMasterWorkflow32.Disposing

              Data > Lifecycle state > State phase     Equals     PRE

              Data > Machine > Machine type     Equals     Virtual Machine

              *a condition that says to NOT trigger the sub when reprovisioning takes place shoud go here*

               

              How can I build an event subscription based on this condition?

              AFAIK you cannot mix both needed topics: check for active events (com.vmware.csp.iaas.blueprint.service.machine.lifecycle.active)

              and check provisioning state (com.vmware.csp.iaas.blueprint.service.machine.lifecycle.provision).

               

              edit: while thinking about the above setup it came to my mind, that I would also need to separate the onProvision trigger from triggering workflows with the VMPSMasterWorkflow32.MachineProvisioned state. Since a new machine is provisioned in course of the reprovisioning action, the provisioning state is triggered too and as a result the day-2 operations run again. However, I do not want to run some of those in case of a reprovisioning action and to achieve this I would need to somehow tell the triggered workflow, that this provisioning state is triggered by a reprovisioning action.

              I think the easiest way to reach my goal is to just create a separate subscription for the reprovisioning event and have it write a custom property to the vm, like myOrg.vmIsBeingReprovisioned = true and query this property during workflow runs when a vm is provisioned or disposed.