How can I get the mac address in the postprovisiong


#1

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.


#2

try this:

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


#3

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

I thing that this method don’t exist!


#4

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.


#5

Here is something you can try.

prov = $evm.root[“miq_provision”]
$evm.log(:info, “Provision:<#{prov.id}> Request:<#{prov.miq_provision_request.id}> 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
end
log(:info, “Got vm: #{vm.name} from $evm.root[‘miq_provision’]”)


#6

@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!


#7

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

The get_option method is only exposed to miq_provision and miq_requests.


#8

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"