Package ganeti :: Package watcher
[hide private]
[frames] | no frames]

Package watcher

source code

Tool to restart erroneously downed virtual machines.

This program and set of classes implement a watchdog to restart virtual machines in a Ganeti cluster that have crashed or been killed by a node reboot. Run from cron or similar.

Classes [hide private]
  NotMasterError
Exception raised when this host is not the master.
  NodeMaintenance
Talks to confd daemons and possible shutdown instances/drbd devices.
  WatcherState
Interface to a state file recording restart attempts.
  Instance
Abstraction for a Virtual Machine instance.
  Watcher
Encapsulate the logic for restarting erroneously halted virtual machines.
Functions [hide private]
 
ShouldPause()
Check whether we should pause.
source code
 
StartNodeDaemons()
Start all the daemons that should be running on all nodes.
source code
 
RunWatcherHooks()
Run the watcher hooks.
source code
 
GetClusterData()
Get a list of instances on this cluster.
source code
 
OpenStateFile(path)
Opens the state file and acquires a lock on it.
source code
bool
IsRapiResponding(hostname)
Connects to RAPI port and does a simple test.
source code
 
ParseOptions()
Parse the command line options.
source code
 
Main()
Main function.
source code
Variables [hide private]
  MAXTRIES = 5
  RETRY_EXPIRATION = 8* 3600
  BAD_STATES = ['ERROR_down']
  HELPLESS_STATES = ['ERROR_nodedown', 'ERROR_nodeoffline']
  NOTICE = 'NOTICE'
  ERROR = 'ERROR'
  KEY_RESTART_COUNT = "restart_count"
  KEY_RESTART_WHEN = "restart_when"
  KEY_BOOT_ID = "bootid"
  client = None

Imports: os, sys, time, logging, OptionParser, utils, constants, serializer, errors, opcodes, cli, luxi, ssconf, bdev, hypervisor, rapi, confd_client, netutils, ganeti


Function Details [hide private]

OpenStateFile(path)

source code 

Opens the state file and acquires a lock on it.

Parameters:
  • path (string) - Path to state file

IsRapiResponding(hostname)

source code 

Connects to RAPI port and does a simple test.

Connects to RAPI port of hostname and does a simple test. At this time, the test is GetVersion.

Parameters:
  • hostname (string) - hostname of the node to connect to.
Returns: bool
Whether RAPI is working properly

ParseOptions()

source code 

Parse the command line options.

Returns:
(options, args) as from OptionParser.parse_args()

Main()

source code 

Main function.

Decorators:
  • @rapi.client.UsesRapiClient