How to Change Lease to Infinite(Never Expire) in VRA
search cancel

How to Change Lease to Infinite(Never Expire) in VRA

book

Article ID: 306250

calendar_today

Updated On:

Products

VMware Aria Suite

Issue/Introduction

This article provides the steps to change the lease the Infinite(Never Expire) in vRA.

Environment

VMware vRealize Automation 7.x

Resolution

Setting Lease to infinite (Never Expire):
Do not set any Min and Max lease while designing blue print from Design Tab. Your provisioned Deployment and machines wont have any lease set.

To Change lease to infinite (Never Expire):

Workaround For Future Requests (New blue print Requests):

Edit blueprint by navigating to Design > Blue print > Edit
Leave Lease ( days): Minimum and Maximum as Empty.
Click OK to save the changes.

Workaround For Existing Not Expired Resources:

Note : Please take a DB backup before running any of the scripts in case you would want to revert it later.

In vRA 7.x, changing the setting from BP won't affect the existing deployments, which is different from 6.x.
In vRA 7.x, each deployment is backed up by snapshot blueprint, i.e. it won't associated with the live/master BP, so that any change to the live/master BP is free to be re-edit for the future use.

To update the lease of the existing resources (deployments and machines) to infinite. Run the following DB update script to set the lease as infinite.

This script updates the following tables:
Postgres DB : catalog and composition tables
IAAS Mysql DB : VirtualMachine table

Steps to run DB script to update lease in Postgres Database:
  1. ssh to VA : ssh root@VA
  2. VA:~ # psql -U postgres
  3. postgres=# \connect vcac; You are now connected to database "vcac" as user "postgres". vcac=#
  4. Query to get count of all resources where lease_end_date is not infinite (will get count of all resources where lease_end_date is not infinite)
vcac=#select count(*) from cat_resource where lease_end_date IS NOT NULL;   OR
 
Query to get count of resources where lease_end_date is not infinite and they have a specific name (will get count of only resources that match the name)
select count(*) from cat_resource where lease_end_date IS NOT NULL AND name = 'test-VM';
  1. Update DB to set all resources lease_end_date to infinite(never expire)
vcac=# update cat_resource set lease_end_date = NULL WHERE lease_end_date IS NOT NULL
             OR
 Update DB to set lease_end_date to infinite(never expire) for only the resources that match the name criteria.

UPDATE cat_resource
SET lease_end_date = NULL
WHERE lease_end_date IS NOT NULL AND name = 'test-VM';

UPDATE cat_resource
SET lease_end_date = NULL
WHERE lease_end_date IS NOT NULL AND name = 'Small-Tools copy-74193669';

The number of rows updated should be same as the number returned in Step (4) for corresponding queries.

This will be reflected in the UI with Expires and Destroy On set to 'Never' and lease Enforcement will not be triggered.

Now you wont be able to change the lease on these updated resources from UI. Please use Expire / Destroy to destroy these resources.

Do not use 'Change Lease' as it will give a validation error if you change lease beyond the min/max range of the original BP snapshot. The Error will look something like below :
"The data specified within the request is invalid. The new expiration date cannot be later than the latest expiration date permitted by the blueprint: Thu May 17 17:58:27 UTC 2018."

Thus once the lease_end_date is set to NULL. Use Destroy/Expire actions.
  1. Remote Desktop to IAAS MySQL Database to update IAAS DB Table
UPDATE dbo.VirtualMachine
SET Expires = NULL
WHERE Expires IS NOT NULL
AND VirtualMachineName = 's7146';