How can I get the mac address in the postprovisiong

In the end of provisioning processes, where I can get the mac address? post provisioning?

I need that to send this information to the DHCP server.

try this:

vm = $evm.root[‘miq_provision’].vm
macaddresses = vm.mac_addresses

<code: mac_addr = vm.mac_addresses>:12:in <main>': undefined methodmac_addresses’ for nil:NilClass (NoMethodError)

I thing that this method don’t exist!

This error message is saying that you are calling a method on a nil object. If you are following the code sample provided that would mean $evm.root['miq_provision'].vm is returning nil instead of a VM object.

If provisioning was successful and you are running this in a post-provision state you should not have a nil object returned from that call.

Here is something you can try.

prov = $evm.root[“miq_provision”]
$evm.log(:info, “Provision:<#{}> Request:<#{}> Type:<#{prov.type}>”)

vm = prov.vm

if vm.nil?
$evm.log(:info, “Waiting 30 seconds for VM to appear”)
$evm.root[‘ae_result’] = ‘retry’
$evm.root[‘ae_retry_interval’] = 30.seconds
exit MIQ_OK
log(:info, “Got vm: #{} from $evm.root[‘miq_provision’]”)

@ramrexx, I tried everything, but never return the mac:

I tried your code, i tried something like that:

hardware = $evm.root[‘hardware’]
mac_addr = hardware.get_option(:mac_addresses)
$evm.log(“info”, “#{@method} - TESTE update_provision_status - MAC = <#{mac_addr}>”)

But nothing!

what is $evm.root[‘hardware’] ? What is your vmdb_object_type?

The get_option method is only exposed to miq_provision and miq_requests.

That’s was a little test, I’m losing my head…that what is happing when with work 12 hours with a problem!

I see that :mac_address can be recovered from “prov = $evm.root[“miq_provision”]” like the vm_name"