This repository was archived by the owner on Mar 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathDomainFeatures.py
More file actions
89 lines (75 loc) · 2.84 KB
/
DomainFeatures.py
File metadata and controls
89 lines (75 loc) · 2.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#
# Copyright 2010 Red Hat, Inc.
# Cole Robinson <crobinso@redhat.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301 USA.
import XMLBuilderDomain
from XMLBuilderDomain import _xml_property
def _none_or_bool(val):
if val is None:
return val
return bool(val)
class DomainFeatures(XMLBuilderDomain.XMLBuilderDomain):
"""
Class for generating <features> XML
"""
_dumpxml_xpath = "/domain/features"
def __init__(self, conn, parsexml=None, parsexmlnode=None, caps=None):
XMLBuilderDomain.XMLBuilderDomain.__init__(self, conn, parsexml,
parsexmlnode, caps)
self._acpi = None
self._apic = None
self._pae = None
def get_acpi(self):
return self._acpi
def set_acpi(self, val):
self._acpi = _none_or_bool(val)
acpi = _xml_property(get_acpi, set_acpi,
xpath="./features/acpi", is_bool=True)
def get_apic(self):
return self._apic
def set_apic(self, val):
self._apic = _none_or_bool(val)
apic = _xml_property(get_apic, set_apic,
xpath="./features/apic", is_bool=True)
def get_pae(self):
return self._pae
def set_pae(self, val):
self._pae = _none_or_bool(val)
pae = _xml_property(get_pae, set_pae,
xpath="./features/pae", is_bool=True)
def __setitem__(self, attr, val):
return setattr(self, attr, val)
def __getitem__(self, attr):
return getattr(self, attr)
def __delitem__(self, attr):
return setattr(self, attr, None)
def _get_xml_config(self, defaults=None):
if not defaults:
defaults = {}
ret = ""
feature_xml = ""
if self.acpi or (self.acpi is None and defaults.get("acpi")):
feature_xml += "<acpi/>"
if self.apic or (self.apic is None and defaults.get("apic")):
feature_xml += "<apic/>"
if self.pae or (self.pae is None and defaults.get("pae")):
feature_xml += "<pae/>"
if feature_xml:
ret += " <features>\n"
ret += " %s\n" % feature_xml
ret += " </features>"
return ret