Documentation ¶
Index ¶
- Constants
- Variables
- func EnsureAdminUser(p EnsureAdminUserParams) (added bool, err error)
- func EnsureServer(dataDir string, namespace string, info params.StateServingInfo, withHA bool) error
- func GenerateSharedSecret() (string, error)
- func IsMaster(session *mgo.Session, obj WithAddresses) (bool, error)
- func Path() (string, error)
- func RemoveService(namespace string) error
- func SelectPeerAddress(addrs []instance.Address) string
- func SelectPeerHostPort(hostPorts []instance.HostPort) string
- func ServiceName(namespace string) string
- type EnsureAdminUserParams
- type WithAddresses
Constants ¶
const ( // located within the Juju data directory. SharedSecretFile = "shared-secret" // ReplicaSetName is the name of the replica set that juju uses for its // state servers. ReplicaSetName = "juju" )
const ( // WithHA is used when we want to start a mongo service with HA support. WithHA = true // WithoutHA is used when we want to start a mongo service without HA support. WithoutHA = false )
Variables ¶
var (
// JujuMongodPath holds the default path to the juju-specific mongod.
JujuMongodPath = "/usr/lib/juju/bin/mongod"
)
Functions ¶
func EnsureAdminUser ¶
func EnsureAdminUser(p EnsureAdminUserParams) (added bool, err error)
EnsureAdminUser ensures that the specified user and password are added to the admin database.
This function will stop the Mongo service if it needs to add the admin user, as it must restart Mongo in --noauth mode.
func EnsureServer ¶
func EnsureServer(dataDir string, namespace string, info params.StateServingInfo, withHA bool) error
EnsureMongoServer ensures that the correct mongo upstart script is installed and running.
This method will remove old versions of the mongo upstart script as necessary before installing the new version.
The namespace is a unique identifier to prevent multiple instances of mongo on this machine from colliding. This should be empty unless using the local provider.
func GenerateSharedSecret ¶
GenerateSharedSecret generates a pseudo-random shared secret (keyfile) for use with Mongo replica sets.
func IsMaster ¶
func IsMaster(session *mgo.Session, obj WithAddresses) (bool, error)
IsMaster returns a boolean that represents whether the given machine's peer address is the primary mongo host for the replicaset
func Path ¶
Path returns the executable path to be used to run mongod on this machine. If the juju-bundled version of mongo exists, it will return that path, otherwise it will return the command to run mongod from the path.
func RemoveService ¶
RemoveService removes the mongoDB upstart service from this machine.
func SelectPeerAddress ¶
SelectPeerAddress returns the address to use as the mongo replica set peer address by selecting it from the given addresses.
func SelectPeerHostPort ¶
SelectPeerHostPort returns the HostPort to use as the mongo replica set peer by selecting it from the given hostPorts.
func ServiceName ¶
ServiceName returns the name of the upstart service config for mongo using the given namespace.
Types ¶
type EnsureAdminUserParams ¶
type EnsureAdminUserParams struct { // DialInfo specifies how to connect to the mongo server. DialInfo *mgo.DialInfo // Namespace is the agent namespace, used to derive the Mongo service name. Namespace string // DataDir is the Juju data directory, used to start a --noauth server. DataDir string // Port is the listening port of the Mongo server. Port int // User holds the user to log in to the mongo server as. User string // Password holds the password for the user to log in as. Password string }
type WithAddresses ¶
WithAddresses represents an entity that has a set of addresses. e.g. a state Machine object