一段可代替"esxcfg-vswitch -l"的代码
时间:2009-04-19 来源:us4unixshield
通常, 运行 "esxcfg-vswitch -l"
--root@esxhost5--# esxcfg-vswitch -l
Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch0 64 4 64 1500 vmnic0
PortGroup Name VLAN ID Used Ports Uplinks
Service Console 0 1 vmnic0
Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch0 64 4 64 1500 vmnic0
PortGroup Name VLAN ID Used Ports Uplinks
Service Console 0 1 vmnic0
Switch Name Num Ports Used Ports Configured Ports MTU Uplinks
vSwitch1 64 18 64 1500 vmnic1
PortGroup Name VLAN ID Used Ports Uplinks
Prod_1 501 5 vmnic1
Prod_2 502 2 vmnic1
Prod_3 503 2 vmnic1
Prod_4 504 3 vmnic1
Prod_5 505 6 vmnic1
读读以下Perl 可使你轻松拥有自己控制代码。
my $portGroups = $vSwitch->portgroup;
foreach my $port (@$portGroups) {
my $pg = FindPortGroupbyKey ($netMgr, $vSwitch->key, $port);
next unless (defined $pg);
my $usedPorts = (defined $pg->port) ? $#{$pg->port} + 1 : 0;
相关阅读 更多 +