]> git.proxmox.com Git - pve-manager.git/blobdiff - bin/pveceph
api: fixup missing trailing commas
[pve-manager.git] / bin / pveceph
index d138ef95037103fae710d7c7b20f9395c13ac2c1..b7193f7f2a8d7ff93573df1fa2fe26fdaca31d68 100755 (executable)
@@ -1,146 +1,8 @@
-#!/usr/bin/perl
+#!/usr/bin/perl -T
 
 use strict;
 use warnings;
-use Getopt::Long;
-use Fcntl ':flock';
-use File::Path;
-use IO::File;
-use JSON;
-use Data::Dumper;
 
-use PVE::SafeSyslog;
-use PVE::Cluster;
-use PVE::INotify;
-use PVE::RPCEnvironment;
-use PVE::Storage;
-use PVE::Tools qw(run_command);
-use PVE::JSONSchema qw(get_standard_option);
-use PVE::API2::Ceph;
+use PVE::CLI::pveceph;
 
-use PVE::CLIHandler;
-
-use base qw(PVE::CLIHandler);
-
-$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
-
-initlog ('pveceph');
-
-die "please run as root\n" if $> != 0;
-
-PVE::INotify::inotify_init();
-
-my $rpcenv = PVE::RPCEnvironment->init('cli');
-
-$rpcenv->init_request();
-$rpcenv->set_language($ENV{LANG});
-$rpcenv->set_user('root@pam');
-
-my $nodename = PVE::INotify::nodename();
-
-__PACKAGE__->register_method ({
-    name => 'purge',
-    path => 'purge',
-    method => 'POST',
-    description => "Destroy ceph related data and configuration files.",
-    parameters => {
-       additionalProperties => 0,
-       properties => {
-       },
-    },
-    returns => { type => 'null' },
-    code => sub {
-       my ($param) = @_;
-
-       my $monstat;
-
-       eval { $monstat = PVE::API2::Ceph::ceph_mon_status(1); };
-       my $err = $@;
-
-       die "detected running ceph services- unable to purge data\n" 
-           if !$err;
-
-       # fixme: this is dangerous - should we really support this function?
-       PVE::API2::Ceph::purge_all_ceph_files();
-
-       return undef;
-    }});
-
-__PACKAGE__->register_method ({
-    name => 'install',
-    path => 'install',
-    method => 'POST',
-    description => "Install ceph related packages.",
-    parameters => {
-       additionalProperties => 0,
-       properties => {
-       },
-    },
-    returns => { type => 'null' },
-    code => sub {
-       my ($param) = @_;
-
-       my $cephver = 'dumpling';
-
-       local $ENV{DEBIAN_FRONTEND} = 'noninteractive';
-
-       my $keyurl = "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc";
-
-       print "download and import ceph reqpository keys\n";
-       system("wget -q -O- '$keyurl'| apt-key add - 2>&1 >/dev/null") == 0 ||
-           die "unable to download ceph release key\n";
-
-
-       my $source = "deb http://ceph.com/debian-$cephver wheezy main\n";
-
-       PVE::Tools::file_set_contents("/etc/apt/sources.list.d/ceph.list", $source);
-
-       print "update available package list\n";
-       eval { run_command(['apt-get', '-q', 'update'], outfunc => sub {}, errfunc => sub {}); };
-
-       run_command(['apt-get', '-q', '--assume-yes', '--no-install-recommends',
-                    '-o', 'Dpkg::Options::=--force-confnew',
-                    'install', '--',
-                    'ceph', 'ceph-common', 'gdisk']);
-
-       return undef;
-    }});
-
-my $cmddef = {
-    init => [ 'PVE::API2::Ceph', 'init', [] ],
-    createosd => [ 'PVE::API2::Ceph', 'createosd', ['dev'] ],
-    destroyosd => [ 'PVE::API2::Ceph', 'destroyosd', ['osdid'] ],
-    createmon => [ 'PVE::API2::Ceph', 'createmon', [] ],
-    destroymon => [ 'PVE::API2::Ceph', 'destroymon', ['monid'] ],
-    start => [ 'PVE::API2::Ceph', 'start', [] ],
-    stop => [ 'PVE::API2::Ceph', 'stop', [] ],
-    install => [ __PACKAGE__, 'install', [] ],
-    purge => [  __PACKAGE__, 'purge', [] ],
-    status => [ 'PVE::API2::Ceph', 'status', [], undef, sub {
-       my $res = shift;
-       my $json = JSON->new->allow_nonref;
-       print $json->pretty->encode($res) . "\n";
-    }],
-};
-
-my $cmd = shift;
-
-PVE::CLIHandler::handle_cmd($cmddef, "pveceph", $cmd, \@ARGV, undef, $0);
-
-exit 0;
-
-__END__
-
-=head1 NAME
-
-pveceph - tool to manage ceph services on pve nodes
-
-=head1 SYNOPSIS
-
-=include synopsis
-
-=head1 DESCRIPTION
-
-Tool to manage ceph services on pve nodes.
-
-=include pve_copyright
+PVE::CLI::pveceph->run_cli_handler();