61 lines
1.8 KiB
Go
61 lines
1.8 KiB
Go
/*
|
|
* 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"
|
|
|
|
"github.com/minio-io/cli"
|
|
)
|
|
|
|
func doAttachDiskCmd(c *cli.Context) {
|
|
if !c.Args().Present() {
|
|
fatal("no args?")
|
|
}
|
|
disks := c.Args()
|
|
mcDonutConfigData, err := loadDonutConfig()
|
|
if err != nil {
|
|
fatal(err.Error())
|
|
}
|
|
donutName := c.String("name")
|
|
if donutName == "" {
|
|
fatal("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)
|
|
fatal(msg)
|
|
}
|
|
if _, ok := mcDonutConfigData.Donuts[donutName].Node["localhost"]; !ok {
|
|
msg := fmt.Sprintf("Corrupted donut config, please consult donut experts")
|
|
fatal(msg)
|
|
}
|
|
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 {
|
|
fatal(err.Error())
|
|
}
|
|
}
|