Example #1
0
// Question: Should we extract the BDR related functionality into a bd* package?
func (b *BDR) CreateUser(dbuser, dbpass string) (err error) {
	nodes, err := b.PGNodes()
	if err != nil {
		log.Error(fmt.Sprintf(`bdr.BDR#CreateUser(%s) ! %s`, dbuser, err))
	}

	for _, pg := range nodes {
		pg.Set(`database`, `postgres`)
		err = pg.CreateUser(dbuser, dbpass)
		if err != nil {
			log.Error(fmt.Sprintf(`bdr.BDR<%s>#CreateUser(%s) pg.CreateUser() ! %s`, pg.IP, dbuser, err))
			return err
		}
	}
	return nil
}
Example #2
0
func (b *BDR) DropDatabase(dbname string) (err error) {
	nodes, err := b.PGNodes()
	if err != nil {
		log.Error(fmt.Sprintf(`bdr.BDR#DropDatabase(%s) ! %s`, dbname, err))
	}

	for i := len(nodes) - 1; i >= 0; i-- {
		pg := nodes[i]
		pg.Set(`database`, `postgres`)
		err = pg.DropDatabase(dbname)
		if err != nil {
			log.Error(fmt.Sprintf("bdr.BDR<%s>#DropDatabase(%s) ! %s", pg.IP, dbname, err))
		}
	}
	return nil
}