VMware Cloud Community
vnagendr
Contributor
Contributor
Jump to solution

Updating Autostart Entry using vmware-vim-cmd (or vmware-vimsh)

Hello

Is there an example of how to update autostart entry using vmware-vim-cmd.

The problem I am running into is

1. When I type

vmware-vim-cmd hostsvc/autostartmanager/update_autostartentry 16 powerOn -1 1 systemDefault -1 systemDefault

where 16 is one of my VMIds, I get the following

Invalid option '1'

Usage: update_autostartentry VMId StartAction StartDelay StartOrder StopAction StopDelay WaitForHeartbeat

I am unable to understand what the Invalid option '1' means.

Here is what I have done so far

1. Searched the communities for any examples. There are a couple of messages, but none seem to provide real working examples (beyond the usage message)

2. I found this link http://pubs.vmware.com/vi-sdk/visdk250/ReferenceGuide/vim.host.AutoStartManager.AutoPowerInfo.html which talks about what type of input it is expecting. I tried double quoting and single quoting the xsd:string parameters, but that didn't work either

3. I tried doublequoting individual (including xsd:int) parameters, that didn't work either

Has anyone had success with this? If so could you please post a real example.

Here is what I am trying to accomplish

1. Enable Autostart - I have done that using

/usr/bin/vmware-vim-cmd hostsvc/autostartmanager/enableautostart true

2. Get all VMIds in the system

I have done that using the following awk script and command

/* Awk script */

BEGIN {

FS = " "

NR > 1

}

{

if (NR == 1){

#ignore the header

}

else {

  1. $1 has VMIds

print $1

}

}

/* End awk script */

then run /bin/awk -f /root/autostart.awk

3. Instead of printing $1 I'd like to add the virtual machines to the list using the following

a. Start delay = systemdefault

b. start action = poweron

c. start order = 1, 2, 3, 4 (don't need help with AWK script), I can post it once I have that.

d. stopaction, stopdelay etc - leave at system default (or -1 as the pubs link suggests)

I am sure there are more effecient and such ways of doing this, I need to follow this approach for a specific reason. Wondering if someone can help me with the correct syntax for vmware-vim-cmd hostsvc/autostartmanager/enable_autostart please?

Thanks for your help!

--Vasu

0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager
Jump to solution

It looks like the issue is with you using -1 as input for StartDelay and StopDelay, -1 is not a valid input from what I've tested and you need to specify either systemDefault or a time interval.

I created 4 dummy VMs on ESXi 4.0 host and did the following and it worked:

Enable autostart via vimsh (vim-cmd)

~ #  vim-cmd hostsvc/autostartmanager/enable_autostart 1
Enabled AutoStart

Setting the 1st VM:

~ # vim-cmd hostsvc/autostartmanager/update_autostartentry 1264 "PowerOn" "15" "1" "systemDefault" "systemDefault" "systemDefault"

1Updated AutoStart order.

Setting the 2nd VM:

~ # vim-cmd hostsvc/autostartmanager/update_autostartentry 1232 "PowerOn" "15" "2" "systemDefault" "systemDefault" "systemDefault"

2Updated AutoStart order.

Setting the 3rd VM:

~ # vim-cmd hostsvc/autostartmanager/update_autostartentry 1280 "PowerOn" "15" "3" "systemDefault" "systemDefault" "systemDefault"

3Updated AutoStart order.

Setting the 4th VM:

~ # vim-cmd hostsvc/autostartmanager/update_autostartentry 1264 "PowerOn" "15" "4" "systemDefault" "systemDefault" "systemDefault"

4Updated AutoStart order.

You can also manually set the auto start/stop using the vSphere Client and using the following command to retrieve the config:

vim-cmd hostsvc/autostartmanager/get_autostartseq

which can then be used as a basis to set the configuration.

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

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

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

VMware Developer Comuunity

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

View solution in original post

0 Kudos
2 Replies
lamw
Community Manager
Community Manager
Jump to solution

It looks like the issue is with you using -1 as input for StartDelay and StopDelay, -1 is not a valid input from what I've tested and you need to specify either systemDefault or a time interval.

I created 4 dummy VMs on ESXi 4.0 host and did the following and it worked:

Enable autostart via vimsh (vim-cmd)

~ #  vim-cmd hostsvc/autostartmanager/enable_autostart 1
Enabled AutoStart

Setting the 1st VM:

~ # vim-cmd hostsvc/autostartmanager/update_autostartentry 1264 "PowerOn" "15" "1" "systemDefault" "systemDefault" "systemDefault"

1Updated AutoStart order.

Setting the 2nd VM:

~ # vim-cmd hostsvc/autostartmanager/update_autostartentry 1232 "PowerOn" "15" "2" "systemDefault" "systemDefault" "systemDefault"

2Updated AutoStart order.

Setting the 3rd VM:

~ # vim-cmd hostsvc/autostartmanager/update_autostartentry 1280 "PowerOn" "15" "3" "systemDefault" "systemDefault" "systemDefault"

3Updated AutoStart order.

Setting the 4th VM:

~ # vim-cmd hostsvc/autostartmanager/update_autostartentry 1264 "PowerOn" "15" "4" "systemDefault" "systemDefault" "systemDefault"

4Updated AutoStart order.

You can also manually set the auto start/stop using the vSphere Client and using the following command to retrieve the config:

vim-cmd hostsvc/autostartmanager/get_autostartseq

which can then be used as a basis to set the configuration.

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

William Lam

VMware vExpert 2009

VMware ESX/ESXi scripts and resources at:

Twitter: @lamw

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

VMware Developer Comuunity

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

0 Kudos
vnagendr
Contributor
Contributor
Jump to solution

Thank you! That was it.. I was getting thrown off by the "1" instead of "-1"..

0 Kudos