Update the Custom Properties of a Machine
After deploying a machine, you can use the IaaS APIs to update the machine with custom properties. Custom properties provide you with the flexibility to add any information about the machine that you want.
For example, machine IDs are
typically autogenerated. By updating the custom properties, you can identify the machine
owner and include their contact email or phone information.
Prerequisites
- Verify that all general prerequisites and prerequisites for the Cloud Assembly Infrastructure as a Service (IaaS) service have been satisfied. See Prerequisites for API Use Case Examples.
- Verify that you have the ID of the virtual machine in your deployment. See Get Deployment Resource IDs.
Procedure
Example: Add a Custom Properties to Your Virtual Machine
Update the virtual machine with resource ID 42f49781-1490-4a08-ae21-8baf383a72ac by adding custom properties.
Assign variables.
Note: If
your organization uses an API service that is hosted outside of the United States,
your URL variable must include a country abbreviation. See Regional Endpoints for vRealize Automation Cloud APIs.
$ url='https://api.mgmt.cloud.vmware.com'
$ api_version='2021-07-15'
Assign the virtual machine ID.
$ virtual_machine_id='42f49781-1490-4a08-ae21-8baf383a72ac'
Update the machine with custom properties.
$ curl -X PATCH \ $url/iaas/api/machines/$virtual_machine_id?apiVersion=$api_version \ -H "Authorization: Bearer $access_token" \ -H 'Content-Type: application/json' \ -d '{ "customProperties": { "ownerName": "VMuser_Example", "ownerEmail": "[email protected]", "ownerCell": "123.456.7890" }, "description": "string", "tags": "[ { \"key\" : \"my.enumeration.type\", \"value\": \"ec2_instance\" } ]" }' | jq "."
A snippet of the response shows that the request was successful.
... "customProperties": { "ownerName": "VMuser_Example", "ownerEmail": "[email protected]", "ownerCell": "123.456.7890" "image": "ubuntu", "OStype": "LINUX", "imageId": "ami-b1234cc5", ... }, ...