initial import

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
This commit is contained in:
2018-03-22 13:35:38 +03:00
commit 83f9fa19ad
73 changed files with 4302 additions and 0 deletions

3
sds-storage/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
sds-storage
data/
test/

17
sds-storage/Makefile Normal file
View File

@@ -0,0 +1,17 @@
FLAGS_DEFAULT := 'proxy_sheepdog backend_filesystem transport_tcp hash_xxhash'
FLAGS_MINIMAL := 'proxy_sheepdog backend_filesystem transport_tcp hash_xxhash'
all:
go build -tags $(FLAGS_DEFAULT)
release:
go build -tags $(FLAGS_DEFAULT) --ldflags '-s -w'
minimal:
go build -tags $(FLAGS_MINIMAL)
test:
#sudo qemu-nbd -f raw --cache=none --aio=threads --discard=unmap --detect-zeroes=unmap -c /dev/nbd0 sheepdog:test
#fio
#qemu-img create -f raw sheepdog:127.0.0.1:7000:test 5G
#qemu-system-x86_64 -machine q35 -cpu kvm64 -smp 2 -accel kvm -m 512M -vnc 0.0.0.0:10 -device virtio-scsi-pci,id=scsi0,iothread=iothread0 -drive aio=threads,rerror=stop,werror=stop,if=none,format=raw,id=drive-scsi-disk0,cache=none,file=sheepdog:test,discard=unmap,detect-zeroes=off -device scsi-hd,bus=scsi0.0,drive=drive-scsi-disk0,id=device-scsi-disk0 -object iothread,id=iothread0

View File

@@ -0,0 +1,7 @@
// +build backend_block
package main
import (
_ "github.com/sdstack/storage/backend/block"
)

View File

@@ -0,0 +1,7 @@
// +build backend_filesystem
package main
import (
_ "github.com/sdstack/storage/backend/filesystem"
)

View File

@@ -0,0 +1,7 @@
// +build cache_block
package main
import (
_ "github.com/sdstack/storage/cache/block"
)

View File

@@ -0,0 +1,7 @@
// +build cache_filesystem
package main
import (
_ "github.com/sdstack/storage/cache/filesystem"
)

View File

@@ -0,0 +1,7 @@
// +build journal_leveldb
package main
import (
_ "github.com/sdstack/storage/journal/leveldb"
)

View File

@@ -0,0 +1,7 @@
// +build cache_memory
package main
import (
_ "github.com/sdstack/storage/cache/memory"
)

View File

@@ -0,0 +1,7 @@
// +build cluster_etcdint
package main
import (
_ "github.com/sdstack/storage/cluster/etcdint"
)

44
sds-storage/cmd/block.go Normal file
View 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")
}

View 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")
},
}

View 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)
}

View 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
}

View 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")
}

View 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")
},
}

View 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
View 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")
}

View 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
View 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")
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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
View 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
View 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
View 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")
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View 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")
},
}

View File

@@ -0,0 +1,7 @@
// +build hash_xxhash
package main
import (
_ "github.com/sdstack/storage/hash/xxhash"
)

7
sds-storage/main.go Normal file
View File

@@ -0,0 +1,7 @@
package main // import "github.com/sdstack/storage"
import "github.com/sdstack/storage/sds-storage/cmd"
func main() {
cmd.Execute()
}

View File

@@ -0,0 +1,7 @@
// +build proxy_sheepdog
package main
import (
_ "github.com/sdstack/storage/proxy/sheepdog"
)

44
sds-storage/storage.yml Normal file
View File

@@ -0,0 +1,44 @@
debug: true
discovery:
engine: mdns
mdns:
zone: local
interface: ib0
cluster:
engine: none
etcdint:
debug: true
server_addr: 172.16.1.254:2380
client_addr: 172.16.1.254:2379
wal_size: 18874368
store: data/cluster/etcdint
proxy:
engine: [ sheepdog ]
sheepdog:
debug: true
maxconn: 10240
listen:
- tcp://172.16.1.254:7000
- unix://var/run/sheepdog.sock
api:
engine: [ json, msgpack ]
json:
listen:
- unix://var/run/storage.sock
backend:
engine: filesystem
filesystem:
debug: true
options:
sync: true
node:
name: cc.z1.sdstack.com
uuid: 1234567-89-00-99-99
zone: zoneuuid
rack: rackuuid