Merge pull request #453 from harshavardhana/pr_out_implement_headbuckethandler_and_its_related_tests
commit
34d06101cc
@ -1 +0,0 @@ |
||||
donut-cli |
58
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-attach-disk.go
generated
vendored
58
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-attach-disk.go
generated
vendored
@ -1,58 +0,0 @@ |
||||
/* |
||||
* Minimalist Object Storage, (C) 2015 Minio, Inc. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package main |
||||
|
||||
import ( |
||||
"log" |
||||
|
||||
"github.com/minio-io/cli" |
||||
) |
||||
|
||||
func doAttachDiskCmd(c *cli.Context) { |
||||
if !c.Args().Present() { |
||||
log.Fatalln("no args?") |
||||
} |
||||
disks := c.Args() |
||||
mcDonutConfigData, err := loadDonutConfig() |
||||
if err != nil { |
||||
log.Fatalln(err) |
||||
} |
||||
donutName := c.String("name") |
||||
if donutName == "" { |
||||
log.Fatalln("Invalid --donut <name> is needed for attach") |
||||
} |
||||
if _, ok := mcDonutConfigData.Donuts[donutName]; !ok { |
||||
log.Fatalf("Requested donut name %s does not exist, please use ``mc donut make`` first\n", donutName) |
||||
} |
||||
if _, ok := mcDonutConfigData.Donuts[donutName].Node["localhost"]; !ok { |
||||
log.Fatalln("Corrupted donut config, please consult donut experts") |
||||
} |
||||
activeDisks := mcDonutConfigData.Donuts[donutName].Node["localhost"].ActiveDisks |
||||
inactiveDisks := mcDonutConfigData.Donuts[donutName].Node["localhost"].InactiveDisks |
||||
for _, disk := range disks { |
||||
activeDisks = appendUniq(activeDisks, disk) |
||||
inactiveDisks = deleteFromSlice(inactiveDisks, disk) |
||||
} |
||||
|
||||
mcDonutConfigData.Donuts[donutName].Node["localhost"] = nodeConfig{ |
||||
ActiveDisks: activeDisks, |
||||
InactiveDisks: inactiveDisks, |
||||
} |
||||
if err := saveDonutConfig(mcDonutConfigData); err != nil { |
||||
log.Fatalln(err) |
||||
} |
||||
} |
110
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-common.go
generated
vendored
110
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-common.go
generated
vendored
@ -1,110 +0,0 @@ |
||||
/* |
||||
* Minimalist Object Storage, (C) 2015 Minio, Inc. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package main |
||||
|
||||
import ( |
||||
"strings" |
||||
|
||||
"net/url" |
||||
) |
||||
|
||||
// url2Object converts URL to bucket and objectname
|
||||
func url2Object(urlStr string) (bucketName, objectName string, err error) { |
||||
u, err := url.Parse(urlStr) |
||||
if u.Path == "" { |
||||
// No bucket name passed. It is a valid case
|
||||
return "", "", nil |
||||
} |
||||
splits := strings.SplitN(u.Path, "/", 3) |
||||
switch len(splits) { |
||||
case 0, 1: |
||||
bucketName = "" |
||||
objectName = "" |
||||
case 2: |
||||
bucketName = splits[1] |
||||
objectName = "" |
||||
case 3: |
||||
bucketName = splits[1] |
||||
objectName = splits[2] |
||||
} |
||||
return bucketName, objectName, nil |
||||
} |
||||
|
||||
func isStringInSlice(items []string, item string) bool { |
||||
for _, s := range items { |
||||
if s == item { |
||||
return true |
||||
} |
||||
} |
||||
return false |
||||
} |
||||
|
||||
func deleteFromSlice(items []string, item string) []string { |
||||
var newitems []string |
||||
for _, s := range items { |
||||
if s == item { |
||||
continue |
||||
} |
||||
newitems = append(newitems, s) |
||||
} |
||||
return newitems |
||||
} |
||||
|
||||
func appendUniq(slice []string, i string) []string { |
||||
for _, ele := range slice { |
||||
if ele == i { |
||||
return slice |
||||
} |
||||
} |
||||
return append(slice, i) |
||||
} |
||||
|
||||
// Is alphanumeric?
|
||||
func isalnum(c rune) bool { |
||||
return '0' <= c && c <= '9' || 'A' <= c && c <= 'Z' || 'a' <= c && c <= 'z' |
||||
} |
||||
|
||||
// isValidDonutName - verify donutName to be valid
|
||||
func isValidDonutName(donutName string) bool { |
||||
if len(donutName) > 1024 || len(donutName) == 0 { |
||||
return false |
||||
} |
||||
for _, char := range donutName { |
||||
if isalnum(char) { |
||||
continue |
||||
} |
||||
switch char { |
||||
case '-': |
||||
case '.': |
||||
case '_': |
||||
case '~': |
||||
continue |
||||
default: |
||||
return false |
||||
} |
||||
} |
||||
return true |
||||
} |
||||
|
||||
// getNodeMap - get a node and disk map through nodeConfig struct
|
||||
func getNodeMap(node map[string]nodeConfig) map[string][]string { |
||||
nodes := make(map[string][]string) |
||||
for k, v := range node { |
||||
nodes[k] = v.ActiveDisks |
||||
} |
||||
return nodes |
||||
} |
105
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-config.go
generated
vendored
105
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-config.go
generated
vendored
@ -1,105 +0,0 @@ |
||||
/* |
||||
* Minimalist Object Storage, (C) 2015 Minio, Inc. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"log" |
||||
"os" |
||||
"os/user" |
||||
"path" |
||||
|
||||
"encoding/json" |
||||
"io/ioutil" |
||||
) |
||||
|
||||
const ( |
||||
donutConfigDir = ".minio/donut" |
||||
donutConfigFilename = "donuts.json" |
||||
) |
||||
|
||||
type nodeConfig struct { |
||||
ActiveDisks []string |
||||
InactiveDisks []string |
||||
} |
||||
|
||||
type donutConfig struct { |
||||
Node map[string]nodeConfig |
||||
} |
||||
|
||||
type mcDonutConfig struct { |
||||
Donuts map[string]donutConfig |
||||
} |
||||
|
||||
func getDonutConfigDir() string { |
||||
u, err := user.Current() |
||||
if err != nil { |
||||
msg := fmt.Sprintf("Unable to obtain user's home directory. \nError: %s", err) |
||||
log.Fatalln(msg) |
||||
} |
||||
|
||||
return path.Join(u.HomeDir, donutConfigDir) |
||||
} |
||||
|
||||
func getDonutConfigFilename() string { |
||||
return path.Join(getDonutConfigDir(), "donuts.json") |
||||
} |
||||
|
||||
// saveDonutConfig writes configuration data in json format to donut config file.
|
||||
func saveDonutConfig(donutConfigData *mcDonutConfig) error { |
||||
jsonConfig, err := json.MarshalIndent(donutConfigData, "", "\t") |
||||
if err != nil { |
||||
return err |
||||
} |
||||
|
||||
err = os.MkdirAll(getDonutConfigDir(), 0755) |
||||
if !os.IsExist(err) && err != nil { |
||||
return err |
||||
} |
||||
|
||||
configFile, err := os.OpenFile(getDonutConfigFilename(), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0600) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
defer configFile.Close() |
||||
|
||||
_, err = configFile.Write(jsonConfig) |
||||
if err != nil { |
||||
return err |
||||
} |
||||
return nil |
||||
} |
||||
|
||||
func loadDonutConfig() (donutConfigData *mcDonutConfig, err error) { |
||||
configFile := getDonutConfigFilename() |
||||
_, err = os.Stat(configFile) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
configBytes, err := ioutil.ReadFile(configFile) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
err = json.Unmarshal(configBytes, &donutConfigData) |
||||
if err != nil { |
||||
return nil, err |
||||
} |
||||
|
||||
return donutConfigData, nil |
||||
} |
66
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-detach-disk.go
generated
vendored
66
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-detach-disk.go
generated
vendored
@ -1,66 +0,0 @@ |
||||
/* |
||||
* Minimalist Object Storage, (C) 2015 Minio, Inc. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"log" |
||||
|
||||
"github.com/minio-io/cli" |
||||
) |
||||
|
||||
func doDetachDiskCmd(c *cli.Context) { |
||||
if !c.Args().Present() { |
||||
log.Fatalln("no args?") |
||||
} |
||||
disks := c.Args() |
||||
mcDonutConfigData, err := loadDonutConfig() |
||||
if err != nil { |
||||
log.Fatalln(err.Error()) |
||||
} |
||||
donutName := c.String("name") |
||||
if donutName == "" { |
||||
log.Fatalln("Invalid --donut <name> is needed for attach") |
||||
} |
||||
if _, ok := mcDonutConfigData.Donuts[donutName]; !ok { |
||||
msg := fmt.Sprintf("Requested donut name <%s> does not exist, please use ``mc donut make`` first", donutName) |
||||
log.Fatalln(msg) |
||||
} |
||||
if _, ok := mcDonutConfigData.Donuts[donutName].Node["localhost"]; !ok { |
||||
msg := fmt.Sprintf("Corrupted donut config, please consult donut experts") |
||||
log.Fatalln(msg) |
||||
} |
||||
|
||||
inactiveDisks := mcDonutConfigData.Donuts[donutName].Node["localhost"].InactiveDisks |
||||
activeDisks := mcDonutConfigData.Donuts[donutName].Node["localhost"].ActiveDisks |
||||
for _, disk := range disks { |
||||
if isStringInSlice(activeDisks, disk) { |
||||
activeDisks = deleteFromSlice(activeDisks, disk) |
||||
inactiveDisks = appendUniq(inactiveDisks, disk) |
||||
} else { |
||||
msg := fmt.Sprintf("Cannot detach disk: <%s>, not part of donut <%s>", disk, donutName) |
||||
log.Println(msg) |
||||
} |
||||
} |
||||
mcDonutConfigData.Donuts[donutName].Node["localhost"] = nodeConfig{ |
||||
ActiveDisks: activeDisks, |
||||
InactiveDisks: inactiveDisks, |
||||
} |
||||
if err := saveDonutConfig(mcDonutConfigData); err != nil { |
||||
log.Fatalln(err.Error()) |
||||
} |
||||
} |
84
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-info.go
generated
vendored
84
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-info.go
generated
vendored
@ -1,84 +0,0 @@ |
||||
/* |
||||
* Minimalist Object Storage, (C) 2014,2015 Minio, Inc. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package main |
||||
|
||||
import ( |
||||
"log" |
||||
"os" |
||||
"strings" |
||||
|
||||
"text/tabwriter" |
||||
"text/template" |
||||
|
||||
"github.com/minio-io/cli" |
||||
"github.com/minio-io/donut" |
||||
) |
||||
|
||||
var infoTemplate = ` |
||||
{{range $donutName, $nodes := .}} |
||||
DONUTNAME: {{$donutName}} |
||||
{{range $nodeName, $disks := $nodes}} |
||||
NODE: {{$nodeName}} |
||||
DISKS: {{$disks}} |
||||
{{end}} |
||||
{{end}} |
||||
` |
||||
|
||||
var infoPrinter = func(templ string, data interface{}) { |
||||
funcMap := template.FuncMap{ |
||||
"join": strings.Join, |
||||
} |
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 8, 1, '\t', 0) |
||||
t := template.Must(template.New("help").Funcs(funcMap).Parse(templ)) |
||||
err := t.Execute(w, data) |
||||
if err != nil { |
||||
panic(err) |
||||
} |
||||
w.Flush() |
||||
} |
||||
|
||||
// doInfoDonutCmd
|
||||
func doInfoDonutCmd(c *cli.Context) { |
||||
if !c.Args().Present() { |
||||
log.Fatalln("no args?") |
||||
} |
||||
if len(c.Args()) != 1 { |
||||
log.Fatalln("invalid number of args") |
||||
} |
||||
donutName := c.Args().First() |
||||
if !isValidDonutName(donutName) { |
||||
log.Fatalln("Invalid donutName") |
||||
} |
||||
mcDonutConfigData, err := loadDonutConfig() |
||||
if err != nil { |
||||
log.Fatalln(err) |
||||
} |
||||
if _, ok := mcDonutConfigData.Donuts[donutName]; !ok { |
||||
log.Fatalln("donut does not exist") |
||||
} |
||||
d, err := donut.NewDonut(donutName, getNodeMap(mcDonutConfigData.Donuts[donutName].Node)) |
||||
if err != nil { |
||||
log.Fatalln(err) |
||||
} |
||||
donutNodes := make(map[string]map[string][]string) |
||||
donutNodes[donutName], err = d.Info() |
||||
if err != nil { |
||||
log.Fatalln(err) |
||||
} |
||||
infoPrinter(infoTemplate, donutNodes) |
||||
} |
36
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-list.go
generated
vendored
36
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-list.go
generated
vendored
@ -1,36 +0,0 @@ |
||||
/* |
||||
* Minimalist Object Storage, (C) 2014,2015 Minio, Inc. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"log" |
||||
|
||||
"github.com/minio-io/cli" |
||||
) |
||||
|
||||
// doListDonutCmd creates a new bucket
|
||||
func doListDonutCmd(c *cli.Context) { |
||||
mcDonutConfigData, err := loadDonutConfig() |
||||
if err != nil { |
||||
log.Fatalln(err) |
||||
} |
||||
|
||||
for k := range mcDonutConfigData.Donuts { |
||||
fmt.Println(k) |
||||
} |
||||
} |
80
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-make.go
generated
vendored
80
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-make.go
generated
vendored
@ -1,80 +0,0 @@ |
||||
/* |
||||
* Minimalist Object Storage, (C) 2015 Minio, Inc. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package main |
||||
|
||||
import ( |
||||
"fmt" |
||||
"log" |
||||
"os" |
||||
|
||||
"github.com/minio-io/cli" |
||||
) |
||||
|
||||
func newDonutConfig(donutName string) (*mcDonutConfig, error) { |
||||
mcDonutConfigData := new(mcDonutConfig) |
||||
mcDonutConfigData.Donuts = make(map[string]donutConfig) |
||||
mcDonutConfigData.Donuts[donutName] = donutConfig{ |
||||
Node: make(map[string]nodeConfig), |
||||
} |
||||
mcDonutConfigData.Donuts[donutName].Node["localhost"] = nodeConfig{ |
||||
ActiveDisks: make([]string, 0), |
||||
InactiveDisks: make([]string, 0), |
||||
} |
||||
return mcDonutConfigData, nil |
||||
} |
||||
|
||||
// doMakeDonutCmd creates a new donut
|
||||
func doMakeDonutCmd(c *cli.Context) { |
||||
if !c.Args().Present() { |
||||
log.Fatalln("no args?") |
||||
} |
||||
if len(c.Args()) != 1 { |
||||
log.Fatalln("invalid number of args") |
||||
} |
||||
donutName := c.Args().First() |
||||
if !isValidDonutName(donutName) { |
||||
log.Fatalln("Invalid donutName") |
||||
} |
||||
mcDonutConfigData, err := loadDonutConfig() |
||||
if os.IsNotExist(err) { |
||||
mcDonutConfigData, err = newDonutConfig(donutName) |
||||
if err != nil { |
||||
log.Fatalln(err) |
||||
} |
||||
if err := saveDonutConfig(mcDonutConfigData); err != nil { |
||||
log.Fatalln(err) |
||||
} |
||||
return |
||||
} else if err != nil { |
||||
log.Fatalln(err) |
||||
} |
||||
if _, ok := mcDonutConfigData.Donuts[donutName]; !ok { |
||||
mcDonutConfigData.Donuts[donutName] = donutConfig{ |
||||
Node: make(map[string]nodeConfig), |
||||
} |
||||
mcDonutConfigData.Donuts[donutName].Node["localhost"] = nodeConfig{ |
||||
ActiveDisks: make([]string, 0), |
||||
InactiveDisks: make([]string, 0), |
||||
} |
||||
if err := saveDonutConfig(mcDonutConfigData); err != nil { |
||||
log.Fatalln(err) |
||||
} |
||||
} else { |
||||
msg := fmt.Sprintf("donut: %s already exists", donutName) |
||||
log.Println(msg) |
||||
} |
||||
} |
95
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-options.go
generated
vendored
95
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-options.go
generated
vendored
@ -1,95 +0,0 @@ |
||||
/* |
||||
* Minimalist Object Storage, (C) 2015 Minio, Inc. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package main |
||||
|
||||
import ( |
||||
"github.com/minio-io/cli" |
||||
) |
||||
|
||||
var makeDonutCmd = cli.Command{ |
||||
Name: "make", |
||||
Usage: "make donut", |
||||
Description: "Make a new donut", |
||||
Action: doMakeDonutCmd, |
||||
} |
||||
|
||||
var listDonutCmd = cli.Command{ |
||||
Name: "list", |
||||
Usage: "list donuts", |
||||
Description: "list all donuts locally or remote", |
||||
Action: doListDonutCmd, |
||||
} |
||||
|
||||
var attachDiskCmd = cli.Command{ |
||||
Name: "attach", |
||||
Usage: "attach disk", |
||||
Description: "Attach disk to an existing donut", |
||||
Action: doAttachDiskCmd, |
||||
Flags: []cli.Flag{ |
||||
cli.StringFlag{ |
||||
Name: "name", |
||||
Usage: "Donut name", |
||||
}, |
||||
}, |
||||
} |
||||
|
||||
var detachDiskCmd = cli.Command{ |
||||
Name: "detach", |
||||
Usage: "detach disk", |
||||
Description: "Detach disk from an existing donut", |
||||
Action: doDetachDiskCmd, |
||||
Flags: []cli.Flag{ |
||||
cli.StringFlag{ |
||||
Name: "name", |
||||
Usage: "Donut name", |
||||
}, |
||||
}, |
||||
} |
||||
|
||||
var healDonutCmd = cli.Command{ |
||||
Name: "heal", |
||||
Usage: "heal donut", |
||||
Description: "Heal donut with any errors", |
||||
Action: doHealDonutCmd, |
||||
} |
||||
|
||||
var rebalanceDonutCmd = cli.Command{ |
||||
Name: "rebalance", |
||||
Usage: "rebalance donut", |
||||
Description: "Rebalance data on donut after adding disks", |
||||
Action: doRebalanceDonutCmd, |
||||
} |
||||
|
||||
var infoDonutCmd = cli.Command{ |
||||
Name: "info", |
||||
Usage: "information about donut", |
||||
Description: "Pretty print donut information", |
||||
Action: doInfoDonutCmd, |
||||
} |
||||
|
||||
var donutOptions = []cli.Command{ |
||||
makeDonutCmd, |
||||
listDonutCmd, |
||||
attachDiskCmd, |
||||
detachDiskCmd, |
||||
healDonutCmd, |
||||
rebalanceDonutCmd, |
||||
infoDonutCmd, |
||||
} |
||||
|
||||
func doHealDonutCmd(c *cli.Context) { |
||||
} |
32
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-rebalance.go
generated
vendored
32
Godeps/_workspace/src/github.com/minio-io/donut/cmd/donut-cli/donut-cmd-rebalance.go
generated
vendored
@ -1,32 +0,0 @@ |
||||
package main |
||||
|
||||
import ( |
||||
"log" |
||||
|
||||
"github.com/minio-io/cli" |
||||
"github.com/minio-io/donut" |
||||
) |
||||
|
||||
func doRebalanceDonutCmd(c *cli.Context) { |
||||
if !c.Args().Present() { |
||||
log.Fatalln("no args?") |
||||
} |
||||
donutName := c.Args().First() |
||||
if !isValidDonutName(donutName) { |
||||
log.Fatalln("Invalid donutName") |
||||
} |
||||
mcDonutConfigData, err := loadDonutConfig() |
||||
if err != nil { |
||||
log.Fatalln(err) |
||||
} |
||||
if _, ok := mcDonutConfigData.Donuts[donutName]; !ok { |
||||
log.Fatalln("donut does not exist") |
||||
} |
||||
d, err := donut.NewDonut(donutName, getNodeMap(mcDonutConfigData.Donuts[donutName].Node)) |
||||
if err != nil { |
||||
log.Fatalln(err) |
||||
} |
||||
if err := d.Rebalance(); err != nil { |
||||
log.Fatalln(err) |
||||
} |
||||
} |
@ -1,33 +0,0 @@ |
||||
/* |
||||
* Minimalist Object Storage, (C) 2014,2015 Minio, Inc. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
package main |
||||
|
||||
import ( |
||||
"os" |
||||
|
||||
"github.com/minio-io/cli" |
||||
) |
||||
|
||||
func main() { |
||||
app := cli.NewApp() |
||||
app.Usage = "" |
||||
app.Version = gitCommitHash |
||||
app.Commands = donutOptions |
||||
app.Author = "Minio.io" |
||||
app.EnableBashCompletion = true |
||||
app.Run(os.Args) |
||||
} |
Loading…
Reference in new issue