Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions plugin/networkinterface.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package plugin

import (
"context"
)

type NetworkInterfaceState string

const (
NetworkInterfaceStatePending NetworkInterfaceState = "Pending"
NetworkInterfaceStatePrepared NetworkInterfaceState = "Ready"
Comment thread
maxmoehl marked this conversation as resolved.
Resolved
NetworkInterfaceStateAttached NetworkInterfaceState = "Attached"
Comment thread
maxmoehl marked this conversation as resolved.
Resolved
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
}
Comment thread
maxmoehl marked this conversation as resolved.
Resolved

// 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
}
Loading