mirror of
https://github.com/virt-manager/virt-manager.git
synced 2026-08-04 02:13:21 -05:00
devices: watchdog: Add set_defaults
This commit is contained in:
+4
-1
@@ -1012,7 +1012,9 @@ class XMLParseTest(unittest.TestCase):
|
||||
guest.remove_device(rmdev)
|
||||
|
||||
# Basic device add
|
||||
guest.add_device(virtinst.DeviceWatchdog(self.conn))
|
||||
d = virtinst.DeviceWatchdog(self.conn)
|
||||
d.set_defaults(guest)
|
||||
guest.add_device(d)
|
||||
|
||||
# Test adding device with child properties (address value)
|
||||
adddev = virtinst.DeviceInterface(self.conn)
|
||||
@@ -1020,6 +1022,7 @@ class XMLParseTest(unittest.TestCase):
|
||||
adddev.source = "default"
|
||||
adddev.macaddr = "1A:2A:3A:4A:5A:6A"
|
||||
adddev.address.set_addrstr("spapr-vio")
|
||||
adddev.set_defaults(guest)
|
||||
|
||||
# Test adding and removing the same device
|
||||
guest.add_device(adddev)
|
||||
|
||||
+4
-4
@@ -2369,8 +2369,8 @@ class ParserInput(VirtCLIParser):
|
||||
|
||||
_register_virt_parser(ParserInput)
|
||||
_add_device_address_args(ParserInput)
|
||||
ParserInput.add_arg("type", "type")
|
||||
ParserInput.add_arg("bus", "bus")
|
||||
ParserInput.add_arg("type", "type", ignore_default=True)
|
||||
ParserInput.add_arg("bus", "bus", ignore_default=True)
|
||||
|
||||
|
||||
#######################
|
||||
@@ -2517,8 +2517,8 @@ class ParserWatchdog(VirtCLIParser):
|
||||
|
||||
_register_virt_parser(ParserWatchdog)
|
||||
_add_device_address_args(ParserWatchdog)
|
||||
ParserWatchdog.add_arg("model", "model")
|
||||
ParserWatchdog.add_arg("action", "action")
|
||||
ParserWatchdog.add_arg("model", "model", ignore_default=True)
|
||||
ParserWatchdog.add_arg("action", "action", ignore_default=True)
|
||||
|
||||
|
||||
####################
|
||||
|
||||
@@ -15,7 +15,6 @@ class DeviceWatchdog(Device):
|
||||
MODEL_I6300 = "i6300esb"
|
||||
MODEL_IB700 = "ib700"
|
||||
MODEL_DIAG288 = "diag288"
|
||||
MODEL_DEFAULT = "default"
|
||||
MODELS = [MODEL_I6300, MODEL_IB700, MODEL_DIAG288]
|
||||
|
||||
ACTION_SHUTDOWN = "shutdown"
|
||||
@@ -24,7 +23,6 @@ class DeviceWatchdog(Device):
|
||||
ACTION_PAUSE = "pause"
|
||||
ACTION_NONE = "none"
|
||||
ACTION_DUMP = "dump"
|
||||
ACTION_DEFAULT = "default"
|
||||
ACTIONS = [ACTION_RESET, ACTION_SHUTDOWN,
|
||||
ACTION_POWEROFF, ACTION_PAUSE,
|
||||
ACTION_DUMP, ACTION_NONE]
|
||||
@@ -46,9 +44,16 @@ class DeviceWatchdog(Device):
|
||||
return action
|
||||
|
||||
_XML_PROP_ORDER = ["model", "action"]
|
||||
model = XMLProperty("./@model",
|
||||
default_name=MODEL_DEFAULT,
|
||||
default_cb=lambda s: s.MODEL_I6300)
|
||||
action = XMLProperty("./@action",
|
||||
default_name=ACTION_DEFAULT,
|
||||
default_cb=lambda s: s.ACTION_RESET)
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user