mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-02 09:47:16 +03:00
Use the a base class for all libvirt object classes
This commit is contained in:
parent
0fd57daca1
commit
e78e2da3f5
@ -393,7 +393,7 @@ def main():
|
||||
if options.show and options.uri == None:
|
||||
raise OptionValueError("can't use --show-* options without --connect")
|
||||
|
||||
engine = vmmEngine(config)
|
||||
engine = vmmEngine()
|
||||
|
||||
if (not (options.nodbus) and
|
||||
not ((os.getenv("DBUS_SESSION_BUS_ADDRESS") is None) and
|
||||
|
@ -991,7 +991,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
def setup_device(self):
|
||||
if (self._dev.virtual_device_type ==
|
||||
virtinst.VirtualDevice.VIRTUAL_DEV_DISK):
|
||||
progWin = vmmAsyncJob(self.config, self.do_file_allocate,
|
||||
progWin = vmmAsyncJob(self.do_file_allocate,
|
||||
[self._dev],
|
||||
title=_("Creating Storage File"),
|
||||
text=_("Allocation of disk storage may take "
|
||||
|
@ -38,7 +38,7 @@ class asyncJobWorker(threading.Thread):
|
||||
# Displays a progress bar while executing the "callback" method.
|
||||
class vmmAsyncJob(vmmGObjectUI):
|
||||
|
||||
def __init__(self, config, callback, args=None,
|
||||
def __init__(self, callback, args=None,
|
||||
text=_("Please wait a few moments..."),
|
||||
title=_("Operation in progress"),
|
||||
run_main=True, cancel_back=None, cancel_args=None):
|
||||
|
@ -710,7 +710,7 @@ class vmmCloneVM(vmmGObjectUI):
|
||||
if self.clone_design.clone_devices:
|
||||
text = title + _(" and selected storage (this may take a while)")
|
||||
|
||||
progWin = vmmAsyncJob(self.config, self._async_clone, [],
|
||||
progWin = vmmAsyncJob(self._async_clone, [],
|
||||
title=title, text=text)
|
||||
progWin.run()
|
||||
error, details = progWin.get_error()
|
||||
|
@ -40,8 +40,9 @@ from virtManager.storagepool import vmmStoragePool
|
||||
from virtManager.interface import vmmInterface
|
||||
from virtManager.netdev import vmmNetDevice
|
||||
from virtManager.mediadev import vmmMediaDevice
|
||||
from virtManager.baseclass import vmmGObject
|
||||
|
||||
class vmmConnection(gobject.GObject):
|
||||
class vmmConnection(vmmGObject):
|
||||
__gsignals__ = {
|
||||
"vm-added": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
[str, str]),
|
||||
@ -100,12 +101,10 @@ class vmmConnection(gobject.GObject):
|
||||
STATE_ACTIVE = 2
|
||||
STATE_INACTIVE = 3
|
||||
|
||||
def __init__(self, config, uri, readOnly=None, engine=None):
|
||||
gobject.GObject.__init__(self)
|
||||
def __init__(self, uri, readOnly=None, engine=None):
|
||||
vmmGObject.__init__(self)
|
||||
|
||||
self.config = config
|
||||
self.engine = engine
|
||||
|
||||
self.connectThread = None
|
||||
self.connectError = None
|
||||
self.uri = uri
|
||||
@ -1116,8 +1115,7 @@ class vmmConnection(gobject.GObject):
|
||||
uuid = util.uuidstr(net.UUID())
|
||||
if not origNets.has_key(uuid):
|
||||
# Brand new network
|
||||
currentNets[uuid] = vmmNetwork(self.config, self, net,
|
||||
uuid, True)
|
||||
currentNets[uuid] = vmmNetwork(self, net, uuid, True)
|
||||
newNets.append(uuid)
|
||||
startNets.append(uuid)
|
||||
else:
|
||||
@ -1136,8 +1134,7 @@ class vmmConnection(gobject.GObject):
|
||||
net = self.vmm.networkLookupByName(name)
|
||||
uuid = util.uuidstr(net.UUID())
|
||||
if not origNets.has_key(uuid):
|
||||
currentNets[uuid] = vmmNetwork(self.config, self, net,
|
||||
uuid, False)
|
||||
currentNets[uuid] = vmmNetwork(self, net, uuid, False)
|
||||
newNets.append(uuid)
|
||||
else:
|
||||
currentNets[uuid] = origNets[uuid]
|
||||
@ -1190,8 +1187,7 @@ class vmmConnection(gobject.GObject):
|
||||
pool = self.vmm.storagePoolLookupByName(name)
|
||||
uuid = util.uuidstr(pool.UUID())
|
||||
if not origPools.has_key(uuid):
|
||||
currentPools[uuid] = vmmStoragePool(self.config, self,
|
||||
pool, uuid, True)
|
||||
currentPools[uuid] = vmmStoragePool(self, pool, uuid, True)
|
||||
newPools.append(uuid)
|
||||
startPools.append(uuid)
|
||||
else:
|
||||
@ -1208,8 +1204,7 @@ class vmmConnection(gobject.GObject):
|
||||
pool = self.vmm.storagePoolLookupByName(name)
|
||||
uuid = util.uuidstr(pool.UUID())
|
||||
if not origPools.has_key(uuid):
|
||||
currentPools[uuid] = vmmStoragePool(self.config, self,
|
||||
pool, uuid, False)
|
||||
currentPools[uuid] = vmmStoragePool(self, pool, uuid, False)
|
||||
newPools.append(uuid)
|
||||
else:
|
||||
currentPools[uuid] = origPools[uuid]
|
||||
@ -1256,8 +1251,7 @@ class vmmConnection(gobject.GObject):
|
||||
if not orig.has_key(key):
|
||||
obj = self.vmm.interfaceLookupByName(name)
|
||||
# Object is brand new this tick period
|
||||
current[key] = vmmInterface(self.config, self, obj, key,
|
||||
is_active)
|
||||
current[key] = vmmInterface(self, obj, key, is_active)
|
||||
new.append(key)
|
||||
|
||||
if is_active:
|
||||
@ -1428,7 +1422,7 @@ class vmmConnection(gobject.GObject):
|
||||
for uuid in maybeNewUUIDs.keys():
|
||||
rawvm = maybeNewUUIDs[uuid]
|
||||
if not(self.vms.has_key(uuid)):
|
||||
vm = vmmDomain(self.config, self, rawvm, uuid)
|
||||
vm = vmmDomain(self, rawvm, uuid)
|
||||
newUUIDs.append(uuid)
|
||||
curUUIDs[uuid] = vm
|
||||
else:
|
||||
|
@ -1553,8 +1553,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
"".join(traceback.format_exc()))
|
||||
|
||||
def customize(self, guest):
|
||||
virtinst_guest = vmmDomainVirtinst(self.config, self.conn, guest,
|
||||
self.guest.uuid)
|
||||
virtinst_guest = vmmDomainVirtinst(self.conn, guest, self.guest.uuid)
|
||||
|
||||
if self.config_window:
|
||||
self.config_window.disconnect(self.config_window_signal)
|
||||
@ -1577,7 +1576,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
self.config_window.show()
|
||||
|
||||
def start_install(self, guest):
|
||||
progWin = vmmAsyncJob(self.config, self.do_install, [guest],
|
||||
progWin = vmmAsyncJob(self.do_install, [guest],
|
||||
title=_("Creating Virtual Machine"),
|
||||
text=_("The virtual machine is now being "
|
||||
"created. Allocation of disk storage "
|
||||
|
@ -1109,7 +1109,7 @@ class vmmCreateInterface(vmmGObjectUI):
|
||||
self.topwin.set_sensitive(False)
|
||||
self.topwin.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
||||
|
||||
progWin = vmmAsyncJob(self.config, self.do_install, [activate],
|
||||
progWin = vmmAsyncJob(self.do_install, [activate],
|
||||
title=_("Creating virtual interface"),
|
||||
text=_("The virtual interface is now being "
|
||||
"created."))
|
||||
|
@ -392,7 +392,7 @@ class vmmCreatePool(vmmGObjectUI):
|
||||
self.topwin.set_sensitive(False)
|
||||
self.topwin.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
||||
|
||||
progWin = vmmAsyncJob(self.config, self._async_pool_create, [],
|
||||
progWin = vmmAsyncJob(self._async_pool_create, [],
|
||||
title=_("Creating storage pool..."),
|
||||
text=_("Creating the storage pool may take a "
|
||||
"while..."))
|
||||
|
@ -202,7 +202,7 @@ class vmmCreateVolume(vmmGObjectUI):
|
||||
self.topwin.set_sensitive(False)
|
||||
self.topwin.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
|
||||
|
||||
progWin = vmmAsyncJob(self.config, self._async_vol_create, [],
|
||||
progWin = vmmAsyncJob(self._async_vol_create, [],
|
||||
title=_("Creating storage volume..."),
|
||||
text=_("Creating the storage volume may take a "
|
||||
"while..."))
|
||||
|
@ -130,7 +130,7 @@ class vmmDeleteDialog(vmmGObjectUI):
|
||||
if devs:
|
||||
text = title + _(" and selected storage (this may take a while)")
|
||||
|
||||
progWin = vmmAsyncJob(self.config, self._async_delete, [devs],
|
||||
progWin = vmmAsyncJob(self._async_delete, [devs],
|
||||
title=title, text=text)
|
||||
progWin.run()
|
||||
error, details = progWin.get_error()
|
||||
|
@ -86,8 +86,8 @@ class vmmDomainBase(vmmLibvirtObject):
|
||||
[]),
|
||||
}
|
||||
|
||||
def __init__(self, config, connection, backend, uuid):
|
||||
vmmLibvirtObject.__init__(self, config, connection)
|
||||
def __init__(self, connection, backend, uuid):
|
||||
vmmLibvirtObject.__init__(self, connection)
|
||||
|
||||
self._backend = backend
|
||||
self.uuid = uuid
|
||||
@ -816,8 +816,8 @@ class vmmDomain(vmmDomainBase):
|
||||
Domain class backed by a libvirt virDomain
|
||||
"""
|
||||
|
||||
def __init__(self, config, connection, backend, uuid):
|
||||
vmmDomainBase.__init__(self, config, connection, backend, uuid)
|
||||
def __init__(self, connection, backend, uuid):
|
||||
vmmDomainBase.__init__(self, connection, backend, uuid)
|
||||
|
||||
self.lastStatus = libvirt.VIR_DOMAIN_SHUTOFF
|
||||
|
||||
@ -1331,8 +1331,8 @@ class vmmDomainVirtinst(vmmDomainBase):
|
||||
|
||||
Used for launching a details window for customizing a VM before install.
|
||||
"""
|
||||
def __init__(self, config, connection, backend, uuid):
|
||||
vmmDomainBase.__init__(self, config, connection, backend, uuid)
|
||||
def __init__(self, connection, backend, uuid):
|
||||
vmmDomainBase.__init__(self, connection, backend, uuid)
|
||||
|
||||
self._orig_xml = None
|
||||
|
||||
@ -1409,6 +1409,6 @@ class vmmDomainVirtinst(vmmDomainBase):
|
||||
def hotplug_both_mem(self, memory, maxmem):
|
||||
raise NotImplementedError()
|
||||
|
||||
gobject.type_register(vmmDomainVirtinst)
|
||||
gobject.type_register(vmmDomainBase)
|
||||
gobject.type_register(vmmDomain)
|
||||
vmmLibvirtObject.type_register(vmmDomainVirtinst)
|
||||
vmmLibvirtObject.type_register(vmmDomainBase)
|
||||
vmmLibvirtObject.type_register(vmmDomain)
|
||||
|
@ -31,6 +31,7 @@ import virtinst
|
||||
import dbus
|
||||
|
||||
from virtManager.about import vmmAbout
|
||||
from virtManager.baseclass import vmmGObject
|
||||
from virtManager.halhelper import vmmHalHelper
|
||||
from virtManager.clone import vmmCloneVM
|
||||
from virtManager.connect import vmmConnect
|
||||
@ -79,7 +80,7 @@ def default_uri():
|
||||
# PackageKit lookup helpers #
|
||||
#############################
|
||||
|
||||
def check_packagekit(config, errbox):
|
||||
def check_packagekit(errbox):
|
||||
"""
|
||||
Returns None when we determine nothing useful.
|
||||
Returns (success, did we just install libvirt) otherwise.
|
||||
@ -101,7 +102,7 @@ def check_packagekit(config, errbox):
|
||||
return
|
||||
|
||||
found = []
|
||||
progWin = vmmAsyncJob(config, _do_async_search,
|
||||
progWin = vmmAsyncJob(_do_async_search,
|
||||
[session, pk_control],
|
||||
_("Searching for available hypervisors..."),
|
||||
run_main=False)
|
||||
@ -211,7 +212,7 @@ def packagekit_search(session, pk_control, package_name):
|
||||
|
||||
|
||||
|
||||
class vmmEngine(gobject.GObject):
|
||||
class vmmEngine(vmmGObject):
|
||||
__gsignals__ = {
|
||||
"connection-added": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
[object]),
|
||||
@ -219,10 +220,8 @@ class vmmEngine(gobject.GObject):
|
||||
[object])
|
||||
}
|
||||
|
||||
def __init__(self, config):
|
||||
gobject.GObject.__init__(self)
|
||||
|
||||
self.config = config
|
||||
def __init__(self):
|
||||
vmmGObject.__init__(self)
|
||||
|
||||
self.windowConnect = None
|
||||
self.windowPreferences = None
|
||||
@ -315,7 +314,7 @@ class vmmEngine(gobject.GObject):
|
||||
ret = None
|
||||
did_install_libvirt = False
|
||||
try:
|
||||
ret = check_packagekit(self.config, self.err)
|
||||
ret = check_packagekit(self.err)
|
||||
except:
|
||||
logging.exception("Error talking to PackageKit")
|
||||
|
||||
@ -497,7 +496,7 @@ class vmmEngine(gobject.GObject):
|
||||
if conn:
|
||||
return conn
|
||||
|
||||
conn = vmmConnection(self.get_config(), uri, readOnly, self)
|
||||
conn = vmmConnection(uri, readOnly, self)
|
||||
self.connections[uri] = {
|
||||
"connection": conn,
|
||||
"windowHost": None,
|
||||
@ -836,7 +835,7 @@ class vmmEngine(gobject.GObject):
|
||||
_cancel_back = None
|
||||
_cancel_args = [None]
|
||||
|
||||
progWin = vmmAsyncJob(self.config, self._save_callback,
|
||||
progWin = vmmAsyncJob(self._save_callback,
|
||||
[vm, path],
|
||||
_("Saving Virtual Machine"),
|
||||
cancel_back=_cancel_back,
|
||||
@ -891,7 +890,7 @@ class vmmEngine(gobject.GObject):
|
||||
if not path:
|
||||
return
|
||||
|
||||
progWin = vmmAsyncJob(self.config, self._restore_saved_callback,
|
||||
progWin = vmmAsyncJob(self._restore_saved_callback,
|
||||
[path, conn], _("Restoring Virtual Machine"))
|
||||
progWin.run()
|
||||
error, details = progWin.get_error()
|
||||
@ -1051,4 +1050,4 @@ class vmmEngine(gobject.GObject):
|
||||
str(reboot_err)),
|
||||
"".join(traceback.format_exc()))
|
||||
|
||||
gobject.type_register(vmmEngine)
|
||||
vmmGObject.type_register(vmmEngine)
|
||||
|
@ -18,18 +18,16 @@
|
||||
# MA 02110-1301 USA.
|
||||
#
|
||||
|
||||
import gobject
|
||||
|
||||
import virtinst
|
||||
from virtinst import Interface
|
||||
|
||||
from virtManager.libvirtobject import vmmLibvirtObject
|
||||
|
||||
class vmmInterface(vmmLibvirtObject):
|
||||
__gsignals__ = { }
|
||||
__gsignals__ = {}
|
||||
|
||||
def __init__(self, config, connection, interface, name, active):
|
||||
vmmLibvirtObject.__init__(self, config, connection)
|
||||
def __init__(self, connection, interface, name, active):
|
||||
vmmLibvirtObject.__init__(self, connection)
|
||||
|
||||
self.interface = interface # Libvirt virInterface object
|
||||
self.name = name # String name
|
||||
@ -213,4 +211,4 @@ class vmmInterface(vmmLibvirtObject):
|
||||
ret = " %s\n" % ret
|
||||
return ret
|
||||
|
||||
gobject.type_register(vmmInterface)
|
||||
vmmLibvirtObject.type_register(vmmInterface)
|
||||
|
@ -26,6 +26,7 @@ import logging
|
||||
import libxml2
|
||||
|
||||
from virtManager import util
|
||||
from virtManager.baseclass import vmmGObject
|
||||
|
||||
def _sanitize_xml(xml):
|
||||
xml = libxml2.parseDoc(xml).serialize()
|
||||
@ -36,16 +37,15 @@ def _sanitize_xml(xml):
|
||||
xml += "\n"
|
||||
return xml
|
||||
|
||||
class vmmLibvirtObject(gobject.GObject):
|
||||
class vmmLibvirtObject(vmmGObject):
|
||||
__gsignals__ = {
|
||||
"config-changed": (gobject.SIGNAL_RUN_FIRST,
|
||||
gobject.TYPE_NONE,
|
||||
[]),
|
||||
}
|
||||
|
||||
def __init__(self, config, connection):
|
||||
gobject.GObject.__init__(self)
|
||||
self.config = config
|
||||
def __init__(self, connection):
|
||||
vmmGObject.__init__(self)
|
||||
self.connection = connection
|
||||
|
||||
self._xml = None
|
||||
@ -69,8 +69,7 @@ class vmmLibvirtObject(gobject.GObject):
|
||||
raise NotImplementedError()
|
||||
|
||||
def _XMLDesc(self, flags):
|
||||
ignore = flags
|
||||
return
|
||||
raise NotImplementedError()
|
||||
|
||||
def _define(self, xml):
|
||||
ignore = xml
|
||||
@ -153,4 +152,4 @@ class vmmLibvirtObject(gobject.GObject):
|
||||
origxml = self.__xml_to_redefine()
|
||||
return self._redefine_helper(origxml, newxml)
|
||||
|
||||
gobject.type_register(vmmLibvirtObject)
|
||||
vmmGObject.type_register(vmmLibvirtObject)
|
||||
|
@ -24,13 +24,14 @@ import logging
|
||||
import virtinst
|
||||
|
||||
from virtManager import util
|
||||
from virtManager.baseclass import vmmGObject
|
||||
|
||||
MEDIA_FLOPPY = "floppy"
|
||||
MEDIA_CDROM = "cdrom"
|
||||
|
||||
MEDIA_TIMEOUT = 3
|
||||
|
||||
class vmmMediaDevice(gobject.GObject):
|
||||
class vmmMediaDevice(vmmGObject):
|
||||
__gsignals__ = {
|
||||
"media-added" : (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE,
|
||||
[]),
|
||||
@ -62,7 +63,7 @@ class vmmMediaDevice(gobject.GObject):
|
||||
|
||||
def __init__(self, path, key, has_media, media_label, media_key,
|
||||
nodedev_obj = None, media_type = MEDIA_CDROM):
|
||||
gobject.GObject.__init__(self)
|
||||
vmmGObject.__init__(self)
|
||||
|
||||
self.path = path
|
||||
self.key = key
|
||||
@ -173,4 +174,4 @@ class vmmMediaDevice(gobject.GObject):
|
||||
|
||||
return True
|
||||
|
||||
gobject.type_register(vmmMediaDevice)
|
||||
vmmGObject.type_register(vmmMediaDevice)
|
||||
|
@ -444,7 +444,7 @@ class vmmMigrateDialog(vmmGObjectUI):
|
||||
_cancel_back = None
|
||||
_cancel_args = [None]
|
||||
|
||||
progWin = vmmAsyncJob(self.config, self._async_migrate,
|
||||
progWin = vmmAsyncJob(self._async_migrate,
|
||||
[self.vm, destconn, uri, rate, live, secure,
|
||||
max_downtime],
|
||||
title=_("Migrating VM '%s'" % self.vm.get_name()),
|
||||
|
@ -17,13 +17,13 @@
|
||||
# MA 02110-1301 USA.
|
||||
#
|
||||
|
||||
import gobject
|
||||
from virtManager.baseclass import vmmGObject
|
||||
|
||||
class vmmNetDevice(gobject.GObject):
|
||||
class vmmNetDevice(vmmGObject):
|
||||
__gsignals__ = {}
|
||||
|
||||
def __init__(self, name, mac, is_shared, bridge=None, hal_path=None):
|
||||
gobject.GObject.__init__(self)
|
||||
vmmGObject.__init__(self)
|
||||
|
||||
self.name = name
|
||||
self.mac = mac
|
||||
@ -48,4 +48,4 @@ class vmmNetDevice(gobject.GObject):
|
||||
def get_hal_path(self):
|
||||
return self.hal_path
|
||||
|
||||
gobject.type_register(vmmNetDevice)
|
||||
vmmGObject.type_register(vmmNetDevice)
|
||||
|
@ -18,14 +18,12 @@
|
||||
# MA 02110-1301 USA.
|
||||
#
|
||||
|
||||
import gobject
|
||||
import virtinst.util as util
|
||||
|
||||
from virtManager.IPy import IP
|
||||
from virtManager.libvirtobject import vmmLibvirtObject
|
||||
|
||||
class vmmNetwork(gobject.GObject):
|
||||
__gsignals__ = { }
|
||||
|
||||
class vmmNetwork(vmmLibvirtObject):
|
||||
@staticmethod
|
||||
def pretty_desc(forward, forwardDev):
|
||||
if forward or forwardDev:
|
||||
@ -49,14 +47,20 @@ class vmmNetwork(gobject.GObject):
|
||||
|
||||
return desc
|
||||
|
||||
def __init__(self, config, connection, net, uuid, active):
|
||||
gobject.GObject.__init__(self)
|
||||
self.config = config
|
||||
self.connection = connection
|
||||
def __init__(self, connection, net, uuid, active):
|
||||
vmmLibvirtObject.__init__(self, connection)
|
||||
self.net = net
|
||||
self.uuid = uuid
|
||||
self.active = active
|
||||
self._xml = self.net.XMLDesc(0)
|
||||
|
||||
# Required class methods
|
||||
def get_name(self):
|
||||
return self.net.name()
|
||||
def _XMLDesc(self, flags):
|
||||
return self.net.XMLDesc(flags)
|
||||
def _define(self, xml):
|
||||
return self.get_connection().vmm.networkDefineXML(xml)
|
||||
|
||||
|
||||
def set_handle(self, net):
|
||||
self.net = net
|
||||
@ -64,23 +68,9 @@ class vmmNetwork(gobject.GObject):
|
||||
def set_active(self, state):
|
||||
self.active = state
|
||||
|
||||
def get_xml(self):
|
||||
if not self._xml:
|
||||
self._update_xml()
|
||||
return self._xml
|
||||
|
||||
def _update_xml(self):
|
||||
self._xml = self.net.XMLDesc(0)
|
||||
|
||||
def is_active(self):
|
||||
return self.active
|
||||
|
||||
def get_connection(self):
|
||||
return self.connection
|
||||
|
||||
def get_name(self):
|
||||
return self.net.name()
|
||||
|
||||
def get_label(self):
|
||||
return self.get_name()
|
||||
|
||||
@ -147,4 +137,4 @@ class vmmNetwork(gobject.GObject):
|
||||
return True
|
||||
return bool(util.get_xml_path(xml, "/network/ip/dhcp/bootp/@file"))
|
||||
|
||||
gobject.type_register(vmmNetwork)
|
||||
vmmLibvirtObject.type_register(vmmNetwork)
|
||||
|
@ -22,27 +22,35 @@ import gobject
|
||||
import virtinst
|
||||
import virtinst.util as util
|
||||
|
||||
from virtManager.libvirtobject import vmmLibvirtObject
|
||||
from virtManager.storagevol import vmmStorageVolume
|
||||
|
||||
class vmmStoragePool(gobject.GObject):
|
||||
class vmmStoragePool(vmmLibvirtObject):
|
||||
__gsignals__ = {
|
||||
"refreshed": (gobject.SIGNAL_RUN_FIRST, gobject.TYPE_NONE, []),
|
||||
}
|
||||
|
||||
def __init__(self, config, connection, pool, uuid, active):
|
||||
gobject.GObject.__init__(self)
|
||||
self.config = config
|
||||
self.connection = connection
|
||||
def __init__(self, connection, pool, uuid, active):
|
||||
vmmLibvirtObject.__init__(self, connection)
|
||||
|
||||
self.pool = pool # Libvirt pool object
|
||||
self.uuid = uuid # String UUID
|
||||
self.active = active # bool indicating if it is running
|
||||
|
||||
self._volumes = {} # UUID->vmmStorageVolume mapping of the
|
||||
# pools associated volumes
|
||||
self._xml = None # xml cache
|
||||
|
||||
self.refresh()
|
||||
|
||||
# Required class methods
|
||||
def get_name(self):
|
||||
return self.pool.name()
|
||||
def _XMLDesc(self, flags):
|
||||
return self.pool.XMLDesc(flags)
|
||||
def _define(self, xml):
|
||||
return self.get_connection().vmm.storagePoolDefineXML(xml, 0)
|
||||
|
||||
|
||||
def set_active(self, state):
|
||||
self.active = state
|
||||
self._update_xml()
|
||||
@ -54,12 +62,6 @@ class vmmStoragePool(gobject.GObject):
|
||||
typ = self.get_type()
|
||||
return (typ in [virtinst.Storage.StoragePool.TYPE_LOGICAL])
|
||||
|
||||
def get_connection(self):
|
||||
return self.connection
|
||||
|
||||
def get_name(self):
|
||||
return self.pool.name()
|
||||
|
||||
def get_uuid(self):
|
||||
return self.uuid
|
||||
|
||||
@ -78,14 +80,6 @@ class vmmStoragePool(gobject.GObject):
|
||||
self.pool.delete(0)
|
||||
del(self.pool)
|
||||
|
||||
def _update_xml(self):
|
||||
self._xml = self.pool.XMLDesc(0)
|
||||
|
||||
def get_xml(self):
|
||||
if self._xml is None:
|
||||
self._update_xml()
|
||||
return self._xml
|
||||
|
||||
def set_autostart(self, value):
|
||||
self.pool.setAutostart(value)
|
||||
|
||||
@ -124,7 +118,7 @@ class vmmStoragePool(gobject.GObject):
|
||||
return
|
||||
|
||||
self.pool.refresh(0)
|
||||
self._update_xml()
|
||||
self.refresh_xml()
|
||||
self.update_volumes()
|
||||
self.emit("refreshed")
|
||||
|
||||
@ -140,10 +134,9 @@ class vmmStoragePool(gobject.GObject):
|
||||
if self._volumes.has_key(volname):
|
||||
new_vol_list[volname] = self._volumes[volname]
|
||||
else:
|
||||
new_vol_list[volname] = vmmStorageVolume(self.config,
|
||||
self.connection,
|
||||
self.pool.storageVolLookupByName(volname),
|
||||
volname)
|
||||
new_vol_list[volname] = vmmStorageVolume(self.connection,
|
||||
self.pool.storageVolLookupByName(volname),
|
||||
volname)
|
||||
self._volumes = new_vol_list
|
||||
|
||||
|
||||
@ -153,4 +146,4 @@ class vmmStoragePool(gobject.GObject):
|
||||
else:
|
||||
return "%2.2f MB" % (val/(1024.0*1024.0))
|
||||
|
||||
gobject.type_register(vmmStoragePool)
|
||||
vmmLibvirtObject.type_register(vmmStoragePool)
|
||||
|
@ -18,26 +18,24 @@
|
||||
# MA 02110-1301 USA.
|
||||
#
|
||||
|
||||
import gobject
|
||||
import virtinst.util as util
|
||||
|
||||
class vmmStorageVolume(gobject.GObject):
|
||||
from virtManager.libvirtobject import vmmLibvirtObject
|
||||
|
||||
class vmmStorageVolume(vmmLibvirtObject):
|
||||
__gsignals__ = { }
|
||||
|
||||
def __init__(self, config, connection, vol, name):
|
||||
gobject.GObject.__init__(self)
|
||||
self.config = config
|
||||
self.connection = connection
|
||||
self.vol = vol # Libvirt storage volume object
|
||||
def __init__(self, connection, vol, name):
|
||||
vmmLibvirtObject.__init__(self, connection)
|
||||
|
||||
self.vol = vol # Libvirt storage volume object
|
||||
self.name = name
|
||||
self._xml = None # Cache xml rather than repeated lookups
|
||||
self._update_xml()
|
||||
|
||||
def get_connection(self):
|
||||
return self.connection
|
||||
|
||||
# Required class methods
|
||||
def get_name(self):
|
||||
return self.name
|
||||
def _XMLDesc(self, flags):
|
||||
return self.vol.XMLDesc(flags)
|
||||
|
||||
def get_path(self):
|
||||
return self.vol.path()
|
||||
@ -50,11 +48,6 @@ class vmmStorageVolume(gobject.GObject):
|
||||
self.vol.delete(0)
|
||||
del(self.vol)
|
||||
|
||||
def get_xml(self):
|
||||
if self._xml is None:
|
||||
self._update_xml()
|
||||
return self._xml
|
||||
|
||||
def get_target_path(self):
|
||||
return util.get_xml_path(self.get_xml(),"/volume/target/path")
|
||||
|
||||
@ -74,13 +67,10 @@ class vmmStorageVolume(gobject.GObject):
|
||||
def get_type(self):
|
||||
return util.get_xml_path(self.get_xml(),"/volume/format/@type")
|
||||
|
||||
def _update_xml(self):
|
||||
self._xml = self.vol.XMLDesc(0)
|
||||
|
||||
def _prettyify(self, val):
|
||||
if val > (1024*1024*1024):
|
||||
return "%2.2f GB" % (val/(1024.0*1024.0*1024.0))
|
||||
else:
|
||||
return "%2.2f MB" % (val/(1024.0*1024.0))
|
||||
|
||||
gobject.type_register(vmmStorageVolume)
|
||||
vmmLibvirtObject.type_register(vmmStorageVolume)
|
||||
|
@ -265,7 +265,7 @@ def _dup_all_conn(config, conn, libconn, return_conn_class):
|
||||
return return_conn_class and conn or vmm
|
||||
|
||||
logging.debug("Duplicating connection for async operation.")
|
||||
newconn = virtManager.connection.vmmConnection(config, uri, is_readonly)
|
||||
newconn = virtManager.connection.vmmConnection(uri, is_readonly)
|
||||
newconn.open(sync=True)
|
||||
|
||||
if return_conn_class:
|
||||
|
Loading…
x
Reference in New Issue
Block a user