methods/vf_common.rb
# Change VMware Fusion VM network type
Change VMware Fusion VM network type
Change VMware Fusion VM network type
def change_fusion_vm_network(options,client_network)
  if options['host-os-name'].to_s.match(/Linux/)
    fusion_vm_dir = options['fusiondir']+"/"+options['name']
  else
    fusion_vm_dir = options['fusiondir']+"/"+options['name']+".vmwarevm"
  end
  fusion_vmx_file  = fusion_vm_dir+"/"+options['name']+".vmx"
  test = 0
  copy = []
  file = IO.readlines(fusion_vmx_file)
  file.each do |line|
    if line.match(/ethernet0\.connectionType/)
      if not line.match(/#{client_network}/)
        test = 1
        copy.push("ethernet0.connectionType = \""+client_network+"\"\n")
      else
        copy.push(line)
      end
    else
      copy.push(line)
    end
  end
  if test == 1
    File.open(fusion_vmx_file,"w") {|file_data| file_data.puts copy}
  end
  return
end
def change_fusion_vm_network ( options , client_network ) if options [ 'host-os-name' ] . to_s . match ( / Linux / ) fusion_vm_dir = options [ 'fusiondir' ] + "/" + options [ 'name' ] else fusion_vm_dir = options [ 'fusiondir' ] + "/" + options [ 'name' ] + ".vmwarevm" end fusion_vmx_file = fusion_vm_dir + "/" + options [ 'name' ] + ".vmx" test = 0 copy = [ ] file = IO . readlines ( fusion_vmx_file ) file . each do | line | if line . match ( / ethernet0 \. connectionType / ) if not line . match ( / #{ client_network } / ) test = 1 copy . push ( "ethernet0.connectionType = \"" + client_network + "\"\n" ) else copy . push ( line ) end else copy . push ( line ) end end if test == 1 File . open ( fusion_vmx_file , "w" ) { | file_data | file_data . puts copy } end return end
Change VMware Fusion VM network type
Change VMware Fusion VM network type
options
<not_specific>
client_network
<not_specific>