The most common use case implemented with vRealize Automation is classic Infrastructure-as-a-Service for VMs. vRealize Automation has the concept of a Deployment that can contain multiple objects incl. network, security and multiple VMs. Although this is the target architecture most of our customers are planning to reach, for many of them their first use case is deployment of a single VM. VRealize Automation requires the “Deployment Name” as a mandatory field to fill and most of the consumers have challenges to put the right value. In this case where there is a 1:1 relationship between Deployment and VM, IT departments often would like to use the same name for Deployment as for the virtual machine for easier navigation. Often this should be enhanced by a time stamp or ID.
This is no OOTB functionality in vRealize Automation but it can be achieved by the following procedure.
Get RefreshToken from vRA
See the documentation here how to get a refresh token.
If you prefer using Postman, you can use below command to get the refresh token as well:
Create ABX Constant/Secret
CloudAssembly: Go to Extensibility à Actions à Action Constants
Create an Action Constant that contains the api RefreshToken from previous step:
Create ABX Action
Cloud Assembly: Go to Extensibility à Actions à New Action
Specify Action Name, assign it to the right project and create the action
Insert below code and modify the yellow marked part based on your environment details:
import requests
import json
def handler(context, inputs):
refreshtoken = context.getSecret(inputs["RefreshToken"])
vrahost = "vra801.space.local"
# Request Bearer Token
requesturl = "https://" + vrahost + "/iaas/api/login"
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
requestbody = {
'refreshToken': refreshtoken
}
response = requests.post(url=requesturl, data=json.dumps(requestbody),headers=headers,verify=False)
responseJson = response.json()
bearer = responseJson["token"]
print(bearer)
# Modify Depoyment Name
requesturl = "https://" + vrahost + "/deployment/api/deployments/" + inputs["deploymentId"]
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json',
'Authorization': 'Bearer ' + bearer
}
requestbody = {
'name': inputs["resourceNames"][0]
}
response = requests.patch(url=requesturl, data=json.dumps(requestbody),headers=headers,verify=False)
print(response.json())
Add action constant and dependency as shown in below screenshot:
Save the action.
Create Subscription
Follow below screenshots and save the subscription:
Feel free to enable it for all projects.
Modify custom form (optional)
When all processes described before are in place, the user will have to provide a deployment name on blueprint request. Whatever he puts in will automatically be overwritten. However, this might be confusing for the user as he doesn’t know which purpose this field is for and what he must enter.
Therefore, several customers decide to hide that field/make it read only and/or add a default value. This can be achieved by following modifications in custom forms:
Be aware that if a constant default value is set it will prevent multiple requests for the same blueprint until the rewrite of the deployment name has happened. You might want to use an external source/Orchestrator Action instead. The Orchestrator Action could dynamically populate the default value and make sure that it is unique per request – e.g. by adding an ID or timestamp. I’ll not cover the related workflow in this blog post.
Have fun!
- Custom Azure Private Endpoint Service for SQL in Aria Automation - 15. December 2022
- Custom categories with ServiceNow Plugin and Aria Automation - 29. November 2022
- Configure roles in Cloud Extensibility Proxy (vRO 8.x) - 1. August 2022
Hi Christian,
thank you for the post, thats a good way to archive the same computername and deploymentname.
But wouldn’t it be easier to make the Computername to the Deploymentname? So you don’t need the Action, only the Custom Form.
Br, Robert
Hi Robert,
thanks for the feedback!
Many customers do want to define their computer name by other means (e.g. external sources), so in my opinion it’s more efficient to set deployment name based on computername.
Also deployment name can contain e.g. spaces which would need to be taken care of.
Anyway there’s multiple ways achieving the goal. This blog shows what I have seen at customers so far.
Regards,
Christian