VMware Cloud Community
CDH_COM-jasonc-
Contributor
Contributor

probably a developer / API question...

Is it possible to change the port group of a virtual network adapter from within the VM? To be more clear, I want to be able to launch an app from with the VM that would move NIC1 from one port group to another. At first blush, it seems like a scenario that's going to require a custom app using the VIPerl Toolkit or the VI SDK. Is it even possible?

Practically speaking, there's VM that has a second NIC that bounces from VLAN to VLAN to do scans and monitor certain traffic. As it stands, those users need to have access to the VIC or the Web Interface. The process could be entirely automated quite easily, but for the port group changes required.

Thanks for any pointers here!

Reply
0 Kudos
5 Replies
RenaudL
Hot Shot
Hot Shot

Well, first of all, you can't change the portgroup of a virtual nic while the VM is running, so that basically seals the deal.

Why not create a portgroup with Guest VLAN tagging, attach this "monitor VM" to it and dynamically change the VLAN of the interface inside the guest? I guess that would work...

Reply
0 Kudos
CDH_COM-jasonc-
Contributor
Contributor

I beg to differ. It is certainly possible to move a vNIC from one port group to another while the VM is powered on. Our ESX servers have 8 NICs bonded as a trunk port and the vSwitch has a dozen or more port groups, each for a different VLAN. Not only can you move a vNIC from one port group to another on the SAME vSwitch. I can move the vNIC to a port group on an entirely different vSwitch. (see attached "networkconnection.JPG")

So the question remains, how complicated will it be to write some kind of script / applet that can change the assignment of a vNIC to a particular port group (therefore VLAN) from the VM itself? Can it be done? Is it worth a go, or are we spitting into the wind...

VGT is out of the question.

Reply
0 Kudos
RenaudL
Hot Shot
Hot Shot

I beg to differ. It is certainly possible to move a vNIC from one port group to another while the VM is powered on. Our ESX servers have 8 NICs bonded as a trunk port and the vSwitch has a dozen or more port groups, each for a different VLAN. Not only can you move a vNIC from one port group to another on the SAME vSwitch. I can move the vNIC to a port group on an entirely different vSwitch. (see attached "networkconnection.JPG")

You're actually right, I sincerely apologize. I was using a version of VC that somehow doesn't allow changing portgroups on the fly, and I didn't know this was now possible on release builds.

So the question remains, how complicated will it be to write some kind of script / applet that can change the assignment of a vNIC to a particular port group (therefore VLAN) from the VM itself? Can it be done? Is it worth a go, or are we spitting into the wind...

I personally don't know if what you're describing is scriptable: none of the esxcfg-* I know of can achieve that. You may be interested in looking into our remote API though, which allows users to access far more parameters than what is available locally.

Reply
0 Kudos
Chamon
Commander
Commander

The only way that I know of to script it would require access to the service console and have a shell script to move them. I am just starting to look into the scripting in ESX or Linux but it was useful for patching multiple ESX hosts with many patches in a faster manner. That is before the update manager. And like I said I only know enough about the scripting to be really dangerous. So most of it is done in our lab .You could limit their access to the SC but I don’t think that this is what you are looking for. Like you said this is probably a question for the developer community. Have you either posted it there or searched that community for this? You may get a good response. If you do it would be interesting to see what they come back with. The CLI vApp may be an option for you. Keep us posted.

Reply
0 Kudos
Chamon
Commander
Commander

The only way I can think of to script it would be to have a script to modify the .vmx file for the VM. Again access to the SC. Check with the developers.

Reply
0 Kudos