Quantcast
Channel: VMware Communities : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 180259

First New-VM : An item with the same key has already been added.

$
0
0


I'm getting a strange error that I've seen a few other posts about, but with no resolution (or at least one that I can find).  When attempting to create a new VM using the New-VM cmdlet, I receive the error "An item with the same key has already been added."

 

Now here is the key that I haven't seen a lot of others mention.  This ONLY happens on the first attempt for each new connection with Connect-VIServer.  I can create as many of the same machines as I want after this first error with the same paramaters (new name of course).  If I disconnect and reconnect again, the error appears for the first time.

 

Normally with PowerShell, I would just trap the error and be on my way.  However, in this case I'm using the -RunAsync paramter, so that I can capture the task that is returned in a variable.  From there I use Wait-Task until the VM is complete before moving on with the script.  Everythings works great when the error doesn't occur, but when it does occur the task object is not returned and the rest of the script barfs out errors.

 

I'm running the lastest release of PowerCLI and I've tried this on PowerShell v3.0 and v2.0 and get the same results.  I've tried various templates and hosts with no success.  I've also tried this with and without linked mode using -AllLinked on Connect-VIServer.  I should mention that I am cloning from template, specifying a customization spec, datastore cluster, and host.  Again, the only common repeatable thread here is that this ONLY occurs on the first attempt to use New-VM per session to vCenter.

 

Any thoughts or suggestions?

 

Below is the output details on the exception if that helps at all:

 

PS C:\> $Error[0]
New-VM : 6/5/2013 9:49:22 AM    New-VM        An item with the same key has already been added.
At line:1 char:11
+ $VMTask = New-VM -Name "NEWTEST20" -Template "Template" -OS ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-VM], VimException
    + FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM

PS C:\> $Error[0].Exception | Select *


