[pve-devel] [PATCH pve-manager 1/2] pvestatd: add fabrics status to pvestatd
Gabriel Goller
g.goller at proxmox.com
Wed Aug 13 15:30:13 CEST 2025
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 <g.goller at proxmox.com>
---
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
More information about the pve-devel
mailing list