From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <d.jaeger@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id CFEDA75EAE
 for <pve-devel@lists.proxmox.com>; Wed, 14 Jul 2021 12:09:53 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id C4CBEF47B
 for <pve-devel@lists.proxmox.com>; Wed, 14 Jul 2021 12:09:53 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS id CBC17F442
 for <pve-devel@lists.proxmox.com>; Wed, 14 Jul 2021 12:09:51 +0200 (CEST)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id A0BB4418BF
 for <pve-devel@lists.proxmox.com>; Wed, 14 Jul 2021 12:09:51 +0200 (CEST)
From: =?UTF-8?q?Dominic=20J=C3=A4ger?= <d.jaeger@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Wed, 14 Jul 2021 12:09:29 +0200
Message-Id: <20210714100933.54491-1-d.jaeger@proxmox.com>
X-Mailer: git-send-email 2.30.2
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 1.169 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
Subject: [pve-devel] [PATCH cluster 1/5 v2] Close #1295: Add notifications
 to datacenter schema
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Wed, 14 Jul 2021 10:09:53 -0000

Permits controlling email notifications about package updates.
Use property string for extensibility to more notification types.

Signed-off-by: Dominic Jäger <d.jaeger@proxmox.com>
---
v2: Use property string

 data/PVE/DataCenterConfig.pm | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/data/PVE/DataCenterConfig.pm b/data/PVE/DataCenterConfig.pm
index 24ebf3f..336f68a 100644
--- a/data/PVE/DataCenterConfig.pm
+++ b/data/PVE/DataCenterConfig.pm
@@ -25,6 +25,15 @@ my $migration_format = {
     },
 };
 
+my $notify_format = {
+    package_updates => {
+	type => 'boolean',
+	description => 'Control notifications about available package updates',
+	format_description => 'boolean',
+	optional => 1,
+    },
+};
+
 my $ha_format = {
     shutdown_policy => {
 	type => 'string',
@@ -146,6 +155,12 @@ my $datacenter_schema = {
 	    format => 'email-opt',
 	    description => "Specify email address to send notification from (default is root@\$hostname)",
 	},
+	notify => {
+	    optional => 1,
+	    type => 'string',
+	    format => $notify_format,
+	    description => 'Control email notifications',
+	},
 	max_workers => {
 	    optional => 1,
 	    type => 'integer',
@@ -196,6 +211,10 @@ sub parse_datacenter_config {
 	$res->{migration} = PVE::JSONSchema::parse_property_string($migration_format, $migration);
     }
 
+    if (my $notify = $res->{notify}) {
+	$res->{notify} = PVE::JSONSchema::parse_property_string($notify_format, $notify);
+    }
+
     if (my $ha = $res->{ha}) {
 	$res->{ha} = PVE::JSONSchema::parse_property_string($ha_format, $ha);
     }
@@ -241,6 +260,11 @@ sub write_datacenter_config {
 	$cfg->{migration} = PVE::JSONSchema::print_property_string($migration, $migration_format);
     }
 
+    if (ref($cfg->{notify})) {
+	my $notify = $cfg->{notify};
+	$cfg->{notify} = PVE::JSONSchema::print_property_string($notify, $notify_format);
+    }
+
     if (ref($cfg->{ha})) {
 	my $ha = $cfg->{ha};
 	$cfg->{ha} = PVE::JSONSchema::print_property_string($ha, $ha_format);
-- 
2.30.2