Revision f07521e5
b/daemons/ganeti-watcher | ||
---|---|---|
276 | 276 |
to restart machines that are down. |
277 | 277 |
|
278 | 278 |
""" |
279 |
def __init__(self): |
|
279 |
def __init__(self, opts):
|
|
280 | 280 |
master = client.QueryConfigValues(["master_node"])[0] |
281 | 281 |
if master != utils.HostInfo().name: |
282 | 282 |
raise NotMasterError("This is not the master node") |
283 | 283 |
self.instances = GetInstanceList() |
284 | 284 |
self.bootids = GetNodeBootIDs() |
285 | 285 |
self.started_instances = set() |
286 |
self.opts = opts |
|
286 | 287 |
|
287 | 288 |
def Run(self): |
288 | 289 |
notepad = WatcherState() |
289 | 290 |
try: |
291 |
self.ArchiveJobs(self.opts.job_age) |
|
290 | 292 |
self.CheckInstances(notepad) |
291 | 293 |
self.CheckDisks(notepad) |
292 | 294 |
self.VerifyDisks() |
293 | 295 |
finally: |
294 | 296 |
notepad.Save() |
295 | 297 |
|
298 |
def ArchiveJobs(self, age): |
|
299 |
"""Archive old jobs. |
|
300 |
|
|
301 |
""" |
|
302 |
arch_count, left_count = client.AutoArchiveJobs(age) |
|
303 |
logging.debug("Archived %s jobs, left %s" % (arch_count, left_count)) |
|
304 |
|
|
296 | 305 |
def CheckDisks(self, notepad): |
297 | 306 |
"""Check all nodes for restarted ones. |
298 | 307 |
|
... | ... | |
408 | 417 |
parser.add_option("-d", "--debug", dest="debug", |
409 | 418 |
help="Write all messages to stderr", |
410 | 419 |
default=False, action="store_true") |
420 |
parser.add_option("-A", "--job-age", dest="job_age", |
|
421 |
help="Autoarchive jobs older than this age (default" |
|
422 |
" 6 hours)", default=6*3600) |
|
411 | 423 |
options, args = parser.parse_args() |
424 |
options.job_age = cli.ParseTimespec(options.job_age) |
|
412 | 425 |
return options, args |
413 | 426 |
|
414 | 427 |
|
... | ... | |
427 | 440 |
client = cli.GetClient() |
428 | 441 |
|
429 | 442 |
try: |
430 |
watcher = Watcher() |
|
443 |
watcher = Watcher(options)
|
|
431 | 444 |
except errors.ConfigurationError: |
432 | 445 |
# Just exit if there's no configuration |
433 | 446 |
sys.exit(constants.EXIT_SUCCESS) |
Also available in: Unified diff