Example #1
0
func main() {
	cfg, err := config.LoadConfig("./config.toml")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}

	var wait_group sync.WaitGroup
	wait_group.Add(len(cfg.Organizations))

	for name, conf := range cfg.Organizations {
		go func(org_name string, org_conf config.OrgConfig) {
			defer wait_group.Done()

			server_string := "https://" + cfg.Server + "/organizations/" + org_name

			o, err := org.NewOrg(server_string, org_conf)
			if err != nil {
				fmt.Println(err.Error())
			}

			err = o.ChefRuns()
			if err != nil {
				fmt.Println(err.Error())
			}
		}(name, conf)
	}

	wait_group.Wait()
}
Example #2
0
func main() {
	cfg, err := config.LoadConfig("./config.toml")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}

	var org_name string
	var org_conf config.OrgConfig

	for name, conf := range cfg.Organizations {
		org_name = name
		org_conf = conf

		break
	}

	server_string := "https://" + cfg.Server + "/organizations/" + org_name

	o, err := org.NewOrg(server_string, org_conf)
	if err != nil {
		fmt.Println(err.Error())
	}

	err = o.CreateNode("testnode999")
	if err != nil {
		fmt.Println(err.Error())
	}
}
Example #3
0
func main() {
	cfg, err := config.LoadConfig("./config.toml")
	if err != nil {
		fmt.Println(err.Error())
		os.Exit(1)
	}

	var org_name string
	var org_conf config.OrgConfig

	for name, conf := range cfg.Organizations {
		org_name = name
		org_conf = conf

		break
	}

	server_string := "https://" + cfg.Server + "/organizations/" + org_name

	good := 0
	bad := 0

	if err != nil {
		fmt.Println(err.Error())
	}
	for i := 1; i <= org_conf.Runs; i++ {
		var runs []<-chan error
		if err != nil {
			fmt.Println("Error with num_nodes arg")
		}
		for i := 1; i <= org_conf.Nodes; i++ {
			c := node_run(fmt.Sprintf("%d", i), server_string, org_conf.KeyDirectory)
			runs = append(runs, c)
		}

		for _, c := range runs {
			e := <-c
			if e != nil {
				bad = bad + 1
			} else {
				good = good + 1
			}
		}
	}

	fmt.Printf("%d nodes finished\n", good)
	fmt.Printf("%d nodes failed\n", bad)
}