VM Name automation

Hello All,

I have a specific requirement for VM Naming. VM naming in my data center needs to happen as departmentnameXXXX. XXXX is a four digit code that is assigned in sequence, first VM is 0001, second is 0002 and so on. These are part of individual service catalog requests. I am only provisioning 1 VM per request and not as a bundle. I understand departmentname could come from a vm_prefix using vm_name=changeme in the service dialogue, i am not sure how i can achieve the XXXX.

As far as i understand $n{3} is for numbering of VM’s within the same request and does not span across multiple requests, so if i use this method i will have failed provisioning as name duplication will happen


You can get all vms curently registered and then take +1 on the last existing digit code.
vms = $evm.vmdb(‘vm’).all.each can get you all vms.