How to include vm ip in VM provisioning emails

automate

#1

Hi everyone, I’m trying to pass an ip address from dialog to be passed on to the miq_provision_complete. The vm ip is set into the dialog with option_5_param_vm_ip name. I have tried many combination to get the ip show up in the email but it’s position always shows up blank. I have tried to set into a variable like:
vmip = $evm.root['dialog_option_5_param_vm_ip']
and call it as shown bellow:

body += "<br><br>You can access and manage your virtual machine <#{vmip}> ....(default part of the method) "

and also with:
#{vmip}
<#{vm.ipaddresses.first}>
#{vm.ipaddresses.first}
<#{vm['ipaddresses'].first}>
#{vm['ipaddresses'].first}

but it always either show up blank or just the <> in the email.


#2

Maybe try something like one of these, may or may not work for you.

prov = $evm.root['miq_provision_request'] || \
        $evm.root['miq_provision'] || \
        $evm.root['miq_provision_request_template']

ip_address = prov.destination.ipaddresses[0]  # Get IP from VM
ip_address = prov.get_option(:dialog_option_5_param_vm_ip)  # Get IP from dialog

#3

@enosullivan Thank you for your reply, I really appreciate it. I have tried your proposed solution but unfortunately it did not work for me.
is putting this way correct

body += "<br><br>If you are not already logged in, you can access your virtual machine with ip address: <#{ip_address2}> or <#{ip_address1}> and manage your virtual machine here <a href='https://#{appliance}/vm_or_template/show/#{vm['id']}'>https://#{appliance}/vm_or_template/show/#{vm['id']}'</a>"

and when I accessed the vm details in Cloudforms there was no Hostname nor ip address. Can it be a problem? and also why I couldn’t pass the dialog inputs?


#4

For the hostname and IP address to be visible in CloudForms, the VM needs to be powered on, and the platform tools must be installed and running (such as VMware Tools or the oVirt guest agent).

pemcg


#5

Thank you for your reply, the VM is powered on and oVirt guest agent is also installed but I still can’t get the IP Address to show up in the emails.