From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id 9ABE11FF16B for ; Tue, 26 Aug 2025 11:51:23 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id F0A792E66E; Tue, 26 Aug 2025 11:50:44 +0200 (CEST) From: Gabriel Goller To: pve-devel@lists.proxmox.com Date: Tue, 26 Aug 2025 11:49:52 +0200 Message-ID: <20250826095000.180173-12-g.goller@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250826095000.180173-1-g.goller@proxmox.com> References: <20250826095000.180173-1-g.goller@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1756201800700 X-SPAM-LEVEL: Spam detection results: 0 AWL -1.005 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 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_MAILER 2 Automated Mailer Tag Left in Email 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 pve-manager v3 1/3] pvestatd: add fabrics status to pvestatd 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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" Add the fabric status returned by SDN::status to the pvestatd resources. This makes the fabrics visible in the SDN resources and in the node resources. Previously the only SDN entity to be added where the SDN zones, so a bit of restructuring is needed: * we also return (and add to the resources) a `sdn_type`, which shows which type of sdn entity this is (e.g. fabric, zone, etc.). * we return/add to resources the `protocol` for fabrics as well, so in the future we can do protocol-specific views. Signed-off-by: Gabriel Goller --- PVE/API2/Cluster.pm | 73 +++++++++++++++++++++++++++++++++-------- PVE/Service/pvestatd.pm | 12 ++++--- 2 files changed, 68 insertions(+), 17 deletions(-) diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm index 02a7ceffee02..c22f8d4fb0e1 100644 --- a/PVE/API2/Cluster.pm +++ b/PVE/API2/Cluster.pm @@ -423,6 +423,21 @@ __PACKAGE__->register_method({ optional => 1, default => 0, }, + sdn => { + description => "The name of the sdn entity.", + type => "string", + optional => 1, + }, + sdn_type => { + description => "The protocol if this item is a SDN fabric.", + type => "string", + optional => 1, + }, + protocol => { + description => "The protocol if this item is a SDN fabric.", + type => "string", + optional => 1, + }, }, }, }, @@ -585,6 +600,8 @@ __PACKAGE__->register_method({ node => $node, type => 'sdn', status => 'ok', + # in the UI we want to show the localnetwork as a zone + sdn_type => 'zone', }; push @$res, $local_sdn; } @@ -594,19 +611,49 @@ __PACKAGE__->register_method({ my $nodes = PVE::Cluster::get_node_kv("sdn"); for my $node (sort keys %{$nodes}) { - my $sdns = decode_json($nodes->{$node}); - - for my $id (sort keys %{$sdns}) { - next if !$rpcenv->check($authuser, "/sdn/zones/$id", ['SDN.Audit'], 1); - my $sdn = $sdns->{$id}; - my $entry = { - id => "sdn/$node/$id", - sdn => $id, - node => $node, - type => 'sdn', - status => $sdn->{'status'}, - }; - push @$res, $entry; + my $node_config = decode_json($nodes->{$node}); + + # iterate through all sdn item types (vnet, zone, fabric, etc.) + for my $item_type (sort keys %{$node_config}) { + # the configuration of a sdn item type (all zones, all fabrics, etc.) + my $type_config = $node_config->{$item_type}; + for my $id (sort keys %{$type_config}) { + my $status = $type_config->{$id}; + + my $new_entry = { + "sdn" => $id, + "node" => $node, + "type" => 'sdn', + "sdn_type" => $item_type, + "status" => $status->{status}, + }; + + if ($item_type eq "zone") { + next + if !$rpcenv->check($authuser, "/sdn/zones/$id", ['SDN.Audit'], + 1); + + $new_entry->{id} = "sdn/$node/$item_type/$id"; + push @$res, $new_entry; + } elsif ($item_type eq "fabric") { + next + if !$rpcenv->check_any( + $authuser, + "/sdn/fabrics/$id", + ['SDN.Audit', 'SDN.Allocate'], + 1, + ); + + my $protocol = $status->{protocol}; + $new_entry->{id} = "sdn/$node/$item_type/$protocol/$id"; + $new_entry->{protocol} = $protocol; + push @$res, $new_entry; + } else { + # if the sdn type is not zones or fabric, just add it + $new_entry->{id} = "sdn/$node/$item_type/$id"; + push @$res, $new_entry; + } + } } } } diff --git a/PVE/Service/pvestatd.pm b/PVE/Service/pvestatd.pm index 618d6139af3e..507df4f6c475 100755 --- a/PVE/Service/pvestatd.pm +++ b/PVE/Service/pvestatd.pm @@ -766,12 +766,16 @@ sub update_ceph_metadata { } sub update_sdn_status { - if ($have_sdn) { - my ($transport_status, $vnet_status) = PVE::Network::SDN::status(); + my ($zone_status, $vnet_status, $fabric_status) = PVE::Network::SDN::status(); + + my $status = {}; + $status->{zone} = $zone_status; + # don't include vnet status, as we don't have a UI panel to show infos for it + #$status->{vnet} = $vnet_status; + $status->{fabric} = $fabric_status; - my $status = $transport_status ? encode_json($transport_status) : undef; - PVE::Cluster::broadcast_node_kv("sdn", $status); + PVE::Cluster::broadcast_node_kv("sdn", encode_json($status)); } } -- 2.47.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel