cjcox
Contributor
Contributor

Using VxRail (Vsphere 6.7 practially latest) using rest api, figured out how to move hosts network to network, but there's an issue on reboot

So, I've been successful in changing the VM network (from one portgroup to another) using (debug, but gives you an idea):

POST https://vx1-vcenter.example.com/rest/vcenter/vm/vm-646/hardware/ethernet/4000/disconnect

PATCH https://vx1-vcenter.example.com/rest/vcenter/vm/vm-646/hardware/ethernet/4000 {'spec': {'backing': {'type': 'DISTRIBUTED_PORTGROUP', 'network': 'dvportgroup-34'}, 'mac_address': '00:50:56:9e:7b:4e'}}

POST https://vx1-vcenter.example.com/rest/vcenter/vm/vm-646/hardware/ethernet/4000/connect

I threw in the disconnect and connect later, hoping it might change things for the better.  I also threw the mac_address in to preserve mac.  (works/doesn't work either way)

Essentially, using the patch, I'm able to switch network on a live VM.  However, when I reboot that VM, nothing works.  The definition in the config of the VM looks sane (shows the changed network), but it doesn't come onto the network. 

If, via vcenter webui, I disconnect the vnic and reconnect, on reconnect, I get the error :

"Invalid configuration for device '0'"

And when I look a the host esxi logs for hostd, I see:

"Device spec doesn't match up with dvport/dvpg configuration"

So, let's say the vm network name is "Dev", and when I look at the VM, it says the vmnic is on "Dev".  I can get this working for the rebooted VM by using the webui and selecting "Dev" as a config change through the drop down, even though "Dev" is already selected.  Then it works.   I've taken config dump of the VM both using my automated api process and doing things through the webui and they don't look different.  And again, the network switch works on a live VM, it just messes up on reboot.  Is there a "way" to do what I'm trying to do through the api, that is, switch networks, that works live and works on reboot of the VM as well?

Tags (1)
0 Kudos
0 Replies