d83c0c0756bf2a000d1c026a62885e9d8702be60
15 use PVE
::RPCEnvironment
;
17 use PVE
::Tools
qw(run_command);
18 use PVE
::JSONSchema
qw(get_standard_option);
23 use base
qw(PVE::CLIHandler);
25 $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
29 die "please run as root\n" if $> != 0;
31 PVE
::INotify
::inotify_init
();
33 my $rpcenv = PVE
::RPCEnvironment-
>init('cli');
35 $rpcenv->init_request();
36 $rpcenv->set_language($ENV{LANG
});
37 $rpcenv->set_user('root@pam');
41 my $status = PVE
::Tools
::upid_read_status
($upid);
42 exit($status eq 'OK' ?
0 : -1);
45 my $nodename = PVE
::INotify
::nodename
();
47 __PACKAGE__-
>register_method ({
51 description
=> "Destroy ceph related data and configuration files.",
53 additionalProperties
=> 0,
57 returns
=> { type
=> 'null' },
63 eval { $monstat = PVE
::API2
::Ceph
::ceph_mon_status
(1); };
66 die "detected running ceph services- unable to purge data\n"
69 # fixme: this is dangerous - should we really support this function?
70 PVE
::API2
::Ceph
::purge_all_ceph_files
();
75 __PACKAGE__-
>register_method ({
79 description
=> "Install ceph related packages.",
81 additionalProperties
=> 0,
85 returns
=> { type
=> 'null' },
89 my $cephver = 'emperor';
91 local $ENV{DEBIAN_FRONTEND
} = 'noninteractive';
93 my $keyurl = "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc";
95 print "download and import ceph reqpository keys\n";
96 system("wget -q -O- '$keyurl'| apt-key add - 2>&1 >/dev/null") == 0 ||
97 die "unable to download ceph release key\n";
100 my $source = "deb http://ceph.com/debian-$cephver wheezy main\n";
102 PVE
::Tools
::file_set_contents
("/etc/apt/sources.list.d/ceph.list", $source);
104 print "update available package list\n";
105 eval { run_command
(['apt-get', '-q', 'update'], outfunc
=> sub {}, errfunc
=> sub {}); };
107 run_command
(['apt-get', '-q', '--assume-yes', '--no-install-recommends',
108 '-o', 'Dpkg::Options::=--force-confnew',
110 'ceph', 'ceph-common', 'gdisk']);
116 init
=> [ 'PVE::API2::Ceph', 'init', [], { node
=> $nodename } ],
117 lspools
=> [ 'PVE::API2::Ceph', 'lspools', [], { node
=> $nodename }, sub {
120 printf("%-20s %10s %10s %20s\n", "Name", "size", "pg_num", "used");
121 foreach my $p (sort {$a->{pool_name
} cmp $b->{pool_name
}} @$res) {
122 printf("%-20s %10d %10d %20d\n", $p->{pool_name
}, $p->{size
}, $p->{pg_num
}, $p->{bytes_used
});
125 createpool
=> [ 'PVE::API2::Ceph', 'createpool', ['name'], { node
=> $nodename }],
126 destroypool
=> [ 'PVE::API2::Ceph', 'destroypool', ['name'], { node
=> $nodename } ],
127 createosd
=> [ 'PVE::API2::CephOSD', 'createosd', ['dev'], { node
=> $nodename }, $upid_exit],
128 destroyosd
=> [ 'PVE::API2::CephOSD', 'destroyosd', ['osdid'], { node
=> $nodename }, $upid_exit],
129 createmon
=> [ 'PVE::API2::Ceph', 'createmon', [], { node
=> $nodename }, $upid_exit],
130 destroymon
=> [ 'PVE::API2::Ceph', 'destroymon', ['monid'], { node
=> $nodename }, $upid_exit],
131 start
=> [ 'PVE::API2::Ceph', 'start', ['service'], { node
=> $nodename }, $upid_exit],
132 stop
=> [ 'PVE::API2::Ceph', 'stop', ['service'], { node
=> $nodename }, $upid_exit],
133 install
=> [ __PACKAGE__
, 'install', [] ],
134 purge
=> [ __PACKAGE__
, 'purge', [] ],
135 status
=> [ 'PVE::API2::Ceph', 'status', [], { node
=> $nodename }, sub {
137 my $json = JSON-
>new->allow_nonref;
138 print $json->pretty->encode($res) . "\n";
144 PVE
::CLIHandler
::handle_cmd
($cmddef, "pveceph", $cmd, \
@ARGV, undef, $0);
152 pveceph - tool to manage ceph services on pve nodes
160 Tool to manage ceph services on pve nodes.
162 =include pve_copyright