use Data::Dumper;
use LWP::UserAgent;
+use Proxmox::RS::Subscription;
+
use PVE::SafeSyslog;
use PVE::Cluster;
use PVE::INotify;
return undef;
}});
+my sub has_valid_subscription {
+ my $info = eval { Proxmox::RS::Subscription::read_subscription('/etc/subscription') } // {};
+ warn "couldn't check subscription info - $@" if $@;
+ return $info->{status} && $info->{status} eq 'active'; # age check?
+}
+
my $supported_ceph_versions = ['quincy'];
my $default_ceph_version = 'quincy';
description => "Ceph version to install.",
optional => 1,
},
- 'allow-experimental' => {
- type => 'boolean',
- default => 0,
+ repository => {
+ type => 'string',
+ enum => ['enterprise', 'no-subscription', 'test'],
+ default => 'enterprise',
+ description => "Ceph repository to use.",
optional => 1,
- description => "Allow experimental versions. Use with care!",
},
- 'test-repository' => {
+ 'allow-experimental' => {
type => 'boolean',
default => 0,
optional => 1,
- description => "Use the test, not the main repository. Use with care!",
+ description => "Allow experimental versions. Use with care!",
},
},
},
my $cephver = $param->{version} || $default_ceph_version;
- my $repo = $param->{'test-repository'} ? 'test' : 'main';
+ my $repo = $param->{'repository'} // 'enterprise';
+ my $enterprise_repo = $repo eq 'enterprise';
+ my $cdn = $enterprise_repo ? 'https://enterprise.proxmox.com' : 'http://download.proxmox.com';
+
+ if (has_valid_subscription()) {
+ warn "\nNOTE: The node has an active subscription but a non-production Ceph repository selected.\n\n"
+ if !$enterprise_repo;
+ } elsif ($enterprise_repo) {
+ warn "\nWARN: Enterprise repository selected, but no active subscription!\n\n";
+ } elsif ($repo eq 'no-subscription') {
+ warn "\nHINT: The no-subscription repository is not the best choice for production setups.\n"
+ ."Proxmox recommends using the enterprise repository with a valid subscription.\n";
+ } else {
+ warn "\nWARN: The test repository should only be used for test setups or after consulting"
+ ." the official Proxmox support!\n\n"
+ }
my $repolist;
if ($cephver eq 'quincy') {
- $repolist = "deb http://download.proxmox.com/debian/ceph-quincy bookworm $repo\n";
+ $repolist = "deb ${cdn}/debian/ceph-quincy bookworm $repo\n";
} else {
die "unsupported ceph version: $cephver";
}
my @ceph_packages = qw(
ceph
ceph-common
- ceph-mds
ceph-fuse
+ ceph-mds
+ ceph-volume
gdisk
nvme-cli
);
- # got split out with quincy and is required by PVE tooling, conditionally exclude it for older
- # FIXME: remove condition with PVE 8.0, i.e., once we only support quincy+ new installations
- if ($cephver ne 'octopus' and $cephver ne 'pacific') {
- push @ceph_packages, 'ceph-volume';
- }
-
print "start installation\n";
# this flag helps to determine when apt is actually done installing (vs. partial extracing)
return $rpcenv->fork_worker('cephdestroyfs', $fs_name, $user, $worker);
}});
+__PACKAGE__->register_method ({
+ name => 'osddetails',
+ path => 'osddetails',
+ method => 'GET',
+ description => "Get OSD details.",
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ osdid => {
+ description => "ID of the OSD",
+ type => 'string',
+ },
+ verbose => {
+ description => "Print verbose information, same as json-pretty output format.",
+ type => 'boolean',
+ default => 0,
+ optional => 1,
+ },
+ },
+ },
+ returns => { type => 'object' },
+ code => sub {
+ my ($param) = @_;
+ PVE::Ceph::Tools::check_ceph_inited();
+ my $res = PVE::API2::Ceph::OSD->osddetails({
+ osdid => $param->{osdid},
+ node => $param->{node},
+ });
+
+ for my $dev (@{ $res->{devices} }) {
+ $dev->{"lv-info"} = PVE::API2::Ceph::OSD->osdvolume({
+ osdid => $param->{osdid},
+ node => $param->{node},
+ type => $dev->{device},
+ });
+ }
+ $res->{verbose} = 1 if $param->{verbose};
+ return $res;
+ }});
+
+my $format_osddetails = sub {
+ my ($data, $schema, $options) = @_;
+ $options->{"output-format"} //= "text";
+
+ if ($data->{verbose}) {
+ $options->{"output-format"} = "json-pretty";
+ delete $data->{verbose};
+ }
+
+ if ($options->{"output-format"} eq "text") {
+ for my $dev (@{ $data->{devices} }) {
+ my $str = "Disk: $dev->{physical_device},"
+ ." Type: $dev->{type},"
+ ." LV Size: $dev->{'lv-info'}->{lv_size},"
+ ." LV Creation Time: $dev->{'lv-info'}->{creation_time}";
+
+ $data->{osd}->{$dev->{device}} = $str;
+ }
+ PVE::CLIFormatter::print_api_result($data->{osd}, $schema, undef, $options);
+ } else {
+ PVE::CLIFormatter::print_api_result($data, $schema, undef, $options);
+ }
+};
+
our $cmddef = {
init => [ 'PVE::API2::Ceph', 'init', [], { node => $nodename } ],
pool => {
osd => {
create => [ 'PVE::API2::Ceph::OSD', 'createosd', ['dev'], { node => $nodename }, $upid_exit],
destroy => [ 'PVE::API2::Ceph::OSD', 'destroyosd', ['osdid'], { node => $nodename }, $upid_exit],
+ details => [ __PACKAGE__, 'osddetails', ['osdid'], { node => $nodename }, $format_osddetails, $PVE::RESTHandler::standard_output_options],
},
createosd => { alias => 'osd create' },
destroyosd => { alias => 'osd destroy' },