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

« back to all changes in this revision

Viewing changes to virtinst/VirtualController.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:
19
19
 
20
20
import VirtualDevice
21
21
#from virtinst import _virtinst as _
 
22
from XMLBuilderDomain import _xml_property
22
23
 
23
24
class VirtualController(VirtualDevice.VirtualDevice):
24
25
 
31
32
    CONTROLLER_TYPE_VIRTIOSERIAL    = "virtio-serial"
32
33
    CONTROLLER_TYPES = [CONTROLLER_TYPE_IDE, CONTROLLER_TYPE_FDC,
33
34
                        CONTROLLER_TYPE_SCSI, CONTROLLER_TYPE_SATA,
34
 
                        CONTROLLER_TYPE_VIRTIOSERIAL ]
 
35
                        CONTROLLER_TYPE_VIRTIOSERIAL]
 
36
 
 
37
    @staticmethod
 
38
    def pretty_type(ctype):
 
39
        pretty_mappings = {
 
40
            VirtualController.CONTROLLER_TYPE_IDE           : "IDE",
 
41
            VirtualController.CONTROLLER_TYPE_FDC           : "Floppy",
 
42
            VirtualController.CONTROLLER_TYPE_SCSI          : "SCSI",
 
43
            VirtualController.CONTROLLER_TYPE_SATA          : "SATA",
 
44
            VirtualController.CONTROLLER_TYPE_VIRTIOSERIAL  : "Virtio Serial"
 
45
        }
 
46
 
 
47
        if ctype not in pretty_mappings:
 
48
            return ctype
 
49
        return pretty_mappings[ctype]
35
50
 
36
51
    @staticmethod
37
52
    def get_class_for_type(ctype):
51
66
 
52
67
    _controller_type = None
53
68
 
54
 
    def __init__(self, conn):
55
 
        VirtualDevice.VirtualDevice.__init__(self, conn)
 
69
    def __init__(self, conn, parsexml=None, parsexmlnode=None, caps=None):
 
70
        VirtualDevice.VirtualDevice.__init__(self, conn,
 
71
                                             parsexml, parsexmlnode, caps)
56
72
 
57
73
        self._index = 0
 
74
        self._ports = None
 
75
        self._vectors = None
58
76
 
59
77
    def get_type(self):
60
78
        return self._controller_type
61
 
    type = property(get_type)
 
79
    type = _xml_property(get_type,
 
80
                         xpath="./@type")
62
81
 
63
82
    def get_index(self):
64
83
        return self._index
65
84
    def set_index(self, val):
66
85
        self._index = int(val)
67
 
    index = property(get_index, set_index)
 
86
    index = _xml_property(get_index, set_index,
 
87
                          xpath="./@index")
 
88
 
 
89
    def get_vectors(self):
 
90
        return self._vectors
 
91
    def set_vectors(self, val):
 
92
        self._vectors = val
 
93
    vectors = _xml_property(get_vectors, set_vectors,
 
94
                            xpath="./@vectors")
 
95
 
 
96
    def get_ports(self):
 
97
        return self._ports
 
98
    def set_ports(self, val):
 
99
        self._ports = val
 
100
    ports = _xml_property(get_ports, set_ports,
 
101
                          xpath="./@ports")
68
102
 
69
103
    def _extra_config(self):
70
104
        return ""
71
105
 
72
 
    def get_xml_config(self):
 
106
    def _get_xml_config(self):
73
107
        extra = self._extra_config()
74
108
 
75
109
        xml = "    <controller type='%s' index='%s'" % (self.type, self.index)
93
127
 
94
128
class VirtualControllerVirtioSerial(VirtualController):
95
129
    _controller_type = VirtualController.CONTROLLER_TYPE_VIRTIOSERIAL
96
 
    _ports = 0
97
 
    _vectors = 0
98
 
 
99
 
    def get_vectors(self):
100
 
        return self._vectors
101
 
    def set_vectors(self, val):
102
 
        self._vectors = val
103
 
    vectors = property(get_vectors, set_vectors)
104
 
 
105
 
    def get_ports(self):
106
 
        return self._ports
107
 
    def set_ports(self, val):
108
 
        self._ports = val
109
 
    ports = property(get_ports, set_ports)
110
130
 
111
131
    def _extra_config(self):
112
132
        xml = ""