~juju-qa/ubuntu/xenial/juju/xenial-2.0-beta3

« back to all changes in this revision

Viewing changes to src/github.com/juju/juju/mongo/mongo.go

  • Committer: Martin Packman
  • Date: 2016-03-30 19:31:08 UTC
  • mfrom: (1.1.41)
  • Revision ID: martin.packman@canonical.com-20160330193108-h9iz3ak334uk0z5r
Merge new upstream source 2.0~beta3

Show diffs side-by-side

added added

removed removed

Lines of Context:
256
256
// SelectPeerHostPort returns the HostPort to use as the mongo replica set peer
257
257
// by selecting it from the given hostPorts.
258
258
func SelectPeerHostPort(hostPorts []network.HostPort) string {
259
 
        logger.Debugf("selecting mongo peer hostPort from %+v", hostPorts)
 
259
        logger.Debugf("selecting mongo peer hostPort by scope from %+v", hostPorts)
 
260
        return network.SelectMongoHostPortsByScope(hostPorts, true)[0]
 
261
}
 
262
 
 
263
// SelectPeerHostPortBySpace returns the HostPort to use as the mongo replica set peer
 
264
// by selecting it from the given hostPorts.
 
265
func SelectPeerHostPortBySpace(hostPorts []network.HostPort, space network.SpaceName) string {
 
266
        logger.Debugf("selecting mongo peer hostPort in space %s from %+v", space, hostPorts)
260
267
        // ScopeMachineLocal addresses are OK if we can't pick by space.
261
 
        return network.SelectControllerHostPort(hostPorts, true)
 
268
        suitableHostPorts, foundHostPortsInSpaces := network.SelectMongoHostPortsBySpaces(hostPorts, []network.SpaceName{space})
 
269
 
 
270
        if !foundHostPortsInSpaces {
 
271
                logger.Debugf("Failed to select hostPort by space - trying by scope from %+v", hostPorts)
 
272
                suitableHostPorts = network.SelectMongoHostPortsByScope(hostPorts, true)
 
273
        }
 
274
        return suitableHostPorts[0]
262
275
}
263
276
 
264
277
// GenerateSharedSecret generates a pseudo-random shared secret (keyfile)