本文整理汇总了Golang中github.com/tsuru/tsuru/provision/docker/container.Container.HostAddr方法的典型用法代码示例。如果您正苦于以下问题:Golang Container.HostAddr方法的具体用法?Golang Container.HostAddr怎么用?Golang Container.HostAddr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/tsuru/tsuru/provision/docker/container.Container
的用法示例。
在下文中一共展示了Container.HostAddr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestAllContainers
func (s *S) TestAllContainers(c *check.C) {
p, err := NewFakeDockerProvisioner()
c.Assert(err, check.IsNil)
defer p.Destroy()
cont1 := container.Container{ID: "cont1"}
cont2 := container.Container{ID: "cont2"}
p.SetContainers("localhost", []container.Container{cont1})
p.SetContainers("remotehost", []container.Container{cont2})
cont1.HostAddr = "localhost"
cont2.HostAddr = "remotehost"
containers := p.AllContainers()
expected := []container.Container{cont1, cont2}
if expected[0].HostAddr != containers[0].HostAddr {
expected = []container.Container{cont2, cont1}
}
c.Assert(containers, check.DeepEquals, expected)
}
示例2: TestMoveOneContainerNoActionNeeded
func (s *S) TestMoveOneContainerNoActionNeeded(c *check.C) {
p, err := NewFakeDockerProvisioner()
c.Assert(err, check.IsNil)
defer p.Destroy()
cont := container.Container{ID: "something"}
p.SetContainers("localhost", []container.Container{cont})
errors := make(chan error, 1)
result := p.MoveOneContainer(cont, "localhost", errors, nil, nil, nil)
cont.HostAddr = "localhost"
c.Assert(result, check.DeepEquals, cont)
select {
case err := <-errors:
c.Error(err)
default:
}
}
示例3: moveOneContainer
func (p *FakeDockerProvisioner) moveOneContainer(cont container.Container, toHost string) (container.Container, error) {
cont, index, err := p.findContainer(cont.ID)
if err != nil {
return cont, err
}
if cont.HostAddr == toHost {
return cont, nil
}
if toHost == "" {
for host := range p.containers {
if host != cont.HostAddr {
toHost = host
break
}
}
}
originHost := cont.HostAddr
moving := ContainerMoving{
ContainerID: cont.ID,
HostFrom: originHost,
HostTo: toHost,
}
p.movings = append(p.movings, moving)
if toHost == "" {
cont.ID += "-recreated"
p.containers[originHost][index] = cont
return cont, nil
}
cont.HostAddr = toHost
cont.ID += "-moved"
last := len(p.containers[originHost]) - 1
p.containers[originHost][index] = p.containers[originHost][last]
p.containers[originHost] = p.containers[originHost][:last]
p.containers[cont.HostAddr] = append(p.containers[cont.HostAddr], cont)
return cont, nil
}