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