]>
git.proxmox.com Git - pve-storage.git/blob - PVE/Storage/CephTools.pm
1 package PVE
::Storage
::CephTools
;
6 use PVE
::Tools
qw(run_command);
9 my ($list_text, $separator) = @_;
11 my @monhostlist = PVE
::Tools
::split_list
($list_text);
12 return join($separator, map {
13 my ($host, $port) = PVE
::Tools
::parse_host_and_port
($_);
14 $port = defined($port) ?
":$port" : '';
15 $host = "[$host]" if Net
::IP
::ip_is_ipv6
($host);
20 sub ceph_connect_option
{
21 my ($scfg, $storeid, %options) = @_;
24 my $ceph_storeid_conf = "/etc/pve/priv/ceph/${storeid}.conf";
25 my $pveceph_config = '/etc/pve/ceph.conf';
26 my $keyfile = "/etc/pve/priv/ceph/${storeid}.keyring";
27 $keyfile = "/etc/pve/priv/ceph/${storeid}.secret" if ($scfg->{type
} eq 'cephfs');
28 my $pveceph_managed = !defined($scfg->{monhost
});
30 $cmd_option->{ceph_conf
} = $pveceph_config if $pveceph_managed;
32 if (-e
$ceph_storeid_conf) {
33 if ($pveceph_managed) {
34 warn "ignoring custom ceph config for storage '$storeid', 'monhost' is not set (assuming pveceph managed cluster)!\n";
36 $cmd_option->{ceph_conf
} = $ceph_storeid_conf;
40 $cmd_option->{keyring
} = $keyfile if (-e
$keyfile);
41 $cmd_option->{auth_supported
} = (defined $cmd_option->{keyring
}) ?
'cephx' : 'none';
42 $cmd_option->{userid
} = $scfg->{username
} ?
$scfg->{username
} : 'admin';
43 $cmd_option->{mon_host
} = hostlist
($scfg->{monhost
}, ',') if (defined($scfg->{monhost
}));
46 foreach my $k (keys %options) {
47 $cmd_option->{$k} = $options{$k};