[pve-devel] [PATCH v2 container] include custom lxc options when displaying config

Fabian Grünbichler f.gruenbichler at proxmox.com
Thu Jun 30 12:31:00 CEST 2016


this makes the "pct config" output more complete, the object
returned by the API path contains the lxc options as parsed
by our config parser, e.g.:

   "lxc" : [
      [
         "lxc.cap.keep",
         "sys_time"
      ],
      [
         "lxc.cap.drop",
         "abc"
      ],
      [
         "lxc.cap.drop",
         ""
      ]
   ],
---
Changes compared to v1:
- don't check for two elements
- don't encode_text() the value

 src/PVE/API2/LXC/Config.pm | 1 -
 src/PVE/CLI/pct.pm         | 7 +++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/LXC/Config.pm b/src/PVE/API2/LXC/Config.pm
index 0d0732e..8597192 100644
--- a/src/PVE/API2/LXC/Config.pm
+++ b/src/PVE/API2/LXC/Config.pm
@@ -51,7 +51,6 @@ __PACKAGE__->register_method({
 	my $conf = PVE::LXC::Config->load_config($param->{vmid});
 
 	delete $conf->{snapshots};
-	delete $conf->{lxc};
 
 	return $conf;
     }});
diff --git a/src/PVE/CLI/pct.pm b/src/PVE/CLI/pct.pm
index ca87229..af95e05 100755
--- a/src/PVE/CLI/pct.pm
+++ b/src/PVE/CLI/pct.pm
@@ -542,12 +542,19 @@ our $cmddef = {
 		    my $config = shift;
 		    foreach my $k (sort (keys %$config)) {
 			next if $k eq 'digest';
+			next if $k eq 'lxc';
 			my $v = $config->{$k};
 			if ($k eq 'description') {
 			    $v = PVE::Tools::encode_text($v);
 			}
 			print "$k: $v\n";
 		    }
+		    if (defined($config->{'lxc'})) {
+			my $lxc_list = $config->{'lxc'};
+			foreach my $lxc_opt (@$lxc_list) {
+			    print "@$lxc_opt[0]: @$lxc_opt[1]\n"
+			}
+		    }
 		}],
     set => [ 'PVE::API2::LXC::Config', 'update_vm', ['vmid'], { node => $nodename }],
 
-- 
2.1.4




More information about the pve-devel mailing list