~ubuntu-branches/ubuntu/precise/virt-manager/precise-proposed

« back to all changes in this revision

Viewing changes to src/virtManager/storagevol.py

  • Committer: Bazaar Package Importer
  • Author(s): Marc Deslauriers
  • Date: 2011-02-03 10:35:22 UTC
  • mfrom: (2.3.3 experimental)
  • Revision ID: james.westby@ubuntu.com-20110203103522-j8and6dsy3taczbj
Tags: 0.8.6-1ubuntu1
* Merge from debian experimental. Remaining changes:
  - Depend on python-appindicator for appindicator support.
  - Add a /usr/share/pixmaps/virt-manager-icon.svg symlink to link icon to
    where the Application Indicator can find it.
  - Add patch da_l10n.patch since it is not integrated. (refreshed)
  - Add patch show_session_or_system_in_console to make the overview
    screen show which local qemu session you're connected to. (refreshed)
  - Add patch more_helpful_error_message to explain to the user why he
    can't connect to qemu:///system and what he can do fix it.
  - Add patch qemu-system-by-default to automatically add qemu:///system
    to the list of hypervisors if the user has write access to the UNIX
    socket.
  - Drop patchsys-quilt include since dpkg-source does the quilt dance for
    us.
  - debian/control: lower libvirt-bin from Recommends to Suggests; seems
    some users (like netbooks) want to manage VMs, but not host them; see
    meta packages (ubuntu-virt, ubuntu-virt-server, ubuntu-virt-mgmt) for
    group installation of virt package sets.
* Removed patches:
  - debian/patches/custom-icon-installation.patch: Upstream.
  - debian/patches/remove-appindicator-workarounds.patch: Upstream.
  - debian/patches/fix-nc-with-zsh.patch: Upstream
* Removed python-ipy dependency as it is in universe:
  - debian/control: remove python-ipy from Depends
  - debian/series: disable 0002-Use-IPy-from-python-ipy.patch patch so
    we use the one that's included in the virt-manager source.
  - debian/rules: don't delete the IPy file.
* debian/patches/fix-cpu-wrong-types.patch: fix "value is of wrong type
  for this column" error by making sure we are using strings in
  src/virtManager/details.py.
* debian/patches/dont-always-launch-consoles.patch: Don't always launch
  consoles for running domains in src/virtManager/manager.py.

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
# MA 02110-1301 USA.
19
19
#
20
20
 
21
 
import gobject
22
21
import virtinst.util as util
23
22
 
24
 
class vmmStorageVolume(gobject.GObject):
25
 
    __gsignals__ = { }
26
 
 
27
 
    def __init__(self, config, connection, vol, name):
28
 
        self.__gobject_init__()
29
 
        self.config = config
30
 
        self.connection = connection
31
 
        self.vol = vol              # Libvirt storage volume object
 
23
from virtManager.libvirtobject import vmmLibvirtObject
 
24
 
 
25
class vmmStorageVolume(vmmLibvirtObject):
 
26
    __gsignals__ = {}
 
27
 
 
28
    def __init__(self, connection, vol, name):
 
29
        vmmLibvirtObject.__init__(self, connection)
 
30
 
 
31
        self.vol = vol      # Libvirt storage volume object
32
32
        self.name = name
33
 
        self._xml = None             # Cache xml rather than repeated lookups
34
 
        self._update_xml()
35
 
 
36
 
    def get_connection(self):
37
 
        return self.connection
38
 
 
 
33
 
 
34
    # Required class methods
39
35
    def get_name(self):
40
36
        return self.name
 
37
    def _XMLDesc(self, flags):
 
38
        return self.vol.XMLDesc(flags)
41
39
 
42
40
    def get_path(self):
43
41
        return self.vol.path()
50
48
        self.vol.delete(0)
51
49
        del(self.vol)
52
50
 
53
 
    def get_xml(self):
54
 
        if self._xml is None:
55
 
            self._update_xml()
56
 
        return self._xml
57
 
 
58
51
    def get_target_path(self):
59
 
        return util.get_xml_path(self.get_xml(),"/volume/target/path")
 
52
        return util.get_xml_path(self.get_xml(), "/volume/target/path")
60
53
 
61
54
    def get_format(self):
62
 
        return util.get_xml_path(self.get_xml(),"/volume/target/format/@type")
 
55
        return util.get_xml_path(self.get_xml(), "/volume/target/format/@type")
63
56
 
64
57
    def get_allocation(self):
65
 
        return long(util.get_xml_path(self.get_xml(),"/volume/allocation"))
 
58
        return long(util.get_xml_path(self.get_xml(), "/volume/allocation"))
66
59
    def get_capacity(self):
67
 
        return long(util.get_xml_path(self.get_xml(),"/volume/capacity"))
 
60
        return long(util.get_xml_path(self.get_xml(), "/volume/capacity"))
68
61
 
69
62
    def get_pretty_capacity(self):
70
63
        return self._prettyify(self.get_capacity())
72
65
        return self._prettyify(self.get_allocation())
73
66
 
74
67
    def get_type(self):
75
 
        return util.get_xml_path(self.get_xml(),"/volume/format/@type")
76
 
 
77
 
    def _update_xml(self):
78
 
        self._xml = self.vol.XMLDesc(0)
 
68
        return util.get_xml_path(self.get_xml(), "/volume/format/@type")
79
69
 
80
70
    def _prettyify(self, val):
81
 
        if val > (1024*1024*1024):
82
 
            return "%2.2f GB" % (val/(1024.0*1024.0*1024.0))
 
71
        if val > (1024 * 1024 * 1024):
 
72
            return "%2.2f GB" % (val / (1024.0 * 1024.0 * 1024.0))
83
73
        else:
84
 
            return "%2.2f MB" % (val/(1024.0*1024.0))
 
74
            return "%2.2f MB" % (val / (1024.0 * 1024.0))
85
75
 
86
 
gobject.type_register(vmmStorageVolume)
 
76
vmmLibvirtObject.type_register(vmmStorageVolume)