VMware Cloud Community
sbeaver
Leadership
Leadership
Jump to solution

Coding help finding a value for network DVS Configuration

Good day all,

I have a workflow that migrates the host and vm's from one vCenter to another.  The workflow get a list of all the VM's, along with the folder it is in and the name of the portgroup it is using. The workflow then disconnects the host on the source vCenter, removes one of the physical nics from the dvs, add the host to the new vCenter and attaches the pnic that was removed to the new DVS then loops through the VM's putting the VM in the correct folder and connecting the the new DVS then migrated the vmkernel ports to the new DVS and this is now where I am stuck

To move the other pnics into the new DVS the VcHostNetworkConfig() wants the uplinkPortKey and I just seem to be having all sorts of problems coming up with that value and was hoping that someone might be able to point me in the right direction

Thanks

Steve

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
0 Kudos
1 Solution

Accepted Solutions
sbeaver
Leadership
Leadership
Jump to solution

I found what I was looking for and wanted to share in case this information will help anyone else

// ------- FetchDVPortKeys -------

var criteria = new VcDistributedVirtualSwitchPortCriteria();

criteria.scope = host

criteria.inside = true

criteria.uplinkPort = true

var upPortKeys = dvSwitch.fetchDVPortKeys(criteria); // dvSwitch = VmwareDistributedVirtualSwitch

for each (var i in upPortKeys){

     System.log(i)

}

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**

View solution in original post

0 Kudos
1 Reply
sbeaver
Leadership
Leadership
Jump to solution

I found what I was looking for and wanted to share in case this information will help anyone else

// ------- FetchDVPortKeys -------

var criteria = new VcDistributedVirtualSwitchPortCriteria();

criteria.scope = host

criteria.inside = true

criteria.uplinkPort = true

var upPortKeys = dvSwitch.fetchDVPortKeys(criteria); // dvSwitch = VmwareDistributedVirtualSwitch

for each (var i in upPortKeys){

     System.log(i)

}

Steve Beaver
VMware Communities User Moderator
VMware vExpert 2009 - 2020
VMware NSX vExpert - 2019 - 2020
====
Co-Author of "VMware ESX Essentials in the Virtual Data Center"
(ISBN:1420070274) from Auerbach
Come check out my blog: [www.virtualizationpractice.com/blog|http://www.virtualizationpractice.com/blog/]
Come follow me on twitter http://www.twitter.com/sbeaver

**The Cloud is a journey, not a project.**
0 Kudos