]> git.proxmox.com Git - pve-container.git/commitdiff
Fix #1924: add snapshot parameter
authorRhonda D'Vine <rhonda@proxmox.com>
Wed, 30 Jan 2019 13:41:33 +0000 (14:41 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Wed, 30 Jan 2019 13:44:05 +0000 (14:44 +0100)
The pct CLI command offer the config function. The output of that may
vary with respect to a given snapshot. This adds a switch that shows the
corresponding snapshot's config.

The code needs a newer libpve-guest-common-perl, thus bumping the
dependency.

Signed-off-by: Rhonda D'Vine <rhonda@proxmox.com>
debian/control
src/PVE/API2/LXC/Config.pm

index 15f42ad1ff4d09720e5973104f36e53ad53a5875..5a1e9ebf94615b6afeef2ce5628e2e32d53d66fa 100644 (file)
@@ -4,7 +4,7 @@ Priority: extra
 Maintainer: Proxmox Support Team <support@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-19),
                libpve-storage-perl,
                libtest-mockmodule-perl,
                lxc (>= 3.0.2-1) | lxc-pve (>= 3.0.1+pve1-1),
index 1ba0ffd12f6e181d234bb10539e03134c6c49860..b69db125f0d8fe6507f801ea1393072b09a6f6a2 100644 (file)
@@ -35,6 +35,14 @@ __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 {
+                    my ($cmd, $pname, $cur, $args) = @_;
+                    PVE::LXC::Config->snapshot_list($args->[0]);
+                },
+            }),
        },
     },
     returns => {
@@ -57,6 +65,17 @@ __PACKAGE__->register_method({
 
        my $conf = PVE::LXC::Config->load_config($param->{vmid});
 
+       my $snapname = $param->{snapshot};
+       if ($snapname) {
+           my $snapshot = $conf->{snapshots}->{$snapname};
+           die "snapshot '$snapname' does not exist\n"
+               if !defined($snapshot);
+
+           # we need the digest of the file
+           $snapshot->{digest} = $conf->{digest};
+           $conf = $snapshot;
+       }
+
        delete $conf->{snapshots};
 
        return $conf;