aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_fs_configure.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2020-11-15 20:15:47 -0800
committerChris Lu <chris.lu@gmail.com>2020-11-15 20:15:47 -0800
commitee2fa14dbeed5496043422e87f44226cdda59830 (patch)
treee99edbca0ff4a83cf84935b3b481c1611e8095c1 /weed/shell/command_fs_configure.go
parent2bd6fd3bbe4489e040abc3a8b6bd957eeab3910c (diff)
downloadseaweedfs-ee2fa14dbeed5496043422e87f44226cdda59830.tar.xz
seaweedfs-ee2fa14dbeed5496043422e87f44226cdda59830.zip
filer conf: delete location specific configuration
Diffstat (limited to 'weed/shell/command_fs_configure.go')
-rw-r--r--weed/shell/command_fs_configure.go33
1 files changed, 30 insertions, 3 deletions
diff --git a/weed/shell/command_fs_configure.go b/weed/shell/command_fs_configure.go
index d8fcda83b..71082ddd4 100644
--- a/weed/shell/command_fs_configure.go
+++ b/weed/shell/command_fs_configure.go
@@ -3,11 +3,14 @@ package shell
import (
"bytes"
"flag"
+ "fmt"
"io"
"math"
+ "net/http"
"github.com/chrislusf/seaweedfs/weed/filer"
"github.com/chrislusf/seaweedfs/weed/pb/filer_pb"
+ "github.com/chrislusf/seaweedfs/weed/util"
)
func init() {
@@ -32,11 +35,12 @@ func (c *commandFsConfigure) Help() string {
func (c *commandFsConfigure) Do(args []string, commandEnv *CommandEnv, writer io.Writer) (err error) {
fsConfigureCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError)
- locationPrefix := fsConfigureCommand.String("locationPrefix", "", "path prefix")
+ locationPrefix := fsConfigureCommand.String("locationPrefix", "", "path prefix, required to update the path-specific configuration")
collection := fsConfigureCommand.String("collection", "", "assign writes to this colletion")
replication := fsConfigureCommand.String("replication", "", "assign writes with this replication")
ttl := fsConfigureCommand.String("ttl", "", "assign writes with this ttl")
fsync := fsConfigureCommand.Bool("fsync", false, "fsync for the writes")
+ isDelete := fsConfigureCommand.Bool("delete", false, "delete the configuration by locationPrefix")
apply := fsConfigureCommand.Bool("apply", false, "update and apply filer configuration")
if err = fsConfigureCommand.Parse(args); err != nil {
return nil
@@ -73,13 +77,36 @@ func (c *commandFsConfigure) Do(args []string, commandEnv *CommandEnv, writer io
Ttl: *ttl,
Fsync: *fsync,
}
- fc.AddLocationConf(locConf)
+ if *isDelete {
+ fc.DeleteLocationConf(*locationPrefix)
+ } else {
+ fc.AddLocationConf(locConf)
+ }
}
- fc.ToText(writer)
+ buf.Reset()
+ fc.ToText(&buf)
+
+ fmt.Fprintf(writer, string(buf.Bytes()))
if *apply {
+ target := fmt.Sprintf("http://%s:%d%s/%s", commandEnv.option.FilerHost, commandEnv.option.FilerPort, filer.DirectoryEtc, filer.FilerConfName)
+
+ // set the HTTP method, url, and request body
+ req, err := http.NewRequest(http.MethodPut, target, &buf)
+ if err != nil {
+ return err
+ }
+
+ // set the request header Content-Type for json
+ req.Header.Set("Content-Type", "text/plain; charset=utf-8")
+ resp, err := http.DefaultClient.Do(req)
+ if err != nil {
+ return err
+ }
+ util.CloseResponse(resp)
+
}
return nil