Commit 475f20cf authored by Benziane Chakib's avatar Benziane Chakib

Added get_disk_path in LibvirtVM class

parent 22334ebe
......@@ -8,6 +8,7 @@ import psutil
from interface import *
from exceptions import *
from time import sleep
import xml.dom.minidom
###
# Defined constants
......@@ -186,6 +187,21 @@ class LibvirtVm(VM):
self._domain.resume()
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):
'''
......@@ -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):
'''
......@@ -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):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment