vRO Locking System

Use Case Scenario:

Environment having issues to deploy multiple machines (2 or more instances <or> multi deployments within short period of time), which was due to duplicated machine Hostnames (custom).

Although the failure was rather critical, solution was very simple just utilizing the #vRO SystemLocking feature within the pre-building workflow.

Direct to the point >>

You may need some of the following codes:

LockingSystem.lock(lockid, owner)
LockingSystem.lockAndWait(lockid, owner);
LockingSystem.unlock(lockid, owner);

If you know what to do, that’s it! 🙂

However, If you are asking about WHAT & WHY, just take a look in my friend Christiaan Roeleveld @vChrisR blog’s ( vCO LockingSystem ) all the concepts are explained there!

Hereby more details for this implementation

Add vRO Locking at begin for what would you like to prevent duplicates (workflow / action / wherever you need)…

vRO Locking System

//Locking System for Hostname Generation ( Avoiding duplicated names)

var lockid = workflow.name
var owner = workflow.id
var lock = false

System.log("lockid " + lockid)
System.log("owner " + owner)

while (lock == false){
	var lock = LockingSystem.lock(lockid, owner);
	//var lockCreated = LockingSystem.lockAndWait(lockid, owner);
	System.log("Trying to lock system for : " + lockid + " Status: -> "+ lock );
	//System Sleep in case extra workflows are releasing locks
//System got locked - Ready for execution
	System.log("System locked for : " + lockid + " Status: -> "+ lock );

*ps: I have added a small loop in order to see the logs when the system is still locked by the previous workflow, you may use the “LockingSystem.lockAndWait” which has same effect, but no output.

vRO Unlocking System

(@End of Execution and @end of Error Logging)

//unlocking System from Hostname Generation lock
LockingSystem.unlock(lockid, owner);
System.log("System got unlocked via exception + ID: " + lockid);

*ps: Don’t forget to unlock at end of your workflow/ action /etc & also @end of your error handling too, in case workflow fails, you won’t get locked.

If needed, just use this command to “Unlock ALL” your locked items, or just execute the one with parameters above.


Enjoy this little POST and I am always glad to have you here…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s