I am using the script below to deploy a VM. It works fine until I try to use the New-OSCustomizationNicMapping cmdlet to try to set up the IP settings for the VM. At that point I get the following:
New-VM : 1/6/2010 1:44:31 PM New-VM 6D834AFF-988A-43E9-B55E-779779548D2C
The operation for the entity vm-1550 failed with the following message: "fau
lt.NicSettingMismatch.summary"
At D:\amc\scripts\deploy-post.ps1:87 char:7
+ New-VM <<<< -Name $VMName -Template $Template -VMHost $VMhost -Datastore $Da
taStore -OSCustomizationSpec $VMspec
+ CategoryInfo : InvalidArgument: (vm-1550:String) , ViEr
ror
+ FullyQualifiedErrorId : Client20_TaskServiceImpl_CheckServerSideTaskUpda
tes_OperationFailed,VMware.VimAutomation.Commands.NewVM
Here is the script segment (the problem appears when I add the New-OSCustomizationNicMapping line):
$VMspec = New-OSCustomizationSpec -OSType Linux -Type Persistent -Name "$VMName-spec" -DnsServer $DNS -DnsSuffix $Suffix -NamingScheme Vm -Domain $Domain
New-OSCustomizationNicMapping -Spec $VMspec -IpMode UseStaticIP -IpAddress $VMIPaddr -SubnetMask $VMMask -DefaultGateway $VMGateway
$Template = Get-Template $TemplateName
$VMhost = Get-VMhost $VMhostName
$Datastore = Get-Datastore $DatastoreName
New-VM -Name $VMName -Template $Template -VMHost $VMhost -Datastore $DataStore -OSCustomizationSpec $VMspec
Does anyone know what I'm doing wrong, or where I might check to get more information on what is causing the error? I've even tried whittling that line down to "New-OSCustomizationNicMapping -Spec $VMspec -IpMode UseDhcp", with the same result.
Thanks
I guess your Template has only one NIC, right? If that is the case then this might be your problem: when you create a new OSCustomizationSpec one OSCustomizationNicMapping is automatically created for you, so when you create a new nic mapping with New-OSCustomizationNicMapping cmdlet you end up with a total of 2. This would cause an error when applying the spec.
You can check out this post to see how to deal with this: http://communities.vmware.com/message/1431187#1431187.
I guess your Template has only one NIC, right? If that is the case then this might be your problem: when you create a new OSCustomizationSpec one OSCustomizationNicMapping is automatically created for you, so when you create a new nic mapping with New-OSCustomizationNicMapping cmdlet you end up with a total of 2. This would cause an error when applying the spec.
You can check out this post to see how to deal with this: http://communities.vmware.com/message/1431187#1431187.
Dimitar, do you consider this a bug ? In the VIC ? In the API ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you! Now I wish I had asked a week ago! Yes, that was it. I'd actually seen the other NIC in the Customization, but didn't realize that was actually what was causing the problem. Not sure why my own searches didn't turn up that article, but I'm grateful for the link. Thanks again.
Luc, I don't think that this is necessarily a bug. Think about the use-case where you just want to customize the domain/user of the machine and wish to have DHCP handle the IP settings. The default nic mapping will do just that - saving you the step of calling New-OSCustomizationNicMapping cmdlet.
However we should better document this functionality, because it's obviously causing confusion. I'll file a bug for updating the documentation of these cmdlets.