예제 #1
0
func (s *MachineSuite) TestSetAddresses(c *C) {
	machine, err := s.State.AddMachine("series", state.JobHostUnits)
	c.Assert(err, IsNil)
	c.Assert(machine.Addresses(), HasLen, 0)

	addresses := []instance.Address{
		instance.NewAddress("127.0.0.1"),
		instance.NewAddress("8.8.8.8"),
	}
	err = machine.SetAddresses(addresses)
	c.Assert(err, IsNil)
	err = machine.Refresh()
	c.Assert(err, IsNil)
	c.Assert(machine.Addresses(), DeepEquals, addresses)
}
예제 #2
0
func (s *UnitSuite) TestGetPublicAddressFromMachine(c *C) {
	machine, err := s.State.AddMachine("series", state.JobHostUnits)
	c.Assert(err, IsNil)
	err = s.unit.AssignToMachine(machine)
	c.Assert(err, IsNil)

	address, ok := s.unit.PublicAddress()
	c.Check(address, Equals, "")
	c.Assert(ok, Equals, false)

	addresses := []instance.Address{
		instance.NewAddress("127.0.0.1"),
		instance.NewAddress("8.8.8.8"),
	}
	err = machine.SetAddresses(addresses)
	c.Assert(err, IsNil)

	address, ok = s.unit.PublicAddress()
	c.Check(address, Equals, "8.8.8.8")
	c.Assert(ok, Equals, true)
}
예제 #3
0
func (s *AddressSuite) TestNewAddressHostname(c *gc.C) {
	addr := instance.NewAddress("localhost")
	c.Check(addr.Value, gc.Equals, "localhost")
	c.Check(addr.Type, gc.Equals, instance.HostName)
}
예제 #4
0
func (s *AddressSuite) TestNewAddressIpv6(c *gc.C) {
	addr := instance.NewAddress("::1")
	c.Check(addr.Value, gc.Equals, "::1")
	c.Check(addr.Type, gc.Equals, instance.Ipv6Address)
}
예제 #5
0
func (s *AddressSuite) TestNewAddressIpv4(c *gc.C) {
	addr := instance.NewAddress("127.0.0.1")
	c.Check(addr.Value, gc.Equals, "127.0.0.1")
	c.Check(addr.Type, gc.Equals, instance.Ipv4Address)
}