[pve-devel] [PATCH 02/10] add is_template sub

Alexandre Derumier aderumier at odiso.com
Wed Dec 12 13:26:12 CET 2012


return 1 if current is template
return 2 if a snapshot is a template

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuServer.pm |   16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 5ca99a3..b918354 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -4127,4 +4127,20 @@ sub template_delete {
 
 }
 
+sub is_template {
+    my ($conf, $snapname, $checkall) = @_;
+
+    return 2 if $snapname && defined($conf->{snapshots}->{$snapname}->{template});
+    return 1 if ($conf->{template} && !$snapname);
+
+    if($checkall){
+	my $snaphash = $conf->{snapshots} || {};
+	foreach my $snapname (keys %$snaphash) {
+	    return 2 if defined($snaphash->{$snapname}->{template});
+	}
+    }
+
+    return undef;
+}
+
 1;
-- 
1.7.10.4




More information about the pve-devel mailing list