methods/vf_common.rb
# Change VMware Fusion VM MAC address
Change VMware Fusion VM MAC address
Change VMware Fusion VM MAC address
def change_fusion_vm_mac(options)
  (fusion_vm_dir,fusion_vmx_file,fusion_disk_file) = check_fusion_vm_doesnt_exist(options)
  if not File.exist?(fusion_vmx_file)
    handle_output(options,"Warning:\t#{options['vmapp']} VM #{options['name']} does not exist ")
    quit(options)
  end
  copy=[]
  file=IO.readlines(fusion_vmx_file)
  file.each do |line|
    if line.match(/generatedAddress/)
      copy.push("ethernet0.address = \""+options['mac']+"\"\n")
    else
      if line.match(/ethernet0\.address/)
        copy.push("ethernet0.address = \""+options['mac']+"\"\n")
      else
        copy.push(line)
      end
    end
  end
  File.open(fusion_vmx_file,"w") {|file_data| file_data.puts copy}
  return
end
def change_fusion_vm_mac ( options ) ( fusion_vm_dir , fusion_vmx_file , fusion_disk_file ) = check_fusion_vm_doesnt_exist ( options ) if not File . exist? ( fusion_vmx_file ) handle_output ( options , "Warning:\t#{options['vmapp']} VM #{options['name']} does not exist " ) quit ( options ) end copy = [ ] file = IO . readlines ( fusion_vmx_file ) file . each do | line | if line . match ( / generatedAddress / ) copy . push ( "ethernet0.address = \"" + options [ 'mac' ] + "\"\n" ) else if line . match ( / ethernet0 \. address / ) copy . push ( "ethernet0.address = \"" + options [ 'mac' ] + "\"\n" ) else copy . push ( line ) end end end File . open ( fusion_vmx_file , "w" ) { | file_data | file_data . puts copy } return end
Change VMware Fusion VM MAC address
Change VMware Fusion VM MAC address
options
<not_specific>