1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-24 15:15:22 +00:00

Add disk cache info for instance

This commit is contained in:
catborise 2019-01-09 15:31:42 +03:00
parent fc6761aabc
commit 6b06ed25ff
2 changed files with 20 additions and 27 deletions

View file

@ -685,7 +685,9 @@
data-trigger="focus" data-trigger="focus"
data-toggle="popover" data-toggle="popover"
data-html="true" data-html="true"
data-content="<strong>Bus:</strong> {{ disk.bus }} <br/> <strong>Format:</strong> {{ disk.format }}"> data-content="<strong>Bus:</strong> {{ disk.bus }} <br/>
<strong>Format:</strong> {{ disk.format }} <br/>
<strong>Cache:</strong> {{ disk.cache }}">
<i class="fa fa-info"></i> <i class="fa fa-info"></i>
</button> </button>
{{ disk.dev }} {{ disk.dev }}

View file

@ -201,7 +201,6 @@ class wvmInstance(wvmConnect):
return util.get_xml_path(self._XMLDesc(0), func=filterrefs) return util.get_xml_path(self._XMLDesc(0), func=filterrefs)
def get_description(self): def get_description(self):
description = util.get_xml_path(self._XMLDesc(0), "/domain/description") description = util.get_xml_path(self._XMLDesc(0), "/domain/description")
return description if description else '' return description if description else ''
@ -248,13 +247,8 @@ class wvmInstance(wvmConnect):
def get_disk_devices(self): def get_disk_devices(self):
def disks(doc): def disks(doc):
result = [] result = []
dev = None dev = volume = storage = src_file = None
volume = None disk_format = used_size = disk_size = None
storage = None
src_fl = None
disk_format = None
used_size = None
disk_size = None
for disk in doc.xpath('/domain/devices/disk'): for disk in doc.xpath('/domain/devices/disk'):
device = disk.xpath('@device')[0] device = disk.xpath('@device')[0]
@ -262,13 +256,14 @@ class wvmInstance(wvmConnect):
try: try:
dev = disk.xpath('target/@dev')[0] dev = disk.xpath('target/@dev')[0]
bus = disk.xpath('target/@bus')[0] bus = disk.xpath('target/@bus')[0]
src_fl = disk.xpath('source/@file|source/@dev|source/@name|source/@volume')[0] src_file = disk.xpath('source/@file|source/@dev|source/@name|source/@volume')[0]
try: try:
disk_format = disk.xpath('driver/@type')[0] disk_format = disk.xpath('driver/@type')[0]
disk_cache = disk.xpath('driver/@cache')[0]
except: except:
pass pass
try: try:
vol = self.get_volume_by_path(src_fl) vol = self.get_volume_by_path(src_file)
volume = vol.name() volume = vol.name()
disk_size = vol.info()[1] disk_size = vol.info()[1]
@ -276,13 +271,13 @@ class wvmInstance(wvmConnect):
stg = vol.storagePoolLookupByVolume() stg = vol.storagePoolLookupByVolume()
storage = stg.name() storage = stg.name()
except libvirtError: except libvirtError:
volume = src_fl volume = src_file
except: except:
pass pass
finally: finally:
result.append( result.append(
{'dev': dev, 'bus': bus, 'image': volume, 'storage': storage, 'path': src_fl, {'dev': dev, 'bus': bus, 'image': volume, 'storage': storage, 'path': src_file,
'format': disk_format, 'size': disk_size, 'used': used_size}) 'format': disk_format, 'size': disk_size, 'used': used_size, 'cache': disk_cache})
return result return result
return util.get_xml_path(self._XMLDesc(0), func=disks) return util.get_xml_path(self._XMLDesc(0), func=disks)
@ -290,10 +285,8 @@ class wvmInstance(wvmConnect):
def get_media_devices(self): def get_media_devices(self):
def disks(doc): def disks(doc):
result = [] result = []
dev = None dev = volume = storage = None
volume = None src_file = None
storage = None
src_fl = None
for media in doc.xpath('/domain/devices/disk'): for media in doc.xpath('/domain/devices/disk'):
device = media.xpath('@device')[0] device = media.xpath('@device')[0]
if device == 'cdrom': if device == 'cdrom':
@ -301,18 +294,18 @@ class wvmInstance(wvmConnect):
dev = media.xpath('target/@dev')[0] dev = media.xpath('target/@dev')[0]
bus = media.xpath('target/@bus')[0] bus = media.xpath('target/@bus')[0]
try: try:
src_fl = media.xpath('source/@file')[0] src_file = media.xpath('source/@file')[0]
vol = self.get_volume_by_path(src_fl) vol = self.get_volume_by_path(src_file)
volume = vol.name() volume = vol.name()
stg = vol.storagePoolLookupByVolume() stg = vol.storagePoolLookupByVolume()
storage = stg.name() storage = stg.name()
except: except:
src_fl = None src_file = None
volume = src_fl volume = src_file
except: except:
pass pass
finally: finally:
result.append({'dev': dev, 'image': volume, 'storage': storage, 'path': src_fl, 'bus': bus}) result.append({'dev': dev, 'image': volume, 'storage': storage, 'path': src_file, 'bus': bus})
return result return result
return util.get_xml_path(self._XMLDesc(0), func=disks) return util.get_xml_path(self._XMLDesc(0), func=disks)
@ -490,11 +483,9 @@ class wvmInstance(wvmConnect):
return telnet_port return telnet_port
def get_console_listen_addr(self): def get_console_listen_addr(self):
listen_addr = util.get_xml_path(self._XMLDesc(0), listen_addr = util.get_xml_path(self._XMLDesc(0), "/domain/devices/graphics/@listen")
"/domain/devices/graphics/@listen")
if listen_addr is None: if listen_addr is None:
listen_addr = util.get_xml_path(self._XMLDesc(0), listen_addr = util.get_xml_path(self._XMLDesc(0), "/domain/devices/graphics/listen/@address")
"/domain/devices/graphics/listen/@address")
if listen_addr is None: if listen_addr is None:
return "127.0.0.1" return "127.0.0.1"
return listen_addr return listen_addr