本文整理匯總了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)
}