From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <f.ebner@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 70E968E1AB
 for <pve-devel@lists.proxmox.com>; Thu, 10 Nov 2022 15:38:43 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id 41461288E3
 for <pve-devel@lists.proxmox.com>; Thu, 10 Nov 2022 15:38:13 +0100 (CET)
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
 for <pve-devel@lists.proxmox.com>; Thu, 10 Nov 2022 15:38:08 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 7284244B9C
 for <pve-devel@lists.proxmox.com>; Thu, 10 Nov 2022 15:38:06 +0100 (CET)
From: Fiona Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Thu, 10 Nov 2022 15:37:48 +0100
Message-Id: <20221110143800.98047-10-f.ebner@proxmox.com>
X-Mailer: git-send-email 2.30.2
In-Reply-To: <20221110143800.98047-1-f.ebner@proxmox.com>
References: <20221110143800.98047-1-f.ebner@proxmox.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.028 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/1] datacenter config: add cluster
 resource scheduling (crs) options
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: Thu, 10 Nov 2022 14:38:43 -0000

Initially, with a setting for HA to switch between basic (just count
services) and static (use static node and resource information).

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 data/PVE/DataCenterConfig.pm | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/data/PVE/DataCenterConfig.pm b/data/PVE/DataCenterConfig.pm
index 6a2adee..fcc9684 100644
--- a/data/PVE/DataCenterConfig.pm
+++ b/data/PVE/DataCenterConfig.pm
@@ -7,6 +7,18 @@ use PVE::JSONSchema qw(parse_property_string);
 use PVE::Tools;
 use PVE::Cluster;
 
+my $crs_format = {
+    ha => {
+	type => 'string',
+	enum => ['basic', 'static'],
+	description => "Use this resource scheduler mode for HA.",
+	default => 'basic',
+	verbose_description => "Configures how the HA manager should select nodes to start or ".
+	    "recover services. With 'basic', only the number of services is used, with 'static', ".
+	    "static CPU and memory configuration of services is considered.",
+    },
+};
+
 my $migration_format = {
     type => {
 	default_key => 1,
@@ -135,6 +147,11 @@ my $datacenter_schema = {
     type => "object",
     additionalProperties => 0,
     properties => {
+	crs => {
+	    optional => 1,
+	    type => 'string', format => $crs_format,
+	    description => "Cluster resource scheduling settings.",
+	},
 	keyboard => {
 	    optional => 1,
 	    type => 'string',
@@ -280,6 +297,10 @@ sub parse_datacenter_config {
 
     $res->{description} = $comment;
 
+    if (my $crs = $res->{crs}) {
+	$res->{crs} = parse_property_string($crs_format, $crs);
+    }
+
     if (my $migration = $res->{migration}) {
 	$res->{migration} = parse_property_string($migration_format, $migration);
     }
@@ -332,6 +353,10 @@ sub write_datacenter_config {
 	$cfg->{console} = 'html5';
     }
 
+    if (ref(my $crs = $cfg->{crs})) {
+	$cfg->{crs} = PVE::JSONSchema::print_property_string($crs, $crs_format);
+    }
+
     if (ref(my $migration = $cfg->{migration})) {
 	$cfg->{migration} = PVE::JSONSchema::print_property_string($migration, $migration_format);
     }
-- 
2.30.2