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 }
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) }
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) } }
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) }
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) } }