~ubuntu-branches/ubuntu/quantal/virtinst/quantal-proposed

« back to all changes in this revision

Viewing changes to virtinst/VirtualHostDevice.py

  • Committer: Bazaar Package Importer
  • Author(s): Jean-Louis Dupond
  • Date: 2010-05-05 03:32:42 UTC
  • mfrom: (1.3.13 sid)
  • Revision ID: james.westby@ubuntu.com-20100505033242-um6f6pjcc89i07m0
Tags: 0.500.3-1ubuntu1
* Merge from debian unstable. (LP: #590068)  Remaining changes:
  - debian/patches/9001_Ubuntu.patch:
     + Added lucid and maverick to OS list and enable virtio for it.
  - debian/patches/0003-Fix-patch-to-keyboard-configuration.patch: disable
    as the keyboard config in Ubuntu is still in /etc/default/console-setup
    and this was causing virt-manager to always default to a en-us
    keyboard. (LP: #524318)
  - debian/control: added acl package to depends. (LP: #533048)
  - Demote virt-viewer to Suggests, as it's in universe.
  - Recommends libvirt-bin (LP: #215084)
* debian/patches/9002-add-ca-keymap.patch: dropped, its now in upstream

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
import VirtualDevice
21
21
import NodeDeviceParser
22
22
import logging
 
23
import libvirt
23
24
 
 
25
from virtinst import support
24
26
from virtinst import _util
25
27
from virtinst import _virtinst as _
26
28
 
30
32
 
31
33
    def device_from_node(conn, name=None, nodedev=None):
32
34
        """
33
 
        Convert the passed libvirt node device name to a VirtualHostDevice
34
 
        instance, with proper error reporting.
 
35
        Convert the passed device name to a VirtualHostDevice
 
36
        instance, with proper error reporting. Name can be any of the
 
37
        values accepted by NodeDeviceParser.lookupNodeName. If a node
 
38
        device name is not specified, a virtinst.NodeDevice instance can
 
39
        be passed in to create a dev from.
35
40
 
36
41
        @param conn: libvirt.virConnect instance to perform the lookup on
37
 
        @param name: libvirt node device name to lookup
 
42
        @param name: optional libvirt node device name to lookup
 
43
        @param nodedev: optional L{virtinst.NodeDevice} instance to use
38
44
 
39
45
        @rtype: L{virtinst.VirtualHostDevice} instance
40
46
        """
147
153
                                 " 'device' are required."))
148
154
        return xml
149
155
 
 
156
    def setup_dev(self, conn=None, meter=None):
 
157
        return self.setup(conn)
150
158
 
151
159
    def setup(self, conn = None):
 
160
        """
 
161
        DEPRECATED: Please use setup_dev instead
 
162
        """
152
163
        if not conn:
153
164
            conn = self.conn
154
165
 
191
202
        xml = "        <address domain='%s' bus='%s' slot='%s' function='%s'/>\n"
192
203
        return xml % (self.domain, self.bus, self.slot, self.function)
193
204
 
194
 
    def setup(self, conn = None):
 
205
    def setup_dev(self, conn=None, meter=None):
195
206
        """
196
207
        Perform DeviceDetach and DeviceReset calls if necessary
197
208
 
198
209
        @param conn: libvirt virConnect instance to use (defaults to devices
199
210
                     connection)
200
211
        """
 
212
        return self.setup(conn)
 
213
 
 
214
    def setup(self, conn = None):
 
215
        """
 
216
        DEPRECATED: Please use setup_dev instead
 
217
        """
201
218
        if not conn:
202
219
            conn = self.conn
203
220
 
205
222
            return
206
223
 
207
224
        try:
208
 
            # Do this as a sanity check, so that we don't fail at domain
209
 
            # start time. This is independent of the 'managed' state, since
210
 
            # this should work regardless.
211
 
            node = conn.nodeDeviceLookupByName(self._nodedev.name)
212
 
            node.dettach()
213
 
            node.reset()
 
225
            try:
 
226
                # Do this as a sanity check, so that we don't fail at domain
 
227
                # start time. This is independent of the 'managed' state, since
 
228
                # this should work regardless.
 
229
                node = conn.nodeDeviceLookupByName(self._nodedev.name)
 
230
                node.dettach()
 
231
                node.reset()
 
232
            except libvirt.libvirtError, e:
 
233
                if not support.is_error_nosupport(e):
 
234
                    raise
214
235
        except Exception, e:
215
236
            raise RuntimeError(_("Could not detach PCI device: %s" % str(e)))
216
237