diff --git a/tests/xmlparse-xml/change-snapshot-in.xml b/tests/xmlparse-xml/change-snapshot-in.xml new file mode 100644 index 000000000..5574c5d1e --- /dev/null +++ b/tests/xmlparse-xml/change-snapshot-in.xml @@ -0,0 +1,37 @@ + + offline-root-child1 + shutoff + offline desk + + offline-root + + 1375905916 + + + + + + test-internal-snapshots + 12345678-1234-fddf-1234-12345678ffff + 409600 + 409600 + 1 + /tmp/bootfoo + + xen + + + destroy + restart + destroy + + + + +
+ + + + + 0 + diff --git a/tests/xmlparse-xml/change-snapshot-out.xml b/tests/xmlparse-xml/change-snapshot-out.xml new file mode 100644 index 000000000..2c55a7f37 --- /dev/null +++ b/tests/xmlparse-xml/change-snapshot-out.xml @@ -0,0 +1,39 @@ + + name-foo + somestate + foo +newline + indent + + newparent + + 1234 + + + + + + test-internal-snapshots + 12345678-1234-fddf-1234-12345678ffff + 409600 + 409600 + 1 + /tmp/bootfoo + + xen + + + destroy + restart + destroy + + + + +
+ + + + + 0 + diff --git a/tests/xmlparse.py b/tests/xmlparse.py index 759ae9246..e5c29b754 100644 --- a/tests/xmlparse.py +++ b/tests/xmlparse.py @@ -787,6 +787,20 @@ class XMLParseTest(unittest.TestCase): self._alter_compare(guest.get_xml_config(), outfile) + def testChangeSnapshot(self): + basename = "change-snapshot" + infile = "tests/xmlparse-xml/%s-in.xml" % basename + outfile = "tests/xmlparse-xml/%s-out.xml" % basename + snap = virtinst.DomainSnapshot(conn, parsexml=file(infile).read()) + + check = self._make_checker(snap) + check("name", "offline-root-child1", "name-foo") + check("state", "shutoff", "somestate") + check("description", "offline desk", "foo\nnewline\n indent") + check("parent", "offline-root", "newparent") + check("creationTime", 1375905916, 1234) + + utils.diff_compare(snap.get_xml_config(), outfile) def testzzzzCheckProps(self): # pylint: disable=W0212 diff --git a/virtinst/__init__.py b/virtinst/__init__.py index 9fc3efbbf..603e2dcb4 100644 --- a/virtinst/__init__.py +++ b/virtinst/__init__.py @@ -61,5 +61,6 @@ from virtinst.distroinstaller import DistroInstaller from virtinst.guest import Guest from virtinst.cloner import Cloner +from virtinst.snapshot import DomainSnapshot from virtinst.connection import VirtualConnection diff --git a/virtinst/snapshot.py b/virtinst/snapshot.py new file mode 100644 index 000000000..befb31b91 --- /dev/null +++ b/virtinst/snapshot.py @@ -0,0 +1,37 @@ +# +# Copyright 2013 Red Hat, Inc. +# Cole Robinson +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301 USA. + +from virtinst.xmlbuilder import XMLBuilder, XMLProperty + + +class DomainSnapshot(XMLBuilder): + _XML_ROOT_XPATH = "/domainsnapshot" + _XML_PROP_ORDER = ["name", "description", "creationTime"] + + name = XMLProperty(xpath="./name") + description = XMLProperty(xpath="./description") + state = XMLProperty(xpath="./state") + creationTime = XMLProperty(xpath="./creationTime", is_int=True) + parent = XMLProperty(xpath="./parent/name") + + # Missing bits: + # @type and @file + # block which has a psuedo VM disk device + # block which tracks the snapshot guest XML + # which should list active status for an internal snapshot diff --git a/virtinst/support.py b/virtinst/support.py index a7329d614..b0a84f27c 100644 --- a/virtinst/support.py +++ b/virtinst/support.py @@ -342,6 +342,9 @@ SUPPORT_DOMAIN_JOB_INFO = _make(function="virDomain.jobInfo", args=()) SUPPORT_DOMAIN_CONSOLE_STREAM = _make(version=9003) SUPPORT_DOMAIN_SET_METADATA = _make(version=9010) SUPPORT_DOMAIN_CPU_HOST_MODEL = _make(version=9010) +SUPPORT_DOMAIN_LIST_SNAPSHOTS = _make(function="virDomain.listAllSnapshots", + args=()) + # Pool checks # This can't ever require a pool object for back compat reasons