2013-03-17 17:06:52 -04:00
#
2013-10-27 21:59:46 +01:00
# Copyright 2011, 2013 Red Hat, Inc.
2013-03-17 17:06:52 -04:00
#
2018-04-04 14:35:41 +01:00
# This work is licensed under the GNU GPLv2 or later.
2018-03-20 15:00:02 -04:00
# See the COPYING file in the top-level directory.
2013-03-17 17:06:52 -04:00
2019-05-13 15:10:38 -04:00
from . char import CharSource
2018-03-20 12:18:35 -04:00
from . device import Device
2019-05-14 11:14:28 -04:00
from . . xmlbuilder import XMLBuilder , XMLChildProperty , XMLProperty
class _Certificate ( XMLBuilder ) :
XML_NAME = " certificate "
value = XMLProperty ( " ./. " )
2013-03-17 17:06:52 -04:00
2013-04-13 14:34:52 -04:00
2018-03-20 12:18:35 -04:00
class DeviceSmartcard ( Device ) :
2018-03-21 10:53:34 -04:00
XML_NAME = " smartcard "
2018-09-01 19:58:24 -04:00
_XML_PROP_ORDER = [ " mode " , " type " ]
2013-03-17 17:06:52 -04:00
2018-09-01 19:58:24 -04:00
mode = XMLProperty ( " ./@mode " )
type = XMLProperty ( " ./@type " )
2019-05-13 15:10:38 -04:00
source = XMLChildProperty ( CharSource , is_single = True )
2013-03-17 17:06:52 -04:00
2019-05-14 11:14:28 -04:00
database = XMLProperty ( " ./database " )
certificates = XMLChildProperty ( _Certificate )
2013-03-17 17:06:52 -04:00
2018-09-01 19:58:24 -04:00
##################
# Default config #
##################
2013-03-17 17:06:52 -04:00
2018-09-01 19:58:24 -04:00
def default_type ( self ) :
return self . mode == " passthrough " and " spicevmc " or " tcp "
2013-03-17 17:06:52 -04:00
2018-09-01 19:58:24 -04:00
def set_defaults ( self , guest ) :
if not self . mode :
self . mode = " passthrough "
if not self . type :
self . type = self . default_type ( )