Exemple #1
0
func makeXLMain(c *cli.Context) {
	if !c.Args().Present() || c.Args().First() == "help" {
		cli.ShowCommandHelpAndExit(c, "make", 1)
	}
	xlName := c.Args().First()
	if c.Args().First() != "" {
		if !xl.IsValidXL(xlName) {
			Fatalf("Invalid xlname %s\n", xlName)
		}
	}
	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, xlName), 0700); err != nil {
			Fatalln(probe.NewError(err))
		}
	}

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

	if err := xl.SaveConfig(xlConfig); 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 := &xl.Config{}
	conf.Version = "0.0.1"
	conf.XLName = "test"
	conf.NodeDiskMap = createTestNodeDiskMap(root)
	conf.MaxSize = 100000
	xl.SetXLConfigPath(filepath.Join(root, "xl.json"))
	perr := xl.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)
}