From 452d8a43e3d59d4dee77611e48eb52574fed1c73 Mon Sep 17 00:00:00 2001 From: Maximilian Moehl Date: Mon, 19 Oct 2026 12:59:01 +0200 Subject: [PATCH 1/5] Add shared plugin definition for network interfaces Signed-off-by: Maximilian Moehl --- plugin/networkinterface.go | 68 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 plugin/networkinterface.go diff --git a/plugin/networkinterface.go b/plugin/networkinterface.go new file mode 100644 index 0000000..8ae15f0 --- /dev/null +++ b/plugin/networkinterface.go @@ -0,0 +1,68 @@ +package plugin + +import ( + "context" +) + +type NetworkInterfaceState string + +const ( + NetworkInterfaceStatePending NetworkInterfaceState = "Pending" + NetworkInterfaceStatePrepared NetworkInterfaceState = "Ready" + NetworkInterfaceStateAttached NetworkInterfaceState = "Attached" + NetworkInterfaceStateError NetworkInterfaceState = "Error" +) + +// NetworkInterface plugin definition to be implemented by the plugin and called +// from the provider. If the plugin requires initial setup it should offer a +// corresponding function for the provider to call. +type NetworkInterface interface { + Name() string + + Apply(ctx context.Context, spec *NetworkInterfaceSpec, machineID string) (*NetworkInterfaceStatus, error) + Delete(ctx context.Context, computeNicName string, machineID string) error +} + +type NetworkInterfaceMetadata struct { + ID string `json:"id,omitempty"` + Name string `json:"name,omitempty"` + Namespace string `json:"namespace,omitempty"` +} + +type NetworkInterfaceSpec struct { + Metadata *NetworkInterfaceMetadata `json:"metadata"` + Name string `json:"name"` + NetworkId string `json:"networkId"` + Ips []string `json:"ips"` +} + +type NetworkInterfaceStatus struct { + Name string `json:"name"` + Handle string `json:"handle"` + State NetworkInterfaceState `json:"state"` + + PCI *PCI + TAP *TAP + Netdev *Netdev +} + +// PCI address on the host to be passed through to the guest as a network +// interface. +type PCI struct { + Domain uint + Bus uint + Slot uint + Function uint +} + +// TAP device of which the hypervisor should take control of the fd-end to +// connect those to the net driver in the guest. +type TAP struct { + Name string +} + +// Netdev to which the guest should be connected, e.g. via a macvlan TAP. The +// netdev itself can be of any type. +type Netdev struct { + Name string +} From 6e943fb83ad3dbcb273d0470f0c536a526427382 Mon Sep 17 00:00:00 2001 From: Maximilian Moehl Date: Tue, 20 Oct 2026 08:03:21 +0200 Subject: [PATCH 2/5] Fix state prepared -> ready typo Signed-off-by: Maximilian Moehl --- plugin/networkinterface.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/networkinterface.go b/plugin/networkinterface.go index 8ae15f0..ea67127 100644 --- a/plugin/networkinterface.go +++ b/plugin/networkinterface.go @@ -8,7 +8,7 @@ type NetworkInterfaceState string const ( NetworkInterfaceStatePending NetworkInterfaceState = "Pending" - NetworkInterfaceStatePrepared NetworkInterfaceState = "Ready" + NetworkInterfaceStateReady NetworkInterfaceState = "Ready" NetworkInterfaceStateAttached NetworkInterfaceState = "Attached" NetworkInterfaceStateError NetworkInterfaceState = "Error" ) From 54dc590ec8e24007f8318e4e0e3636b7f3a92adc Mon Sep 17 00:00:00 2001 From: Maximilian Moehl Date: Tue, 20 Oct 2026 08:05:01 +0200 Subject: [PATCH 3/5] Set SPDX header Signed-off-by: Maximilian Moehl --- plugin/networkinterface.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plugin/networkinterface.go b/plugin/networkinterface.go index ea67127..10247c7 100644 --- a/plugin/networkinterface.go +++ b/plugin/networkinterface.go @@ -1,3 +1,6 @@ +// SPDX-FileCopyrightText: SAP SE or an SAP affiliate company and IronCore contributors +// SPDX-License-Identifier: Apache-2.0 + package plugin import ( From c7b1eddc9cf7c8c55c6bd8a3162a6d92a812be98 Mon Sep 17 00:00:00 2001 From: Maximilian Moehl Date: Wed, 21 Oct 2026 13:03:52 +0200 Subject: [PATCH 4/5] Remove attached state which a plugin can not determine on its own Signed-off-by: Maximilian Moehl --- plugin/networkinterface.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugin/networkinterface.go b/plugin/networkinterface.go index 10247c7..f762089 100644 --- a/plugin/networkinterface.go +++ b/plugin/networkinterface.go @@ -10,10 +10,9 @@ import ( type NetworkInterfaceState string const ( - NetworkInterfaceStatePending NetworkInterfaceState = "Pending" - NetworkInterfaceStateReady NetworkInterfaceState = "Ready" - NetworkInterfaceStateAttached NetworkInterfaceState = "Attached" - NetworkInterfaceStateError NetworkInterfaceState = "Error" + NetworkInterfaceStatePending NetworkInterfaceState = "Pending" + NetworkInterfaceStateReady NetworkInterfaceState = "Ready" + NetworkInterfaceStateError NetworkInterfaceState = "Error" ) // NetworkInterface plugin definition to be implemented by the plugin and called From eea88cf47a408dddffc24eedd95c43921d8a9f2a Mon Sep 17 00:00:00 2001 From: Maximilian Moehl Date: Wed, 21 Oct 2026 13:04:25 +0200 Subject: [PATCH 5/5] Use string BDF representation instead of individual uints Signed-off-by: Maximilian Moehl --- plugin/networkinterface.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/plugin/networkinterface.go b/plugin/networkinterface.go index f762089..2267218 100644 --- a/plugin/networkinterface.go +++ b/plugin/networkinterface.go @@ -51,10 +51,9 @@ type NetworkInterfaceStatus struct { // PCI address on the host to be passed through to the guest as a network // interface. type PCI struct { - Domain uint - Bus uint - Slot uint - Function uint + // BDF is the (Domain) / Bus / Device / Function address of the PCI + // function in the format `(domain:)bus:device:function`. + BDF string } // TAP device of which the hypervisor should take control of the fd-end to