[pve-devel] [PATCH container] Fix #1924: add snapshot parameter
Rhonda D'Vine
rhonda at proxmox.com
Mon Nov 12 14:59:19 CET 2018
The config CLI command offer the config and showcmd functions. The
output of that may vary with respect to a given snapshot. This adds a
switch that shows the corresponding snapshot's config.
This patch needs the one in pve-guest-common applied first.
Signed-off-by: Rhonda D'Vine <rhonda at proxmox.com>
---
debian/control | 2 +-
src/PVE/API2/LXC/Config.pm | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/debian/control b/debian/control
index d1226dd..2c03135 100644
--- a/debian/control
+++ b/debian/control
@@ -4,7 +4,7 @@ Priority: extra
Maintainer: Proxmox Support Team <support at proxmox.com>
Build-Depends: debhelper (>= 7.0.50~),
libpve-common-perl,
- libpve-guest-common-perl | libpve-common-perl (<= 4.0-89),
+ libpve-guest-common-perl (>> 2.0-18) | libpve-common-perl (<= 4.0-89),
libpve-storage-perl,
libtest-mockmodule-perl,
lxc (>= 3.0.2-1) | lxc-pve (>= 3.0.1+pve1-1),
diff --git a/src/PVE/API2/LXC/Config.pm b/src/PVE/API2/LXC/Config.pm
index 1ba0ffd..a38fe86 100644
--- a/src/PVE/API2/LXC/Config.pm
+++ b/src/PVE/API2/LXC/Config.pm
@@ -35,6 +35,13 @@ __PACKAGE__->register_method({
properties => {
node => get_standard_option('pve-node'),
vmid => get_standard_option('pve-vmid', { completion => \&PVE::LXC::complete_ctid }),
+ snapshot => get_standard_option('pve-snapshot-name', {
+ description => "Fetch config values from given snapshot.",
+ optional => 1,
+ completion => sub {
+ PVE::LXC::Config->complete_snapshot_name(@_)
+ },
+ }),
},
},
returns => {
@@ -57,6 +64,15 @@ __PACKAGE__->register_method({
my $conf = PVE::LXC::Config->load_config($param->{vmid});
+ if ($param->{snapshot}) {
+ die "snapshot '$param->{snapshot}' does not exist\n"
+ if !defined( $conf->{snapshots}->{$param->{snapshot}});
+
+ # we need the digest of the file
+ $conf->{snapshots}->{$param->{snapshot}}->{digest} = $conf->{digest};
+ $conf = $conf->{snapshots}->{$param->{snapshot}};
+ }
+
delete $conf->{snapshots};
return $conf;
--
2.11.0
More information about the pve-devel
mailing list