ceph tools: factor out frequent keyring and config init check

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Thomas Lamprecht 2019-07-23 07:48:45 +02:00
parent e1ed931dd9
commit 7ef69f338e
3 changed files with 16 additions and 29 deletions

View File

@ -725,12 +725,7 @@ __PACKAGE__->register_method ({
my ($param) = @_;
PVE::Cluster::check_cfs_quorum();
PVE::Ceph::Tools::check_ceph_inited();
my $pve_ckeyring_path = PVE::Ceph::Tools::get_config('pve_ckeyring_path');
die "not fully configured - missing '$pve_ckeyring_path'\n"
if ! -f $pve_ckeyring_path;
PVE::Ceph::Tools::check_ceph_configured();
my $pool = $param->{name};
my $rpcenv = PVE::RPCEnvironment::get();
@ -786,12 +781,7 @@ __PACKAGE__->register_method ({
code => sub {
my ($param) = @_;
PVE::Ceph::Tools::check_ceph_inited();
my $pve_ckeyring_path = PVE::Ceph::Tools::get_config('pve_ckeyring_path');
die "not fully configured - missing '$pve_ckeyring_path'\n"
if ! -f $pve_ckeyring_path;
PVE::Ceph::Tools::check_ceph_configured();
my $rados = PVE::RADOS->new();
@ -825,12 +815,7 @@ __PACKAGE__->register_method ({
code => sub {
my ($param) = @_;
PVE::Ceph::Tools::check_ceph_inited();
my $pve_ckeyring_path = PVE::Ceph::Tools::get_config('pve_ckeyring_path');
die "not fully configured - missing '$pve_ckeyring_path'\n"
if ! -f $pve_ckeyring_path;
PVE::Ceph::Tools::check_ceph_configured();
my $set = $param->{set} // !$param->{unset};
my $rados = PVE::RADOS->new();
@ -868,12 +853,7 @@ __PACKAGE__->register_method ({
code => sub {
my ($param) = @_;
PVE::Ceph::Tools::check_ceph_inited();
my $pve_ckeyring_path = PVE::Ceph::Tools::get_config('pve_ckeyring_path');
die "not fully configured - missing '$pve_ckeyring_path'\n"
if ! -f $pve_ckeyring_path;
PVE::Ceph::Tools::check_ceph_configured();
my $set = $param->{set} // !$param->{unset};
my $rados = PVE::RADOS->new();

View File

@ -121,11 +121,7 @@ __PACKAGE__->register_method ({
code => sub {
my ($param) = @_;
PVE::Ceph::Tools::check_ceph_inited();
my $pve_ckeyring_path = PVE::Ceph::Tools::get_config('pve_ckeyring_path');
die "Ceph is not fully configured - missing '$pve_ckeyring_path'\n"
if ! -f $pve_ckeyring_path;
PVE::Ceph::Tools::check_ceph_configured();
my $fs_name = $param->{name} // 'cephfs';
my $pg_num = $param->{pg_num} // 128;

View File

@ -109,6 +109,17 @@ sub check_ceph_installed {
return 1;
}
sub check_ceph_configured {
check_ceph_inited();
die "ceph not fully configured - missing '$pve_ckeyring_path'\n"
if ! -f $pve_ckeyring_path;
return 1;
}
sub check_ceph_inited {
my ($noerr) = @_;