Automation

 View Only
  • 1.  Issues with Set-OSCustomizationNicMapping

    Posted Mar 20, 2013 10:59 AM

    Hi All,

    After taking bits of code from here and other (LucD + Mr Epping amongst many others - cheers!) I'm nearly done with a script to deploy a template with 3 NICs and addresses, masks and GW from a CSV.

    Everything seems to work nicely, but I keep getting the error 'Fault.NicSettingMismatch.summary' when the customization of a the temporary non persistent spec takes place.

    The code is here

    Original custom spec is got here:

    Get-OSCustomizationSpec -Name $Spec | New-OSCustomizationSpec -Name TempSp -Type NonPersistent

    The we work on a nonpersistent copy to make the amendments to the IP, Mask and GW:

    # Setup the IP addresses

    $osCust = Get-OSCustomizationSpec -Name TempSp -Type NonPersistent

    $osCust | Get-OSCustomizationNicMapping | where {$_.Position -eq 1} |
    Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $vm.IP1   -SubnetMask $vm.MASK1 -DefaultGateway $vm.GW1

    $osCust | Get-OSCustomizationNicMapping | where {$_.Position -eq 2} |
    Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $vm.IP2   -SubnetMask $vm.MASK2 -DefaultGateway $vm.GW2

    $osCust | Get-OSCustomizationNicMapping | where {$_.Position -eq 3} |
    Set-OSCustomizationNicMapping -IpMode UseStaticIP -IpAddress $vm.IP3   -SubnetMask $vm.MASK3 -DefaultGateway $vm.GW3
    .. where the $vm.XXX are being pulled from a CSV in the loop to create each VM .. followed by

    New-VM -Name $vm.Name -OSCustomizationSpec $osCust -Template $Template -VMHost $NewHost -Datastore $NewDatastore

    to do the clone from template.

    I get output that suggests the customisation is OK .... i.e. right IPs in the right positions but still it fails.

    The template deploys with 3 NICs on the right portgroups, and when I boot it manually it has not received any customisation at all (name not changed etc.)

    Any ideas? I can put the full script up if it helps. Guest is RHEL 6.

    All help gratefully received :-)



  • 2.  RE: Issues with Set-OSCustomizationNicMapping

    Posted Mar 20, 2013 12:42 PM

    Quick update. Applying the Customisation spec directly to the template seems to work as intended, so the problem is occurring when I copy it up to

    a non persistent spec to edit the NIC parameters. I got this from these forums so hopefully it might narrow it down a bit.



  • 3.  RE: Issues with Set-OSCustomizationNicMapping

    Posted Mar 20, 2013 06:29 PM

    You might want to have a look in the vpxd log on your vCenter, normally that log shows some extra information when there is a fault.



  • 4.  RE: Issues with Set-OSCustomizationNicMapping

    Posted Mar 20, 2013 08:43 PM

    Thanks Luc - sorted it in the end. I had an extra line at the top of the script that effectively meant I was copying the spec into the temp spec twice .. for some reason this equated to a temp spec that was blank. Anyway, once this was sorted I was deploying 100 VMs in about 1/2 an hour ... got to love PowerCLI :-)



  • 5.  RE: Issues with Set-OSCustomizationNicMapping

    Posted Mar 20, 2013 09:14 PM

    Indeed :smileyhappy:

    Glad you found the source of the problem