Score:0

Changing VM network without restart the virtual machine in ESXi 7

us flag

I want to change my VM network from CLI. I managed to do this by editing the .vmx file, but I need to Restart my VM for the changes that will take place. I tried: vim-cmd vmsvc/power.off #id change vmx file vim-cmd vmsvc/power.on #id

I also tried to use vim-cmd vmsvc/reload #id to reload the vmx file, but it does not succeed. If I run the command: esxcli network vm list I get:

World ID Name Num Ports Networks


2100862 vm1 1 VLAN110 2100869 vm2 1 VLAN102 2100864 vm9 1 VLAN109

I want to change vm1's Network to VLAN101. From the Admin UI, I can do it without restarting the VM.

How can I do it?

Score:1
it flag

You shouldn't touch the .vmx file, at least not for such trivial tasks as changing VM network. The proper way to do it is by using VMware's PowerCLI. That way the changes can be effective immediately, as if done on the GUI.

PowerCLI is a module for Powershell, it adds vmware specific cmdlets. You can also add it to Powershell on Linux, in case you have a Linux workstation.

Have on look on this link, it's about Set-NetworkAdapter cmdlet: VMware PowerCLI Set-NetworkAdapter


Up to ESXi 6.7, vSphere CLI is also available. It's also a set of commands to manage/administer ESXi and VMs but it's deprecated. It's based on Perl. If you have an up to 6.7 version of ESXi, you can also use this. vSphere CLI

user2354982 avatar
us flag
Thank you. I'm trying to change my VM's VLAN from a remote server. My first thought was SSH, and then change the network, but the only way I was able to find out how to do this is through the vmx file. Do you know how can I change the VM's network from remote server with python scirpt ?
Krackout avatar
it flag
Sorry @user2354982, I don't know how you could make changes directly to ESXi using Python. Perhaps other may help. VMware If you are into Perl, Perl SDK is still available for the latest versions of ESXi, still it needs installation. Perhaps setting up a bastion-jump system, a small Linux with Powershell and PowerCLI (or Perl SDK) installed and then connecting to it may be a solution; a complicated one for my tastes.
JMHerrer avatar
us flag
If you want to use python you should use vsphere api to change network adapter.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.