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