Loading ccnode/libvirtwrapper.py +18 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import psutil from interface import * from exceptions import * from time import sleep import xml.dom.minidom ### # Defined constants Loading Loading @@ -187,6 +188,21 @@ class LibvirtVm(VM): except libvirt.libvirtError: raise VMError('%s is not running !' % self.get_name()) def get_disk_path(self): ''' Returns the path to the disk atached to the vm ''' # We parse xml description of the vm to get this info xml_string = self._domain.XMLDesc(libvirt.VIR_DOMAIN_XML_INACTIVE) dom = xml.dom.minidom.parseString(xml_string) disk = dom.getElementsByTagName('disk').pop() #FIXME Currently only handles file type backend, must add other backends path = disk.getElementsByTagName('source').pop() path = path.getAttribute('file') return path def get_uuid(self): ''' Returns the uuid string of the vm Loading Loading @@ -237,6 +253,7 @@ class LibvirtHypervisor(Hypervisor): self._build_vm_list() self.hv_info = {} self.hv_type = hv_type self.st_handle = LibvirtHVStorage(self) def get_name(self): ''' Loading Loading @@ -570,6 +587,7 @@ class LibvirtHVStorage(HVStorage): except libvirt.libvirtError as e: raise StorageError("Volume has no capacity information (%s)" % e) #### Helper functions def map_process(process): Loading Loading
ccnode/libvirtwrapper.py +18 −0 Original line number Diff line number Diff line Loading @@ -8,6 +8,7 @@ import psutil from interface import * from exceptions import * from time import sleep import xml.dom.minidom ### # Defined constants Loading Loading @@ -187,6 +188,21 @@ class LibvirtVm(VM): except libvirt.libvirtError: raise VMError('%s is not running !' % self.get_name()) def get_disk_path(self): ''' Returns the path to the disk atached to the vm ''' # We parse xml description of the vm to get this info xml_string = self._domain.XMLDesc(libvirt.VIR_DOMAIN_XML_INACTIVE) dom = xml.dom.minidom.parseString(xml_string) disk = dom.getElementsByTagName('disk').pop() #FIXME Currently only handles file type backend, must add other backends path = disk.getElementsByTagName('source').pop() path = path.getAttribute('file') return path def get_uuid(self): ''' Returns the uuid string of the vm Loading Loading @@ -237,6 +253,7 @@ class LibvirtHypervisor(Hypervisor): self._build_vm_list() self.hv_info = {} self.hv_type = hv_type self.st_handle = LibvirtHVStorage(self) def get_name(self): ''' Loading Loading @@ -570,6 +587,7 @@ class LibvirtHVStorage(HVStorage): except libvirt.libvirtError as e: raise StorageError("Volume has no capacity information (%s)" % e) #### Helper functions def map_process(process): Loading