]>
git.proxmox.com Git - librados2-perl.git/blob - PVE/RADOS.pm
11 our @ISA = qw(Exporter);
13 # Items to export into callers namespace by default. Note: do not export
14 # names by default without a very good reason. Use EXPORT_OK instead.
15 # Do not simply export all your public functions/methods/constants.
17 # This allows declaration use PVE::RADOS ':all';
18 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
20 our %EXPORT_TAGS = ( 'all' => [ qw(
24 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
33 XSLoader
::load
('PVE::RADOS', $VERSION);
36 my ($class, %params) = @_;
38 my $conn = pve_rados_create
() ||
39 die "unable to create RADOS object\n";
41 my $timeout = delete $params{timeout
} || 5;
43 pve_rados_conf_set
($conn, 'client_mount_timeout', $timeout);
45 foreach my $k (keys %params) {
46 pve_rados_conf_set
($conn, $k, $params{$k});
49 pve_rados_connect
($conn);
51 my $self = bless { conn
=> $conn };
59 pve_rados_shutdown
($self->{conn
});
65 return pve_rados_cluster_stat
($self->{conn
});
68 # example: { prefix => 'mon dump', format => 'json' }
70 my ($self, $cmd) = @_;
72 $cmd->{format
} = 'json' if !$cmd->{format
};
74 my $json = encode_json
($cmd);
75 my $raw = pve_rados_mon_command
($self->{conn
}, [ $json ]);
76 if ($cmd->{format
} && $cmd->{format
} eq 'json') {
77 return decode_json
($raw);
88 PVE::RADOS - Perl bindings for librados
94 my $rados = PVE::RADOS::new();
95 my $stat = $rados->cluster_stat();
96 my $res = $rados->mon_command({ prefix => 'mon dump', format => 'json' });
100 Perl bindings for librados.
108 Dietmar Maurer, E<lt>dietmar@proxmox.com<gt>