public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [PATCH manager/network v2 0/2] sdn: add guest/nic selectors to IPAM create window
@ 2026-08-26 11:13 Hannes Laimer
  2026-08-26 11:13 ` [PATCH pve-network v2 1/2] api: sdn: ipam: add optional vmid to POST endpoint Hannes Laimer
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Hannes Laimer @ 2026-08-26 11:13 UTC (permalink / raw)
  To: pve-devel

Make it simpler to create IP mapping for guests, so MAC addresses don't have to
be hand-copied over every time. This also adds the vmid as an optional POST
parameter, so a vmid can be set on create, and not just on update through PUT.

Aside from the POST endpoint accepting an optional vmid, no functional change
is intended, this should only improve UX. The MAC field can still be filled by
hand without using the selector, I guess there could be a use-case for having
outside-macs be in our SDN IPAM, but I also think there's an argument for not
allowing that. Either way, that stays unchanged with this. 

v2, thanks @Gabriel:
 - ui: actually submit MAC, setEditable(false) prevented submission


pve-network:

Hannes Laimer (1):
  api: sdn: ipam: add optional vmid to POST endpoint

 src/PVE/API2/Network/SDN/Ips.pm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)


pve-manager:

Hannes Laimer (1):
  ui: sdn: ipam: allow picking the nic instead of typing its MAC

 www/manager6/sdn/IpamEdit.js | 114 ++++++++++++++++++++++++++++++++++-
 1 file changed, 111 insertions(+), 3 deletions(-)


Summary over all repositories:
  2 files changed, 116 insertions(+), 4 deletions(-)

-- 
Generated by murpp 0.12.0




^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH pve-network v2 1/2] api: sdn: ipam: add optional vmid to POST endpoint
  2026-08-26 11:13 [PATCH manager/network v2 0/2] sdn: add guest/nic selectors to IPAM create window Hannes Laimer
@ 2026-08-26 11:13 ` Hannes Laimer
  2026-08-26 11:13 ` [PATCH pve-manager v2 2/2] ui: sdn: ipam: allow picking the nic instead of typing its MAC Hannes Laimer
  2026-08-26 11:43 ` [PATCH manager/network v2 0/2] sdn: add guest/nic selectors to IPAM create window Gabriel Goller
  2 siblings, 0 replies; 5+ messages in thread
From: Hannes Laimer @ 2026-08-26 11:13 UTC (permalink / raw)
  To: pve-devel

The update PUT endpoint allows an optional vmid, this alligns the POST
one. And allows creating new assignments with a vmid associated.

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
 src/PVE/API2/Network/SDN/Ips.pm | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/PVE/API2/Network/SDN/Ips.pm b/src/PVE/API2/Network/SDN/Ips.pm
