public inbox for pdm-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Michael Köppl" <m.koeppl@proxmox.com>
To: "Proxmox Datacenter Manager development discussion"
	<pdm-devel@lists.proxmox.com>
Cc: "pdm-devel" <pdm-devel-bounces@lists.proxmox.com>
Subject: Re: [pdm-devel] [PATCH proxmox-datacenter-manager v2 2/4] api: firewall: add option, rules and status endpoints
Date: Thu, 06 Nov 2025 17:58:22 +0100	[thread overview]
Message-ID: <DE1RS4Y0WDM8.3N6RKZT6HXO6Y@proxmox.com> (raw)
In-Reply-To: <20251105163546.450094-11-h.laimer@proxmox.com>

1 comment inline

On Wed Nov 5, 2025 at 5:35 PM CET, Hannes Laimer wrote:
> +#[derive(Clone, Debug)]
> +struct ClusterFirewallData {
> +    status: Option<FirewallStatus>,
> +    guests: Vec<ClusterResource>,
> +}
> +
> +async fn fetch_cluster_firewall_data(
> +    _context: (),
> +    remote: Remote,
> +    _node: String, // unused for cluster-level data
> +) -> Result<ClusterFirewallData, Error> {
> +    let pve = crate::connection::make_pve_client(&remote)?;
> +
> +    let guests = match pve.cluster_resources(Some(ClusterResourceKind::Vm)).await {
> +        Ok(guests) => guests,
> +        Err(_) => {
> +            return Ok(ClusterFirewallData {
> +                status: None,
> +                guests: vec![],
> +            });
> +        }
> +    };
> +
> +    let options_response = pve.cluster_firewall_options();
> +    let rules_response = pve.list_cluster_firewall_rules();
> +
> +    let enabled = options_response.await.map(|opts| opts.enable != Some(0));

Shouldn't this be opts.enable == Some(1), as otherwise the firewall will
also be shown as enabled for a newly-created cluster where the
/etc/pve/firewall/cluster.fw file has not been created yet (i.e. the
firewall is shown as off in the PVE web UI).

> +    let rules = rules_response.await.map(|rules| {
> +        let all = rules.len();
> +        let active = rules.iter().filter(|r| r.enable == Some(1)).count();
> +        RuleStat { all, active }
> +    });
> +
> +    let status = match (enabled, rules) {
> +        (Ok(enabled), Ok(rules)) => Some(FirewallStatus { enabled, rules }),
> +        _ => None,
> +    };
> +
> +    Ok(ClusterFirewallData { status, guests })
> +}
> +



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel


  reply	other threads:[~2025-11-06 16:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-05 16:35 [pdm-devel] [PATCH proxmox{, -yew-comp, -datacenter-manager} v2 00/12] add basic integration of PVE firewall Hannes Laimer
2025-11-05 16:35 ` [pdm-devel] [PATCH proxmox v2 1/4] pve-api-types: update pve-api.json Hannes Laimer
2025-11-05 16:35 ` [pdm-devel] [PATCH proxmox v2 2/4] pve-api-types: add get/update firewall options endpoints Hannes Laimer
2025-11-05 16:35 ` [pdm-devel] [PATCH proxmox v2 3/4] pve-api-types: add list firewall rules endpoints Hannes Laimer
2025-11-05 16:35 ` [pdm-devel] [PATCH proxmox v2 4/4] pve-api-types: regenerate Hannes Laimer
2025-11-05 16:35 ` [pdm-devel] [PATCH proxmox-yew-comp v2 1/4] form: add helpers for extractig data out of schemas Hannes Laimer
2025-11-05 16:35 ` [pdm-devel] [PATCH proxmox-yew-comp v2 2/4] firewall: add FirewallContext Hannes Laimer
2025-11-05 16:35 ` [pdm-devel] [PATCH proxmox-yew-comp v2 3/4] firewall: add options edit form Hannes Laimer
2025-11-05 16:35 ` [pdm-devel] [PATCH proxmox-yew-comp v2 4/4] firewall: add rules table Hannes Laimer
2025-11-05 16:35 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 1/4] pdm-api-types: add firewall status types Hannes Laimer
2025-11-05 16:35 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 2/4] api: firewall: add option, rules and status endpoints Hannes Laimer
2025-11-06 16:58   ` Michael Köppl [this message]
2025-11-05 16:35 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 3/4] pdm-client: add api methods for firewall options, " Hannes Laimer
2025-11-05 16:35 ` [pdm-devel] [PATCH proxmox-datacenter-manager v2 4/4] ui: add firewall status tree Hannes Laimer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=DE1RS4Y0WDM8.3N6RKZT6HXO6Y@proxmox.com \
    --to=m.koeppl@proxmox.com \
    --cc=pdm-devel-bounces@lists.proxmox.com \
    --cc=pdm-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal