Exemplo n.º 1
0
Arquivo: main.go Projeto: cycps/addie
func onMaterialize(w http.ResponseWriter, r *http.Request,
	ps httprouter.Params) {
	log.Println("addie materializing experiment")

	topDL, err := ioutil.ReadFile(topdlFileName())
	if err != nil {
		log.Println("unable to read topdl file :" + topdlFileName())
		w.WriteHeader(500)
		return
	}

	// Get active realizations
	log.Println("checking to see if we are already materialized")
	ms, err := spi.ViewRealizations(user, ".*"+design.Name+".*")
	if err != nil {
		log.Println("spi call to get realizations failed")
		log.Println(err)
		w.WriteHeader(500)
		return
	}
	if len(ms.Return) > 0 {
		msg := "the design is already materialize, de-materialize first to re-materialize"
		log.Println(msg)
		w.WriteHeader(400)
		fmt.Fprintf(w, msg)
		return
	}

	//++ Create
	log.Println("creating experiment")
	response, err := spi.CreateExperiment(user+":"+design.Name, user, string(topDL),
		false)
	if err != nil {
		log.Println("spi call to create experiment failed")
		log.Println(err)
		w.WriteHeader(500)
		return
	}
	if response != nil && response.Return != true {
		log.Println("the badness happend with the spi call to create experiment")
		w.WriteHeader(500)
		return
	}

	//~~ Realize
	log.Println("realizing experiment")
	mresponse, err := spi.RealizeExperiment(user+":"+design.Name, "cypress:cypress", user)
	if err != nil {
		log.Println("spi call to realize experiment failed")
		log.Println(err)
		w.WriteHeader(500)
		return
	}

	log.Println("realization response")
	log.Println(mresponse.Return)

	w.Write([]byte("ok"))
}
Exemplo n.º 2
0
func create() {

	if *rzF == "" {
		cli.Fatal(
			"you must specify a realization name with the -rz flag, " +
				"use the -help flag for details")
	}

	if *circF == "" {
		cli.Fatal(
			"you must specify a circle name with the -circle flag, " +
				"use the -help flag for details")
	}

	cli.PreRun()

	rsp, err := spi.RealizeExperiment(*rzF, *circF, cli.User)
	if err != nil {
		cli.Fatal("create realization failed")
	}

	fmt.Println(rsp)

}