From: "Lukas Wagner" <l.wagner@proxmox.com>
To: "Proxmox Datacenter Manager development discussion"
<pdm-devel@lists.proxmox.com>
Subject: Re: [pdm-devel] [PATCH proxmox-datacenter-manager v2 1/4] pdm-api-types: add firewall status types
Date: Fri, 07 Nov 2025 13:27:08 +0100 [thread overview]
Message-ID: <DE2GN05K9N6M.2U45V7SFRAPY4@proxmox.com> (raw)
In-Reply-To: <20251105163546.450094-10-h.laimer@proxmox.com>
2 small nits inline, but other than that:
Reviewed-by: Lukas Wagner <l.wagner@proxmox.com>
Tested-by: Lukas Wagner <l.wagner@proxmox.com>
On Wed Nov 5, 2025 at 5:35 PM CET, Hannes Laimer wrote:
> These types are returned by all the `../firewall/status` endpoints. The
> UI also uses them.
>
> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
> ---
> lib/pdm-api-types/src/firewall.rs | 171 ++++++++++++++++++++++++++++++
> lib/pdm-api-types/src/lib.rs | 2 +
> 2 files changed, 173 insertions(+)
> create mode 100644 lib/pdm-api-types/src/firewall.rs
>
> diff --git a/lib/pdm-api-types/src/firewall.rs b/lib/pdm-api-types/src/firewall.rs
> new file mode 100644
> index 0000000..10357ad
> --- /dev/null
> +++ b/lib/pdm-api-types/src/firewall.rs
> @@ -0,0 +1,171 @@
> +use proxmox_schema::{api, Schema};
> +use serde::{Deserialize, Serialize};
> +
> +use crate::remotes::REMOTE_ID_SCHEMA;
> +use crate::{NODE_SCHEMA, VMID_SCHEMA};
> +
> +const FIREWALL_RULES_COUNT: Schema =
> + proxmox_schema::IntegerSchema::new("The total amount of rules present")
> + .minimum(0)
> + .schema();
> +
> +const FIREWALL_ACTIVE_RULES_COUNT: Schema =
> + proxmox_schema::IntegerSchema::new("The amount of enabled rules")
> + .minimum(0)
> + .schema();
> +
> +#[api(
> + properties: {
> + all: {
> + schema: FIREWALL_RULES_COUNT,
> + },
> + active: {
> + schema: FIREWALL_ACTIVE_RULES_COUNT,
> + }
> + }
> +)]
> +/// Count of all rules present and count of all enabled firewall rules.
> +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
> +pub struct RuleStat {
> + pub all: usize,
> + pub active: usize,
> +}
Could make sense to add 'serde(rename_all = "kebab-case")' even if you
don't need it right now, but just to avoid forgetting it in the future
when you or somebody else adds new members to the struct.
No need to send a new version for this alone though, can happen in a follow-up
patch.
> +
> +#[api(
> + properties: {
> + enabled: {
> + type: bool,
> + description: "True if the firewall is enabled",
> + },
> + rules: {
> + type: RuleStat,
> + flatten: true,
> + },
> + }
> +)]
> +/// Firewall status.
> +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
> +#[serde(rename_all = "kebab-case")]
> +pub struct FirewallStatus {
> + pub enabled: bool,
> + #[serde(flatten)]
> + pub rules: RuleStat,
> +}
> +
> +#[api(
> + properties: {
> + remote: {
> + schema: REMOTE_ID_SCHEMA,
> + },
> + status: {
> + type: FirewallStatus,
> + optional: true,
> + },
> + nodes: {
> + description: "Nodes in the cluster",
> + items: {
> + type: NodeFirewallStatus
> + },
> + type: Array,
> + },
> + }
> +)]
> +/// Firewall status of a PVE remote.
> +#[derive(Serialize, Deserialize, Clone, PartialEq)]
> +#[serde(rename_all = "kebab-case")]
> +pub struct RemoteFirewallStatus {
> + pub remote: String,
> + pub status: Option<FirewallStatus>,
> + pub nodes: Vec<NodeFirewallStatus>,
> +}
> +
> +#[api(
> + properties: {
> + node: {
> + schema: NODE_SCHEMA,
> + },
> + status: {
> + type: FirewallStatus,
> + optional: true,
> + },
> + guests: {
> + description: "Guests on a node",
> + items: {
> + type: GuestFirewallStatus
> + },
> + type: Array,
> + },
> + }
> +)]
> +/// Firewall status of a node
> +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
> +pub struct NodeFirewallStatus {
> + pub node: String,
> + pub status: Option<FirewallStatus>,
> + pub guests: Vec<GuestFirewallStatus>,
> +}
Same here.
> +
> +#[api]
> +#[derive(Clone, Copy, Debug, Deserialize, Serialize, PartialEq)]
> +#[serde(rename_all = "lowercase")]
> +/// The type of the guest
> +pub enum GuestKind {
> + /// Guest is a LXC
> + Lxc,
> + /// Guets is a QEMU
> + Qemu,
> +}
> +
> +impl GuestKind {
> + pub const fn as_str(&self) -> &'static str {
> + match self {
> + GuestKind::Lxc => "lxc",
> + GuestKind::Qemu => "qemu",
> + }
> + }
> +}
> +
> +impl AsRef<str> for GuestKind {
> + fn as_ref(&self) -> &str {
> + self.as_str()
> + }
> +}
> +
> +impl From<GuestKind> for &'static str {
> + fn from(kind: GuestKind) -> Self {
> + kind.as_str()
> + }
> +}
> +
> +impl From<&GuestKind> for &'static str {
> + fn from(kind: &GuestKind) -> Self {
> + kind.as_str()
> + }
> +}
> +
> +#[api(
> + properties: {
> + vmid: {
> + schema: VMID_SCHEMA,
> + },
> + name: {
> + type: String,
> + description: "Name of the guest.",
> + },
> + status: {
> + type: FirewallStatus,
> + optional: true,
> + },
> + kind: {
> + type: GuestKind,
> + }
> + }
> +)]
> +/// Firewall status of a guest
> +#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
> +pub struct GuestFirewallStatus {
> + pub vmid: u32,
> + pub name: String,
> + pub status: Option<FirewallStatus>,
> + pub kind: GuestKind,
> +}
> diff --git a/lib/pdm-api-types/src/lib.rs b/lib/pdm-api-types/src/lib.rs
> index ee4dfb2..78a9fa5 100644
> --- a/lib/pdm-api-types/src/lib.rs
> +++ b/lib/pdm-api-types/src/lib.rs
> @@ -94,6 +94,8 @@ pub use proxmox_schema::upid::*;
> mod openid;
> pub use openid::*;
>
> +pub mod firewall;
> +
> pub mod remotes;
>
> pub mod remote_updates;
_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel
next prev parent reply other threads:[~2025-11-07 12:26 UTC|newest]
Thread overview: 20+ 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-07 12:26 ` Lukas Wagner
2025-11-05 16:35 ` [pdm-devel] [PATCH proxmox-yew-comp v2 4/4] firewall: add rules table Hannes Laimer
2025-11-07 12:26 ` Lukas Wagner
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-07 12:27 ` Lukas Wagner [this message]
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
2025-11-07 6:43 ` Hannes Laimer
2025-11-07 12:27 ` Lukas Wagner
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
2025-11-07 12:27 ` Lukas Wagner
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=DE2GN05K9N6M.2U45V7SFRAPY4@proxmox.com \
--to=l.wagner@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