How to set VM name based on Dialog

Hi, I am using CloudForms 4.6 and I have a bundle where I can provision a number of vms and install Services on it using Ansible Tower. The bundle is working fine now but the problem is that I was testing only with one provisioned vm. Now if I want to order more than one vm, I get that the vm name is already in use. I want to enter a vm name in the dialog where the vm name will be updated according on the number of vms set on that same dialog. For example, if I chose “D99MASTER” as the option_0_vm_name I want this name to be updated with the right prefix for each vm is getting provisioned according to option_0_number_of_vms: D99MASTER001, D99MASTER002, etc…

I have made the service template and I have put in the VM Name = “changeme”. It used to work just fine as a standalone service catalog, then even in the bundle or on a service catalog it doesn’t wanna work.
Can someone redirect me and guide me on how to solve this problem, I have tried manny solution suggested here but none of them worked for me, maybe I messed something …


Unfortunately this is a known frustration. There’s a BZ ( that describes the problem and this contains a link to some workaround code that one of the Red Hat consultants has developed.


@pemcg Thank you for your reply, I tried this but unfortunately it did not work for me, so I tried to work with the default naming class under /Infrastructure/VM/Provisioning/Naming and it seems to work but the problem is that it will always put the class field vm_prefix as I set it, it was cfme but then I have changed it to D99MASTER, and then I made a dialog input and named it vm_prefix but it doesn’t seem to override the default vm_prefix class field. It will always end up using D99MASTER. How can I fix this?

I think you have to remove the vm_prefix attribute from the instance for the options hash version to be used. From the naming method:

# Returns the name prefix (preferences model over dialog) or nil
def prefix
  @handle.object['vm_prefix'] || provision_object.get_option(:vm_prefix).to_s.strip

I have removed vm_prefix attribute from the Naming Class but now the vm name gets set to only 001 or 002, I did not make any changes for the method, should I specify something? because it seems to still not get the vm_prefix from the dialog

Try changing that line in the naming method to be:

@handle.object['vm_prefix'] || provision_object.get_option(:vm_prefix).to_s.strip || provision_object.get_option(:dialog_vm_prefix).to_s.strip

Sorry for the delay, I have changed it but with no luck.