예제 #1
0
func (s *InterfaceInfoSuite) TestSortInterfaceInfo(c *gc.C) {
	info := []network.InterfaceInfo{
		{VLANTag: 42, DeviceIndex: 2, InterfaceName: "br2"},
		{VLANTag: 0, DeviceIndex: 1, InterfaceName: "eth1"},
		{VLANTag: 1, DeviceIndex: 0, InterfaceName: "eth0"},
	}
	expectedInfo := []network.InterfaceInfo{
		{VLANTag: 1, DeviceIndex: 0, InterfaceName: "eth0"},
		{VLANTag: 0, DeviceIndex: 1, InterfaceName: "eth1"},
		{VLANTag: 42, DeviceIndex: 2, InterfaceName: "br2"},
	}
	network.SortInterfaceInfo(info)
	c.Assert(info, jc.DeepEquals, expectedInfo)
}
예제 #2
0
func (suite *environSuite) TestNetworkInterfacesLegacy(c *gc.C) {
	testInstance := suite.createSubnets(c, false)

	netInfo, err := suite.makeEnviron().NetworkInterfaces(testInstance.Id())
	c.Assert(err, jc.ErrorIsNil)

	expectedInfo := []network.InterfaceInfo{{
		DeviceIndex:      0,
		MACAddress:       "aa:bb:cc:dd:ee:ff",
		CIDR:             "192.168.1.2/24",
		ProviderSubnetId: "WLAN",
		VLANTag:          0,
		InterfaceName:    "wlan0",
		Disabled:         true,
		NoAutoStart:      true,
		ConfigType:       network.ConfigDHCP,
		ExtraConfig:      nil,
		GatewayAddress:   network.Address{},
		Address:          network.NewScopedAddress("192.168.1.2", network.ScopeCloudLocal),
	}, {
		DeviceIndex:      1,
		MACAddress:       "aa:bb:cc:dd:ee:f1",
		CIDR:             "192.168.2.2/24",
		ProviderSubnetId: "LAN",
		VLANTag:          42,
		InterfaceName:    "eth0",
		Disabled:         false,
		NoAutoStart:      false,
		ConfigType:       network.ConfigDHCP,
		ExtraConfig:      nil,
		GatewayAddress:   network.NewScopedAddress("192.168.2.1", network.ScopeCloudLocal),
		Address:          network.NewScopedAddress("192.168.2.2", network.ScopeCloudLocal),
	}, {
		DeviceIndex:      2,
		MACAddress:       "aa:bb:cc:dd:ee:f2",
		CIDR:             "192.168.3.2/24",
		ProviderSubnetId: "Virt",
		VLANTag:          0,
		InterfaceName:    "vnet1",
		Disabled:         false,
		NoAutoStart:      false,
		ConfigType:       network.ConfigDHCP,
		ExtraConfig:      nil,
		GatewayAddress:   network.Address{},
		Address:          network.NewScopedAddress("192.168.3.2", network.ScopeCloudLocal),
	}}
	network.SortInterfaceInfo(netInfo)
	c.Assert(netInfo, jc.DeepEquals, expectedInfo)
}