Exemple #1
0
func (s Salt) StartMon(nodes []string, ctxt string) (bool, error) {
	mutex.Lock()
	defer mutex.Unlock()
	pyobj, err := pyFuncs["StartMon"].Call(nodes, ctxt)
	if err == nil {
		return gopy.Bool(pyobj), nil
	}

	return false, err
}
Exemple #2
0
func (s Salt) CreateCluster(clusterName string, fsid uuid.UUID, mons []backend.Mon, ctxt string) (bool, error) {
	mutex.Lock()
	defer mutex.Unlock()
	pyobj, err := pyFuncs["CreateCluster"].Call(clusterName, fsid.String(), mons, ctxt)
	if err == nil {
		return gopy.Bool(pyobj), nil
	}

	return false, err
}
Exemple #3
0
func (s Salt) AddMon(clusterName string, mons []backend.Mon, ctxt string) (bool, error) {
	mutex.Lock()
	defer mutex.Unlock()
	pyobj, err := pyFuncs["AddMon"].Call(clusterName, mons, ctxt)
	if err == nil {
		return gopy.Bool(pyobj), nil
	}

	return false, err
}
Exemple #4
0
func (s Salt) AddOsdToCrush(mon string, clusterName string, osdName string, weight float64, host string, ctxt string) (bool, error) {
	mutex.Lock()
	defer mutex.Unlock()
	pyobj, err := pyFuncs["AddOsdToCrush"].Call(mon, clusterName, osdName, weight, host, ctxt)
	if err == nil {
		return gopy.Bool(pyobj), nil
	}

	return false, err
}
Exemple #5
0
func (c Salt) ParticipatesInCluster(node string, ctxt string) bool {
	mutex.Lock()
	defer mutex.Unlock()
	pyobj, err := pyFuncs["ParticipatesInCluster"].Call(node, ctxt)
	if err == nil {
		return gopy.Bool(pyobj)
	}

	return false
}
Exemple #6
0
func (s Salt) RemovePool(mon string, clusterId uuid.UUID, clusterName string, pool string, poolId int, ctxt string) (bool, error) {
	mutex.Lock()
	defer mutex.Unlock()
	pyobj, err := pyFuncs["RemovePool"].Call(mon, clusterName, pool, ctxt)
	if err == nil {
		return gopy.Bool(pyobj), nil
	}

	return false, err
}
Exemple #7
0
func (s Salt) CreatePool(name string, mon string, clusterName string, pgnum uint, replicas int, quotaMaxObjects int, quotaMaxBytes uint64, ruleset int, ctxt string) (bool, error) {
	mutex.Lock()
	defer mutex.Unlock()
	pyobj, err := pyFuncs["CreatePool"].Call(name, mon, clusterName, pgnum, ctxt)
	if err == nil {
		return gopy.Bool(pyobj), nil
	}

	return false, err
}
Exemple #8
0
func Init(module string, filename string, logToStderr bool, level logging.Level) error {
	if logInit {
		return nil
	}

	logName := path.Base(os.Args[0])

	if pyFunc, err := gopy.Import(module, "InitLog"); err != nil {
		return err
	} else if pyobj, err := pyFunc["InitLog"].Call(logName, filename, logToStderr, level.String()); err != nil {
		return err
	} else if !gopy.Bool(pyobj) {
		return errors.New("python: log init failed")
	}

	var fileBackend, stderrBackend *logging.LogBackend
	var fileLeveled, stderrLeveled logging.LeveledBackend

	log = logging.MustGetLogger(logName)

	if file, err := os.OpenFile(filename, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0644); err != nil {
		return err
	} else {
		fileBackend = logging.NewLogBackend(file, "", 0)
		fileLeveled = logging.AddModuleLevel(logging.NewBackendFormatter(fileBackend, fileFormat))
		fileLeveled.SetLevel(level, "")
	}

	if logToStderr {
		stderrBackend = logging.NewLogBackend(os.Stderr, "", 0)
		stderrLeveled = logging.AddModuleLevel(logging.NewBackendFormatter(stderrBackend, stderrFormat))
		stderrLeveled.SetLevel(level, "")
		log.SetBackend(logging.MultiLogger(stderrLeveled, fileLeveled))
	} else {
		log.SetBackend(fileLeveled)
	}

	logInit = true
	return nil
}