本文整理汇总了Golang中launchpad/net/juju-core/instance.Instance.Id方法的典型用法代码示例。如果您正苦于以下问题:Golang Instance.Id方法的具体用法?Golang Instance.Id怎么用?Golang Instance.Id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类launchpad/net/juju-core/instance.Instance
的用法示例。
在下文中一共展示了Instance.Id方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: WaitDNSName
// WaitDNSName is an implementation that the providers can use. It builds on
// the provider's implementation of Instance.DNSName.
func WaitDNSName(inst instance.Instance) (string, error) {
for a := LongAttempt.Start(); a.Next(); {
name, err := inst.DNSName()
if err == nil || err != instance.ErrNoDNSName {
return name, err
}
}
return "", fmt.Errorf("timed out trying to get DNS address for %v", inst.Id())
}
示例2: StopContainer
func (manager *containerManager) StopContainer(instance instance.Instance) error {
name := string(instance.Id())
container := lxcObjectFactory.New(name)
if err := container.Stop(); err != nil {
logger.Errorf("failed to stop lxc container: %v", err)
return err
}
// Destroy removes the restart symlink for us.
if err := container.Destroy(); err != nil {
logger.Errorf("failed to destroy lxc container: %v", err)
return err
}
// Move the directory.
logger.Tracef("create old container dir: %s", removedContainerDir)
if err := os.MkdirAll(removedContainerDir, 0755); err != nil {
logger.Errorf("failed to create removed container directory: %v", err)
return err
}
removedDir, err := uniqueDirectory(removedContainerDir, name)
if err != nil {
logger.Errorf("was not able to generate a unique directory: %v", err)
return err
}
if err := os.Rename(jujuContainerDirectory(name), removedDir); err != nil {
logger.Errorf("failed to rename container directory: %v", err)
return err
}
return nil
}
示例3: assertInstanceId
// assertInstanceId asserts that the machine has an instance id
// that matches that of the given instance. If the instance is nil,
// It asserts that the instance id is unset.
func assertInstanceId(c *C, m *state.Machine, inst instance.Instance) {
var wantId, gotId instance.Id
var err error
if inst != nil {
wantId = inst.Id()
}
for a := waitAgent.Start(); a.Next(); {
err := m.Refresh()
c.Assert(err, IsNil)
gotId, err = m.InstanceId()
if err != nil {
c.Assert(state.IsNotProvisionedError(err), IsTrue)
if inst == nil {
return
}
continue
}
break
}
c.Assert(err, IsNil)
c.Assert(gotId, Equals, wantId)
}
示例4: lxcRemovedContainerDir
func (s *lxcBrokerSuite) lxcRemovedContainerDir(inst instance.Instance) string {
return filepath.Join(s.RemovedDir, string(inst.Id()))
}