mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-10-27 01:55:20 +03:00
Keep the value of filesystem/source when attribute is changed
When the attribute of filesystem/source is changed the old value was not assigned to the new attribute.
This commit is contained in:
parent
4be3d030b5
commit
0dfc371f18
@ -47,8 +47,8 @@
|
|||||||
<source usage="123" units="KiB"/>
|
<source usage="123" units="KiB"/>
|
||||||
<target dir="/bar/baz"/>
|
<target dir="/bar/baz"/>
|
||||||
</filesystem>
|
</filesystem>
|
||||||
<filesystem type="block">
|
<filesystem type="file">
|
||||||
<source dev="/dev/new"/>
|
<source dev="/dev/new" file="/dev/new"/>
|
||||||
<target dir="/bar/baz"/>
|
<target dir="/bar/baz"/>
|
||||||
<readonly/>
|
<readonly/>
|
||||||
</filesystem>
|
</filesystem>
|
||||||
|
@ -781,9 +781,9 @@ class XMLParseTest(unittest.TestCase):
|
|||||||
check("units", "MB", "KiB")
|
check("units", "MB", "KiB")
|
||||||
|
|
||||||
check = self._make_checker(dev6)
|
check = self._make_checker(dev6)
|
||||||
check("type", "block")
|
|
||||||
check("source", "/foo/bar", "/dev/new")
|
check("source", "/foo/bar", "/dev/new")
|
||||||
check("readonly", False, True)
|
check("readonly", False, True)
|
||||||
|
check("type", "block", "file")
|
||||||
|
|
||||||
check = self._make_checker(dev7)
|
check = self._make_checker(dev7)
|
||||||
check("type", "file")
|
check("type", "file")
|
||||||
|
@ -54,7 +54,7 @@ class VirtualFilesystem(VirtualDevice):
|
|||||||
DRIVER_DEFAULT]
|
DRIVER_DEFAULT]
|
||||||
|
|
||||||
|
|
||||||
type = XMLProperty("./@type",
|
_type_prop = XMLProperty("./@type",
|
||||||
default_cb=lambda s: None,
|
default_cb=lambda s: None,
|
||||||
default_name=TYPE_DEFAULT)
|
default_name=TYPE_DEFAULT)
|
||||||
accessmode = XMLProperty("./@accessmode",
|
accessmode = XMLProperty("./@accessmode",
|
||||||
@ -111,6 +111,25 @@ class VirtualFilesystem(VirtualDevice):
|
|||||||
return setattr(self, self._type_to_source_prop(), val)
|
return setattr(self, self._type_to_source_prop(), val)
|
||||||
source = property(_get_source, _set_source)
|
source = property(_get_source, _set_source)
|
||||||
|
|
||||||
|
def _get_type(self):
|
||||||
|
return getattr(self, '_type_prop')
|
||||||
|
def _set_type(self, val):
|
||||||
|
# Get type/value of the attrubute of "source" property
|
||||||
|
old_source_type = self._type_to_source_prop()
|
||||||
|
old_source_value = self.source
|
||||||
|
|
||||||
|
# Update "type" property
|
||||||
|
new_type = setattr(self, '_type_prop', val)
|
||||||
|
|
||||||
|
# If the attribute type of 'source' property has changed
|
||||||
|
# restore the value
|
||||||
|
if old_source_type != self._type_to_source_prop():
|
||||||
|
self.source = old_source_value
|
||||||
|
|
||||||
|
return new_type
|
||||||
|
|
||||||
|
type = property(_get_type, _set_type)
|
||||||
|
|
||||||
def set_defaults(self, guest):
|
def set_defaults(self, guest):
|
||||||
ignore = guest
|
ignore = guest
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user