本文整理汇总了Golang中github.com/juju/juju/state.LinkLayerDevice类的典型用法代码示例。如果您正苦于以下问题:Golang LinkLayerDevice类的具体用法?Golang LinkLayerDevice怎么用?Golang LinkLayerDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LinkLayerDevice类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
}
示例3: checkSetDeviceMatchesMachineIDAndModelUUID
func (s *linkLayerDevicesStateSuite) checkSetDeviceMatchesMachineIDAndModelUUID(c *gc.C, setDevice *state.LinkLayerDevice, machineID, modelUUID string) {
globalKey := fmt.Sprintf("m#%s#d#%s", machineID, setDevice.Name())
c.Check(setDevice.DocID(), gc.Equals, modelUUID+":"+globalKey)
c.Check(setDevice.MachineID(), gc.Equals, machineID)
}
示例4: checkSetDeviceMatchesArgs
func (s *linkLayerDevicesStateSuite) checkSetDeviceMatchesArgs(c *gc.C, setDevice *state.LinkLayerDevice, args state.LinkLayerDeviceArgs) {
c.Check(setDevice.Name(), gc.Equals, args.Name)
c.Check(setDevice.MTU(), gc.Equals, args.MTU)
c.Check(setDevice.ProviderID(), gc.Equals, args.ProviderID)
c.Check(setDevice.Type(), gc.Equals, args.Type)
c.Check(setDevice.MACAddress(), gc.Equals, args.MACAddress)
c.Check(setDevice.IsAutoStart(), gc.Equals, args.IsAutoStart)
c.Check(setDevice.IsUp(), gc.Equals, args.IsUp)
c.Check(setDevice.ParentName(), gc.Equals, args.ParentName)
}
示例5: removeDeviceAddressesAndAssertNoneRemainOnMacine
func (s *ipAddressesStateSuite) removeDeviceAddressesAndAssertNoneRemainOnMacine(c *gc.C, device *state.LinkLayerDevice) {
err := device.RemoveAddresses()
c.Assert(err, jc.ErrorIsNil)
s.assertNoAddressesOnMachine(c, s.machine)
}