Example #1
0
func (s *AddressSuite) TestPrioritizeInternalHostPorts(c *gc.C) {
	for i, t := range prioritizeInternalHostPortsTests {
		c.Logf("test %d: %s", i, t.about)
		prioritized := network.PrioritizeInternalHostPorts(t.addresses, false)
		c.Check(prioritized, gc.DeepEquals, t.expected)
	}
}
Example #2
0
func (s *AddressSuite) TestPrioritizeInternalHostPorts(c *gc.C) {
	oldValue := network.PreferIPv6()
	defer func() {
		network.SetPreferIPv6(oldValue)
	}()
	for i, t := range prioritizeInternalHostPortsTests {
		c.Logf("test %d: %s", i, t.about)
		network.SetPreferIPv6(t.preferIPv6)
		prioritized := network.PrioritizeInternalHostPorts(t.addresses, false)
		c.Check(prioritized, gc.DeepEquals, t.expected)
	}
}
Example #3
0
File: agent.go Project: kat-co/juju
func (c *configInternal) SetAPIHostPorts(servers [][]network.HostPort) {
	if c.apiDetails == nil {
		return
	}
	var addrs []string
	for _, serverHostPorts := range servers {
		hps := network.PrioritizeInternalHostPorts(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)
}
Example #4
0
func apiAddresses(getter APIHostPortsGetter) ([]string, error) {
	apiHostPorts, err := getter.APIHostPorts()
	if err != nil {
		return nil, err
	}
	var addrs = make([]string, 0, len(apiHostPorts))
	for _, hostPorts := range apiHostPorts {
		ordered := network.PrioritizeInternalHostPorts(hostPorts, false)
		for _, addr := range ordered {
			if addr != "" {
				addrs = append(addrs, addr)
			}
		}
	}
	return addrs, nil
}