VMware Cloud Community
Michelle_Laveri
Virtuoso
Virtuoso

esxcfg-vmknic command

I've been investigating this command... to create VM Kernel switches from the COS....

It works pretty well - but one thing I've noticed is that there doesn't seem to be switch for enabling VMotion on the switch... or setting the default gateway value - which the VI client does prompt you do...

Does any one know of way of setting these parameters from the COS?

Regards

Mike

Regards
Michelle Laverick
@m_laverick
http://www.michellelaverick.com
Reply
0 Kudos
89 Replies
virtech
Expert
Expert

I don't believe so, if they have please lets us know!

Reply
0 Kudos
GavinJ
Hot Shot
Hot Shot

After a bit of playing around I have this working pretty well. I couldn't get the sed command to do what I wanted so ran an alternative:

cat >> /etc/vmware/hostd/hostsvc.xml

EOF

esxcfg-advcfg -s 1 /Migrate/Enabled

I've run this up in a clean scripted build situation and with a dirty one and both work fine and consistently with vmotion being configured and enabled upon connecting with a VC server. With the clean build it's part of a few other post deploy scripts and is then rebooted so you don't run the 'kill' command. You have to be a little more careful testing with an existing build as the order you do thing's matters more.

Hope you guys find it works well for you.

Cheers

Gavin

Reply
0 Kudos
cduffy
VMware Employee
VMware Employee

Ok, so I got this to work (I think). I will test some more -- I just want to get this down somewhere in case I get hit by a bus.

This doesn't require you to know the portgroup name, but it assumes you named your VMotion switch "VMotion" if you named it in lower case or something; modify the below script.

\# --- here is the vmotioncfg.sh script that you are calling

#!/bin/bash

portvar=$(esxcfg-vswitch -l | awk '/VMotion/ \{print $2}')

cat > /etc/vmware/hostd/hostsvc.xml

EOF

esxcfg-advcfg -s 1 /Migrate/Enabled[/b]

\# \------- End of script

So. Where do you put it? I have the script on the NFS server where I keep my ESX patches and it is copied over to the ESX server with the patches during the build.

So, how do you call it? Inside the PostInstall script (In the script after you create the switches/vlans).

It should look something like:

/usr/sbin/esxcfg-vmknic -a VMotion -i 10.6.1.1 -n 255.255.128.0

/usr/sbin/esxcfg-route 10.6.127.254

chmod 755 /somepath/vmotioncfg.sh

/somepath/vmotioncfg.sh[/b]

More later.

Chris

Reply
0 Kudos
andrew_hald
Hot Shot
Hot Shot

Sweet! This thread kind of died out after some folks could not get things to work. This procedure is still working for me in my automated installs. Is anybody else having success/trouble using this?

Thanks Chris for the added automation!

Reply
0 Kudos
dinny
Expert
Expert

Hiya,

I've successfully used this method to enable vmotion in my build script.

(I like the way of getting the portgroup number Chris)

I had hoped to be able to use the following command:

vimsh -n -e "/hostsvc/vmotion/vnic_set portgroupn"

(where n is the relevant portgroup number)

This command worked perfectly for me from the command line - but failed to work when run in rc.local.

I've no idea why - has anyone any ideas - as it is a neat way of doing it.

I next need to look at getting my vSwitch security and nic teaming settings into my scripted install.

I had hoped to use vimsh for this - but if that too fails at build time - does anyone have any suggestions for other scripting methods to set these properties?

I suspect I could write directly to the esx.conf - but I was trying to avoid that method if at all possible?

Dinny

Reply
0 Kudos
dinny
Expert
Expert

Hiya,

I found out what the problem with vimsh was:

Thanks to GavinJ - http://www.xtravirt.com/index.php?option=com_content&task=view&id=59&Itemid=67

If once I've set up my vSwitches and Portgroups, I do a:

service mgmt-vmware restart

sleep 15[/i]

and then my vimsh command

vimsh -n -e "/hostsvc/vmotion/vnic_set portgroupn"[/i]

It works fine.

Dinny

Reply
0 Kudos
steve_c
Contributor
Contributor

Hi,

I have one minor issue with both of the otions offered and that is that while they work, they overwrite whatever was pre-existing in the hostsvc.xml file i.e. the NTPD service is no longer present after these options are used.

Cheers

Steve

Reply
0 Kudos
dinny
Expert
Expert

Hi Steve,

If you're using a build script?

What if you add the NTPD stuff after configuring vmotion - or does that stop vmotion being enabled?

Dinny

Reply
0 Kudos
steve_c
Contributor
Contributor

Hi,

After a bit of effort I came up with the following. This basically strips off the

EOF

#Set advanced setting migrate/enabled to 1

esxcfg-advcfg -s 1 /Migrate/Enabled

}

Reply
0 Kudos
Dennis2
Contributor
Contributor

The arguments for vimsh -n -e "/hostsvc/vmotion/vnic_set" has changed in ESX 3.5 so you can't use the internal portgroup id anymore.

4.5 Enable VMotion
Enable a VirtualNic to be used as the VMotion NIC. This can be useful when undertaking automated ESX builds. Thanks to Mike Laverick () for picking up the change between 3.0 and 3.5 for this.
USAGE vimsh -n -e "hostsvc/vmotion/vnic_set "
EXAMPLE vimsh -n -e "hostsvc/vmotion/vnic_set vmk0"

Use following to get the vmkernel nic and enable vmotion

vmk_nic=$(esxcfg-vmknic -l | awk /VMotion/'{print $1}')

vimsh -n -e "hostsvc/vmotion/vnic_set $vmk_nic"

Reply
0 Kudos