Trying to set the description on our VDS portgroups with the following code:
Read-Host "Changing $fullportgroupName description to $portGroupDescription"
# ------- ReconfigureDVPortgroup_Task -------
$spec = New-Object VMware.Vim.DVPortgroupConfigSpec
$spec.configVersion = "0"
$spec.description = $PortGroupDescription
$spec.type = "earlyBinding"
$_this = $portGroup | Get-View
$_this.ReconfigureDVPortgroup_Task($spec)
The Portgroups in question set the first time around, no problem; however, lets say i want to RESET the same port group, if i attempt to use the same code to set the portgroup to another description, the task fails as "Cannot complete operation due to concurrent modification by another operation"
Using powercli 5.5.0.0 and tested against vcenter server 5.1 and 5.5.
Any suggestions? Is there an easier way to set the description?
Thanks!
Sure, I assume the $portgroup variable contains the dvPortgroup that needs to be changed.
Then you could do
$spec = New-Object VMware.Vim.DVPortgroupConfigSpec
$spec.configVersion = $portGroup.ExtensionData.Config.ConfigVersion
$spec.description = $PortGroupDescription
$spec.type = "earlyBinding"
$portgroup.ExtensionData.ReconfigureDVPortgroup_Task($spec)
You can also find an example in one of my posts in my dvSwitch series.
See dvSwitch scripting – Part 9 – Traffic Shaping, line 61.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Your problem comes from the ConfigVersion property.
You can't hardcode that, you have to fetch the actual value from the portgroup.
This number is used to avoid concurrent updates to the same vSphere object.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I'm pretty sure i can figure it out, but do you happen to know where i can get that information? (sorry but am new to using view as a modification resource, that code was gotten from thealpha ONYX version.
Sure, I assume the $portgroup variable contains the dvPortgroup that needs to be changed.
Then you could do
$spec = New-Object VMware.Vim.DVPortgroupConfigSpec
$spec.configVersion = $portGroup.ExtensionData.Config.ConfigVersion
$spec.description = $PortGroupDescription
$spec.type = "earlyBinding"
$portgroup.ExtensionData.ReconfigureDVPortgroup_Task($spec)
You can also find an example in one of my posts in my dvSwitch series.
See dvSwitch scripting – Part 9 – Traffic Shaping, line 61.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Worked, once again Luc, you are the man.
Thanks again!
Hi, is there a requirement to set the portgroup type to early binding if you are just trying to change the description. Would the below code work?
$spec = New-Object VMware.Vim.DVPortgroupConfigSpec
$spec.configVersion = $portGroup.ExtensionData.Config.ConfigVersion
$spec.description = $PortGroupDescription
$portgroup.ExtensionData.ReconfigureDVPortgroup_Task($spec)
According to the SDK Reference, that is not required (see the red asterisk next to the type property in the DVPortgroupConfigSpec).
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thats what I thought. Thank you for confirming.