diff options
| author | Daniel P. Berrange <berrange@redhat.com> | 2012-03-07 13:10:07 -0500 |
|---|---|---|
| committer | Daniel P. Berrange <berrange@redhat.com> | 2012-03-23 19:23:13 +0000 |
| commit | 720b96363b8c2973d43c763ccaf4e213e0e2e02d (patch) | |
| tree | 42dd7f59852c1ab2ebf145ae82e5f8bf97d0a517 | |
| parent | 6249d6c1f6c8548d3a867eb0357e5c1c1094ccf1 (diff) | |
Introduce a class for storing libvirt snapshot configuration
Extend the libvirt config APIs to include a new class
LibvirtConfigGuestSnapshot for storing information about
guest snapshots
blueprint libvirt-xml-config-apis
Change-Id: Icc54f6f5cf41b05d904659e0a337bddb4bef5733
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
| -rw-r--r-- | nova/tests/test_libvirt_config.py | 13 | ||||
| -rw-r--r-- | nova/virt/libvirt/config.py | 15 |
2 files changed, 28 insertions, 0 deletions
diff --git a/nova/tests/test_libvirt_config.py b/nova/tests/test_libvirt_config.py index 8d6ede1be..b910849a5 100644 --- a/nova/tests/test_libvirt_config.py +++ b/nova/tests/test_libvirt_config.py @@ -398,3 +398,16 @@ class LibvirtConfigCPUTest(LibvirtConfigBaseTest): <vendor>AMD</vendor> <topology cores="4" threads="2" sockets="2"/> </cpu>""") + + +class LibvirtConfigGuestSnapshotTest(LibvirtConfigBaseTest): + + def test_config_snapshot(self): + obj = config.LibvirtConfigGuestSnapshot() + obj.name = "Demo" + + xml = obj.to_xml() + self.assertXmlEqual(xml, """ + <domainsnapshot> + <name>Demo</name> + </domainsnapshot>""") diff --git a/nova/virt/libvirt/config.py b/nova/virt/libvirt/config.py index e4f99a7ba..63499eaf8 100644 --- a/nova/virt/libvirt/config.py +++ b/nova/virt/libvirt/config.py @@ -396,3 +396,18 @@ class LibvirtConfigCPU(LibvirtConfigObject): name=f)) return cpu + + +class LibvirtConfigGuestSnapshot(LibvirtConfigObject): + + def __init__(self, **kwargs): + super(LibvirtConfigGuestSnapshot, self).__init__( + root_name="domainsnapshot", + **kwargs) + + self.name = None + + def format_dom(self): + ss = super(LibvirtConfigGuestSnapshot, self).format_dom() + ss.append(self._text_node("name", self.name)) + return ss |
