From: Alwin Antreich Date: Thu, 5 Apr 2018 08:41:36 +0000 (+0200) Subject: allow to specify the userid with rados_create X-Git-Url: https://git.proxmox.com/?p=librados2-perl.git;a=commitdiff_plain;h=c0a9abbddf885d4bb83887220f4b123febaceaf9 allow to specify the userid with rados_create This allows to connect to a cluster with a different user, besides admin Signed-off-by: Alwin Antreich --- diff --git a/PVE/RADOS.pm b/PVE/RADOS.pm index 2ed92b7..d53f655 100644 --- a/PVE/RADOS.pm +++ b/PVE/RADOS.pm @@ -14,6 +14,7 @@ require Exporter; my $rados_default_timeout = 5; my $ceph_default_conf = '/etc/ceph/ceph.conf'; +my $ceph_default_user = 'admin'; our @ISA = qw(Exporter); @@ -162,7 +163,8 @@ sub new { my $conn; eval { - $conn = pve_rados_create() || + my $ceph_user = delete $params{userid} || $ceph_default_user; + $conn = pve_rados_create($ceph_user) || die "unable to create RADOS object\n"; if (defined($params{ceph_conf}) && (!-e $params{ceph_conf})) { diff --git a/RADOS.xs b/RADOS.xs index ad3cf96..f3f5516 100644 --- a/RADOS.xs +++ b/RADOS.xs @@ -14,12 +14,19 @@ MODULE = PVE::RADOS PACKAGE = PVE::RADOS rados_t -pve_rados_create() -PROTOTYPE: +pve_rados_create(user) +SV *user +PROTOTYPE: $ CODE: { + char *u = NULL; rados_t clu = NULL; - int ret = rados_create(&clu, NULL); + + if (SvOK(user)) { + u = SvPV_nolen(user); + } + + int ret = rados_create(&clu, u); if (ret == 0) RETVAL = clu;