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.Trace()) } disks = append(disks, disk) } for _, disk := range disks { if err := os.MkdirAll(filepath.Join(disk, donutName), 0700); err != nil { Fatalln(probe.NewError(err)) } } hostname, err := os.Hostname() if err != nil { Fatalln(probe.NewError(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.Trace()) } Infoln("Success!") }
func (s *MyAPISignatureV4Suite) SetUpSuite(c *C) { root, err := ioutil.TempDir(os.TempDir(), "api-") c.Assert(err, IsNil) s.root = root conf := &donut.Config{} conf.Version = "0.0.1" conf.DonutName = "test" conf.NodeDiskMap = createTestNodeDiskMap(root) conf.MaxSize = 100000 donut.SetDonutConfigPath(filepath.Join(root, "donut.json")) perr := donut.SaveConfig(conf) c.Assert(perr, IsNil) accessKeyID, perr := generateAccessKeyID() c.Assert(perr, IsNil) secretAccessKey, perr := generateSecretAccessKey() c.Assert(perr, IsNil) authConf := &AuthConfig{} authConf.Users = make(map[string]*AuthUser) authConf.Users[string(accessKeyID)] = &AuthUser{ Name: "testuser", AccessKeyID: string(accessKeyID), SecretAccessKey: string(secretAccessKey), } s.accessKeyID = string(accessKeyID) s.secretAccessKey = string(secretAccessKey) SetAuthConfigPath(root) perr = SaveConfig(authConf) c.Assert(perr, IsNil) minioAPI := getNewAPI(false) httpHandler := getAPIHandler(false, minioAPI) go startTM(minioAPI) testSignatureV4Server = httptest.NewServer(httpHandler) }