ErrorId           : Core_BaseCmdlet_UnknownError
ErrorCategory     : NotSpecified
TargetObject      :
RecommendedAction :
SessionId         :
ConnectionId      : /VIServer=USERNAME@SERVER:443/
Severity          : Error
Message           : 6/5/2013 9:49:22 AM    New-VM        An item with the same key has already been added.
Data              : {ParameterValues}
InnerException    : System.ArgumentException: An item with the same key has already been added.
                       at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
                       at VMware.VimAutomation.ViCore.Impl.V1.Service.StaticDataServiceImpl.PopulateTaskDescriptionDict
                    ionary()
                       at VMware.VimAutomation.ViCore.Impl.V1.Service.StaticDataServiceImpl.GetTaskDescription(String
                    taskDescriptionId)
                       at VMware.VimAutomation.ViCore.Impl.V1.Task.TaskImpl.Create(ManagedObjectReference moRef,
                    VimClient client, Dictionary`2 props, Object extensionData)
                       at VMware.VimAutomation.ViCore.Impl.V1.Task.ViCoreTaskCoreServiceProviderImpl.<GetTaskListForCli
                    ent>d__7.MoveNext()
                       at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
                       at VMware.VimAutomation.ViCore.Impl.V1.Task.ViCoreTaskCoreServiceProviderImpl.GetTaskList(IEnume
                    rable`1 uidList, IEnumerable`1 connectionUidList)
                       at VMware.VimAutomation.Sdk.Impl.V1.Task.CoreTaskServiceImpl.GetTaskList(IEnumerable`1 uidList,
                    IEnumerable`1 connectionUidList)
                       at VMware.VimAutomation.ViCore.Impl.V1.Service.TaskServiceImpl.GetTaskCore(Nullable`1 state,
                    IList`1 connectionUidList)
                       at VMware.VimAutomation.ViCore.Impl.V1.Service.TaskServiceImpl.GetTask(Nullable`1 state,
                    CmdletTaskInfoProvider cmdletTaskInfoProvider)
                       at VMware.VimAutomation.ViCore.Impl.V1.Service.TaskServiceImpl.GetTaskById(String uid,
                    CmdletTaskInfoProvider cmdletTaskInfoProvider)
                       at VMware.VimAutomation.ViCore.Impl.V1.Service.VmServiceImpl.NewVM(TemplateInterop template,
                    VMHostInterop vmHost, String name, VIContainerInterop resourceContainer, FolderInterop location,
                    StorageResourceInterop datastore, Nullable`1 diskStorageFormat, OSCustomizationSpecInterop
                    customization, Boolean allowNested, Boolean isRequestedAsync, String description, Nullable`1
                    haRestartPriority, Nullable`1 haIsolationResponse, Nullable`1 drsAutomationLevel, AdvancedOption[]
                    options)
                       at VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM.DoWork(VIAutomation client, List`1 moList)
                       at VMware.VimAutomation.ViCore.Util10Ps.BaseCmdlet.BaseCmdlet.DoWork(VIConnection connection,
                    List`1 moList)
                       at VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.BaseCmdlet.DoWorkEx(VIConnection connection,
                    List`1 moList)
                       at
                    VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.ConnectionDispatchHelper.ExecuteRunlist(Dictionary`2
                    runlist, DoWorkDelegate doWorkDelegate, UidDispatchHelper uidDispatchHelper, List`1 result)
TargetSite        :
StackTrace        :
HelpLink          :
Source            :

 

PS C:\> $Error[0].Exception.InnerException | Select *


Message        : An item with the same key has already been added.
ParamName      :
Data           : {ConnectionId}
InnerException :
TargetSite     : Void Insert(TKey, TValue, Boolean)
StackTrace     :    at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
                    at
                 VMware.VimAutomation.ViCore.Impl.V1.Service.StaticDataServiceImpl.PopulateTaskDescriptionDictionary()
                    at VMware.VimAutomation.ViCore.Impl.V1.Service.StaticDataServiceImpl.GetTaskDescription(String
                 taskDescriptionId)
                    at VMware.VimAutomation.ViCore.Impl.V1.Task.TaskImpl.Create(ManagedObjectReference moRef,
                 VimClient client, Dictionary`2 props, Object extensionData)
                    at VMware.VimAutomation.ViCore.Impl.V1.Task.ViCoreTaskCoreServiceProviderImpl.<GetTaskListForClient
                 >d__7.MoveNext()
                    at System.Collections.Generic.List`1.InsertRange(Int32 index, IEnumerable`1 collection)
                    at
                 VMware.VimAutomation.ViCore.Impl.V1.Task.ViCoreTaskCoreServiceProviderImpl.GetTaskList(IEnumerable`1
                 uidList, IEnumerable`1 connectionUidList)
                    at VMware.VimAutomation.Sdk.Impl.V1.Task.CoreTaskServiceImpl.GetTaskList(IEnumerable`1 uidList,
                 IEnumerable`1 connectionUidList)
                    at VMware.VimAutomation.ViCore.Impl.V1.Service.TaskServiceImpl.GetTaskCore(Nullable`1 state,
                 IList`1 connectionUidList)
                    at VMware.VimAutomation.ViCore.Impl.V1.Service.TaskServiceImpl.GetTask(Nullable`1 state,
                 CmdletTaskInfoProvider cmdletTaskInfoProvider)
                    at VMware.VimAutomation.ViCore.Impl.V1.Service.TaskServiceImpl.GetTaskById(String uid,
                 CmdletTaskInfoProvider cmdletTaskInfoProvider)
                    at VMware.VimAutomation.ViCore.Impl.V1.Service.VmServiceImpl.NewVM(TemplateInterop template,
                 VMHostInterop vmHost, String name, VIContainerInterop resourceContainer, FolderInterop location,
                 StorageResourceInterop datastore, Nullable`1 diskStorageFormat, OSCustomizationSpecInterop
                 customization, Boolean allowNested, Boolean isRequestedAsync, String description, Nullable`1
                 haRestartPriority, Nullable`1 haIsolationResponse, Nullable`1 drsAutomationLevel, AdvancedOption[]
                 options)
                    at VMware.VimAutomation.ViCore.Cmdlets.Commands.NewVM.DoWork(VIAutomation client, List`1 moList)
                    at VMware.VimAutomation.ViCore.Util10Ps.BaseCmdlet.BaseCmdlet.DoWork(VIConnection connection,
                 List`1 moList)
                    at VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.BaseCmdlet.DoWorkEx(VIConnection connection,
                 List`1 moList)
                    at
                 VMware.VimAutomation.Sdk.Util10Ps.BaseCmdlet.ConnectionDispatchHelper.ExecuteRunlist(Dictionary`2
                 runlist, DoWorkDelegate doWorkDelegate, UidDispatchHelper uidDispatchHelper, List`1 result)
HelpLink       :
Source         : mscorlib



Viewing all articles
Browse latest Browse all 180259

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>