示例#1
0
文件: address_test.go 项目: bac/juju
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)
	}
}
示例#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)
	}
}
示例#3
0
文件: agent.go 项目: 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)
}
示例#4
0
文件: addresses.go 项目: bac/juju
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
}