index 5ff05e7..d0902f5 100644
--- a/src/PVE/API2/Network/SDN/Ips.pm
+++ b/src/PVE/API2/Network/SDN/Ips.pm
@@ -64,6 +64,9 @@ __PACKAGE__->register_method({
         properties => {
             zone => get_standard_option('pve-sdn-zone-id'),
             vnet => get_standard_option('pve-sdn-vnet-id'),
+            vmid => get_standard_option('pve-vmid', {
+                    optional => 1,
+            }),
             mac => get_standard_option('mac-addr'),
             ip => {
                 type => 'string',
@@ -78,9 +81,10 @@ __PACKAGE__->register_method({
 
         my $vnet = extract_param($param, 'vnet');
         my $mac = extract_param($param, 'mac');
+        my $vmid = extract_param($param, 'vmid');
         my $ip = extract_param($param, 'ip');
 
-        PVE::Network::SDN::Vnets::add_ip($vnet, $ip, '', $mac, undef);
+        PVE::Network::SDN::Vnets::add_ip($vnet, $ip, '', $mac, $vmid);
 
         return undef;
     },
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH pve-manager v2 2/2] ui: sdn: ipam: allow picking the nic instead of typing its MAC
  2026-08-26 11:13 [PATCH manager/network v2 0/2] sdn: add guest/nic selectors to IPAM create window Hannes Laimer
  2026-08-26 11:13 ` [PATCH pve-network v2 1/2] api: sdn: ipam: add optional vmid to POST endpoint Hannes Laimer
@ 2026-08-26 11:13 ` Hannes Laimer
  2026-08-26 11:43 ` [PATCH manager/network v2 0/2] sdn: add guest/nic selectors to IPAM create window Gabriel Goller
  2 siblings, 0 replies; 5+ messages in thread
From: Hannes Laimer @ 2026-08-26 11:13 UTC (permalink / raw)
  To: pve-devel

Instead of hand-copying a MAC from the guest's hardware panel, take a
guest and one of its NICs on the assignments's VNet, and fill the MAC in
from there.

Setting a MAC without a guest stays possible, so this is purely a UX
improvement. We could also restrict this, so our IPAM only manages IPs
of guests in our SDN.

Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
---
v2:
 - add `displayConfig: (get) => ({ submitValue: get('isCreate') })` to
   mac field so it is submitted if filled by nic selection

 www/manager6/sdn/IpamEdit.js | 114 ++++++++++++++++++++++++++++++++++-
 1 file changed, 111 insertions(+), 3 deletions(-)

diff --git a/www/manager6/sdn/IpamEdit.js b/www/manager6/sdn/IpamEdit.js
index cdefe436..718fee67 100644
--- a/www/manager6/sdn/IpamEdit.js
+++ b/www/manager6/sdn/IpamEdit.js
@@ -16,22 +16,54 @@ Ext.define('PVE.sdn.IpamEditInputPanel', {
 
     items: [
         {
-            xtype: 'pmxDisplayEditField',
             name: 'vmid',
-            fieldLabel: 'VMID',
+            fieldLabel: gettext('Guest'),
+            allowBlank: true,
+            notFoundIsValid: true,
+            emptyText: Proxmox.Utils.NoneText,
+            cbind: {
+                xtype: (get) => (get('isCreate') ? 'vmComboSelector' : 'displayfield'),
+            },
+            listeners: {
+                change: 'onGuestChange',
+            },
+        },
+        {
+            xtype: 'combobox',
+            reference: 'netid',
+            fieldLabel: gettext('Network Device'),
+            emptyText: gettext('Select a guest first'),
+            submitValue: false,
             allowBlank: false,
             editable: false,
+            disabled: true,
+            queryMode: 'local',
+            valueField: 'netid',
+            displayField: 'netid',
+            listConfig: {
+                itemTpl: '{netid} <i>{mac:htmlEncode}</i>',
+            },
+            store: {
+                fields: ['netid', 'mac'],
+                data: [],
+            },
             cbind: {
-                hidden: '{isCreate}',
+                hidden: '{!isCreate}',
+            },
+            listeners: {
+                select: 'onDeviceSelect',
             },
         },
         {
             xtype: 'pmxDisplayEditField',
             name: 'mac',
+            reference: 'mac',
             fieldLabel: 'MAC',
             allowBlank: false,
             cbind: {
                 editable: '{isCreate}',
+                // display fields do not submit by default, but the MAC set from the NIC selection must
+                displayConfig: (get) => ({ submitValue: get('isCreate') }),
             },
         },
         {
@@ -58,11 +90,87 @@ Ext.define('PVE.sdn.IpamEdit', {
         return `${url}/${values.vnet}/ips`;
     },
 
+    controller: {
+        xclass: 'Ext.app.ViewController',
+
+        onGuestChange: function (f, vmid) {
+            if (!this.getView().isCreate) {
+                return;
+            }
+            this.setGuest(vmid ? f.getSelection() : undefined);
+        },
+
+        onDeviceSelect: function (f, record) {
+            this.lookup('mac').setValue(record?.data.mac ?? '');
+        },
+
+        setGuest: function (record) {
+            let me = this;
+            let view = me.getView();
+
+            let selector = me.lookup('netid');
+            let mac = me.lookup('mac');
+
+            selector.clearValue();
+            selector.getStore().removeAll();
+            selector.setDisabled(!record);
+
+            mac.setValue('');
+            mac.setEditable(!record);
+
+            if (!record) {
+                selector.setEmptyText(gettext('Select a guest first'));
+                return;
+            }
+
+            Proxmox.Utils.API2Request({
+                url: `/nodes/${record.data.node}/${record.data.type}/${record.data.vmid}/config`,
+                method: 'GET',
+                failure: (response) => Ext.Msg.alert(gettext('Error'), response.htmlStatus),
+                success: function ({ result }) {
+                    if (selector.destroyed) {
+                        return;
+                    }
+
+                    let vnet = view.extraRequestParams?.vnet;
+                    let nics = [];
+
+                    for (const [key, value] of Object.entries(result.data)) {
+                        if (!key.match(/^net\d+$/)) {
+                            continue;
+                        }
+
+                        let net =
+                            record.data.type === 'qemu'
+                                ? PVE.Parser.parseQemuNetwork(key, value)
+                                : PVE.Parser.parseLxcNetwork(value);
+
+                        let mac = net?.macaddr ?? net?.hwaddr;
+                        if (!mac || net.bridge !== vnet) {
+                            continue;
+                        }
+
+                        nics.push({ netid: key, mac });
+                    }
+
+                    selector.getStore().setData(nics);
+                    selector.setEmptyText(
+                        nics.length
+                            ? gettext('Select a network device')
+                            : Ext.String.format(gettext('No network device on {0}'), vnet),
+                    );
+                },
+            });
+        },
+    },
+
     initComponent: function () {
         var me = this;
 
         me.method = me.isCreate ? 'POST' : 'PUT';
 
+        me.defaultFocus = me.isCreate ? 'textfield[name=mac]' : 'textfield[name=ip]';
+
         let ipanel = Ext.create('PVE.sdn.IpamEditInputPanel', {
             isCreate: me.isCreate,
         });
-- 
2.47.3





^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH manager/network v2 0/2] sdn: add guest/nic selectors to IPAM create window
  2026-08-26 11:13 [PATCH manager/network v2 0/2] sdn: add guest/nic selectors to IPAM create window Hannes Laimer
  2026-08-26 11:13 ` [PATCH pve-network v2 1/2] api: sdn: ipam: add optional vmid to POST endpoint Hannes Laimer
  2026-08-26 11:13 ` [PATCH pve-manager v2 2/2] ui: sdn: ipam: allow picking the nic instead of typing its MAC Hannes Laimer
@ 2026-08-26 11:43 ` Gabriel Goller
  2026-08-26 12:16   ` Hannes Laimer
  2 siblings, 1 reply; 5+ messages in thread
From: Gabriel Goller @ 2026-08-26 11:43 UTC (permalink / raw)
  To: Hannes Laimer; +Cc: pve-devel

Small nit: the submitValue property doesn't need to be in the cBind, we could
just always set it to true.

LGTM though.

Tested-by: Gabriel Goller <g.goller@proxmox.com>
Reviewed-by: Gabriel Goller <g.goller@proxmox.com>




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH manager/network v2 0/2] sdn: add guest/nic selectors to IPAM create window
  2026-08-26 11:43 ` [PATCH manager/network v2 0/2] sdn: add guest/nic selectors to IPAM create window Gabriel Goller
@ 2026-08-26 12:16   ` Hannes Laimer
  0 siblings, 0 replies; 5+ messages in thread
From: Hannes Laimer @ 2026-08-26 12:16 UTC (permalink / raw)
  To: pve-devel

On 2026-08-26 13:43, Gabriel Goller wrote:
> Small nit: the submitValue property doesn't need to be in the cBind, we could
> just always set it to true.
>

we could, but on update the mac only gets submitted because its part of
`extraRequestParams` in DhcpTree, so forcing this to true would
technically also change the update behavior.. result should be the same
though

> LGTM though.

thanks for taking a look!

> 
> Tested-by: Gabriel Goller <g.goller@proxmox.com>
> Reviewed-by: Gabriel Goller <g.goller@proxmox.com>





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-08-26 12:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-26 11:13 [PATCH manager/network v2 0/2] sdn: add guest/nic selectors to IPAM create window Hannes Laimer
2026-08-26 11:13 ` [PATCH pve-network v2 1/2] api: sdn: ipam: add optional vmid to POST endpoint Hannes Laimer
2026-08-26 11:13 ` [PATCH pve-manager v2 2/2] ui: sdn: ipam: allow picking the nic instead of typing its MAC Hannes Laimer
2026-08-26 11:43 ` [PATCH manager/network v2 0/2] sdn: add guest/nic selectors to IPAM create window Gabriel Goller
2026-08-26 12:16   ` Hannes Laimer

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