Esempio n. 1
0
func controllerMain(c *cli.Context) {
	if len(c.Args()) < 2 || c.Args().First() == "help" {
		cli.ShowCommandHelpAndExit(c, "controller", 1) // last argument is exit code
	}
	if c.Args().First() == "get" {
		newArgs := c.Args().Tail()
		switch newArgs.First() {
		case "mem":
			memstats, err := controller.GetMemStats(newArgs.Tail().First())
			if err != nil {
				Fatalln(err)
			}
			Println(string(memstats))
		case "sysinfo":
			sysinfo, err := controller.GetSysInfo(newArgs.Tail().First())
			if err != nil {
				Fatalln(err)
			}
			Println(string(sysinfo))
		case "auth":
			keys, err := controller.GetAuthKeys(newArgs.Tail().First())
			if err != nil {
				Fatalln(err)
			}
			Println(string(keys))
		}
	}
	if c.Args().First() == "set" {
		Fatalln("Not supported yet")
	}
}
Esempio n. 2
0
func serverMain(c *cli.Context) {
	if c.Args().Present() {
		cli.ShowCommandHelpAndExit(c, "server", 1)
	}
	apiServerConfig := getServerConfig(c)
	err := server.StartServices(apiServerConfig)
	if err != nil {
		Fatalln(err)
	}
}
Esempio n. 3
0
func makeDonutMain(c *cli.Context) {
	if !c.Args().Present() || c.Args().First() == "help" {
		cli.ShowCommandHelpAndExit(c, "make", 1)
	}
	donutName := c.Args().First()
	if c.Args().First() != "" {
		if !donut.IsValidDonut(donutName) {
			Fatalf("Invalid donutname %s\n", donutName)
		}
	}
	var disks []string
	for _, disk := range c.Args().Tail() {
		if _, err := isUsable(disk); err != nil {
			Fatalln(err)
		}
		disks = append(disks, disk)
	}
	for _, disk := range disks {
		if err := os.MkdirAll(filepath.Join(disk, donutName), 0700); err != nil {
			Fatalln(err)
		}
	}

	hostname, err := os.Hostname()
	if err != nil {
		Fatalln(err)
	}
	donutConfig := &donut.Config{}
	donutConfig.Version = "0.0.1"
	donutConfig.DonutName = donutName
	donutConfig.NodeDiskMap = make(map[string][]string)
	// keep it in exact order as it was specified, do not try to sort disks
	donutConfig.NodeDiskMap[hostname] = disks
	// default cache is unlimited
	donutConfig.MaxSize = 512000000

	if err := donut.SaveConfig(donutConfig); err != nil {
		Fatalln(err)
	}

	Infoln("Success!")
}