2013-03-18 05:06:52 +08:00
|
|
|
#
|
2013-10-28 04:59:46 +08:00
|
|
|
# Copyright 2010, 2013 Red Hat, Inc.
|
2013-03-18 05:06:52 +08:00
|
|
|
# Cole Robinson <crobinso@redhat.com>
|
|
|
|
#
|
2018-04-04 21:35:41 +08:00
|
|
|
# This work is licensed under the GNU GPLv2 or later.
|
2018-03-21 03:00:02 +08:00
|
|
|
# See the COPYING file in the top-level directory.
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2018-03-21 00:18:35 +08:00
|
|
|
from .device import Device
|
2018-03-21 00:27:37 +08:00
|
|
|
from ..xmlbuilder import XMLProperty
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2013-04-14 02:34:52 +08:00
|
|
|
|
2018-03-21 00:18:35 +08:00
|
|
|
class DeviceWatchdog(Device):
|
2018-03-21 22:53:34 +08:00
|
|
|
XML_NAME = "watchdog"
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2013-07-15 22:57:16 +08:00
|
|
|
MODEL_I6300 = "i6300esb"
|
|
|
|
MODEL_IB700 = "ib700"
|
2015-11-09 10:57:29 +08:00
|
|
|
MODEL_DIAG288 = "diag288"
|
|
|
|
MODELS = [MODEL_I6300, MODEL_IB700, MODEL_DIAG288]
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
ACTION_SHUTDOWN = "shutdown"
|
|
|
|
ACTION_RESET = "reset"
|
|
|
|
ACTION_POWEROFF = "poweroff"
|
|
|
|
ACTION_PAUSE = "pause"
|
|
|
|
ACTION_NONE = "none"
|
2013-08-19 04:06:18 +08:00
|
|
|
ACTION_DUMP = "dump"
|
2013-03-18 05:06:52 +08:00
|
|
|
ACTIONS = [ACTION_RESET, ACTION_SHUTDOWN,
|
|
|
|
ACTION_POWEROFF, ACTION_PAUSE,
|
2018-01-19 07:17:57 +08:00
|
|
|
ACTION_DUMP, ACTION_NONE]
|
2013-03-18 05:06:52 +08:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_action_desc(action):
|
2018-03-21 00:18:35 +08:00
|
|
|
if action == DeviceWatchdog.ACTION_RESET:
|
2013-03-18 05:06:52 +08:00
|
|
|
return _("Forcefully reset the guest")
|
2018-03-21 00:18:35 +08:00
|
|
|
if action == DeviceWatchdog.ACTION_SHUTDOWN:
|
2013-03-18 05:06:52 +08:00
|
|
|
return _("Gracefully shutdown the guest")
|
2018-03-21 00:18:35 +08:00
|
|
|
if action == DeviceWatchdog.ACTION_POWEROFF:
|
2013-03-18 05:06:52 +08:00
|
|
|
return _("Forcefully power off the guest")
|
2018-03-21 00:18:35 +08:00
|
|
|
if action == DeviceWatchdog.ACTION_PAUSE:
|
2013-03-18 05:06:52 +08:00
|
|
|
return _("Pause the guest")
|
2018-03-21 00:18:35 +08:00
|
|
|
if action == DeviceWatchdog.ACTION_NONE:
|
2013-03-18 05:06:52 +08:00
|
|
|
return _("No action")
|
2018-03-21 00:18:35 +08:00
|
|
|
if action == DeviceWatchdog.ACTION_DUMP:
|
2018-01-19 07:17:57 +08:00
|
|
|
return _("Dump guest memory core")
|
2013-07-15 22:57:16 +08:00
|
|
|
return action
|
|
|
|
|
|
|
|
_XML_PROP_ORDER = ["model", "action"]
|
2018-09-02 05:34:32 +08:00
|
|
|
model = XMLProperty("./@model")
|
|
|
|
action = XMLProperty("./@action")
|
|
|
|
|
|
|
|
|
|
|
|
##################
|
|
|
|
# Default config #
|
|
|
|
##################
|
|
|
|
|
|
|
|
def set_defaults(self, _guest):
|
|
|
|
if not self.model:
|
|
|
|
self.model = self.MODEL_I6300
|
|
|
|
if not self.action:
|
|
|
|
self.action = self.ACTION_RESET
|