VMware {code} Community
matrix123321
Contributor
Contributor

what is the function to get name of virtualswitch

Hi,

What is the function in VI SDK 2.5 to get the virtualswitch name(vSwitch0..etc) and device name(vswif0...etc)

0 Kudos
1 Reply
StefanPahrmann

Hi,

it's the same as in dsk 3.x:

my $host_view = Vim::find_entity_view(view_type => 'HostSystem'};
my $vswitches = $host_view->config->network->vswitch;
foreach(@$vswitches){
   my $vswitch = $_->name;
   print "vSwitch: ".$vswitch;
   foreach($_->pnic){
      print "Physical Nic on ".$vswitch.": ".$_->spec->name;
   }
}

Haven't tested the code, but this or something similar should do it.

-Stefan