Ejemplo n.º 1
0
func setDonut(args *DonutArgs, reply *Reply) error {
	conf := &donut.Config{Version: "0.0.1"}
	conf.DonutName = args.Name
	conf.MaxSize = args.MaxSize
	conf.NodeDiskMap = make(map[string][]string)
	conf.NodeDiskMap[args.Hostname] = args.Disks
	if err := donut.SaveConfig(conf); err != nil {
		return iodine.New(err, nil)
	}
	reply.Message = "success"
	reply.Error = nil
	return nil
}
Ejemplo n.º 2
0
func makeDonut(args *DonutArgs, reply *DefaultRep) *probe.Error {
	conf := &donut.Config{Version: "0.0.1"}
	conf.DonutName = args.Name
	conf.MaxSize = args.MaxSize
	conf.NodeDiskMap = make(map[string][]string)
	conf.NodeDiskMap[args.Hostname] = args.Disks
	if err := donut.SaveConfig(conf); err != nil {
		return err.Trace()
	}
	reply.Message = "success"
	reply.Error = nil
	return nil
}
Ejemplo n.º 3
0
func (s *MyAPIDonutCacheSuite) 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.MaxSize = 100000
	donut.SetDonutConfigPath(filepath.Join(root, "donut.json"))
	perr := donut.SaveConfig(conf)
	c.Assert(perr, IsNil)

	httpHandler, minioAPI := getAPIHandler(api.Config{RateLimit: 16})
	go startTM(minioAPI)
	testAPIDonutCacheServer = httptest.NewServer(httpHandler)
}
Ejemplo n.º 4
0
func (s *MyAPIDonutSuite) SetUpSuite(c *C) {
	root, err := ioutil.TempDir(os.TempDir(), "api-")
	c.Assert(err, IsNil)
	s.root = root

	conf := new(donut.Config)
	conf.Version = "0.0.1"
	conf.DonutName = "test"
	conf.NodeDiskMap = createTestNodeDiskMap(root)
	conf.MaxSize = 100000
	donut.SetDonutConfigPath(filepath.Join(root, "donut.json"))
	err = donut.SaveConfig(conf)
	c.Assert(err, IsNil)

	httpHandler, minioAPI := getAPIHandler(api.Config{RateLimit: 16})
	go startTM(minioAPI)
	testAPIDonutServer = httptest.NewServer(httpHandler)
}
Ejemplo n.º 5
0
Archivo: main.go Proyecto: flandr/minio
func runMkdonut(c *cli.Context) {
	if !c.Args().Present() || c.Args().First() == "help" {
		cli.ShowAppHelp(c)
		os.Exit(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 = 0

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

	Infoln("Success!")
}
Ejemplo n.º 6
0
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)
}
Ejemplo n.º 7
0
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.CustomConfigPath = filepath.Join(root, "donut.json")
	err = donut.SaveConfig(conf)
	c.Assert(err, IsNil)

	accessKeyID, err := auth.GenerateAccessKeyID()
	c.Assert(err, IsNil)
	secretAccessKey, err := auth.GenerateSecretAccessKey()
	c.Assert(err, IsNil)

	authConf := &auth.Config{}
	authConf.Users = make(map[string]*auth.User)
	authConf.Users[string(accessKeyID)] = &auth.User{
		Name:            "testuser",
		AccessKeyID:     string(accessKeyID),
		SecretAccessKey: string(secretAccessKey),
	}
	s.accessKeyID = string(accessKeyID)
	s.secretAccessKey = string(secretAccessKey)

	auth.CustomConfigPath = filepath.Join(root, "users.json")
	err = auth.SaveConfig(authConf)
	c.Assert(err, IsNil)

	httpHandler, minioAPI := getAPIHandler(api.Config{RateLimit: 16})
	go startTM(minioAPI)
	testSignatureV4Server = httptest.NewServer(httpHandler)
}