mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
Modified libvirtworker to use vmmConnection and vmmDomain objects.
This commit is contained in:
parent
7a8a35e564
commit
fbf138b02b
@ -16,13 +16,16 @@
|
|||||||
# MA 02110-1301, USA. A copy of the GNU General Public License is
|
# MA 02110-1301, USA. A copy of the GNU General Public License is
|
||||||
# also available at http://www.gnu.org/copyleft/gpl.html.
|
# also available at http://www.gnu.org/copyleft/gpl.html.
|
||||||
|
|
||||||
import dbus
|
|
||||||
import libvirt
|
|
||||||
import os
|
import os
|
||||||
import virtinst
|
|
||||||
import utils
|
import utils
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
import dbus
|
||||||
|
import virtinst
|
||||||
|
import libvirt
|
||||||
|
|
||||||
|
from virtManager.connection import vmmConnection
|
||||||
|
|
||||||
from domainconfig import DomainConfig
|
from domainconfig import DomainConfig
|
||||||
|
|
||||||
DEFAULT_POOL_TARGET_PATH="/var/lib/libvirt/images"
|
DEFAULT_POOL_TARGET_PATH="/var/lib/libvirt/images"
|
||||||
@ -78,8 +81,11 @@ class LibvirtWorker:
|
|||||||
logging.info("Connecting to libvirt: %s" % url)
|
logging.info("Connecting to libvirt: %s" % url)
|
||||||
self.__url = None
|
self.__url = None
|
||||||
self.__conn = None
|
self.__conn = None
|
||||||
|
self.__vmmconn = None
|
||||||
|
|
||||||
self.open_connection(url)
|
self.open_connection(url)
|
||||||
self.__capabilities = virtinst.CapabilitiesParser.parse(self.__conn.getCapabilities())
|
|
||||||
|
self.__capabilities = self.__vmmconn.get_capabilities()
|
||||||
self.__net = virtinst.VirtualNetworkInterface(conn = self.__conn)
|
self.__net = virtinst.VirtualNetworkInterface(conn = self.__conn)
|
||||||
self.__net.setup(self.__conn)
|
self.__net.setup(self.__conn)
|
||||||
(self.__new_guest, self.__new_domain) = virtinst.CapabilitiesParser.guest_lookup(conn = self.__conn)
|
(self.__new_guest, self.__new_domain) = virtinst.CapabilitiesParser.guest_lookup(conn = self.__conn)
|
||||||
@ -95,31 +101,30 @@ class LibvirtWorker:
|
|||||||
'''Lets the user change the url for the connection.'''
|
'''Lets the user change the url for the connection.'''
|
||||||
old_conn = self.__conn
|
old_conn = self.__conn
|
||||||
old_url = self.__url
|
old_url = self.__url
|
||||||
|
old_vmmconn = self.__vmmconn
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.__conn = libvirt.open(url)
|
self.__vmmconn = vmmConnection(url)
|
||||||
|
self.__vmmconn.open(sync=True)
|
||||||
|
|
||||||
|
self.__conn = self.__vmmconn.vmm
|
||||||
self.__url = url
|
self.__url = url
|
||||||
set_default_url(url)
|
set_default_url(url)
|
||||||
except Exception, error:
|
except Exception, error:
|
||||||
self.__conn = old_conn
|
self.__conn = old_conn
|
||||||
self.__url = old_url
|
self.__url = old_url
|
||||||
|
self.__vmmconn = old_vmmconn
|
||||||
raise error
|
raise error
|
||||||
|
|
||||||
def list_domains(self, defined = True, started = True):
|
def list_domains(self, defined = True, started = True):
|
||||||
'''Lists all domains.'''
|
'''Lists all domains.'''
|
||||||
result = []
|
# XXX: This doesn't abide the passed parameters
|
||||||
if defined:
|
self.__vmmconn.tick()
|
||||||
result.extend(self.__conn.listDefinedDomains())
|
return self.__vmmconn.list_vm_uuids()
|
||||||
if started:
|
|
||||||
for id in self.__conn.listDomainsID():
|
|
||||||
result.append(self.__conn.lookupByID(id).name())
|
|
||||||
return result
|
|
||||||
|
|
||||||
def get_domain(self, name):
|
def get_domain(self, uuid):
|
||||||
'''Returns the specified domain.'''
|
'''Returns the specified domain.'''
|
||||||
result = self.__conn.lookupByName(name)
|
return self.__vmmconn.get_vm(uuid)
|
||||||
if result is None: raise Exception("No such domain exists: %s" % name)
|
|
||||||
|
|
||||||
return result
|
|
||||||
|
|
||||||
def domain_exists(self, name):
|
def domain_exists(self, name):
|
||||||
'''Returns whether a domain with the specified node exists.'''
|
'''Returns whether a domain with the specified node exists.'''
|
||||||
|
Loading…
Reference in New Issue
Block a user