本文整理汇总了Golang中github.com/juju/juju/state.LinkLayerDevice.Remove方法的典型用法代码示例。如果您正苦于以下问题:Golang LinkLayerDevice.Remove方法的具体用法?Golang LinkLayerDevice.Remove怎么用?Golang LinkLayerDevice.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/juju/juju/state.LinkLayerDevice
的用法示例。
在下文中一共展示了LinkLayerDevice.Remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestLinkLayerDeviceMigratesReferences
func (s *MigrationImportSuite) TestLinkLayerDeviceMigratesReferences(c *gc.C) {
machine := s.Factory.MakeMachine(c, &factory.MachineParams{
Constraints: constraints.MustParse("arch=amd64 mem=8G"),
})
machine2 := s.Factory.MakeMachineNested(c, machine.Id(), &factory.MachineParams{
Constraints: constraints.MustParse("arch=amd64 mem=8G"),
})
deviceArgs := []state.LinkLayerDeviceArgs{{
Name: "foo",
Type: state.BridgeDevice,
}, {
Name: "bar",
ParentName: "foo",
Type: state.EthernetDevice,
}}
for _, args := range deviceArgs {
err := machine.SetLinkLayerDevices(args)
c.Assert(err, jc.ErrorIsNil)
}
machine2DeviceArgs := state.LinkLayerDeviceArgs{
Name: "baz",
ParentName: fmt.Sprintf("m#%v#d#foo", machine.Id()),
Type: state.EthernetDevice,
}
err := machine2.SetLinkLayerDevices(machine2DeviceArgs)
c.Assert(err, jc.ErrorIsNil)
_, newSt := s.importModel(c)
devices, err := newSt.AllLinkLayerDevices()
c.Assert(err, jc.ErrorIsNil)
c.Assert(devices, gc.HasLen, 3)
var parent *state.LinkLayerDevice
others := []*state.LinkLayerDevice{}
for _, device := range devices {
if device.Name() == "foo" {
parent = device
} else {
others = append(others, device)
}
}
// Assert we found the parent.
c.Assert(others, gc.HasLen, 2)
err = parent.Remove()
c.Assert(err, gc.ErrorMatches, `.*parent device "foo" has 2 children.*`)
err = others[0].Remove()
c.Assert(err, jc.ErrorIsNil)
err = parent.Remove()
c.Assert(err, gc.ErrorMatches, `.*parent device "foo" has 1 children.*`)
err = others[1].Remove()
c.Assert(err, jc.ErrorIsNil)
err = parent.Remove()
c.Assert(err, jc.ErrorIsNil)
}
示例2: removeDeviceAndAssertSuccess
func (s *linkLayerDevicesStateSuite) removeDeviceAndAssertSuccess(c *gc.C, givenDevice *state.LinkLayerDevice) {
err := givenDevice.Remove()
c.Assert(err, jc.ErrorIsNil)
}