コード例 #1
0
ファイル: agent.go プロジェクト: andrewdmcleod/juju
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
}
コード例 #2
0
ファイル: agent.go プロジェクト: imoapps/juju
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)
}
コード例 #3
0
ファイル: address_test.go プロジェクト: AlexisBruemmer/juju
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)
	}
}
コード例 #4
0
ファイル: agent.go プロジェクト: 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)
}
コード例 #5
0
ファイル: address_test.go プロジェクト: bac/juju
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)
	}
}