Ejemplo 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")
	}
}
Ejemplo 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)
	}
}
Ejemplo 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!")
}
Ejemplo n.º 4
0
func getServerConfig(c *cli.Context) api.Config {
	certFile := c.GlobalString("cert")
	keyFile := c.GlobalString("key")
	if (certFile != "" && keyFile == "") || (certFile == "" && keyFile != "") {
		Fatalln("Both certificate and key are required to enable https.")
	}
	tls := (certFile != "" && keyFile != "")
	return api.Config{
		Address:   c.GlobalString("address"),
		TLS:       tls,
		CertFile:  certFile,
		KeyFile:   keyFile,
		RateLimit: c.GlobalInt("ratelimit"),
	}
}
Ejemplo n.º 5
0
Archivo: main.go Proyecto: wkuans/minio
func registerBefore(c *cli.Context) error {
	globalDebugFlag = c.GlobalBool("debug")
	return nil
}