~ubuntu-branches/ubuntu/precise/virtinst/precise-updates

« back to all changes in this revision

Viewing changes to virtinst/DomainFeatures.py

  • Committer: Bazaar Package Importer
  • Author(s): Marc Deslauriers
  • Date: 2011-02-01 15:40:11 UTC
  • mfrom: (1.3.16 experimental)
  • Revision ID: james.westby@ubuntu.com-20110201154011-op0nusgc240xajvb
Tags: 0.500.5-1ubuntu1
* Merge from debian experimental. Remaining changes:
  - debian/patches/9001_Ubuntu.patch:
     + Updated to add maverick and natty to OS list and enable virtio
       for them.
  - debian/patches/9003-fix-path-to-hvmloader-in-testsuite.patch: adjust
    testsuite for 0001-fix-path-to-hvmloader.patch and
    0002-Fix-path-to-pygrub.patch. (refreshed)
  - debian/control: added acl package to depends.
  - Demote virt-viewer to Suggests, as it's in universe.
  - Recommends libvirt-bin
* Removed patches:
  - debian/patches/9002-libvirt_disk_format.patch: Upstream.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Copyright 2010  Red Hat, Inc.
 
3
# Cole Robinson <crobinso@redhat.com>
 
4
#
 
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.
 
9
#
 
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.
 
14
#
 
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,
 
18
# MA 02110-1301 USA.
 
19
 
 
20
import XMLBuilderDomain
 
21
from XMLBuilderDomain import _xml_property
 
22
 
 
23
def _none_or_bool(val):
 
24
    if val is None:
 
25
        return val
 
26
    return bool(val)
 
27
 
 
28
class DomainFeatures(XMLBuilderDomain.XMLBuilderDomain):
 
29
    """
 
30
    Class for generating <features> XML
 
31
    """
 
32
 
 
33
    _dumpxml_xpath = "/domain/features"
 
34
    def __init__(self, conn, parsexml=None, parsexmlnode=None, caps=None):
 
35
        XMLBuilderDomain.XMLBuilderDomain.__init__(self, conn, parsexml,
 
36
                                                   parsexmlnode, caps)
 
37
 
 
38
        self._acpi = None
 
39
        self._apic = None
 
40
        self._pae = None
 
41
 
 
42
    def get_acpi(self):
 
43
        return self._acpi
 
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)
 
48
 
 
49
    def get_apic(self):
 
50
        return self._apic
 
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)
 
55
 
 
56
    def get_pae(self):
 
57
        return self._pae
 
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)
 
62
 
 
63
    def __setitem__(self, attr, val):
 
64
        setattr(self, attr, val)
 
65
    def __getitem__(self, attr):
 
66
        getattr(self, attr)
 
67
    def __delitem__(self, attr):
 
68
        setattr(self, attr, None)
 
69
 
 
70
 
 
71
    def _get_xml_config(self, defaults=None):
 
72
        if not defaults:
 
73
            defaults = {}
 
74
        ret = ""
 
75
 
 
76
        feature_xml = ""
 
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/>"
 
83
 
 
84
        if feature_xml:
 
85
            ret += "  <features>\n"
 
86
            ret += "    %s\n" % feature_xml
 
87
            ret += "  </features>"
 
88
 
 
89
        return ret