maaca
Enthusiast
Enthusiast

pnic vs. pnic in networkInfo

Jump to solution

I have found strange thing,

when I call host.configManager.networkSystem.networkInfo.pnic , I receive Array of VcPhysicalNic

But when I call host.configManager.networkSystem.networkInfo.vswitch[0].pnic , I receive Array of String (looks to be Array of ....pnic.key)

I'm using Orchestrator 7.0.1. Is it so by design? Is there some other easy way to get physical NICs connected to the standard virtual switch?

maaca

1 Solution

Accepted Solutions
iiliev
VMware Employee
VMware Employee

Hi maaca,

The correct output of host.configManager.networkSystem.networkInfo.vswitch[0].pnic is array of string, so yes, what you see is by design.

vRO documentation states the result should be array of VcPhysicalNic; perhaps there is some error/out-of-date documentation issue that need to be investigated. I'll open a PR to get it fixed in future release.

For getting a list of physical NICs connected to the virtual switch you may use a combination of these 2 APIs:

  • First, get the list of all physical NICs using host.configManager.networkSystem.networkInfo.pnic
  • Then, get the list of NICs' keys of NICs connected to the virtual switch using host.configManager.networkSystem.networkInfo.vswitch[0].pnic
  • And finally, iterate over the first list and pick only the items whose key property appears in the second list.

Let me know if you have troubles writing scripting code for the algorithm above, and I'll try to provide some sample code.

View solution in original post

0 Kudos
2 Replies
iiliev
VMware Employee
VMware Employee

Hi maaca,

The correct output of host.configManager.networkSystem.networkInfo.vswitch[0].pnic is array of string, so yes, what you see is by design.

vRO documentation states the result should be array of VcPhysicalNic; perhaps there is some error/out-of-date documentation issue that need to be investigated. I'll open a PR to get it fixed in future release.

For getting a list of physical NICs connected to the virtual switch you may use a combination of these 2 APIs:

  • First, get the list of all physical NICs using host.configManager.networkSystem.networkInfo.pnic
  • Then, get the list of NICs' keys of NICs connected to the virtual switch using host.configManager.networkSystem.networkInfo.vswitch[0].pnic
  • And finally, iterate over the first list and pick only the items whose key property appears in the second list.

Let me know if you have troubles writing scripting code for the algorithm above, and I'll try to provide some sample code.

0 Kudos
maaca
Enthusiast
Enthusiast

Hi Ilian,

thanks for making it clear. I'll put the script together, no problem.

maaca

0 Kudos