Skip navigation
VMware

This Question is Possibly Answered

1 "correct" answer available (10 pts)
2,924 Views 16 Replies Last post: Sep 29, 2010 11:38 PM by mossko RSS
1 2 Previous Next
bug_juice Enthusiast 25 posts since
Aug 26, 2008
Currently Being Moderated

Jul 17, 2010 7:26 PM

How do you enable "Management traffic" with vim-cmd in ESXi 4.1?

 

Hi,

 

 

   I need to enable "Traffic management" on a vmkernel port group from the commandline.  I'm trying to use vim-cmd, but i can't seem to find the proper command for this.  Is vim-cmd what i'm suppose to be using or is there a different way of doing this?

 

 

Thanks in advance.

 

 

FranckRookie Virtuoso User Moderators vExpert 1,516 posts since
Dec 15, 2008
Currently Being Moderated
1. Jul 18, 2010 11:37 PM in response to: bug_juice
Re: How do you enable "Management traffic" with vim-cmd in ESXi 4.1?

 

Hi Bug_juice,

 

 

 

 

 

I hope you'll find some information in that thread .

 

 

 

 

 

Regards

 

 

Franck

 

 

FranckRookie Virtuoso User Moderators vExpert 1,516 posts since
Dec 15, 2008
Currently Being Moderated
3. Jul 19, 2010 8:38 AM in response to: bug_juice
Re: How do you enable "Management traffic" with vim-cmd in ESXi 4.1?

Have a look at "esxcfg-vmknic".

 

Regards

 

Franck

SVE Novice 16 posts since
Apr 8, 2005
Currently Being Moderated
5. Aug 6, 2010 3:44 AM in response to: bug_juice
Re: How do you enable "Management traffic" with vim-cmd in ESXi 4.1?

Did you find a way ton enable this from the commandline?

lamw Guru vExpert 5,952 posts since
Nov 27, 2007
Currently Being Moderated
7. Aug 9, 2010 11:37 AM in response to: bug_juice
Re: How do you enable "Management traffic" with vim-cmd in ESXi 4.1?

I'm sure you can use the vimsh's vim-cmd, but you can also enable and disable management traffic, vMotion and FT using vSphere SDK for Perl script remotely.

 

Check this script out -

 

 

 

 

=========================================================================

William Lam

VMware vExpert 2009,2010

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

 

 

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

*Disclaimer: VMware Employee - William Lam | http://www.virtuallyghetto.com | http://blogs.vmware.com/vsphere/automation | @lamw
lamw Guru vExpert 5,952 posts since
Nov 27, 2007
Currently Being Moderated
9. Aug 9, 2010 1:52 PM in response to: bug_juice
Re: How do you enable "Management traffic" with vim-cmd in ESXi 4.1?

I just played with it for a few minutes and found a way It's actually pretty simple but may not be super obvious.

 

Remember that vimsh is still using the the APIs, but not all functionality is implemented or explicit. There's quite a few bugs with vimsh but if you want it all within a kickstart, it's understandable. Using the various SDK's like vSphere SDK for Perl or PowerCLI is really the approach to go.

 

Let me write this up tonight, as it's worth a post and I'll share with everyone tonight. Hope you can wait

 

 

 

 

=========================================================================

William Lam

VMware vExpert 2009,2010

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

 

 

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

*Disclaimer: VMware Employee - William Lam | http://www.virtuallyghetto.com | http://blogs.vmware.com/vsphere/automation | @lamw
lamw Guru vExpert 5,952 posts since
Nov 27, 2007
Currently Being Moderated
11. Aug 9, 2010 9:24 PM in response to: bug_juice
Re: How do you enable "Management traffic" with vim-cmd in ESXi 4.1?

So I swear I was able to perform this option using just vimsh but once I got home, I've been unable to reproduce the results. I'm pretty sure it had worked, but perhaps it was too early in the morning ....

 

I'm assuming it was some type of advanced configuration to enable management interface, some of these advanced configurations are stored in /etc/vmware/esx.conf and if you've enabled vMotion or FT via vim-cmd, you'll notice entries in this configuration file. I took a look to see if there was anything related to the management interface and there is an entry called "/Net/ManagementIface" which by default is set to vmk0. I thought, perhaps this might be the correct entry and after giving it a try, I was able to enable the management interface for any valid vmkernel interface. I even created multiple interfaces and was able to enable without any issues. I'm not sure if it was a fluke or from other commands that some how made it work, as I said, I'm unable to reproduce the results.

 

Enable vMotion:


vim-cmd hostsvc/advopt/update Migrate.Vmknic string vmk1

Enable FT:


vim-cmd hostsvc/advopt/update FT.Vmknic string vmk1

Enable Management:


vim-cmd hostsvc/advopt/update Net.ManagementIface string vmk1

Refresh networking:


vim-cmd hostsvc/net/refresh

 

I was looking to see if there was another method and I thought of one which is indirectly making a call to the API method which is used in my vSphere SDK for Perl script to enable the various vmkernel interfaces using the vSphere MOB. I actually remembered another blogger who created a python script on an ESXi host which allowed him to join his host to vCenter w/o the use of the external SDK's - http://geauxvirtual.wordpress.com/2010/07/25/automatically-add-esxi-to-vcenter-from-esxi/

 

