Dave_Mac
Contributor
Contributor

Hostops.pl reboot error

Jump to solution

Using the vSphere CLI, trying to reboot a standalone vSphere ESXi host. Calling the hostops.pl script to reboot and getting an error. The argument I'm using is:

hostops.pl --server line 1.

End Disconnect'

I can confirm it's not my connection parameters as I can put the host in and out of maintenance mode using hostops. When I run with the --operation shutdown argument I get the same error.

Any ideas? I don't know Perl, but I would guess it's trying to flag up an error whilst running hostops, buggy script?

Tags (4)
0 Kudos
1 Solution

Accepted Solutions
lamw
Community Manager
Community Manager

The script definitely is buggy, there's a few things to take a look at:

1) Is your host already in maintenance mode?

2) Even though there is a force option, IRRC, VMware did not implement the code to actually allow you to force a reboot/shutdown

3) If you take a look at the help options, there's an additional parameter that is required called target_host, I think you used host instead which is incorrect.

[vi-admin@scofield ~]$ /usr/lib/vmware-vcli/apps/host/hostops.pl --help

Synopsis: /usr/lib/vmware-vcli/apps/host/hostops.pl OPTIONS


Command-specific options:
   --cluster
       The cluster in which to add the host
   --folder
       The folder in which to add the host
   --force (default '0')
       Flag to specify whether or not to force the addition of host even if this is being managed by other virtual center.
   --operation (required)
      Operation to perform on target host:add_standalone, disconnect, enter_maintenance,exit_maintenance, reboot, shutdown, addhost, reconnect,removehost, moveintofolder, moveintocluster
   --port
       The port number for the connection
   --quiet (default '1')
       Flag to specify whether or not to provide progress messages as the virtual machines are suspended for some operations.
   --suspend (default '0')
       Flag to specify whether or not to suspend the virtual machines
   --target_host (required)
      Target host
   --target_password
      Target host password
   --target_username
      Target host username

You may also want to take a look at my version of host operations: It currently supports only subset of the features, but it's pretty trivial to add the remainder functionality. I've just updated the script to allow reboots, let me know if there are others you need. I'll try to get the rest in by later this week.

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

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

The script definitely is buggy, there's a few things to take a look at:

1) Is your host already in maintenance mode?

2) Even though there is a force option, IRRC, VMware did not implement the code to actually allow you to force a reboot/shutdown

3) If you take a look at the help options, there's an additional parameter that is required called target_host, I think you used host instead which is incorrect.

[vi-admin@scofield ~]$ /usr/lib/vmware-vcli/apps/host/hostops.pl --help

Synopsis: /usr/lib/vmware-vcli/apps/host/hostops.pl OPTIONS


Command-specific options:
   --cluster
       The cluster in which to add the host
   --folder
       The folder in which to add the host
   --force (default '0')
       Flag to specify whether or not to force the addition of host even if this is being managed by other virtual center.
   --operation (required)
      Operation to perform on target host:add_standalone, disconnect, enter_maintenance,exit_maintenance, reboot, shutdown, addhost, reconnect,removehost, moveintofolder, moveintocluster
   --port
       The port number for the connection
   --quiet (default '1')
       Flag to specify whether or not to provide progress messages as the virtual machines are suspended for some operations.
   --suspend (default '0')
       Flag to specify whether or not to suspend the virtual machines
   --target_host (required)
      Target host
   --target_password
      Target host password
   --target_username
      Target host username

You may also want to take a look at my version of host operations: It currently supports only subset of the features, but it's pretty trivial to add the remainder functionality. I've just updated the script to allow reboots, let me know if there are others you need. I'll try to get the rest in by later this week.

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

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
Dave_Mac
Contributor
Contributor

Apologies for the late response, cheers for taking the time out to look at this.

Dave

0 Kudos