From 3a6973cd1c9ad84263e989c6b693fe8ac7cd2860 Mon Sep 17 00:00:00 2001 From: Samuel Sieg Date: Wed, 13 Jan 2016 11:26:27 +0100 Subject: [PATCH 1/2] Support to provide a username when authenticating This has already been merged into the original repo at netskin/ceph-ruby, see https://github.com/netskin/ceph-ruby/pull/1 --- lib/ceph-ruby/cluster.rb | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/ceph-ruby/cluster.rb b/lib/ceph-ruby/cluster.rb index e387464..99ab09c 100644 --- a/lib/ceph-ruby/cluster.rb +++ b/lib/ceph-ruby/cluster.rb @@ -2,15 +2,17 @@ module CephRuby class Cluster attr_accessor :handle - def initialize(config_path = "/etc/ceph/ceph.conf") + def initialize(options = {}) + options[:config_path] ||= "/etc/ceph/ceph.conf" + log("init lib rados #{Lib::Rados.version_string}, lib rbd #{Lib::Rbd.version_string}") handle_p = FFI::MemoryPointer.new(:pointer) - ret = Lib::Rados.rados_create(handle_p, nil) + ret = Lib::Rados.rados_create(handle_p, options[:username]) raise SystemCallError.new("open of cluster failed", -ret) if ret < 0 self.handle = handle_p.get_pointer(0) - setup_using_file(config_path) + setup_using_file(options[:config_path]) connect From 20adc5873196407733f33e647ba02aec1389a6ef Mon Sep 17 00:00:00 2001 From: Samuel Sieg Date: Fri, 3 Jun 2016 16:57:56 +0200 Subject: [PATCH 2/2] Don't change the api --- lib/ceph-ruby/cluster.rb | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/ceph-ruby/cluster.rb b/lib/ceph-ruby/cluster.rb index 99ab09c..e0e0cc3 100644 --- a/lib/ceph-ruby/cluster.rb +++ b/lib/ceph-ruby/cluster.rb @@ -2,9 +2,7 @@ module CephRuby class Cluster attr_accessor :handle - def initialize(options = {}) - options[:config_path] ||= "/etc/ceph/ceph.conf" - + def initialize(config_path = "/etc/ceph/ceph.conf", options = {}) log("init lib rados #{Lib::Rados.version_string}, lib rbd #{Lib::Rbd.version_string}") handle_p = FFI::MemoryPointer.new(:pointer) @@ -12,7 +10,7 @@ def initialize(options = {}) raise SystemCallError.new("open of cluster failed", -ret) if ret < 0 self.handle = handle_p.get_pointer(0) - setup_using_file(options[:config_path]) + setup_using_file(config_path) connect