Ejemplo n.º 1
0
Archivo: mongo.go Proyecto: makyo/juju
// SelectPeerHostPortBySpace returns the HostPort to use as the mongo replica set peer
// by selecting it from the given hostPorts.
func SelectPeerHostPortBySpace(hostPorts []network.HostPort, space network.SpaceName) string {
	logger.Debugf("selecting mongo peer hostPort in space %s from %+v", space, hostPorts)
	// ScopeMachineLocal addresses are OK if we can't pick by space.
	suitableHostPorts, foundHostPortsInSpaces := network.SelectMongoHostPortsBySpaces(hostPorts, []network.SpaceName{space})

	if !foundHostPortsInSpaces {
		logger.Debugf("Failed to select hostPort by space - trying by scope from %+v", hostPorts)
		suitableHostPorts = network.SelectMongoHostPortsByScope(hostPorts, true)
	}
	return suitableHostPorts[0]
}
Ejemplo n.º 2
0
Archivo: mongo.go Proyecto: makyo/juju
// SelectPeerHostPort returns the HostPort to use as the mongo replica set peer
// by selecting it from the given hostPorts.
func SelectPeerHostPort(hostPorts []network.HostPort) string {
	logger.Debugf("selecting mongo peer hostPort by scope from %+v", hostPorts)
	return network.SelectMongoHostPortsByScope(hostPorts, true)[0]
}