Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ceph rados plugin #5744

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ env:
- TEST_NO_FUSE=1 TEST_VERBOSE=1 TEST_SUITE=test_go_expensive
- TEST_NO_FUSE=1 TEST_VERBOSE=1 TEST_SUITE=test_sharness_expensive

before_install:
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y librados-dev; fi

install:
- make install

Expand Down
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -592,6 +592,12 @@
"hash": "QmTzWwfHZr9N6Tnk4iDTtKMWY57D3wik73qNCVo21Bu1UP",
"name": "iptb-plugins",
"version": "1.0.3"
},
{
"author": "bjzhang",
"hash": "QmYyMML9pPAFqQAtHW56YHzUXK7CBnubB1g7kK123eo98G",
"name": "go-ds-rados",
"version": "0.0.4"
}
],
"gxVersion": "0.10.0",
Expand Down
2 changes: 1 addition & 1 deletion plugin/plugins/Rules.mk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include mk/header.mk

$(d)_plugins:=$(d)/git $(d)/badgerds $(d)/flatfs $(d)/levelds
$(d)_plugins:=$(d)/git $(d)/badgerds $(d)/flatfs $(d)/levelds $(d)/rados
$(d)_plugins_so:=$(addsuffix .so,$($(d)_plugins))
$(d)_plugins_main:=$(addsuffix /main/main.go,$($(d)_plugins))

Expand Down
80 changes: 80 additions & 0 deletions plugin/plugins/rados/rados.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
// +build linux

package radosds

import (
"fmt"
"os"

"github.com/ipfs/go-ipfs/plugin"
"github.com/ipfs/go-ipfs/repo"
"github.com/ipfs/go-ipfs/repo/fsrepo"

rados "gx/ipfs/QmYyMML9pPAFqQAtHW56YHzUXK7CBnubB1g7kK123eo98G/go-ds-rados"
)

// Plugins is exported list of plugins that will be loaded
var Plugins = []plugin.Plugin{
&radosPlugin{},
}

type radosPlugin struct{}

var _ plugin.PluginDatastore = (*radosPlugin)(nil)

func (*radosPlugin) Name() string {
return "ds-rados"
}

func (*radosPlugin) Version() string {
return "0.1.0"
}

func (*radosPlugin) Init() error {
return nil
}

func (*radosPlugin) DatastoreTypeName() string {
return "rados"
}

type radosDatastoreConfig struct {
confPath string
pool string
}

func (*radosPlugin) DatastoreConfigParser() fsrepo.ConfigFromMap {
return func(params map[string]interface{}) (fsrepo.DatastoreConfig, error) {
var c radosDatastoreConfig
var ok bool
c.confPath, ok = params["confpath"].(string)
if !ok {
return nil, fmt.Errorf("confpath filed is missing or not string")
}
c.pool, ok = params["pool"].(string)
if !ok {
return nil, fmt.Errorf("'pool' filed is missing or not string")
}
return &c, nil
}
}

func (c *radosDatastoreConfig) DiskSpec() fsrepo.DiskSpec {
return map[string]interface{}{
"type": "rados",
"confpath": c.confPath,
"pool": c.pool,
}
}

func (c *radosDatastoreConfig) Create(string) (repo.Datastore, error) {
_, err := os.Open(c.confPath)
if os.IsNotExist(err) {
return nil, fmt.Errorf("Config file for rados doesn't exist:%s", c.confPath)
}
if os.IsPermission(err) {
return nil, fmt.Errorf("Permission deny for file:%s", c.confPath)
}

return rados.NewDatastore(c.confPath, c.pool)
}