VMware

This Question is Answered

13 Replies Last post: Jun 12, 2009 2:30 PM by codeace  

vmware-cmd setconfig Alternative?? posted: Jun 5, 2009 6:48 PM

Click to view codeace's profile Novice 8 posts since
Jun 1, 2009

Hi folks,

I was looking to see if I could dynamically change the Network Configuration of a Clone running on a ESXi 3.5 host from command line. So I installed the CLI tools to access. But sadly the CLI documentation on Vmwaredoesn't tell anything about changing virtual machine configuration (NO SETCONFIG / GETCONFIG).

Then I found a lot of posts talking about the not working vmware-cmd <> setconfig <> command. I thought the problem has been fixed in the recent version, but looks like they just removed the "getconfig / setconfig" option. Even the setresource option is non-existent. BTW, the getconfigfile works great. But when I run the getconfig / setconfig nothing is returned to my console.

So I was wondering if they replaced it with some other option??? Does vmware-vim-cmd and vimsh scripting help?

Thanks in advance.

ssk

Re: vmware-cmd setconfig Alternative??

3. Jun 5, 2009 10:26 PM in response to: codeace
Click to view AndreTheGiant's profile Guru 5,916 posts since
Aug 28, 2008
I would like to change the CLONE_001's network connection from VM_NET_1 to VM_NET_2 from command-line.

You have to add a new portgroup and delete the old one.
Use:
esxcfg-vswitch

Andre
**if you found this or any other answer useful please consider allocating points for helpful or correct answers

Re: vmware-cmd setconfig Alternative??

4. Jun 6, 2009 8:54 AM in response to: codeace
Click to view lamw's profile Champion 2,803 posts since
Nov 27, 2007
Unfortunately there are no commands in vimsh that'll allow you to change a VMs portgroup, this was something I've tried to investigate but had no luck. You may want to take a look at using the VI API and utilize either vSphere SDK for Perl or PowerCLI to modify your VM. Take a look at this Re: changing vlan of an virtual machine for a Perl solution, you can probably find something similar in the PowerCLI's forum

If you're still interested in doing this via the Service Console, take a look at a script I wrote: my-vmware-cmd.sh - Custom management script for administering a large amount of virtual machines on ESX 3.x and ESXi There is an operation called vnic which allows you to change the portgroup of the VM, it's really a hack because I'm actually manually updating the VM configuration file (.vmx) and then using vimsh to reload the configurations which will allow you to change the portgroup. One big caveat is this will not work if the VM is running, it must be powered down else the configurations will not persist.

Hopefully this will get you going in the right direction.

=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
vGhetto Script Repository
VMware Code Central - Scripts/Sample code for Developers and Administrators
http://twitter.com/lamw

http://engineering.ucsb.edu/~duonglt/vmware/vexpert_silver_icon.jpg

If you find this information useful, please award points for "correct" or "helpful".

Re: vmware-cmd setconfig Alternative??

5. Jun 6, 2009 8:56 AM in response to: AndreTheGiant
Click to view lamw's profile Champion 2,803 posts since
Nov 27, 2007
Please read the OP request more carefully, the question is regarding changing the portgroup/vlan of a VM, this has nothing to do with adding a portgroup to a vSwitch. Take a look at my reply for a possible solution


=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
vGhetto Script Repository
VMware Code Central - Scripts/Sample code for Developers and Administrators
http://twitter.com/lamw

http://engineering.ucsb.edu/~duonglt/vmware/vexpert_silver_icon.jpg

If you find this information useful, please award points for "correct" or "helpful".

Re: vmware-cmd setconfig Alternative??

6. Jun 6, 2009 9:02 AM in response to: lamw
Click to view AndreTheGiant's profile Guru 5,916 posts since
Aug 28, 2008
the question is regarding changing the portgroup/vlan of a VM, this has nothing to do with adding a portgroup to a vSwitch.

You are right, sorry for the misunderstanding.

Andre

Re: vmware-cmd setconfig Alternative??

8. Jun 6, 2009 12:42 PM in response to: codeace
Click to view lamw's profile Champion 2,803 posts since
Nov 27, 2007
The vmware-cmd is actually a deprecated utility and there are known issues and some of the params may have worked in previous releases, but YMMV. It's really available for backwards compatibility for any scripts that may have been written in the past, but you won't find any new changes/improvements to the tool.

