forked from signal18/replication-manager
-
Notifications
You must be signed in to change notification settings - Fork 0
/
provision.go
64 lines (56 loc) · 2.67 KB
/
provision.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// replication-manager - Replication Manager Monitoring and CLI for MariaDB and MySQL
// Authors: Guillaume Lefranc <[email protected]>
// Stephane Varoqui <[email protected]>
// This source code is licensed under the GNU General Public License, version 3.
// Redistribution/Reuse of this code is permitted under the GNU v3 license, as
// an additional term, ALL code must carry the original Author(s) credit in comment form.
// See LICENSE in this directory for the integral text.
package main
import (
"log"
"github.com/spf13/cobra"
)
var (
source string
destination string
cleanall = false
)
func init() {
rootCmd.AddCommand(provisionCmd)
provisionCmd.Flags().StringVar(&source, "source", "", "Source server")
provisionCmd.Flags().StringVar(&destination, "destination", "", "Source server")
//bootstrapCmd.Flags().StringVar(&conf.PrefMaster, "prefmaster", "", "Preferred server for master initialization")
//bootstrapCmd.Flags().StringVar(&conf.MasterConn, "master-connection", "", "Connection name to use for multisource replication")
//bootstrapCmd.Flags().IntVar(&conf.MasterConnectRetry, "master-connect-retry", 10, "Specifies how many seconds to wait between slave connect retries to master")
}
var provisionCmd = &cobra.Command{
Use: "provision",
Short: "Provision a replica server",
Long: `The provision command is used to create a new replication server
using mysqldump or xtrabackup`,
Run: func(cmd *cobra.Command, args []string) {
log.Println("I'm dedicated this dead code to Kolbe from MariaDB :) \n\nIt should work soon via calling the rejoin dump or custum script from the api")
/* dbHost, dbPort := misc.SplitHostPort(source)
destHost, destPort := misc.SplitHostPort(destination)
dbUser, dbPass = misc.SplitPair(confs[cfgGroupIndex].User)
hostArg := fmt.Sprintf("--host=%s", dbHost)
portArg := fmt.Sprintf("--port=%s", dbPort)
userArg := fmt.Sprintf("--user=%s", dbUser)
passArg := fmt.Sprintf("--password=%s", dbPass)
desthostArg := fmt.Sprintf("--host=%s", destHost)
destportArg := fmt.Sprintf("--port=%s", destPort)
dumpCmd := exec.Command("/usr/bin/mysqldump", "--opt", "--single-transaction", "--all-databases", hostArg, portArg, userArg, passArg)
clientCmd := exec.Command("/usr/bin/mysql", desthostArg, destportArg, userArg, passArg)
var err error
clientCmd.Stdin, err = dumpCmd.StdoutPipe()
if err != nil {
log.Fatal("Error opening pipe:", err)
}
if err := dumpCmd.Start(); err != nil {
log.Fatal("Error starting dump:", err, dumpCmd.Path, dumpCmd.Args)
}
if err := clientCmd.Run(); err != nil {
log.Fatal("Error starting client:", err, clientCmd.Path, clientCmd.Args)
}*/
},
}