I adapted his example and produced the following python script:

 


import sys,re,os,urllib,urllib2

# William Lam
# Python URL code based on http://geauxvirtual.wordpress.com/2010/07/25/automatically-add-esxi-to-vcenter-from-esxi/

# connection info to MOB
url = "https://localhost/mob/?moid=ha-vnic-mgr&method=selectVnic"
username = "root"
password = "password"

#nicType = (management,vmotion,faultToleranceLogging)
nictype=sys.argv[1]

#device = (vmkX)
device=sys.argv[2]

#auth
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None,url,username,password)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)

#execute method
params = {'nicType':nictype,'device':device}
e_params = urllib.urlencode(params)
req = urllib2.Request(url,e_params)
page = urllib2.urlopen(req).read()

 

You will need to edit the script and specify the local root password and then the rest can be passed via the commandline.

 

You will need to specify the nicType which can be one of the following management,vmotion,faultToleranceLogging and the device which is vmkX where X is one of your vmkernel interface which can be listed using esxcfg-vmknic -l

 

Here is an example of enabling the management on vmk1:


~ # python enableVmkInterface.py management vmk1
~ #

 

If it was successful, you will not see any output from the script as the API method is void if executed successfully. If you take a look at the vSphere Client, you should see the Management Traffic enabled for the given vmkernel interface. It's not ideal as you require an additional script to execute, but at least this allows you to enable it directly in Tech Support Mode. Ideally, you'll want to use the SDK's to perform all this work, makes all this much much easier.

 

Sorry I was not able to get it working using vimsh

 

 

 

 

 

=========================================================================

William Lam

VMware vExpert 2009,2010

VMware scripts and resources at:

Twitter: @lamw

Getting Started with the vMA (tips/tricks)

Getting Started with the vSphere SDK for Perl

VMware Code Central - Scripts/Sample code for Developers and Administrators

VMware Developer Community

 

 

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

*Disclaimer: VMware Employee - William Lam | http://www.virtuallyghetto.com | http://blogs.vmware.com/vsphere/automation | @lamw
Tuurtje Novice 2 posts since
Aug 31, 2010
Currently Being Moderated
12. Aug 31, 2010 2:14 AM in response to: lamw
Re: How do you enable "Management traffic" with vim-cmd in ESXi 4.1?

Thank you so much for the pythonscript. If you use the script in %firstboot the root password is still empty.

 

 


%firstboot --unsupported --interpreter=python

import sys,re,os,urllib,urllib2

# William Lam
# Python URL code based on http://geauxvirtual.wordpress.com/2010/07/25/automatically-add-esxi-to-vcenter-from-esxi/

# connection info to MOB
url = "https://localhost/mob/?moid=ha-vnic-mgr&method=selectVnic"
username = "root"
password = ""

#auth
passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
passman.add_password(None,url,username,password)
authhandler = urllib2.HTTPBasicAuthHandler(passman)
opener = urllib2.build_opener(authhandler)
urllib2.install_opener(opener)

#execute method
params = {'nicType':'management','device':'vmk0'}
e_params = urllib.urlencode(params)
req = urllib2.Request(url,e_params)
page = urllib2.urlopen(req).read()

params = {'nicType':'management','device':'vmk2'}
e_params = urllib.urlencode(params)
req = urllib2.Request(url,e_params)
page = urllib2.urlopen(req).read()

 

mossko Novice 8 posts since
Jan 7, 2008
Currently Being Moderated
13. Sep 27, 2010 6:28 PM in response to: bug_juice
Re: How do you enable "Management traffic" with vim-cmd in ESXi 4.1?

Hi Guys

 

I found another way to do this. After enabling Management Traffic in the VI Client, I noticed that one XML file on the ESXi host had changed: /etc/vmware/hostd/hostsvc.xml

 

 

Here's the code to enable the tickbox in the VI client

 

#

                

  1. Update the file /etc/vmware/hostd/hostsvc.xml with the parameters to tick the Management Network portgroup Management Traffic box

               echo "Stopping the hostd"

               /etc/init.d/hostd stop

               sleep 5

               echo "Enabling 'Management' on vmk0"

               hostsvc=/etc/vmware/hostd/hostsvc.xml

               hostsvcout=/etc/vmware/hostd/hostsvc.xml.new

 

               sed -e 's/<ConfigRoot>/<ConfigRoot>\n  <mangementVnics>\n    <nic id="0000">vmk0<\/nic>\n  <\/mangementVnics>/' $hostsvc > $hostsvcout

               mv $hostsvcout $hostsvc

 

               echo "Starting the hostd"

               /etc/init.d/hostd start

 

NIC ID relates to the entry in /etc/vmware/esx.conf for vmk0

Tuurtje Novice 2 posts since
Aug 31, 2010
Currently Being Moderated
14. Sep 28, 2010 12:27 AM in response to: mossko
Re: How do you enable "Management traffic" with vim-cmd in ESXi 4.1?

/etc/vmware/hostd/hostsvc.xml is stored in /vmfs/Hypervisor1/state.tgz.

 

If you know a way to save the state, your problem is fixed.

Bookmarked By (0)

Share This Page

Communities