44
sds-storage/cmd/block.go
Normal file
44
sds-storage/cmd/block.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// blockCmd represents the node command
|
||||
var blockCmd = &cobra.Command{
|
||||
Use: "block",
|
||||
Short: "Control block devices",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("block called")
|
||||
fmt.Println("Available Commands:")
|
||||
for _, c := range cmd.Commands() {
|
||||
if c.IsAvailableCommand() {
|
||||
fmt.Printf(" %s\t%s\n", c.Name(), c.Short)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
blockCmd.AddCommand(blockSCSICmd)
|
||||
blockCmd.AddCommand(blockNBDCmd)
|
||||
rootCmd.AddCommand(blockCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// nodeCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// nodeCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
21
sds-storage/cmd/block_nbd.go
Normal file
21
sds-storage/cmd/block_nbd.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var blockNBDCmd = &cobra.Command{
|
||||
Use: "nbd",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("block nbd called")
|
||||
},
|
||||
}
|
32
sds-storage/cmd/block_scsi.go
Normal file
32
sds-storage/cmd/block_scsi.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var blockSCSICmd = &cobra.Command{
|
||||
Use: "scsi",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("block scsi called")
|
||||
fmt.Println("Available Commands:")
|
||||
for _, c := range cmd.Commands() {
|
||||
if c.IsAvailableCommand() {
|
||||
fmt.Printf(" %s\t%s\n", c.Name(), c.Short)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
blockSCSICmd.AddCommand(blockSCSIAttachCmd)
|
||||
//rootCmd.AddCommand(blockCmd)
|
||||
}
|
21
sds-storage/cmd/block_scsi_attach.go
Normal file
21
sds-storage/cmd/block_scsi_attach.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import "github.com/spf13/cobra"
|
||||
|
||||
var blockSCSIAttachCmd = &cobra.Command{
|
||||
Use: "attach",
|
||||
Short: "attach volume to scsi device",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
blockSCSIAttachAction(cmd, args)
|
||||
},
|
||||
}
|
||||
|
||||
func blockSCSIAttachAction(cmd *cobra.Command, args []string) error {
|
||||
return nil
|
||||
}
|
44
sds-storage/cmd/cluster.go
Normal file
44
sds-storage/cmd/cluster.go
Normal file
@@ -0,0 +1,44 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// clusterCmd represents the node command
|
||||
var clusterCmd = &cobra.Command{
|
||||
Use: "cluster",
|
||||
Short: "Control cluster",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("cluster called")
|
||||
fmt.Println("Available Commands:")
|
||||
for _, c := range cmd.Commands() {
|
||||
if c.IsAvailableCommand() {
|
||||
fmt.Printf(" %s\t%s\n", c.Name(), c.Short)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
clusterCmd.AddCommand(clusterCheckCmd)
|
||||
clusterCmd.AddCommand(clusterCopiesCmd)
|
||||
rootCmd.AddCommand(clusterCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// nodeCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// nodeCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
21
sds-storage/cmd/cluster_check.go
Normal file
21
sds-storage/cmd/cluster_check.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var clusterCheckCmd = &cobra.Command{
|
||||
Use: "check",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("cluster check called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/cluster_copies.go
Normal file
21
sds-storage/cmd/cluster_copies.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var clusterCopiesCmd = &cobra.Command{
|
||||
Use: "copies",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("cluster copies called")
|
||||
},
|
||||
}
|
36
sds-storage/cmd/dog.go
Normal file
36
sds-storage/cmd/dog.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// dogCmd represents the dog command
|
||||
var dogCmd = &cobra.Command{
|
||||
Use: "dog",
|
||||
Short: "Control sheepdog like",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("dog called")
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(dogCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// dogCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// dogCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
36
sds-storage/cmd/gateway.go
Normal file
36
sds-storage/cmd/gateway.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// gatewayCmd represents the gateway command
|
||||
var gatewayCmd = &cobra.Command{
|
||||
Use: "gateway",
|
||||
Short: "Control gateway",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("gateway called")
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(gatewayCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// gatewayCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// gatewayCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
50
sds-storage/cmd/node.go
Normal file
50
sds-storage/cmd/node.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// nodeCmd represents the node command
|
||||
var nodeCmd = &cobra.Command{
|
||||
Use: "node",
|
||||
Short: "Control node",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("node called")
|
||||
fmt.Println("Available Commands:")
|
||||
for _, c := range cmd.Commands() {
|
||||
if c.IsAvailableCommand() {
|
||||
fmt.Printf(" %s\t%s\n", c.Name(), c.Short)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
nodeCmd.AddCommand(nodeListCmd)
|
||||
nodeCmd.AddCommand(nodeCheckCmd)
|
||||
nodeCmd.AddCommand(nodePingCmd)
|
||||
nodeCmd.AddCommand(nodeStoreCmd)
|
||||
nodeCmd.AddCommand(nodeInfoCmd)
|
||||
nodeCmd.AddCommand(nodeLogCmd)
|
||||
nodeCmd.AddCommand(nodeKillCmd)
|
||||
nodeCmd.AddCommand(nodeWeightCmd)
|
||||
rootCmd.AddCommand(nodeCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// nodeCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// nodeCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
21
sds-storage/cmd/node_check.go
Normal file
21
sds-storage/cmd/node_check.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var nodeCheckCmd = &cobra.Command{
|
||||
Use: "check",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("node check called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/node_info.go
Normal file
21
sds-storage/cmd/node_info.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var nodeInfoCmd = &cobra.Command{
|
||||
Use: "info",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("node info called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/node_kill.go
Normal file
21
sds-storage/cmd/node_kill.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var nodeKillCmd = &cobra.Command{
|
||||
Use: "kill",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("node kill called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/node_list.go
Normal file
21
sds-storage/cmd/node_list.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var nodeListCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("node list called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/node_log.go
Normal file
21
sds-storage/cmd/node_log.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var nodeLogCmd = &cobra.Command{
|
||||
Use: "log",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("node log called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/node_ping.go
Normal file
21
sds-storage/cmd/node_ping.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var nodePingCmd = &cobra.Command{
|
||||
Use: "ping",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("node ping called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/node_store.go
Normal file
21
sds-storage/cmd/node_store.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var nodeStoreCmd = &cobra.Command{
|
||||
Use: "store",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("node store called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/node_weight.go
Normal file
21
sds-storage/cmd/node_weight.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var nodeWeightCmd = &cobra.Command{
|
||||
Use: "weight",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("node weight called")
|
||||
},
|
||||
}
|
79
sds-storage/cmd/root.go
Normal file
79
sds-storage/cmd/root.go
Normal file
@@ -0,0 +1,79 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
homedir "github.com/mitchellh/go-homedir"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
var cfgFile string
|
||||
|
||||
// rootCmd represents the base command when called without any subcommands
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: "storage",
|
||||
Short: "A brief description of your application",
|
||||
Long: `A longer description that spans multiple lines and likely contains
|
||||
examples and usage of using your application. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
// Uncomment the following line if your bare application
|
||||
// has an action associated with it:
|
||||
// Run: func(cmd *cobra.Command, args []string) { },
|
||||
}
|
||||
|
||||
// Execute adds all child commands to the root command and sets flags appropriately.
|
||||
// This is called by main.main(). It only needs to happen once to the rootCmd.
|
||||
func Execute() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
func init() {
|
||||
cobra.OnInitialize(initConfig)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
// Cobra supports persistent flags, which, if defined here,
|
||||
// will be global for your application.
|
||||
rootCmd.PersistentFlags().StringVar(&cfgFile, "config", "", "config file (default is $HOME/.storage.yaml)")
|
||||
|
||||
// Cobra also supports local flags, which will only run
|
||||
// when this action is called directly.
|
||||
rootCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
|
||||
}
|
||||
|
||||
// initConfig reads in config file and ENV variables if set.
|
||||
func initConfig() {
|
||||
viper.SetConfigType("yaml")
|
||||
if cfgFile != "" {
|
||||
// Use config file from the flag.
|
||||
viper.SetConfigFile(cfgFile)
|
||||
} else {
|
||||
// Find home directory.
|
||||
home, err := homedir.Dir()
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Search config in home directory with name ".storage" (without extension).
|
||||
viper.AddConfigPath("/etc/storage/")
|
||||
viper.AddConfigPath(home)
|
||||
viper.AddConfigPath(".")
|
||||
viper.SetConfigName("storage")
|
||||
}
|
||||
|
||||
viper.AutomaticEnv() // read in environment variables that match
|
||||
|
||||
// If a config file is found, read it in.
|
||||
if err := viper.ReadInConfig(); err == nil {
|
||||
fmt.Println("Using config file:", viper.ConfigFileUsed())
|
||||
}
|
||||
}
|
117
sds-storage/cmd/server.go
Normal file
117
sds-storage/cmd/server.go
Normal file
@@ -0,0 +1,117 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/sdstack/storage/backend"
|
||||
"github.com/sdstack/storage/cluster"
|
||||
"github.com/sdstack/storage/kv"
|
||||
"github.com/sdstack/storage/proxy"
|
||||
|
||||
// github.com/google/uuid
|
||||
|
||||
"net/http"
|
||||
_ "net/http/pprof"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// serverCmd represents the server command
|
||||
var serverCmd = &cobra.Command{
|
||||
Use: "server",
|
||||
Short: "Control server",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: server,
|
||||
}
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(serverCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// serverCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// serverCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
||||
|
||||
func server(cmd *cobra.Command, args []string) {
|
||||
if viper.GetBool("debug") {
|
||||
go func() {
|
||||
log.Println(http.ListenAndServe("localhost:6060", nil))
|
||||
}()
|
||||
}
|
||||
|
||||
var clusterEngine string
|
||||
if viper.GetStringMap("cluster")["engine"] != nil {
|
||||
clusterEngine = viper.GetStringMap("cluster")["engine"].(string)
|
||||
}
|
||||
if clusterEngine == "" {
|
||||
clusterEngine = "none"
|
||||
}
|
||||
ce, err := cluster.New(clusterEngine, viper.GetStringMap("cluster")[clusterEngine])
|
||||
if err != nil {
|
||||
log.Printf("cluster start error %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err = ce.Start(); err != nil {
|
||||
log.Printf("cluster start error %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer ce.Stop()
|
||||
|
||||
backendEngine := viper.GetStringMap("backend")["engine"].(string)
|
||||
be, err := backend.New(backendEngine, viper.GetStringMap("backend")[backendEngine])
|
||||
if err != nil {
|
||||
log.Printf("store init error %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
engine, _ := kv.New(nil)
|
||||
engine.SetBackend(be)
|
||||
engine.SetCluster(ce)
|
||||
|
||||
for _, proxyEngine := range viper.GetStringMap("proxy")["engine"].([]interface{}) {
|
||||
pe, err := proxy.New(proxyEngine.(string), viper.GetStringMap("proxy")[proxyEngine.(string)], engine)
|
||||
if err != nil {
|
||||
log.Printf("err: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err = pe.Start(); err != nil {
|
||||
log.Printf("err: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer pe.Stop()
|
||||
//conf.proxy = append(conf.proxy, proxy)
|
||||
}
|
||||
|
||||
/*
|
||||
for _, apiEngine := range viper.GetStringMap("api")["engine"].([]interface{}) {
|
||||
ae, err := api.New(apiEngine.(string), viper.GetStringMap("api")[apiEngine.(string)], engine)
|
||||
if err != nil {
|
||||
log.Printf("err: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
if err = ae.Start(); err != nil {
|
||||
log.Printf("err: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
defer ae.Stop()
|
||||
//conf.proxy = append(conf.proxy, proxy)
|
||||
}
|
||||
*/
|
||||
select {}
|
||||
}
|
58
sds-storage/cmd/volume.go
Normal file
58
sds-storage/cmd/volume.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
// volumeCmd represents the node command
|
||||
var volumeCmd = &cobra.Command{
|
||||
Use: "volume",
|
||||
Short: "Control volumes",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("volume called")
|
||||
fmt.Println("Available Commands:")
|
||||
for _, c := range cmd.Commands() {
|
||||
if c.IsAvailableCommand() {
|
||||
fmt.Printf(" %s\t%s\n", c.Name(), c.Short)
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
func init() {
|
||||
volumeCmd.AddCommand(volumeListCmd)
|
||||
volumeCmd.AddCommand(volumeCheckCmd)
|
||||
volumeCmd.AddCommand(volumeInfoCmd)
|
||||
volumeCmd.AddCommand(volumeCreateCmd)
|
||||
volumeCmd.AddCommand(volumeCloneCmd)
|
||||
volumeCmd.AddCommand(volumeDeleteCmd)
|
||||
volumeCmd.AddCommand(volumeRollbackCmd)
|
||||
volumeCmd.AddCommand(volumeResizeCmd)
|
||||
volumeCmd.AddCommand(volumeReadCmd)
|
||||
volumeCmd.AddCommand(volumeWriteCmd)
|
||||
volumeCmd.AddCommand(volumeExportCmd)
|
||||
volumeCmd.AddCommand(volumeImportCmd)
|
||||
volumeCmd.AddCommand(volumeLockCmd)
|
||||
volumeCmd.AddCommand(volumeUnlockCmd)
|
||||
volumeCmd.AddCommand(volumeCopiesCmd)
|
||||
volumeCmd.AddCommand(volumeSnapshotCmd)
|
||||
rootCmd.AddCommand(volumeCmd)
|
||||
|
||||
// Here you will define your flags and configuration settings.
|
||||
|
||||
// Cobra supports Persistent Flags which will work for this command
|
||||
// and all subcommands, e.g.:
|
||||
// nodeCmd.PersistentFlags().String("foo", "", "A help for foo")
|
||||
|
||||
// Cobra supports local flags which will only run when this command
|
||||
// is called directly, e.g.:
|
||||
// nodeCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
|
||||
}
|
21
sds-storage/cmd/volume_check.go
Normal file
21
sds-storage/cmd/volume_check.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var volumeCheckCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("volume check called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/volume_clone.go
Normal file
21
sds-storage/cmd/volume_clone.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var volumeCloneCmd = &cobra.Command{
|
||||
Use: "clone",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("volume clone called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/volume_copies.go
Normal file
21
sds-storage/cmd/volume_copies.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var volumeCopiesCmd = &cobra.Command{
|
||||
Use: "copies",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("volume copies called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/volume_create.go
Normal file
21
sds-storage/cmd/volume_create.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var volumeCreateCmd = &cobra.Command{
|
||||
Use: "create",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("volume create called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/volume_delete.go
Normal file
21
sds-storage/cmd/volume_delete.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var volumeDeleteCmd = &cobra.Command{
|
||||
Use: "delete",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("volume delete called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/volume_export.go
Normal file
21
sds-storage/cmd/volume_export.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var volumeExportCmd = &cobra.Command{
|
||||
Use: "export",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("volume export called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/volume_import.go
Normal file
21
sds-storage/cmd/volume_import.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var volumeImportCmd = &cobra.Command{
|
||||
Use: "import",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("volume import called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/volume_info.go
Normal file
21
sds-storage/cmd/volume_info.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var volumeInfoCmd = &cobra.Command{
|
||||
Use: "info",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("volume info called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/volume_list.go
Normal file
21
sds-storage/cmd/volume_list.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var volumeListCmd = &cobra.Command{
|
||||
Use: "list",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("volume list called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/volume_lock.go
Normal file
21
sds-storage/cmd/volume_lock.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var volumeLockCmd = &cobra.Command{
|
||||
Use: "lock",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("volume lock called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/volume_read.go
Normal file
21
sds-storage/cmd/volume_read.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var volumeReadCmd = &cobra.Command{
|
||||
Use: "read",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("volume read called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/volume_resize.go
Normal file
21
sds-storage/cmd/volume_resize.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var volumeResizeCmd = &cobra.Command{
|
||||
Use: "resize",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("volume resize called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/volume_rollback.go
Normal file
21
sds-storage/cmd/volume_rollback.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var volumeRollbackCmd = &cobra.Command{
|
||||
Use: "rollback",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("volume rollback called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/volume_snapshot.go
Normal file
21
sds-storage/cmd/volume_snapshot.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var volumeSnapshotCmd = &cobra.Command{
|
||||
Use: "snapshot",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("volume snapshot called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/volume_unlock.go
Normal file
21
sds-storage/cmd/volume_unlock.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var volumeUnlockCmd = &cobra.Command{
|
||||
Use: "unlock",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("volume unlock called")
|
||||
},
|
||||
}
|
21
sds-storage/cmd/volume_write.go
Normal file
21
sds-storage/cmd/volume_write.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
var volumeWriteCmd = &cobra.Command{
|
||||
Use: "write",
|
||||
Short: "A brief description of your command",
|
||||
Long: `A longer description that spans multiple lines and likely contains examples
|
||||
and usage of using your command. For example:
|
||||
|
||||
Cobra is a CLI library for Go that empowers applications.
|
||||
This application is a tool to generate the needed files
|
||||
to quickly create a Cobra application.`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("volume write called")
|
||||
},
|
||||
}
|
Reference in New Issue
Block a user