Commit e2ddeff9 authored by Dietmar Maurer's avatar Dietmar Maurer

Merge remote-tracking branch 'origin/pve-ceph'

parents 3acbeafa ad3fc0d6
This diff is collapsed.
include ../../defines.mk
PERLSOURCE = \
Ceph.pm \
APT.pm \
Subscription.pm \
VZDump.pm \
......
......@@ -32,6 +32,7 @@ use PVE::API2::Qemu;
use PVE::API2::OpenVZ;
use PVE::API2::VZDump;
use PVE::API2::APT;
use PVE::API2::Ceph;
use JSON;
use base qw(PVE::RESTHandler);
......@@ -41,6 +42,11 @@ __PACKAGE__->register_method ({
path => 'qemu',
});
__PACKAGE__->register_method ({
subclass => "PVE::API2::Ceph",
path => 'ceph',
});
__PACKAGE__->register_method ({
subclass => "PVE::API2::OpenVZ",
path => 'openvz',
......@@ -110,6 +116,7 @@ __PACKAGE__->register_method ({
my ($param) = @_;
my $result = [
{ name => 'ceph' },
{ name => 'apt' },
{ name => 'version' },
{ name => 'syslog' },
......
......@@ -3,6 +3,7 @@ include ../defines.mk
SUBDIRS = init.d cron ocf test
SCRIPTS = \
pveceph \
vzdump \
vzrestore \
pvestatd \
......@@ -20,6 +21,7 @@ SCRIPTS = \
pveperf
MANS = \
pveceph.1 \
pvectl.1 \
vzdump.1 \
vzrestore.1 \
......@@ -44,6 +46,9 @@ all: ${MANS} pvemailforward
pvectl.1.pod: pvectl
perl -I.. ./pvectl printmanpod >$@
pveceph.1.pod: pveceph
perl -I.. ./pveceph printmanpod >$@
vzdump.1.pod: vzdump
perl -I.. -T ./vzdump printmanpod >$@
......
#!/usr/bin/perl
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::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 $upid_exit = sub {
my $upid = shift;
my $status = PVE::Tools::upid_read_status($upid);
exit($status eq 'OK' ? 0 : -1);
};
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 = 'emperor';
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', [], { node => $nodename } ],
lspools => [ 'PVE::API2::Ceph', 'lspools', [], { node => $nodename }, sub {
my $res = shift;
printf("%-20s %10s %10s\n", "Name", "size", "pg_num");
foreach my $p (sort {$a->{pool_name} cmp $b->{pool_name}} @$res) {
printf("%-20s %10d %10d\n", $p->{pool_name}, $p->{size}, $p->{pg_num});
}
}],
createpool => [ 'PVE::API2::Ceph', 'createpool', ['name'], { node => $nodename }],
destroypool => [ 'PVE::API2::Ceph', 'destroypool', ['name'], { node => $nodename } ],
createosd => [ 'PVE::API2::Ceph', 'createosd', ['dev'], { node => $nodename }, $upid_exit],
destroyosd => [ 'PVE::API2::Ceph', 'destroyosd', ['osdid'], { node => $nodename }, $upid_exit],
createmon => [ 'PVE::API2::Ceph', 'createmon', [], { node => $nodename }, $upid_exit],
destroymon => [ 'PVE::API2::Ceph', 'destroymon', ['monid'], { node => $nodename }, $upid_exit],
start => [ 'PVE::API2::Ceph', 'start', ['service'], { node => $nodename }, $upid_exit],
stop => [ 'PVE::API2::Ceph', 'stop', ['service'], { node => $nodename }, $upid_exit],
install => [ __PACKAGE__, 'install', [] ],
purge => [ __PACKAGE__, 'purge', [] ],
status => [ 'PVE::API2::Ceph', 'status', [], { node => $nodename }, 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
......@@ -3,7 +3,7 @@ Version: @VERSION@-@PACKAGERELEASE@
Section: admin
Priority: optional
Architecture: amd64
Depends: perl (>= 5.10.0-19), libtimedate-perl, libauthen-pam-perl, libintl-perl, rsync, libjson-perl, liblockfile-simple-perl, vncterm, qemu-server (>= 1.1-1), libwww-perl (>= 6.04-1), libnet-http-perl (>= 6.06-1), libhttp-daemon-perl, wget, libnet-dns-perl, vlan, ifenslave-2.6 (>= 1.1.0-10), liblinux-inotify2-perl, debconf (>= 0.5) | debconf-2.0, netcat-traditional, pve-cluster (>= 1.0-29), libpve-common-perl, libpve-storage-perl, libterm-readline-gnu-perl, libpve-access-control (>= 3.0-2), libio-socket-ssl-perl, libfilesys-df-perl, libfile-readbackwards-perl, libfile-sync-perl, redhat-cluster-pve, resource-agents-pve, fence-agents-pve, cstream, postfix | mail-transport-agent, libxml-parser-perl, lzop, dtach, libanyevent-perl, liburi-perl, logrotate, libanyevent-http-perl, apt-transport-https, libapt-pkg-perl, libcrypt-ssleay-perl, liblwp-protocol-https-perl, spiceterm
Depends: perl (>= 5.10.0-19), libtimedate-perl, libauthen-pam-perl, libintl-perl, rsync, libjson-perl, liblockfile-simple-perl, vncterm, qemu-server (>= 1.1-1), libwww-perl (>= 6.04-1), libnet-http-perl (>= 6.06-1), libhttp-daemon-perl, wget, libnet-dns-perl, vlan, ifenslave-2.6 (>= 1.1.0-10), liblinux-inotify2-perl, debconf (>= 0.5) | debconf-2.0, netcat-traditional, pve-cluster (>= 1.0-29), libpve-common-perl, libpve-storage-perl, libterm-readline-gnu-perl, libpve-access-control (>= 3.0-2), libio-socket-ssl-perl, libfilesys-df-perl, libfile-readbackwards-perl, libfile-sync-perl, redhat-cluster-pve, resource-agents-pve, fence-agents-pve, cstream, postfix | mail-transport-agent, libxml-parser-perl, lzop, dtach, libanyevent-perl, liburi-perl, logrotate, libanyevent-http-perl, apt-transport-https, libapt-pkg-perl, libcrypt-ssleay-perl, liblwp-protocol-https-perl, spiceterm, libuuid-perl, hdparm
Conflicts: netcat-openbsd, vzdump
Replaces: vzdump
Provides: vzdump
......
......@@ -86,6 +86,7 @@ JSSRC= \
node/Tasks.js \
node/Subscription.js \
node/APT.js \
node/Ceph.js \
node/Config.js \
qemu/StatusView.js \
window/Migrate.js \
......
......@@ -553,6 +553,10 @@ Ext.define('PVE.Utils', { statics: {
srvstop: ['SRV', gettext('Stop') ],
srvrestart: ['SRV', gettext('Restart') ],
srvreload: ['SRV', gettext('Reload') ],
cephcreatemon: ['Ceph Monitor', gettext('Create') ],
cephdestroymon: ['Ceph Monitor', gettext('Destroy') ],
cephcreateosd: ['Ceph OSD', gettext('Create') ],
cephdestroyosd: ['Ceph OSD', gettext('Destroy') ],
imgcopy: ['', gettext('Copy data') ],
imgdel: ['', gettext('Erase data') ],
download: ['', gettext('Download') ],
......
This diff is collapsed.
......@@ -147,6 +147,13 @@ Ext.define('PVE.node.Config', {
xtype: 'pveNodeAPT',
nodename: nodename
}]);
me.items.push([{
title: 'Ceph',
itemId: 'ceph',
xtype: 'pveNodeCeph',
phstateid: me.hstateid,
nodename: nodename
}]);
}
me.callParent();
......
......@@ -11,10 +11,15 @@ Ext.define('PVE.panel.Config', {
var activeTab;
var hsregex = /^([^\-\s]+)(-\S+)?$/;
if (stateid) {
var state = sp.get(stateid);
if (state && state.value) {
activeTab = state.value;
var res = hsregex.exec(state.value);
if (res && res[1]) {
activeTab = res[1];
}
}
}
......@@ -70,13 +75,14 @@ Ext.define('PVE.panel.Config', {
},
tabchange: function(tp, newcard, oldcard) {
var ntab = newcard.itemId;
// Note: '' is alias for first tab.
// First tab can be 'search' or something else
if (newcard.itemId === items[0].itemId) {
ntab = '';
}
var state = { value: ntab };
if (stateid) {
if (stateid && !newcard.phstateid) {
sp.set(stateid, state);
}
}
......@@ -91,10 +97,11 @@ Ext.define('PVE.panel.Config', {
me.callParent();
var statechange = function(sp, key, state) {
if (stateid && key === stateid) {
if (stateid && (key === stateid) && state) {
var atab = tab.getActiveTab().itemId;
var ntab = state.value || items[0].itemId;
if (state && ntab && (atab != ntab)) {
var res = hsregex.exec(state.value);
var ntab = (res && res[1]) ? res[1] : items[0].itemId;
if (ntab && (atab != ntab)) {
tab.setActiveTab(ntab);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment