func CommitConfig(host, name string, cfg *models.CCConfig) error {
	c, err := newProxyClient(host, cfg.ProxyUserName, cfg.ProxyPassword)
	if err != nil {
		log.Fatal("create proxy client failed, %v", err)
		return err
	}
	err = c.CommitConfig(name)
	if err != nil {
		log.Fatal("commit proxy config failed, %v", err)
		return err
	}
	return nil
}
CommitConfig commit phase of config change
package proxy
import (
	"fmt"
	"time"
	"github.com/nooncall/shazam/log"
	"github.com/nooncall/shazam/models"
)
type Stats struct {
	Host     string `json:"host"`
	Closed   bool   `json:"closed"`
	Error    string `json:"error"`
	UnixTime int64  `json:"unixtime"`
	Timeout  bool   `json:"timeout"`
}
type SQLFingerprint struct {
	SlowSQL  map[string]string `json:"slow_sql"`
	ErrorSQL map[string]string `json:"error_sql"`
}
func GetStats(p *models.ProxyMonitorMetric, cfg *models.CCConfig, timeout time.Duration) *Stats {
	fmt.Println(string(p.Encode()))
	var ch = make(chan struct{})
	var host = p.IP + ":" + p.AdminPort
	fmt.Println(host)
	stats := &Stats{}
	go func(host string) {
		defer close(ch)
		stats.Host = host
		_, err := newProxyClient(host, cfg.ProxyUserName, cfg.ProxyPassword)
		if err != nil {
			stats.Error = err.Error()
			stats.Closed = true
		} else {
			stats.Closed = false
		}
	}(host)
	select {
	case <-ch:
		return stats
	case <-time.After(timeout):
		return &Stats{Host: host, Timeout: true}
	}
}
func newProxyClient(host, user, password string) (*APIClient, error) {
	log.Debug("call rpc xping to proxy %s", host)
	c := NewAPIClient(host, user, password)
	if err := c.Ping(); err != nil {
		log.Fatal("call rpc xping to proxy failed")
		return c, err
	}
	log.Debug("call rpc xping OK")
	return c, nil
}
func PrepareConfig(host, name string, cfg *models.CCConfig) error {
	c, err := newProxyClient(host, cfg.ProxyUserName, cfg.ProxyPassword)
	if err != nil {
		log.Fatal("create proxy client failed, %v", err)
		return err
	}
	err = c.PrepareConfig(name)
	if err != nil {
		log.Fatal("prepare proxy config failed, %v", err)
		return err
	}
	return nil
}