2014-01-10 03:37:54 -06:00
|
|
|
#
|
|
|
|
# Copyright 2013 Fujitsu Limited.
|
|
|
|
# Chen Hanxiao <chenhanxiao at cn.fujitsu.com>
|
|
|
|
#
|
2018-03-20 14:00:02 -05:00
|
|
|
# This work is licensed under the GNU GPLv2.
|
|
|
|
# See the COPYING file in the top-level directory.
|
2014-01-10 03:37:54 -06:00
|
|
|
|
2018-03-20 11:18:35 -05:00
|
|
|
from .device import Device
|
2018-03-20 11:27:37 -05:00
|
|
|
from ..xmlbuilder import XMLProperty
|
2014-01-10 03:37:54 -06:00
|
|
|
|
|
|
|
|
2018-03-20 11:18:35 -05:00
|
|
|
class DevicePanic(Device):
|
2018-03-20 17:59:14 -05:00
|
|
|
_XML_ROOT_NAME = "panic"
|
2017-09-04 11:40:34 -05:00
|
|
|
|
|
|
|
MODEL_DEFAULT = "default"
|
|
|
|
MODEL_ISA = "isa"
|
2017-09-05 02:38:39 -05:00
|
|
|
MODEL_PSERIES = "pseries"
|
|
|
|
MODEL_HYPERV = "hyperv"
|
|
|
|
MODEL_S390 = "s390"
|
|
|
|
MODELS = [MODEL_ISA, MODEL_PSERIES, MODEL_HYPERV, MODEL_S390]
|
2017-09-04 11:40:34 -05:00
|
|
|
|
|
|
|
ISA_ADDRESS_TYPE = "isa"
|
2014-01-10 03:37:54 -06:00
|
|
|
|
|
|
|
@staticmethod
|
2017-09-04 11:40:34 -05:00
|
|
|
def get_pretty_model(panic_model):
|
2018-03-20 11:18:35 -05:00
|
|
|
if panic_model == DevicePanic.MODEL_ISA:
|
2014-01-10 03:37:54 -06:00
|
|
|
return _("ISA")
|
2018-03-20 11:18:35 -05:00
|
|
|
elif panic_model == DevicePanic.MODEL_PSERIES:
|
2017-09-05 02:38:39 -05:00
|
|
|
return _("pSeries")
|
2018-03-20 11:18:35 -05:00
|
|
|
elif panic_model == DevicePanic.MODEL_HYPERV:
|
2017-09-05 02:38:39 -05:00
|
|
|
return _("Hyper-V")
|
2018-03-20 11:18:35 -05:00
|
|
|
elif panic_model == DevicePanic.MODEL_S390:
|
2017-09-05 02:38:39 -05:00
|
|
|
return _("s390")
|
2017-09-04 11:40:34 -05:00
|
|
|
return panic_model
|
2014-01-10 03:37:54 -06:00
|
|
|
|
2017-09-05 02:38:39 -05:00
|
|
|
@staticmethod
|
|
|
|
def get_models(os):
|
|
|
|
if os.is_x86():
|
2018-03-20 11:18:35 -05:00
|
|
|
return [DevicePanic.MODEL_ISA,
|
|
|
|
DevicePanic.MODEL_HYPERV]
|
2017-09-05 02:38:39 -05:00
|
|
|
elif os.is_pseries():
|
2018-03-20 11:18:35 -05:00
|
|
|
return [DevicePanic.MODEL_PSERIES]
|
2017-09-05 02:38:39 -05:00
|
|
|
elif os.is_s390x():
|
2018-03-20 11:18:35 -05:00
|
|
|
return [DevicePanic.MODEL_S390]
|
2017-10-27 02:42:54 -05:00
|
|
|
return []
|
2017-09-05 02:38:39 -05:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def get_default_model(os):
|
2018-03-20 11:18:35 -05:00
|
|
|
models = DevicePanic.get_models(os)
|
2017-09-05 02:38:39 -05:00
|
|
|
if models:
|
|
|
|
return models[0]
|
|
|
|
return None
|
|
|
|
|
2017-09-04 11:40:34 -05:00
|
|
|
def _get_default_address_type(self):
|
|
|
|
if self.iobase:
|
2018-03-20 11:18:35 -05:00
|
|
|
return DevicePanic.ISA_ADDRESS_TYPE
|
2017-09-04 11:40:34 -05:00
|
|
|
return None
|
2014-01-10 03:37:54 -06:00
|
|
|
|
2017-09-04 11:40:34 -05:00
|
|
|
model = XMLProperty("./@model",
|
2018-03-20 11:18:35 -05:00
|
|
|
default_cb=lambda s: DevicePanic.MODEL_ISA,
|
2017-09-04 11:40:34 -05:00
|
|
|
default_name=MODEL_DEFAULT)
|
2014-01-10 03:37:54 -06:00
|
|
|
type = XMLProperty("./address/@type",
|
2017-09-04 11:40:34 -05:00
|
|
|
default_cb=_get_default_address_type)
|
2017-09-04 11:44:56 -05:00
|
|
|
iobase = XMLProperty("./address/@iobase")
|