2013-03-18 05:06:52 +08:00
|
|
|
#
|
2013-10-28 04:59:46 +08:00
|
|
|
# Copyright 2011, 2013 Red Hat, Inc.
|
2013-03-18 05:06:52 +08:00
|
|
|
#
|
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
|
|
|
|
2019-05-14 03:10:38 +08:00
|
|
|
from .char import CharSource
|
2018-03-21 00:18:35 +08:00
|
|
|
from .device import Device
|
2019-05-14 23:14:28 +08:00
|
|
|
from ..xmlbuilder import XMLBuilder, XMLChildProperty, XMLProperty
|
|
|
|
|
|
|
|
|
|
|
|
class _Certificate(XMLBuilder):
|
|
|
|
XML_NAME = "certificate"
|
|
|
|
|
|
|
|
value = 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 DeviceSmartcard(Device):
|
2018-03-21 22:53:34 +08:00
|
|
|
XML_NAME = "smartcard"
|
2018-09-02 07:58:24 +08:00
|
|
|
_XML_PROP_ORDER = ["mode", "type"]
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2018-09-02 07:58:24 +08:00
|
|
|
mode = XMLProperty("./@mode")
|
|
|
|
type = XMLProperty("./@type")
|
2019-05-14 03:10:38 +08:00
|
|
|
source = XMLChildProperty(CharSource, is_single=True)
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2019-05-14 23:14:28 +08:00
|
|
|
database = XMLProperty("./database")
|
|
|
|
certificates = XMLChildProperty(_Certificate)
|
|
|
|
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2018-09-02 07:58:24 +08:00
|
|
|
##################
|
|
|
|
# Default config #
|
|
|
|
##################
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2018-09-02 07:58:24 +08:00
|
|
|
def default_type(self):
|
|
|
|
return self.mode == "passthrough" and "spicevmc" or "tcp"
|
2013-03-18 05:06:52 +08:00
|
|
|
|
2018-09-02 07:58:24 +08:00
|
|
|
def set_defaults(self, guest):
|
|
|
|
if not self.mode:
|
|
|
|
self.mode = "passthrough"
|
|
|
|
if not self.type:
|
|
|
|
self.type = self.default_type()
|