mirror of
https://github.com/cubefs/cubefs.git
synced 2026-08-02 02:00:56 +00:00
refactor: remove unused token structures and functions
Signed-off-by: Shuoran Liu <shuoranliu@gmail.com>
This commit is contained in:
parent
73fdb86046
commit
d326bb9624
@ -34,8 +34,8 @@ const (
|
||||
CliOpReset = "reset"
|
||||
CliOpReplicate = "add-replica"
|
||||
CliOpDelReplica = "del-replica"
|
||||
CliOpExpand = "expand"
|
||||
CliOpShrink = "shrink"
|
||||
CliOpExpand = "expand"
|
||||
CliOpShrink = "shrink"
|
||||
|
||||
//Shorthand format of operation name
|
||||
CliOpDecommissionShortHand = "dec"
|
||||
@ -60,7 +60,6 @@ const (
|
||||
CliFlagEnable = "enable"
|
||||
CliFlagEnableFollowerRead = "follower-read"
|
||||
CliFlagAuthenticate = "authenticate"
|
||||
CliFlagEnableToken = "enable-token"
|
||||
CliFlagCapacity = "capacity"
|
||||
CliFlagThreshold = "threshold"
|
||||
CliFlagAddress = "addr"
|
||||
@ -82,7 +81,9 @@ const (
|
||||
ResourceDataPartitionShortHand = "dp"
|
||||
ResourceMetaPartitionShortHand = "mp"
|
||||
)
|
||||
|
||||
type MasterOp int
|
||||
|
||||
const (
|
||||
OpExpandVol MasterOp = iota
|
||||
OpShrinkVol
|
||||
|
||||
@ -99,7 +99,6 @@ func formatSimpleVolView(svv *proto.SimpleVolView) string {
|
||||
sb.WriteString(fmt.Sprintf(" Create time : %v\n", svv.CreateTime))
|
||||
sb.WriteString(fmt.Sprintf(" Authenticate : %v\n", formatEnabledDisabled(svv.Authenticate)))
|
||||
sb.WriteString(fmt.Sprintf(" Follower read : %v\n", formatEnabledDisabled(svv.FollowerRead)))
|
||||
sb.WriteString(fmt.Sprintf(" Enable token : %v\n", formatEnabledDisabled(svv.EnableToken)))
|
||||
sb.WriteString(fmt.Sprintf(" Cross zone : %v\n", formatEnabledDisabled(svv.CrossZone)))
|
||||
sb.WriteString(fmt.Sprintf(" Inode count : %v\n", svv.InodeCount))
|
||||
sb.WriteString(fmt.Sprintf(" Dentry count : %v\n", svv.DentryCount))
|
||||
@ -179,7 +178,7 @@ func formatDataPartitionInfo(partition *proto.DataPartitionInfo) string {
|
||||
sb.WriteString(fmt.Sprintf("Peers :\n"))
|
||||
sb.WriteString(fmt.Sprintf("%v\n", formatPeerTableHeader()))
|
||||
for _, peer := range partition.Peers {
|
||||
sb.WriteString(fmt.Sprintf("%v\n", formatPeer( peer)))
|
||||
sb.WriteString(fmt.Sprintf("%v\n", formatPeer(peer)))
|
||||
}
|
||||
sb.WriteString("\n")
|
||||
sb.WriteString(fmt.Sprintf("Hosts :\n"))
|
||||
@ -223,7 +222,7 @@ func formatMetaPartitionInfo(partition *proto.MetaPartitionInfo) string {
|
||||
sb.WriteString("\n")
|
||||
sb.WriteString(fmt.Sprintf("Peers :\n"))
|
||||
for _, peer := range partition.Peers {
|
||||
sb.WriteString(fmt.Sprintf("%v\n", formatPeer( peer)))
|
||||
sb.WriteString(fmt.Sprintf("%v\n", formatPeer(peer)))
|
||||
}
|
||||
sb.WriteString("\n")
|
||||
sb.WriteString(fmt.Sprintf("Hosts :\n"))
|
||||
@ -361,7 +360,7 @@ func formatTime(timeUnix int64) string {
|
||||
return time.Unix(timeUnix, 0).Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
func formatTimeToString(t time.Time) string{
|
||||
func formatTimeToString(t time.Time) string {
|
||||
return t.Format("2006-01-02 15:04:05")
|
||||
}
|
||||
|
||||
@ -374,7 +373,7 @@ func formatDataReplicaTableHeader() string {
|
||||
func formatDataReplica(indentation string, replica *proto.DataReplica, rowTable bool) string {
|
||||
if rowTable {
|
||||
return fmt.Sprintf(dataReplicaTableRowPattern, replica.Addr, formatSize(replica.Used), formatSize(replica.Total),
|
||||
replica.IsLeader, replica.FileCount, formatDataPartitionStatus(replica.Status), formatTime(replica.ReportTime))
|
||||
replica.IsLeader, replica.FileCount, formatDataPartitionStatus(replica.Status), formatTime(replica.ReportTime))
|
||||
}
|
||||
var sb = strings.Builder{}
|
||||
sb.WriteString(fmt.Sprintf("%v- Addr : %v\n", indentation, replica.Addr))
|
||||
@ -399,7 +398,7 @@ func formatMetaReplicaTableHeader() string {
|
||||
func formatMetaReplica(indentation string, replica *proto.MetaReplicaInfo, rowTable bool) string {
|
||||
if rowTable {
|
||||
return fmt.Sprintf(metaReplicaTableRowPattern, replica.Addr, replica.IsLeader, formatMetaPartitionStatus(replica.Status),
|
||||
formatTime(replica.ReportTime))
|
||||
formatTime(replica.ReportTime))
|
||||
}
|
||||
var sb = strings.Builder{}
|
||||
sb.WriteString(fmt.Sprintf("%v- Addr : %v\n", indentation, replica.Addr))
|
||||
@ -409,8 +408,6 @@ func formatMetaReplica(indentation string, replica *proto.MetaReplicaInfo, rowTa
|
||||
return sb.String()
|
||||
}
|
||||
|
||||
|
||||
|
||||
var peerTableRowPattern = "%-6v %-18v"
|
||||
|
||||
func formatPeerTableHeader() string {
|
||||
@ -420,7 +417,6 @@ func formatPeer(peer proto.Peer) string {
|
||||
return fmt.Sprintf(peerTableRowPattern, peer.ID, peer.Addr)
|
||||
}
|
||||
|
||||
|
||||
var dataNodeDetailTableRowPattern = "%-6v %-6v %-18v %-6v %-6v %-6v %-10v"
|
||||
|
||||
func formatDataNodeDetailTableHeader() string {
|
||||
@ -484,13 +480,13 @@ func formatZoneView(zv *proto.ZoneView) string {
|
||||
sb.WriteString(fmt.Sprintf("NodeSet-%v:\n", index))
|
||||
sb.WriteString(fmt.Sprintf(" DataNodes[%v]:\n", ns.DataNodeLen))
|
||||
sb.WriteString(fmt.Sprintf(" %v\n", formatNodeViewTableHeader()))
|
||||
for _, nv := range ns.DataNodes{
|
||||
for _, nv := range ns.DataNodes {
|
||||
sb.WriteString(fmt.Sprintf(" %v\n", formatNodeView(&nv, true)))
|
||||
}
|
||||
sb.WriteString(fmt.Sprintf("\n"))
|
||||
sb.WriteString(fmt.Sprintf(" MetaNodes[%v]:\n", ns.MetaNodeLen))
|
||||
sb.WriteString(fmt.Sprintf(" %v\n", formatNodeViewTableHeader()))
|
||||
for _, nv := range ns.MetaNodes{
|
||||
for _, nv := range ns.MetaNodes {
|
||||
sb.WriteString(fmt.Sprintf(" %v\n", formatNodeView(&nv, true)))
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ const (
|
||||
cmdVolDefaultCapacity = 10 // 100GB
|
||||
cmdVolDefaultReplicas = 3
|
||||
cmdVolDefaultFollowerReader = true
|
||||
cmdVolDefaultZoneName = "default"
|
||||
cmdVolDefaultZoneName = "default"
|
||||
)
|
||||
|
||||
func newVolCreateCmd(client *master.MasterClient) *cobra.Command {
|
||||
@ -156,9 +156,11 @@ func newVolCreateCmd(client *master.MasterClient) *cobra.Command {
|
||||
cmd.Flags().BoolVarP(&optYes, "yes", "y", false, "Answer yes for all questions")
|
||||
return cmd
|
||||
}
|
||||
|
||||
const (
|
||||
cmdVolSetShort = "Set configuration of the volume"
|
||||
cmdVolSetShort = "Set configuration of the volume"
|
||||
)
|
||||
|
||||
func newVolSetCmd(client *master.MasterClient) *cobra.Command {
|
||||
var optCapacity uint64
|
||||
var optReplicas int
|
||||
@ -190,7 +192,7 @@ func newVolSetCmd(client *master.MasterClient) *cobra.Command {
|
||||
if optCapacity > 0 {
|
||||
isChange = true
|
||||
confirmString.WriteString(fmt.Sprintf(" Capacity : %v GB -> %v GB\n", vv.Capacity, optCapacity))
|
||||
vv.Capacity = optCapacity
|
||||
vv.Capacity = optCapacity
|
||||
} else {
|
||||
confirmString.WriteString(fmt.Sprintf(" Capacity : %v GB\n", vv.Capacity))
|
||||
}
|
||||
@ -282,7 +284,6 @@ func newVolSetCmd(client *master.MasterClient) *cobra.Command {
|
||||
cmd.Flags().IntVar(&optReplicas, CliFlagReplicas, 0, "Specify data partition replicas number")
|
||||
cmd.Flags().StringVar(&optFollowerRead, CliFlagEnableFollowerRead, "", "Enable read form replica follower")
|
||||
cmd.Flags().StringVar(&optAuthenticate, CliFlagAuthenticate, "", "Enable authenticate")
|
||||
cmd.Flags().StringVar(&optEnableToken, CliFlagEnableToken, "", "ReadOnly/ReadWrite token validation for fuse client")
|
||||
cmd.Flags().StringVar(&optZoneName, CliFlagZoneName, "", "Specify volume zone name")
|
||||
cmd.Flags().BoolVarP(&optYes, "yes", "y", false, "Answer yes for all questions")
|
||||
return cmd
|
||||
|
||||
@ -89,12 +89,6 @@ const (
|
||||
UpdateZone = "/zone/update"
|
||||
GetAllZones = "/zone/list"
|
||||
|
||||
//token
|
||||
TokenGetURI = "/token/get"
|
||||
TokenAddURI = "/token/add"
|
||||
TokenDelURI = "/token/delete"
|
||||
TokenUpdateURI = "/token/update"
|
||||
|
||||
// Header keys
|
||||
SkipOwnerValidation = "Skip-Owner-Validation"
|
||||
ForceDelete = "Force-Delete"
|
||||
@ -120,17 +114,6 @@ const (
|
||||
|
||||
const TimeFormat = "2006-01-02 15:04:05"
|
||||
|
||||
const (
|
||||
ReadOnlyToken = 1
|
||||
ReadWriteToken = 2
|
||||
)
|
||||
|
||||
type Token struct {
|
||||
TokenType int8
|
||||
Value string
|
||||
VolName string
|
||||
}
|
||||
|
||||
// HTTPReply uniform response structure
|
||||
type HTTPReply struct {
|
||||
Code int32 `json:"code"`
|
||||
@ -494,7 +477,6 @@ type SimpleVolView struct {
|
||||
CrossZone bool
|
||||
CreateTime string
|
||||
EnableToken bool
|
||||
Tokens map[string]*Token `graphql:"-"`
|
||||
Description string
|
||||
DpSelectorName string
|
||||
DpSelectorParm string
|
||||
|
||||
@ -17,7 +17,6 @@ package master
|
||||
import (
|
||||
"encoding/json"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
"github.com/chubaofs/chubaofs/proto"
|
||||
@ -98,21 +97,6 @@ func (api *ClientAPI) GetVolumeStat(volName string) (info *proto.VolStatInfo, er
|
||||
return
|
||||
}
|
||||
|
||||
func (api *ClientAPI) GetToken(volName, tokenKey string) (token *proto.Token, err error) {
|
||||
var request = newAPIRequest(http.MethodGet, proto.TokenGetURI)
|
||||
request.addParam("name", volName)
|
||||
request.addParam("token", url.QueryEscape(tokenKey))
|
||||
var data []byte
|
||||
if data, err = api.mc.serveRequest(request); err != nil {
|
||||
return
|
||||
}
|
||||
token = &proto.Token{}
|
||||
if err = json.Unmarshal(data, token); err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (api *ClientAPI) GetMetaPartition(partitionID uint64) (partition *proto.MetaPartitionInfo, err error) {
|
||||
var request = newAPIRequest(http.MethodGet, proto.ClientMetaPartition)
|
||||
request.addParam("id", strconv.FormatUint(partitionID, 10))
|
||||
|
||||
@ -222,42 +222,6 @@ list_vol(){
|
||||
parse_curl ${operation}
|
||||
}
|
||||
|
||||
#add token
|
||||
add_token(){
|
||||
volName=$1
|
||||
tokenType=$2
|
||||
Key=$3
|
||||
operation="/token/add?name=${volName}&tokenType=${tokenType}&authKey=${Key}"
|
||||
parse_curl ${operation}
|
||||
}
|
||||
|
||||
#update token
|
||||
update_token(){
|
||||
volName=$1
|
||||
tokenValue=$2
|
||||
tokenType=$3
|
||||
Key=$4
|
||||
operation="/token/update?name=${volName}&token=${tokenValue}&tokenType=${tokenType}&authKey=${Key}"
|
||||
parse_curl ${operation}
|
||||
}
|
||||
|
||||
#delete token
|
||||
delete_token(){
|
||||
volName=$1
|
||||
tokenValue=$2
|
||||
Key=$3
|
||||
operation="/token/delete?name=${volName}&token=${tokenValue}&authKey=${Key}"
|
||||
parse_curl ${operation}
|
||||
}
|
||||
|
||||
#get token
|
||||
get_token(){
|
||||
volName=$1
|
||||
tokenValue=$2
|
||||
operation="/token/get?name=${volName}&token=${tokenValue}"
|
||||
parse_curl ${operation}
|
||||
}
|
||||
|
||||
#update zone
|
||||
update_zone(){
|
||||
Name=$1
|
||||
|
||||
Loading…
Reference in New Issue
Block a user