this is useful as meta information for e.g., provisioning or config
management systems

adding the info also to the 'status' api call to make it easier to show
it in the gui

Signed-off-by: Dominik Csapak <d.csa...@proxmox.com>
---
 src/PVE/LXC.pm        | 6 ++++++
 src/PVE/LXC/Config.pm | 9 +++++++--
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/PVE/LXC.pm b/src/PVE/LXC.pm
index 475d9be..bdf2e5c 100644
--- a/src/PVE/LXC.pm
+++ b/src/PVE/LXC.pm
@@ -166,6 +166,11 @@ our $vmstatus_return_properties = {
        description => "The current config lock, if any.",
        type => 'string',
        optional => 1,
+    },
+    tags => {
+       description => "The current configured tags, if any.",
+       type => 'string',
+       optional => 1,
     }
 };
 
@@ -205,6 +210,7 @@ sub vmstatus {
        $d->{cpus} = $cpucount if !$d->{cpus};
 
        $d->{lock} = $conf->{lock} || '';
+       $d->{tags} = $conf->{tags} if defined($conf->{tags});
 
        if ($d->{pid}) {
            my $res = get_container_disk_usage($vmid, $d->{pid});
diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
index 9790345..2a67e7f 100644
--- a/src/PVE/LXC/Config.pm
+++ b/src/PVE/LXC/Config.pm
@@ -473,6 +473,11 @@ my $confdesc = {
        format => 'pve-volume-id',
        description => 'Script that will be exectued during various steps in 
the containers lifetime.',
     },
+    tags => {
+       type => 'string', format => 'pve-tag-list',
+       description => 'Tags of the Container. This is only meta information.',
+       optional => 1,
+    },
 };
 
 my $valid_lxc_conf_keys = {
@@ -910,7 +915,7 @@ sub update_pct_config {
                delete $conf->{$opt};
                PVE::LXC::write_cgroup_value("memory", $vmid,
                                             "memory.memsw.limit_in_bytes", -1);
-           } elsif ($opt eq 'description' || $opt eq 'onboot' || $opt eq 
'startup' || $opt eq 'hookscript') {
+           } elsif ($opt eq 'description' || $opt eq 'onboot' || $opt eq 
'startup' || $opt eq 'hookscript' || $opt eq 'tags') {
                delete $conf->{$opt};
            } elsif ($opt eq 'nameserver' || $opt eq 'searchdomain' ||
                     $opt eq 'tty' || $opt eq 'console' || $opt eq 'cmode') {
@@ -1045,7 +1050,7 @@ sub update_pct_config {
        } elsif ($opt eq 'cpuunits') {
            $conf->{$opt} = $value;
            PVE::LXC::write_cgroup_value("cpu", $vmid, "cpu.shares", $value);
-       } elsif ($opt eq 'description') {
+       } elsif ($opt eq 'description' || $opt eq 'tags') {
            $conf->{$opt} = $value;
        } elsif ($opt =~ m/^net(\d+)$/) {
            my $netid = $1;
-- 
2.20.1


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to