Skip to content

Commit

Permalink
feat: parse openvswitch for any netplan interface
Browse files Browse the repository at this point in the history
The openvswitch stanza can apply to any interface, so we remove it from
the specific bridge and VLAN devices, and add it to the generic
interface type that those embed.
  • Loading branch information
manadart committed Nov 13, 2024
1 parent bf738b2 commit 9ca6cb8
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions network/netplan/netplan.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@ type Interface struct {
// specified, this instructs netplan not to bring any ipv4/ipv6 address
// up.
LinkLocal *[]string `yaml:"link-local,omitempty"`

// According to the netplan examples, this section typically includes
// some OVS-specific configuration bits. However, MAAS may just
// include an empty block to indicate the presence of an OVS-managed
// bridge (LP1942328). As a workaround, we make this an optional map
// so we can tell whether it is present (but empty) vs not being
// present.
//
// See: https://github.com/canonical/netplan/blob/main/examples/openvswitch.yaml
OVSParameters *map[string]interface{} `yaml:"openvswitch,omitempty"`
}

// Ethernet defines fields for just Ethernet devices
Expand All @@ -61,11 +71,13 @@ type Ethernet struct {
SetName string `yaml:"set-name,omitempty"`
Interface `yaml:",inline"`
}

type AccessPoint struct {
Password string `yaml:"password,omitempty"`
Mode string `yaml:"mode,omitempty"`
Channel int `yaml:"channel,omitempty"`
}

type Wifi struct {
Match map[string]string `yaml:"match,omitempty"`
SetName string `yaml:"set-name,omitempty"`
Expand All @@ -89,16 +101,6 @@ type Bridge struct {
Interfaces []string `yaml:"interfaces,omitempty,flow"`
Interface `yaml:",inline"`
Parameters BridgeParameters `yaml:"parameters,omitempty"`

// According to the netplan examples, this section typically includes
// some OVS-specific configuration bits. However, MAAS may just
// include an empty block to indicate the presence of an OVS-managed
// bridge (LP1942328). As a workaround, we make this an optional map
// so we can tell whether it is present (but empty) vs not being
// present.
//
// See: https://github.com/canonical/netplan/blob/main/examples/openvswitch.yaml
OVSParameters *map[string]interface{} `yaml:"openvswitch,omitempty"`
}

type Route struct {
Expand Down Expand Up @@ -142,10 +144,9 @@ type Netplan struct {

// VLAN represents the structures for defining VLAN sections
type VLAN struct {
Id *int `yaml:"id,omitempty"`
Link string `yaml:"link,omitempty"`
Interface `yaml:",inline"`
OVSParameters *map[string]interface{} `yaml:"openvswitch,omitempty"`
Id *int `yaml:"id,omitempty"`
Link string `yaml:"link,omitempty"`
Interface `yaml:",inline"`
}

// Bond is the interface definition of the bonds: section of netplan
Expand Down

0 comments on commit 9ca6cb8

Please sign in to comment.