2
# Copyright 2010 Red Hat, Inc.
3
# Cole Robinson <crobinso@redhat.com>
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2 of the License, or
8
# (at your option) any later version.
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software
17
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
20
import XMLBuilderDomain
21
from XMLBuilderDomain import _xml_property
23
def _none_or_bool(val):
28
class DomainFeatures(XMLBuilderDomain.XMLBuilderDomain):
30
Class for generating <features> XML
33
_dumpxml_xpath = "/domain/features"
34
def __init__(self, conn, parsexml=None, parsexmlnode=None, caps=None):
35
XMLBuilderDomain.XMLBuilderDomain.__init__(self, conn, parsexml,
44
def set_acpi(self, val):
45
self._acpi = _none_or_bool(val)
46
acpi = _xml_property(get_acpi, set_acpi,
47
xpath="./features/acpi", is_bool=True)
51
def set_apic(self, val):
52
self._apic = _none_or_bool(val)
53
apic = _xml_property(get_apic, set_apic,
54
xpath="./features/apic", is_bool=True)
58
def set_pae(self, val):
59
self._pae = _none_or_bool(val)
60
pae = _xml_property(get_pae, set_pae,
61
xpath="./features/pae", is_bool=True)
63
def __setitem__(self, attr, val):
64
setattr(self, attr, val)
65
def __getitem__(self, attr):
67
def __delitem__(self, attr):
68
setattr(self, attr, None)
71
def _get_xml_config(self, defaults=None):
77
if self.acpi or (self.acpi is None and defaults.get("acpi")):
78
feature_xml += "<acpi/>"
79
if self.apic or (self.apic is None and defaults.get("apic")):
80
feature_xml += "<apic/>"
81
if self.pae or (self.pae is None and defaults.get("pae")):
82
feature_xml += "<pae/>"
85
ret += " <features>\n"
86
ret += " %s\n" % feature_xml