1
0
Fork 0
mirror of https://github.com/retspen/webvirtcloud synced 2024-12-23 22:55:23 +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-toggle="popover"
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>
</button>
{{ disk.dev }}

View file

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