VMware {code} Community
shaka
Enthusiast
Enthusiast

updatevirtualswitch problems

I am trying to use updatevirtualswitch() to update the number of ports on a virtual switch that already has two vmnics assigned to it. When I run my script it removes the two vmnics from the switch but updates the number of ports and the ESX host becomes disconnected from VIrtual Center. I have to connect through my remote access card and add the vmnics back to the vSwitch to get access back to the service console. Anyone know why updating the number of ports is removing the vmnics from the switch?

Here is my code:

my $host_view = Vim::find_entity_view (view_type => 'HostSystem');

Opts::assert_usage(defined($host_view), "Invalid host.");

  1. Before I try to update the switch ports I add the virtual switch, add the vmnics to vswitch and add the port groups.

my $configManager = $host_view->configManager;

my $networkSystem = Vim::get_view( mo_ref => $configManager->networkSystem );

my $hostVirtualSwitchSpec = HostVirtualSwitchSpec->new(numPorts=>$numPorts );

$networkSystem->UpdateVirtualSwitch( vswitchName=>$vSwitch, spec => $hostVirtualSwitchSpec , );

  1. I am also trying to set the vmkernel nic I add to use vmotion. If you could help me with this I would also be very thankful

my $configManangervMotionSystem = $host_view->configManager.vMotionSystem;

my $HostVmotionSystem = Vim::get_view( mo_ref => $configManager.vMotionSystem->HostVmotionSystem );

$HostVmotionSystem->SelectVNic( new(device =>

0 Kudos
0 Replies