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
# Cole Robinson <crobinso@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
2013-10-28 00:59:47 +04:00
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
2013-03-18 01:06:52 +04:00
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA.
2014-09-12 23:59:22 +04:00
from . device import VirtualDevice
from . xmlbuilder import XMLProperty
2013-03-18 01:06:52 +04:00
2013-04-13 22:34:52 +04:00
2013-04-11 03:48:07 +04:00
class VirtualWatchdog ( VirtualDevice ) :
2013-03-18 01:06:52 +04:00
2013-07-16 17:14:37 +04:00
virtual_device_type = VirtualDevice . VIRTUAL_DEV_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 "
2013-03-18 01:06:52 +04:00
MODEL_DEFAULT = " default "
2015-11-09 05:57:29 +03:00
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-07-15 18:57:16 +04:00
ACTION_DEFAULT = " default "
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 ) :
if action == VirtualWatchdog . ACTION_RESET :
return _ ( " Forcefully reset the guest " )
if action == VirtualWatchdog . ACTION_SHUTDOWN :
return _ ( " Gracefully shutdown the guest " )
if action == VirtualWatchdog . ACTION_POWEROFF :
return _ ( " Forcefully power off the guest " )
if action == VirtualWatchdog . ACTION_PAUSE :
return _ ( " Pause the guest " )
if action == VirtualWatchdog . ACTION_NONE :
return _ ( " No action " )
2018-01-19 02:17:57 +03:00
if action == VirtualWatchdog . ACTION_DUMP :
return _ ( " Dump guest memory core " )
2013-07-15 18:57:16 +04:00
return action
_XML_PROP_ORDER = [ " model " , " action " ]
2013-09-19 21:27:30 +04:00
model = XMLProperty ( " ./@model " ,
2013-07-15 18:57:16 +04:00
default_name = MODEL_DEFAULT ,
default_cb = lambda s : s . MODEL_I6300 )
2013-09-19 21:27:30 +04:00
action = XMLProperty ( " ./@action " ,
2013-07-15 18:57:16 +04:00
default_name = ACTION_DEFAULT ,
default_cb = lambda s : s . ACTION_RESET )
2013-07-24 16:46:55 +04:00
VirtualWatchdog . register_type ( )