Skip to content

Commit

Permalink
Removes InterfaceTupe and replaces its usage with LinkLayerDevice type.
Browse files Browse the repository at this point in the history
These were duplicates with identical string values.
  • Loading branch information
manadart committed May 5, 2021
1 parent 137b9fc commit 787da01
Show file tree
Hide file tree
Showing 31 changed files with 274 additions and 283 deletions.
6 changes: 3 additions & 3 deletions api/common/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ func GetObservedNetworkConfig(source network.ConfigSource) ([]params.NetworkConf
nicConfig.GatewayAddress = defaultRoute.String()
}

if nicType == network.BridgeInterface {
if nicType == network.BridgeDevice {
updateParentForBridgePorts(source, nic.Name(), nameToConfigs)
}

Expand Down Expand Up @@ -128,12 +128,12 @@ func GetObservedNetworkConfig(source network.ConfigSource) ([]params.NetworkConf
}

func interfaceToNetworkConfig(nic network.ConfigSourceNIC,
nicType network.InterfaceType,
nicType network.LinkLayerDeviceType,
virtualPortType network.VirtualPortType,
networkOrigin network.Origin,
) params.NetworkConfig {
configType := network.ConfigManual
if nicType == network.LoopbackInterface {
if nicType == network.LoopbackDevice {
configType = network.ConfigLoopback
}

Expand Down
9 changes: 5 additions & 4 deletions api/common/network_mock_test.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions api/common/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func (s *networkConfigSuite) TestGetObservedNetworkConfigInterfaceAddressesError
nic := NewMockConfigSourceNIC(ctrl)
exp := nic.EXPECT()
exp.Name().Return("eth0").MinTimes(1)
exp.Type().Return(network.EthernetInterface)
exp.Type().Return(network.EthernetDevice)
exp.IsUp().Return(true)
exp.Index().Return(2)
exp.HardwareAddr().Return(net.HardwareAddr{})
Expand All @@ -78,7 +78,7 @@ func (s *networkConfigSuite) TestGetObservedNetworkConfigNilAddressError(c *gc.C
nic := NewMockConfigSourceNIC(ctrl)
exp := nic.EXPECT()
exp.Name().Return("eth1").MinTimes(1)
exp.Type().Return(network.EthernetInterface)
exp.Type().Return(network.EthernetDevice)
exp.IsUp().Return(true)
exp.Index().Return(2)
exp.HardwareAddr().Return(parseMAC(c, "aa:bb:cc:dd:ee:ff"))
Expand All @@ -101,7 +101,7 @@ func (s *networkConfigSuite) TestGetObservedNetworkConfigNoInterfaceAddresses(c

// Note that eth1 is not the default gateway.
exp.Name().Return("eth1").MinTimes(1)
exp.Type().Return(network.EthernetInterface)
exp.Type().Return(network.EthernetDevice)
exp.IsUp().Return(true)
exp.Index().Return(2)
exp.HardwareAddr().Return(parseMAC(c, "aa:bb:cc:dd:ee:ff"))
Expand Down Expand Up @@ -145,7 +145,7 @@ func (s *networkConfigSuite) TestGetObservedNetworkConfigDefaultGatewayWithAddre

// eth0 matches the device returned as the default gateway.
exp.Name().Return("eth0").MinTimes(1)
exp.Type().Return(network.EthernetInterface)
exp.Type().Return(network.EthernetDevice)
exp.IsUp().Return(true)
exp.Index().Return(2)
exp.HardwareAddr().Return(parseMAC(c, "aa:bb:cc:dd:ee:ff"))
Expand Down Expand Up @@ -196,7 +196,7 @@ func (s *networkConfigSuite) TestGetObservedNetworkConfigForOVSDevice(c *gc.C) {
exp := nic.EXPECT()

exp.Name().Return("ovsbr0").MinTimes(1)
exp.Type().Return(network.BridgeInterface)
exp.Type().Return(network.BridgeDevice)
exp.IsUp().Return(true)
exp.Index().Return(2)
exp.HardwareAddr().Return(parseMAC(c, "aa:bb:cc:dd:ee:ff"))
Expand Down Expand Up @@ -230,7 +230,7 @@ func (s *networkConfigSuite) TestGetObservedNetworkConfigBridgePortsHaveParentSe
exp1 := nic1.EXPECT()

exp1.Name().Return("eth1").MinTimes(1)
exp1.Type().Return(network.EthernetInterface)
exp1.Type().Return(network.EthernetDevice)
exp1.IsUp().Return(true)
exp1.Index().Return(2)
exp1.HardwareAddr().Return(parseMAC(c, "aa:bb:cc:dd:ee:ff"))
Expand All @@ -241,7 +241,7 @@ func (s *networkConfigSuite) TestGetObservedNetworkConfigBridgePortsHaveParentSe
exp2 := nic2.EXPECT()

exp2.Name().Return("br-eth1").MinTimes(1)
exp2.Type().Return(network.BridgeInterface)
exp2.Type().Return(network.BridgeDevice)
exp2.IsUp().Return(true)
exp2.Index().Return(3)
exp2.HardwareAddr().Return(parseMAC(c, "aa:bb:cc:dd:ee:ff"))
Expand Down
2 changes: 1 addition & 1 deletion apiserver/common/networkingcommon/networkconfigapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ func (o *updateMachineLinkLayerOp) processSubnets(name string) ([]txn.Op, error)
cidrSet := set.NewStrings()
var isVLAN bool
for _, matching := range o.Incoming().GetByName(name) {
if matching.InterfaceType == network.LoopbackInterface {
if matching.InterfaceType == network.LoopbackDevice {
continue
}

Expand Down
36 changes: 18 additions & 18 deletions apiserver/common/networkingcommon/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (s *TypesSuite) SetUpTest(c *gc.C) {
var observedNetworkConfigs = []params.NetworkConfig{{
DeviceIndex: 1,
InterfaceName: "lo",
InterfaceType: string(network.LoopbackInterface),
InterfaceType: string(network.LoopbackDevice),
MACAddress: "",
CIDR: "127.0.0.0/8",
Address: "127.0.0.1",
Expand All @@ -36,7 +36,7 @@ var observedNetworkConfigs = []params.NetworkConfig{{
}, {
DeviceIndex: 10,
InterfaceName: "br-eth0",
InterfaceType: string(network.BridgeInterface),
InterfaceType: string(network.BridgeDevice),
MACAddress: "aa:bb:cc:dd:ee:f0",
CIDR: "10.20.19.0/24",
Address: "10.20.19.100",
Expand All @@ -46,7 +46,7 @@ var observedNetworkConfigs = []params.NetworkConfig{{
}, {
DeviceIndex: 10,
InterfaceName: "br-eth0",
InterfaceType: string(network.BridgeInterface),
InterfaceType: string(network.BridgeDevice),
MACAddress: "aa:bb:cc:dd:ee:f0",
CIDR: "10.20.19.0/24",
Address: "10.20.19.123",
Expand All @@ -56,7 +56,7 @@ var observedNetworkConfigs = []params.NetworkConfig{{
}, {
DeviceIndex: 12,
InterfaceName: "br-eth0.100",
InterfaceType: string(network.BridgeInterface),
InterfaceType: string(network.BridgeDevice),
MACAddress: "aa:bb:cc:dd:ee:f0",
CIDR: "10.100.19.0/24",
Address: "10.100.19.100",
Expand All @@ -65,7 +65,7 @@ var observedNetworkConfigs = []params.NetworkConfig{{
}, {
DeviceIndex: 14,
InterfaceName: "br-eth0.250",
InterfaceType: string(network.BridgeInterface),
InterfaceType: string(network.BridgeDevice),
MACAddress: "aa:bb:cc:dd:ee:f0",
CIDR: "10.250.19.0/24",
Address: "10.250.19.100",
Expand All @@ -75,7 +75,7 @@ var observedNetworkConfigs = []params.NetworkConfig{{
}, {
DeviceIndex: 16,
InterfaceName: "br-eth0.50",
InterfaceType: string(network.BridgeInterface),
InterfaceType: string(network.BridgeDevice),
MACAddress: "aa:bb:cc:dd:ee:f0",
CIDR: "10.50.19.0/24",
Address: "10.50.19.100",
Expand All @@ -86,7 +86,7 @@ var observedNetworkConfigs = []params.NetworkConfig{{
DeviceIndex: 2,
InterfaceName: "eth0",
ParentInterfaceName: "br-eth0",
InterfaceType: string(network.EthernetInterface),
InterfaceType: string(network.EthernetDevice),
MACAddress: "aa:bb:cc:dd:ee:f0",
MTU: 1500,
ConfigType: string(network.ConfigManual),
Expand All @@ -95,7 +95,7 @@ var observedNetworkConfigs = []params.NetworkConfig{{
DeviceIndex: 13,
InterfaceName: "eth0.100",
ParentInterfaceName: "br-eth0.100",
InterfaceType: string(network.VLAN_8021QInterface),
InterfaceType: string(network.VLAN8021QDevice),
MACAddress: "aa:bb:cc:dd:ee:f0",
MTU: 1500,
ConfigType: string(network.ConfigManual),
Expand All @@ -104,7 +104,7 @@ var observedNetworkConfigs = []params.NetworkConfig{{
DeviceIndex: 15,
InterfaceName: "eth0.250",
ParentInterfaceName: "br-eth0.250",
InterfaceType: string(network.VLAN_8021QInterface),
InterfaceType: string(network.VLAN8021QDevice),
MACAddress: "aa:bb:cc:dd:ee:f0",
MTU: 1500,
ConfigType: string(network.ConfigManual),
Expand All @@ -113,15 +113,15 @@ var observedNetworkConfigs = []params.NetworkConfig{{
DeviceIndex: 17,
InterfaceName: "eth0.50",
ParentInterfaceName: "br-eth0.50",
InterfaceType: string(network.VLAN_8021QInterface),
InterfaceType: string(network.VLAN8021QDevice),
MACAddress: "aa:bb:cc:dd:ee:f0",
MTU: 1500,
ConfigType: string(network.ConfigManual),
NetworkOrigin: params.NetworkOrigin(network.OriginMachine),
}, {
DeviceIndex: 11,
InterfaceName: "br-eth1",
InterfaceType: string(network.BridgeInterface),
InterfaceType: string(network.BridgeDevice),
MACAddress: "aa:bb:cc:dd:ee:f1",
CIDR: "10.20.19.0/24",
Address: "10.20.19.105",
Expand All @@ -131,7 +131,7 @@ var observedNetworkConfigs = []params.NetworkConfig{{
}, {
DeviceIndex: 18,
InterfaceName: "br-eth1.11",
InterfaceType: string(network.BridgeInterface),
InterfaceType: string(network.BridgeDevice),
MACAddress: "aa:bb:cc:dd:ee:f1",
CIDR: "10.11.19.0/24",
Address: "10.11.19.101",
Expand All @@ -141,7 +141,7 @@ var observedNetworkConfigs = []params.NetworkConfig{{
}, {
DeviceIndex: 20,
InterfaceName: "br-eth1.12",
InterfaceType: string(network.BridgeInterface),
InterfaceType: string(network.BridgeDevice),
MACAddress: "aa:bb:cc:dd:ee:f1",
CIDR: "10.12.19.0/24",
Address: "10.12.19.101",
Expand All @@ -151,7 +151,7 @@ var observedNetworkConfigs = []params.NetworkConfig{{
}, {
DeviceIndex: 22,
InterfaceName: "br-eth1.13",
InterfaceType: string(network.BridgeInterface),
InterfaceType: string(network.BridgeDevice),
MACAddress: "aa:bb:cc:dd:ee:f1",
CIDR: "10.13.19.0/24",
Address: "10.13.19.101",
Expand All @@ -162,7 +162,7 @@ var observedNetworkConfigs = []params.NetworkConfig{{
DeviceIndex: 3,
InterfaceName: "eth1",
ParentInterfaceName: "br-eth1",
InterfaceType: string(network.EthernetInterface),
InterfaceType: string(network.EthernetDevice),
MACAddress: "aa:bb:cc:dd:ee:f1",
MTU: 1500,
ConfigType: string(network.ConfigManual),
Expand All @@ -171,7 +171,7 @@ var observedNetworkConfigs = []params.NetworkConfig{{
DeviceIndex: 19,
InterfaceName: "eth1.11",
ParentInterfaceName: "br-eth1.11",
InterfaceType: string(network.VLAN_8021QInterface),
InterfaceType: string(network.VLAN8021QDevice),
MACAddress: "aa:bb:cc:dd:ee:f1",
MTU: 1500,
ConfigType: string(network.ConfigManual),
Expand All @@ -180,7 +180,7 @@ var observedNetworkConfigs = []params.NetworkConfig{{
DeviceIndex: 21,
InterfaceName: "eth1.12",
ParentInterfaceName: "br-eth1.12",
InterfaceType: string(network.VLAN_8021QInterface),
InterfaceType: string(network.VLAN8021QDevice),
MACAddress: "aa:bb:cc:dd:ee:f1",
MTU: 1500,
ConfigType: string(network.ConfigManual),
Expand All @@ -189,7 +189,7 @@ var observedNetworkConfigs = []params.NetworkConfig{{
DeviceIndex: 23,
InterfaceName: "eth1.13",
ParentInterfaceName: "br-eth1.13",
InterfaceType: string(network.VLAN_8021QInterface),
InterfaceType: string(network.VLAN8021QDevice),
MACAddress: "aa:bb:cc:dd:ee:f1",
MTU: 1500,
ConfigType: string(network.ConfigManual),
Expand Down
2 changes: 1 addition & 1 deletion apiserver/params/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func InterfaceInfoFromNetworkConfig(configs []NetworkConfig) network.InterfaceIn
VLANTag: v.VLANTag,
InterfaceName: v.InterfaceName,
ParentInterfaceName: v.ParentInterfaceName,
InterfaceType: network.InterfaceType(v.InterfaceType),
InterfaceType: network.LinkLayerDeviceType(v.InterfaceType),
Disabled: v.Disabled,
NoAutoStart: v.NoAutoStart,
ConfigType: configType,
Expand Down
6 changes: 3 additions & 3 deletions container/broker/host_preparer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ var cannedObservedNetworkConfig = []params.NetworkConfig{{
MTU: 1500,
InterfaceName: "lo",
ParentInterfaceName: "",
InterfaceType: string(corenetwork.LoopbackInterface),
InterfaceType: string(corenetwork.LoopbackDevice),
Disabled: false,
NoAutoStart: false,
ConfigType: string(corenetwork.ConfigLoopback),
Expand All @@ -172,7 +172,7 @@ var cannedObservedNetworkConfig = []params.NetworkConfig{{
MTU: 1500,
InterfaceName: "eth0",
ParentInterfaceName: "br-eth0",
InterfaceType: string(corenetwork.EthernetInterface),
InterfaceType: string(corenetwork.EthernetDevice),
Disabled: false,
NoAutoStart: false,
ConfigType: string(corenetwork.ConfigStatic),
Expand All @@ -183,7 +183,7 @@ var cannedObservedNetworkConfig = []params.NetworkConfig{{
MTU: 1500,
InterfaceName: "br-eth0",
ParentInterfaceName: "",
InterfaceType: string(corenetwork.BridgeInterface),
InterfaceType: string(corenetwork.BridgeDevice),
Disabled: false,
NoAutoStart: false,
ConfigType: string(corenetwork.ConfigStatic),
Expand Down
4 changes: 2 additions & 2 deletions container/lxd/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func prepInstanceConfig(c *gc.C) *instancecfg.InstanceConfig {
func prepNetworkConfig() *container.NetworkConfig {
return container.BridgeNetworkConfig("eth0", 1500, corenetwork.InterfaceInfos{{
InterfaceName: "eth0",
InterfaceType: corenetwork.EthernetInterface,
InterfaceType: corenetwork.EthernetDevice,
ConfigType: corenetwork.ConfigDHCP,
ParentInterfaceName: "eth0",
}})
Expand Down Expand Up @@ -220,7 +220,7 @@ func (s *managerSuite) TestContainerCreateUpdateIPv4Network(c *gc.C) {
// CIDR will cause the default bridge to be updated with IPv4 config.
netConfig := container.BridgeNetworkConfig("eth0", 1500, corenetwork.InterfaceInfos{{
InterfaceName: "eth0",
InterfaceType: corenetwork.EthernetInterface,
InterfaceType: corenetwork.EthernetDevice,
ConfigType: corenetwork.ConfigDHCP,
ParentInterfaceName: network.DefaultLXDBridge,
}})
Expand Down
4 changes: 2 additions & 2 deletions container/lxd/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,10 +476,10 @@ func DevicesFromInterfaceInfo(interfaces corenetwork.InterfaceInfos, machineID s
var unknown []string
var nicCount int
for _, v := range interfaces {
if v.InterfaceType == corenetwork.LoopbackInterface {
if v.InterfaceType == corenetwork.LoopbackDevice {
continue
}
if v.InterfaceType != corenetwork.EthernetInterface {
if v.InterfaceType != corenetwork.EthernetDevice {
return nil, nil, errors.Errorf("interface type %q not supported", v.InterfaceType)
}
if v.ParentInterfaceName == "" {
Expand Down
14 changes: 7 additions & 7 deletions container/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
package container

import (
corenetwork "github.com/juju/juju/core/network"
"github.com/juju/juju/core/network"
)

const (
Expand All @@ -18,15 +18,15 @@ type NetworkConfig struct {
Device string
MTU int

Interfaces corenetwork.InterfaceInfos
Interfaces network.InterfaceInfos
}

// FallbackInterfaceInfo returns a single "eth0" interface configured with DHCP.
func FallbackInterfaceInfo() corenetwork.InterfaceInfos {
return corenetwork.InterfaceInfos{{
func FallbackInterfaceInfo() network.InterfaceInfos {
return network.InterfaceInfos{{
InterfaceName: "eth0",
InterfaceType: corenetwork.EthernetInterface,
ConfigType: corenetwork.ConfigDHCP,
InterfaceType: network.EthernetDevice,
ConfigType: network.ConfigDHCP,
}}
}

Expand All @@ -35,7 +35,7 @@ func FallbackInterfaceInfo() corenetwork.InterfaceInfos {
// configuration for the container's network interfaces and default MTU to use.
// If interfaces is empty, FallbackInterfaceInfo() is used to get the a sane
// default
func BridgeNetworkConfig(device string, mtu int, interfaces corenetwork.InterfaceInfos) *NetworkConfig {
func BridgeNetworkConfig(device string, mtu int, interfaces network.InterfaceInfos) *NetworkConfig {
if len(interfaces) == 0 {
interfaces = FallbackInterfaceInfo()
}
Expand Down
Loading

0 comments on commit 787da01

Please sign in to comment.