Ejemplo n.º 1
0
func (c *configInternal) SetAPIHostPorts(servers [][]network.HostPort) {
	if c.apiDetails == nil {
		return
	}
	var addrs []string
	for _, serverHostPorts := range servers {
		addrs = append(addrs, network.SelectInternalHostPorts(serverHostPorts, false)...)
	}
	c.apiDetails.addresses = addrs
}
Ejemplo n.º 2
0
func (c *configInternal) SetAPIHostPorts(servers [][]network.HostPort) {
	if c.apiDetails == nil {
		return
	}
	var addrs []string
	for _, serverHostPorts := range servers {
		addrs = append(addrs, network.SelectInternalHostPorts(serverHostPorts, false)...)
	}
	c.apiDetails.addresses = addrs
	logger.Infof("API server address details %q written to agent config as %q", servers, addrs)
}
Ejemplo n.º 3
0
func (s *AddressSuite) TestSelectInternalHostPorts(c *gc.C) {
	oldValue := network.PreferIPv6()
	defer func() {
		network.SetPreferIPv6(oldValue)
	}()
	for i, t := range selectInternalHostPortsTests {
		c.Logf("test %d: %s", i, t.about)
		network.SetPreferIPv6(t.preferIPv6)
		c.Check(network.SelectInternalHostPorts(t.addresses, false), gc.DeepEquals, t.expected)
	}
}
Ejemplo n.º 4
0
Archivo: agent.go Proyecto: OSBI/juju
func (c *configInternal) SetAPIHostPorts(servers [][]network.HostPort) {
	if c.apiDetails == nil {
		return
	}
	var addrs []string
	for _, serverHostPorts := range servers {
		// Try the preferred approach first.
		serverHP, ok := network.SelectHostPortBySpace(serverHostPorts, network.DefaultSpace)
		if ok {
			addrs = append(addrs, serverHP.NetAddr())
		} else {
			// Fallback to the legacy approach.
			hps := network.SelectInternalHostPorts(serverHostPorts, false)
			addrs = append(addrs, hps...)
		}
	}
	c.apiDetails.addresses = addrs
	logger.Infof("API server address details %q written to agent config as %q", servers, addrs)
}
Ejemplo n.º 5
0
func (s *AddressSuite) TestSelectInternalHostPorts(c *gc.C) {
	for i, t := range selectInternalHostPortsTests {
		c.Logf("test %d: %s", i, t.about)
		c.Check(network.SelectInternalHostPorts(t.addresses, false), gc.DeepEquals, t.expected)
	}
}