// SelectMongoHostPort returns the best hostport for the machine for // MongoDB use, perhaps using the space provided. func (m *machineTracker) SelectMongoHostPort(mongoSpace network.SpaceName) string { m.mu.Lock() defer m.mu.Unlock() if mongoSpace != "" { return mongo.SelectPeerHostPortBySpace(m.mongoHostPorts, mongoSpace) } return mongo.SelectPeerHostPort(m.mongoHostPorts) }
func (s *MongoSuite) TestSelectPeerHostPort(c *gc.C) { hostPorts := []network.HostPort{{ Address: network.Address{ Value: "10.0.0.1", Type: network.IPv4Address, Scope: network.ScopeCloudLocal, }, Port: environs.DefaultStatePort}, { Address: network.Address{ Value: "8.8.8.8", Type: network.IPv4Address, Scope: network.ScopePublic, }, Port: environs.DefaultStatePort}} address := mongo.SelectPeerHostPort(hostPorts) c.Assert(address, gc.Equals, "10.0.0.1:"+strconv.Itoa(environs.DefaultStatePort)) }
func (s *MongoSuite) TestSelectPeerHostPort(c *gc.C) { hostPorts := []network.HostPort{{ Address: network.Address{ Value: "10.0.0.1", Type: network.IPv4Address, NetworkName: "cloud", Scope: network.ScopeCloudLocal, }, Port: 37017}, { Address: network.Address{ Value: "8.8.8.8", Type: network.IPv4Address, NetworkName: "public", Scope: network.ScopePublic, }, Port: 37017}} address := mongo.SelectPeerHostPort(hostPorts) c.Assert(address, gc.Equals, "10.0.0.1:37017") }
func (m *machine) mongoHostPort() string { return mongo.SelectPeerHostPort(m.mongoHostPorts) }
func (m *machine) mongoHostPort() string { if m.mongoSpaceValid { return mongo.SelectPeerHostPortBySpace(m.mongoHostPorts, m.mongoSpace) } return mongo.SelectPeerHostPort(m.mongoHostPorts) }