示例#1
0
文件: init.go 项目: eeayiaia/scmt
//TODO: add hadoop support
func FirstSetup() error {
	fmt.Println("Welcome to SCMT setup wizard! We start by setting up the configuration: (Exit by entering 'q', go back by entering ´b´)")
	//to enable going back in the setup wizard
	newConf.RootPath = os.Getenv("SCMT_ROOT")
	var functions []userDataFn = []userDataFn{
		setClusterName,
		setClusterSubnet,
		setBroadcastIP,
		setDeviceIPRange,
		setMasterIP,
		setExtNetworkInterface,
		setIntNetworkInterface,
		//setDatabaseName,
		setDatabaseUser,
		setDatabaseRootPw,
		setDatabasePw,
		//setLoginCred,
		monitor,
		clusterAppinstall,
		clusterApp,
	}
	length := len(functions)

	//run user input functions
	for functionIndex < length {
		functions[functionIndex]()
	}
	conf.GenerateJSONConfiguration(&newConf)
	fmt.Print(newConf)
	err := setup()
	if err != nil {
		Log.Error("Failed SCMT setup")
		return err
	}
	return nil

}
示例#2
0
文件: init.go 项目: eeayiaia/scmt
func setup() error {
	//Write conf
	Log.Info("Installing..")
	Log.Info("Generating congfiguration")
	err := conf.GenerateJSONConfiguration(&newConf)
	if err != nil {
		Log.WithFields(log.Fields{
			"error": err,
		}).Fatal("Could not generate configuration")
		return err
	}

	conf.InitConfiguration()
	Config = conf.Conf

	database.Init(Config.Database, Config.DatabaseUser, Config.DatabasePassword)

	invoker.Init()
	//init scripts master
	Log.Info("Initializing master node")
	master.Init()
	Log.Info("Master node initialized")

	Log.Info("Running master init scripts")
	err = master.RunInitScripts()
	if err != nil {
		Log.WithFields(log.Fields{
			"error": err,
		}).Fatal("Failed to initialize master")
		return err
	}
	Log.Info("Master init scripts done")

	//check (install) monitor
	if monitorName != "none" {
		Log.WithFields(log.Fields{
			"plugin": monitorName,
		}).Info("Installing plugin")
		err = master.InstallPlugin(monitorName)
		if err != nil {
			Log.WithFields(log.Fields{
				"plugin": monitorName,
				"error":  err,
			}).Error("Failed to install plugin")
		}
	}

	//install mpi
	switch clusterAppName {
	case "none":

	case "both":
		Log.WithFields(log.Fields{
			"plugin": "openmpi",
		}).Info("Installing plugin")
		err = master.InstallPlugin("openmpi")
		if err != nil {
			Log.WithFields(log.Fields{
				"plugin": "openmpi",
				"error":  err,
			}).Error("Failed to install plugin")
		}

		Log.WithFields(log.Fields{
			"plugin": "mpich",
		}).Info("Installing plugin")
		err = master.InstallPlugin("mpich")
		if err != nil {
			Log.WithFields(log.Fields{
				"plugin": "mpich",
				"error":  err,
			}).Error("Failed to install plugin")
		}

	default:
		Log.WithFields(log.Fields{
			"plugin": clusterAppName,
		}).Info("Installing plugin")
		err = master.InstallPlugin(clusterAppName)
		if err != nil {
			Log.WithFields(log.Fields{
				"plugin": clusterAppName,
				"error":  err,
			}).Error("Failed to install plugin")
		}
	}

	return nil
}