Пример #1
0
func (t *LxdSuite) TestNetworkDevicesWithParentDevice(c *gc.C) {
	interfaces := []network.InterfaceInfo{{
		ParentInterfaceName: "br-eth0",
		InterfaceName:       "eth0",
		InterfaceType:       "ethernet",
		Address:             network.NewAddress("0.10.0.20"),
		MACAddress:          "aa:bb:cc:dd:ee:f0",
	}}

	expected := lxdclient.Devices{
		"eth0": lxdclient.Device{
			"hwaddr":  "aa:bb:cc:dd:ee:f0",
			"name":    "eth0",
			"nictype": "bridged",
			"parent":  "br-eth0",
			"type":    "nic",
		},
	}

	result, err := lxd.NetworkDevices(&container.NetworkConfig{
		Device:     "lxdbr0",
		Interfaces: interfaces,
	})

	c.Assert(err, jc.ErrorIsNil)
	c.Assert(result, jc.DeepEquals, expected)
}
Пример #2
0
func (t *LxdSuite) TestNetworkDevicesWithEmptyParentDevice(c *gc.C) {
	interfaces := []network.InterfaceInfo{{
		InterfaceName: "eth1",
		InterfaceType: "ethernet",
		Address:       network.NewAddress("0.10.0.21"),
		MACAddress:    "aa:bb:cc:dd:ee:f1",
		MTU:           9000,
	}}

	result, err := lxd.NetworkDevices(&container.NetworkConfig{
		Interfaces: interfaces,
	})

	c.Assert(err, gc.ErrorMatches, "invalid parent device name")
	c.Assert(result, gc.IsNil)
}