Automation

 View Only
  • 1.  How to add a VMXNET3 adapter

    Posted Jun 30, 2009 01:37 PM

    I' m exploring the helpfile from PowerCLI and can't find the VMXNET3 setting.

    Type

    Specifies the type of the network adapter to create. The valid types are

    e1000, Flexible, Vmxnet, EnhancedVmxnet. If the parameter is not specified, the

    network adapter is created of the type recommended by VMware for the given guest

    OS.

    false

    false

    Did anyone succeed adding the VMXNET3 adapter using PowerCLI?



  • 2.  RE: How to add a VMXNET3 adapter

    Posted Jul 01, 2009 11:37 AM

    did you try using the EnhancedVmxnet type?

    http://www.vmwareadmins.com

    http://www.vmwarescripting.com



  • 3.  RE: How to add a VMXNET3 adapter

    Posted Jul 01, 2009 11:43 AM

    Yes I did, It will add the Enhanced VMX2 adapter :smileysad:



  • 4.  RE: How to add a VMXNET3 adapter

    Broadcom Employee
    Posted Jul 02, 2009 03:18 PM

    This is an interesting question. My first thought was to make sure you had a VM running virtual HW version 7, but I tried it with the same results.

    So, I also started messing around with it to see if I could figure out how ESX is determining the adapter types. In the following output, adapter 1 is the Flexible type, followed by a VMXNET 3, a VMXNET and an Enhanced VMXNET. (I added the VMXNET3 using the GUI) As you can see, all of the VMXNET adapters show up as 'Vmxnet', meaning that there is somewhere else the type is stored.

    [vSphere PowerCLI] C:\> get-vm test | Get-NetworkAdapter | select Name,Type,MacAddress
    
    Name                                             Type MacAddress
    ----                                             ---- ----------
    Network adapter 1                            Flexible 00:50:56:90:01:f9
    Network adapter 2                              Vmxnet 00:0c:29:a9:05:b2
    Network adapter 3                              Vmxnet 00:0c:29:a9:05:bc
    Network adapter 4                              Vmxnet 00:0c:29:a9:05:c6
    

    I get the following error when I try to add the adapter

    [vSphere PowerCLI] C:\> $nic =  New-NetworkAdapter -NetworkName "VM Network" -vm $t -Type "VMXNET 3"
    New-NetworkAdapter : Cannot bind parameter 'Type'. Cannot convert value "VMXNET 3" to type 
    "VMware.VimAutomation.Types.VirtualNetworkAdapterType" due to invalid enumeration values. 
    Specify one of the following enumeration values and try again. 
    The possible enumeration values are "Unknown, e1000, Flexible, Vmxnet, EnhancedVmxnet".
    

    My guess is that the enumeration type that is being used by the New-NetworkAdapter cmdlet needs to be updated to support the new type of adapter so that all of the appropriate bits get flipped in the correct places.

    Is Carter Shanklin around? :smileyhappy:

    For completeness, I grabbed the .vmx file lines for the above VM

    ethernet0.addressType = "vpx"
    ethernet0.generatedAddress = "00:50:56:90:01:f9"
    ethernet0.networkName = "VM Network"
    ethernet0.pciSlotNumber = "32"
    ethernet0.present = "TRUE"
    
    ethernet1.addressType = "generated"
    ethernet1.generatedAddress = "00:0c:29:a9:05:b2"
    ethernet1.generatedAddressOffset = "10"
    ethernet1.networkName = "VM Network"
    ethernet1.pciSlotNumber = "160"
    ethernet1.present = "TRUE"
    *ethernet1.virtualDev = "vmxnet3"*
    
    ethernet2.addressType = "generated"
    ethernet2.allowGuestConnectionControl = "FALSE"
    ethernet2.generatedAddress = "00:0c:29:a9:05:bc"
    ethernet2.generatedAddressOffset = "20"
    ethernet2.networkName = "VM Network"
    ethernet2.pciSlotNumber = "34"
    ethernet2.present = "TRUE"
    ethernet2.startConnected = "FALSE"
    *ethernet2.virtualDev = "vmxnet"*
    ethernet2.wakeOnPcktRcv = "FALSE"
    
    ethernet3.addressType = "generated"
    ethernet3.allowGuestConnectionControl = "FALSE"
    *ethernet3.features = "15"*
    ethernet3.generatedAddress = "00:0c:29:a9:05:c6"
    ethernet3.generatedAddressOffset = "30"
    ethernet3.networkName = "VM Network"
    ethernet3.pciSlotNumber = "35"
    ethernet3.present = "TRUE"
    ethernet3.startConnected = "FALSE"
    *ethernet3.virtualDev = "vmxnet"*
    ethernet3.wakeOnPcktRcv = "FALSE"
    
    

    it appears that the 'Enhanced VMxnet' adapter is flagged via the 'features="15"' option to a 'vmxnet' type and that 'vmxnet3' is its own type.



  • 5.  RE: How to add a VMXNET3 adapter

    Posted Jul 02, 2009 03:38 PM

    It is a bug. There are actually 2 bugs, one is the inability to create VMXNET3, the other is if you run Set-NetworkAdapter on a VMXNET3 it will reset it to VMXNET. These are getting fixed but for now you should use ReconfigVM if you need to deal with VMXNET3.



  • 6.  RE: How to add a VMXNET3 adapter
    Best Answer

    Broadcom Employee
    Posted Jul 02, 2009 04:10 PM

    Try this... it isn't pretty, but should do the trick

      $filter = @{"Name" = "Test"}
      $VM = Get-View -ViewType "VirtualMachine" -Filter $filter
    
      $NetworkBacking = New-Object Vmware.Vim.VirtualEthernetCardNetworkBackingInfo
      $networkbacking.deviceName = "VM Network"
      
      $NetworkSpec = New-Object Vmware.Vim.VirtualVmxnet3
      $NetworkSpec.key=-1
      $NetworkSpec.backing=$NetworkBacking
      
      $VDevSpec = New-Object Vmware.Vim.VirtualDeviceConfigSpec
      $VDevSpec.operation = 'add'
      $VDevSpec.device = $NetworkSpec
      
      $VmConfigSpec = New-Object Vmware.Vim.VirtualMachineConfigSpec
      $VmConfigSpec.deviceChange = $VDevSpec
      $VmConfigSpec.changeVersion = $Vm.config.changeVersion
    
      $Vm.ReconfigVM( $VmConfigSpec );
    
    



  • 7.  RE: How to add a VMXNET3 adapter

    Posted Jul 03, 2009 09:28 AM

    @DougBaer: Thanks for solution!