Best practice is to definitely taking a look at the VI API, which is exposed through vSphere SDK for Perl or PowerCLI. If you're looking at the Perl example, you'll want to start taking a look at the following documentation and install the toolkit on either your Windows/Linux or even VMware vMA system.

http://www.vmware.com/support/developer/vcli/

Here are additional links with more information and examples:
http://engr.ucsb.edu/~duonglt/vmware/#vmware_viptk
http://engr.ucsb.edu/~duonglt/vmware/#vmware_rcli

With regards to the Perl solution, you may need to write your own script using the snippet of code to get it working. I won't have access to my development system for few more days so I won't be able provide a working sample. You also may find something already written in PowerCLI, but you'll need to search the forum.

VIX is a totally different API and is specifically for guest management and not modifying the VM shell params, take a look here for more info: http://engr.ucsb.edu/~duonglt/vmware/#vmware_vix

Regarding: How to change VM IP or nic settings through API? the OP was looking in changing the IP Address within the guest VM, this is different from what you're looking for and you will not be able to use VIX to do the same.


Hopefully this clears everything up, and definitely go through the documentation to get a better understanding of the various ways of accomplishing your task. At the end, if you're looking for a quick and completed solution without digging too much, I would highly recommend looking into PowerCLI...perhaps a solution already exists.


=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
vGhetto Script Repository
VMware Code Central - Scripts/Sample code for Developers and Administrators
http://twitter.com/lamw

http://engineering.ucsb.edu/~duonglt/vmware/vexpert_silver_icon.jpg

If you find this information useful, please award points for "correct" or "helpful".

Re: vmware-cmd setconfig Alternative??

9. Jun 6, 2009 9:02 PM in response to: codeace
Click to view lamw's profile Champion 2,803 posts since
Nov 27, 2007
Here is a script I just wrote using the vSphere SDK for Perl: updateVMPortgroup.pl

You'll need to install either the VI Perl Toolkit (VI 3.5) or vSphere SDK for Perl (vSphere 4.0), take a look at the documentation for the respective toolkit for further setup. Once you have it configured you'll be able to use the scrip to update a specific VM network adapter and set a specific portgroup.



=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
vGhetto Script Repository
VMware Code Central - Scripts/Sample code for Developers and Administrators
http://twitter.com/lamw

http://engineering.ucsb.edu/~duonglt/vmware/vexpert_silver_icon.jpg

If you find this information useful, please award points for "correct" or "helpful".

Re: vmware-cmd setconfig Alternative??

11. Jun 6, 2009 9:26 PM in response to: codeace
Click to view lamw's profile Champion 2,803 posts since
Nov 27, 2007
Looks like the script did not get uploaded, give me a few. There are known issues with trying to create,modify VMTN documents which have been quite frustrating!

For now, I've attached the script here so you can download.

UPDATE1: It looks like the forum might have some issue with attaching files
UPDATE2: I've uploaded the script to our site, please find it here: http://engineering.ucsb.edu/~duonglt/vmware/updateVMPortgroup.pl


=========================================================================
William Lam
VMware vExpert 2009
VMware ESX/ESXi scripts and resources at: http://engineering.ucsb.edu/~duonglt/vmware/
vGhetto Script Repository
VMware Code Central - Scripts/Sample code for Developers and Administrators
http://twitter.com/lamw

http://engineering.ucsb.edu/~duonglt/vmware/vexpert_silver_icon.jpg

If you find this information useful, please award points for "correct" or "helpful".

VMware Developer

SDKs, APIs, Videos, Learn and much more in the Developer community.

Learn More

Developer Sample Code

Increase your developer productivity with VMware API sample code.

Learn More

VMworld Sessions & Labs

Online access to the latest VMworld Sessions & Labs and online services.

Learn more

Purchase PSO Credits Online

Purchase credits to redeem training and consulting services online.

Buy Now

Community Hardware Software

View reported configurations or report your own.

Learn More

VMware vSphere

Come witness the next giant leap in virtualization.

Register Today

Communities