From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 287D11FF187 for ; Mon, 25 Aug 2025 06:19:49 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 3B13A89DB; Mon, 25 Aug 2025 06:19:53 +0200 (CEST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1756095583; x=1756700383; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=9ctQLBIEcSsBK8XRt3iOTl+25XWx+ZQJUKPtJCZawdk=; b=UNFRNXc2hJ4REkY5VLFtYhYY2K7zLzWsNiAXRuNB3c0ijCpY9iptbl6GsEcZqfXTI9 dvcRyUSZKlI078ib6RqFt+4k4lJLbw2yEdT70SnnX3FKDtRmI8vinK8CvEhjPTOW+6ux JaA0spe+bV6CcnweAMXCu0jdoufOc9KvtuBB4BKO0zelMA6XOI+Xct831Y8YQZf1KH9a Fwre0bgTtsNCTBB3nRc57wggVWjRx8q2AdoEgbCNzZglG9TKPdWK/OAiZ4QX/JPlr3rr Wgxtot8l7jTfhBziLjTaBFTp+uHto8pE3YmocFbZVwVf4d27uxUnHvPFvenwwPp+TExF SCMw== X-Gm-Message-State: AOJu0YzSt1bi2wUKvjRb2lNveVTbk6IZrf2mMb0yZWrdHE8BQxP4Ixo0 iWWkyugZVyPtyFQUNYme4LgCxNUgOtCZ8VUh37/5i4pkzhr4AbXX7g4NRxuJng== X-Gm-Gg: ASbGncvZ+bzyHpXEPb3a70rzoKxAvA+ihiho2EuOmcTHlNavLmaMpD7O36Cs527WnXP XVcXLSGWL6my2YQQs9rjSbYEnVpu9r7+1T4awL2c8x2zZErKfl3qR0AGuJMxdMZT3RodYv96Rxi XYvH4l5BuCbaKo7U/efETP90gDgPThW8nicab+Iew7lN3NdzXlt6tCAiRvnEl1a6LoeAfI+Qxdy +EE4BlpPMfnS3ySg+oDiKjOeKcOUKH3FVIp7ez+CoDcoaYjDJKK4e1g2c8OpAEaY0EMR2oHB837 1hKLEriXNDjsPrqP21Eg9B2tMN/hfLp8yPwZNO2NnrPP9jeV9Axbl3jRXDAu6eFsadwFceS7xsh NiAxujBS8R2X3GrXELa7kDX04H3IUSNl5QgiENcHxhPyv+KSy4UIBfjBezRBLGTVbefUsf2K2Ac EcIPVbjVGIYIuKFrFFWR8Odie3fHEoeWNKjak= X-Google-Smtp-Source: AGHT+IEP4c78XWKMvg0tt89vR9U6fBV5Zwkj2HIb8YUkj8j1kt1kjkqIta88E4q8GLR3q0BEgZDnTw== X-Received: by 2002:a05:6902:1285:b0:e8f:e526:fda9 with SMTP id 3f1490d57ef6-e951c23d0femr11343334276.22.1756095133458; Sun, 24 Aug 2025 21:12:13 -0700 (PDT) From: Thomas Skinner To: pve-devel@lists.proxmox.com Date: Sun, 24 Aug 2025 23:11:27 -0500 Message-ID: <20250825041128.132814-5-thomas@atskinner.net> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250825041128.132814-1-thomas@atskinner.net> References: <20250825041128.132814-1-thomas@atskinner.net> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.010 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy FREEMAIL_FORGED_FROMDOMAIN 0.001 2nd level domains in From and EnvelopeFrom freemail headers are different FREEMAIL_FROM 0.001 Sender email is commonly abused enduser mail provider HEADER_FROM_DIFFERENT_DOMAINS 0.001 From and EnvelopeFrom 2nd level mail domains are different KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_NONE -0.0001 Sender listed at https://www.dnswl.org/, no trust RCVD_IN_MSPIKE_H2 0.001 Average reputation (+2) 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 ha-manager 2/2] add api getter/setter for node maintenance mode X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Cc: Thomas Skinner Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Signed-off-by: Thomas Skinner --- debian/pve-ha-manager.install | 1 + src/PVE/API2/HA/Makefile | 2 +- src/PVE/API2/HA/Nodes.pm | 176 ++++++++++++++++++++++++++++++++++ 3 files changed, 178 insertions(+), 1 deletion(-) create mode 100644 src/PVE/API2/HA/Nodes.pm diff --git a/debian/pve-ha-manager.install b/debian/pve-ha-manager.install index 2e6b7d5..ec85037 100644 --- a/debian/pve-ha-manager.install +++ b/debian/pve-ha-manager.install @@ -15,6 +15,7 @@ /usr/share/man/man8/pve-ha-crm.8.gz /usr/share/man/man8/pve-ha-lrm.8.gz /usr/share/perl5/PVE/API2/HA/Groups.pm +/usr/share/perl5/PVE/API2/HA/Nodes.pm /usr/share/perl5/PVE/API2/HA/Resources.pm /usr/share/perl5/PVE/API2/HA/Rules.pm /usr/share/perl5/PVE/API2/HA/Status.pm diff --git a/src/PVE/API2/HA/Makefile b/src/PVE/API2/HA/Makefile index 86c1013..45d714b 100644 --- a/src/PVE/API2/HA/Makefile +++ b/src/PVE/API2/HA/Makefile @@ -1,4 +1,4 @@ -SOURCES=Resources.pm Groups.pm Rules.pm Status.pm +SOURCES=Resources.pm Groups.pm Nodes.pm Rules.pm Status.pm .PHONY: install install: diff --git a/src/PVE/API2/HA/Nodes.pm b/src/PVE/API2/HA/Nodes.pm new file mode 100644 index 0000000..2afc3a3 --- /dev/null +++ b/src/PVE/API2/HA/Nodes.pm @@ -0,0 +1,176 @@ +package PVE::API2::HA::Nodes::Nodeinfo; + +use strict; +use warnings; + +use PVE::SafeSyslog; +use PVE::Tools qw(extract_param); +use PVE::Cluster qw(cfs_read_file cfs_write_file); +use PVE::HA::Config; +use HTTP::Status qw(:constants); +use Storable qw(dclone); +use PVE::JSONSchema qw(get_standard_option); +use PVE::RPCEnvironment; + +use PVE::RESTHandler; + +use base qw(PVE::RESTHandler); + +__PACKAGE__->register_method({ + name => 'index', + path => '', + method => 'GET', + permissions => { user => 'all' }, + description => "Node index.", + parameters => { + additionalProperties => 0, + properties => { + node => get_standard_option('pve-node'), + }, + }, + returns => { + type => 'array', + items => { + type => "object", + properties => {}, + }, + links => [{ rel => 'child', href => "{name}" }], + }, + code => sub { + my ($param) = @_; + + my $result = [ + { name => 'maintenance' }, + ]; + + return $result; + }, +}); + +__PACKAGE__->register_method({ + name => 'maintenance_state', + path => 'maintenance', + method => 'GET', + permissions => { user => 'all' }, + description => "Get the node maintenance state.", + permissions => { + check => ['perm', '/', [ 'Sys.Audit' ]], + }, + parameters => { + additionalProperties => 0, + properties => { + node => get_standard_option('pve-node'), + }, + }, + returns => { + type => "object", + properties => {}, + }, + code => sub { + my ($param) = @_; + + my $status = PVE::HA::Config::read_manager_status(); + + my $data = { + request => $status->{node_request}->{$param->{node}}, + status => $status->{node_status}->{$param->{node}}, + }; + + return $data; + }, +}); + +__PACKAGE__->register_method ({ + name => 'maintenance_set', + protected => 1, + path => 'maintenance', + method => 'POST', + description => "Change the node-maintenance request state.", + permissions => { + check => ['perm', '/', [ 'Sys.Console' ]], + }, + parameters => { + additionalProperties => 0, + properties => { + node => get_standard_option('pve-node'), + disable => { + description => "Requests disabling or enabling maintenance-mode.", + type => 'boolean', + }, + }, + }, + returns => { type => 'null' }, + code => sub { + my ($param) = @_; + + PVE::Cluster::check_node_exists($param->{node}); + + my $cmd = $param->{disable} ? 'disable-node-maintenance' : 'enable-node-maintenance'; + PVE::HA::Config::queue_crm_commands("$cmd $param->{node}"); + + return undef; + } +}); + +package PVE::API2::HA::Nodes; + +use strict; +use warnings; + +use PVE::RESTHandler; +use PVE::JSONSchema qw(get_standard_option); +use PVE::RPCEnvironment; +use PVE::Cluster; + +use base qw(PVE::RESTHandler); + +__PACKAGE__->register_method({ + subclass => "PVE::API2::HA::Nodes::Nodeinfo", + path => '{node}', +}); + +__PACKAGE__->register_method({ + name => 'index', + path => '', + method => 'GET', + permissions => { user => 'all' }, + description => "Cluster HA node index.", + parameters => { + additionalProperties => 0, + properties => {}, + }, + returns => { + type => 'array', + items => { + type => "object", + properties => { + node => get_standard_option('pve-node'), + }, + }, + links => [{ rel => 'child', href => "{node}" }], + }, + code => sub { + my ($param) = @_; + + my $rpcenv = PVE::RPCEnvironment::get(); + my $authuser = $rpcenv->get_user(); + + my $clinfo = PVE::Cluster::get_clinfo(); + my $res = []; + + my $nodelist = PVE::Cluster::get_nodelist(); + my $members = PVE::Cluster::get_members(); + my $rrd = PVE::Cluster::rrd_dump(); + + foreach my $node (@$nodelist) { + my $can_audit = $rpcenv->check($authuser, "/nodes/$node", ['Sys.Audit'], 1); + my $entry = { node => $node }; + + push @$res, $entry; + } + + return $res; + }, +}); + +1; -- 2.47.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel