Skip to content

Commit

Permalink
Merge pull request avocado-framework#2886 from chloerh/parent
Browse files Browse the repository at this point in the history
XMLElementList: create parent xpath if not exists
  • Loading branch information
dzhengfy authored Feb 25, 2021
2 parents 62df0be + b181871 commit 04a14e7
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion virttest/libvirt_xml/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -786,7 +786,12 @@ def __call__(self, value):
# Allow other classes to generate parent structure
parent = self.xmltreefile().find(self.parent_xpath)
if parent is None:
raise xcepts.LibvirtXMLNotFoundError
# Create parent xpath if not exists
self.xmltreefile().create_by_xpath(self.parent_xpath)
parent = self.xmltreefile().find(self.parent_xpath)
if parent is None:
raise xcepts.LibvirtXMLNotFoundError(
'Parent xpath %s not found.' % self.parent_xpath)
# Remove existing by calling accessor method, allowing
# any "untouchable" or "filtered" elements (by marshal)
# to be ignored and left as-is.
Expand Down

0 comments on commit 04a14e7

Please sign in to comment.