VMware Cloud Community
jinhoe
Enthusiast
Enthusiast
Jump to solution

Get vRO parameters upon deployment deletion

Hi guys, I've a vRO workflow to create AD user and deploy it in Service Broker. When I delete that deployment, I want the user to be deleted as well.

I'm using subscription to trigger another vRO workflow (delete user), but I can't get back the parameters (e.g. accountName) from the first workflow (create user). Not with inputProperties too.

I would like to know how can I retrieve those parameters so I can use it to run vRO workflow (delete user).

Or I can somehow use deploymentId to retrieve those parameters from vRO Workflow Runs instead.

Please advice, thanks!

Reply
0 Kudos
2 Solutions

Accepted Solutions
eoinbyrne
Expert
Expert
Jump to solution

OK, I get it now. 

In my setup, the event for deployment.action.pre doesn't seem to fire, but I *do* get the deployment.resource.action.pre event for the resource delete. This event has the ID of the parent deployment on it so you can use the API to get the Deployment content which will have the original inputs on it

Here's what my lab setup shows for parent deployment content

eoinbyrne_0-1686227824259.png

 

So, this should work 

 

Also, @xian_ has added a brilliant worked example of everything you need here

View solution in original post

7 Replies
eoinbyrne
Expert
Expert
Jump to solution

Hi

Do I understand correctly, you expect the delete workflow to be able to recover the input parameters of the original create workflow? While this would technically be possible it should not be necessary IMO.

What you need to do is setup an Event Subscription for the Deployment Delete event and this will have the details of the resource being deleted which should contain enough info to resolve the account to be deleted?

Here's the event content for a CustomResource I deleted recently in our lab

eoinbyrne_0-1686144355302.png

You can see under the resourceName field which resource it was. In your case, this should be a value you can use to search for the account in the ADHost?

 

Reply
0 Kudos
jinhoe
Enthusiast
Enthusiast
Jump to solution

@eoinbyrne, you understood me correctly.

I can't find Deployment Delete event. What I'm using is Deployment requested (deployment.request.pre) for the Event Subscription. As you see in the screenshot below (red box), there is nothing in the requestInputs (Input parameters of the original create workflow).

I noticed in your screenshot, the requestInputs seems to be empty as well. Also my deployment is directly from a vRO workflow and yours looks like a Cloud Template deployment, not sure if there is any different.

Could you share with me which Event Subscription you are using? Maybe I can test it out?

Screenshot 2023-06-08 at 9.33.44 AM.png

Reply
0 Kudos
eoinbyrne
Expert
Expert
Jump to solution

Can I ask a couple of questions as I think I don't get how your setup is working.

How is the create workflow triggered & how are the inputs for it specified? 

For the event you've selected - this will be fired BEFORE a Deployment is created? What are the resource contents of the Deployment when it is created?

eoinbyrne_0-1686214861448.png

The event you want for catching the deployment deletion is this one - Delete is a Day-2 action on a deployment

eoinbyrne_1-1686214998827.png

Assuming your Deployment has a record of the resource corresponding to the AD:User it's possible to use the deploymentId in the Event content to locate the target deployment (via REST API call). Once you have the Deployment data, it *should* be possible to get

- The resource entry representing the user account (if such a thing exists in your setup)

OR

- The input specified at Deployment create time which was used for the user account

Here's the schema model for the Deployment type on the API docs (you can see this on 

https://<vra-fqdn>/automation-ui/api-docs then open the Deployment / Deployments page & look for GET Deployment by ID)

eoinbyrne_2-1686215381300.png

 

jinhoe
Enthusiast
Enthusiast
Jump to solution

1. The first vRO workflow is trigger via Service Broker

1a. User enters AD username, password, roles, number of users, etc. (This is the input) Then the first vRO workflow will run a script that creates multiple AD user accounts.

2. The second vRO workflow is triggered when user deletes the deployment in Service Broker.

2a. This is when the "Deployment requested" subscription gets fired BEFORE the deployment gets deleted.

2b. Rightfully the second vRO workflow is suppose to delete all users that was created in the first workflow, but now I can't because there isn't any parameters (AD usernames) to do that.

My inital workflow uses Cloud Template for user creation, but I converted it to vRO as the multiple users creation requires some complex logic. I might revisit the idea of using custom resources in order to use Delete- Day -2 action. Else using DeploymentID (via REST API call) might be the next option.

Reply
0 Kudos
eoinbyrne
Expert
Expert
Jump to solution

OK, I get it now. 

In my setup, the event for deployment.action.pre doesn't seem to fire, but I *do* get the deployment.resource.action.pre event for the resource delete. This event has the ID of the parent deployment on it so you can use the API to get the Deployment content which will have the original inputs on it

Here's what my lab setup shows for parent deployment content

eoinbyrne_0-1686227824259.png

 

So, this should work 

 

Also, @xian_ has added a brilliant worked example of everything you need here

jinhoe
Enthusiast
Enthusiast
Jump to solution

@eoinbyrne  @xian_ Thank you guys! Managed to get it the parameters using deploymentId method! Awesome!

Reply
0 Kudos