]>
git.proxmox.com Git - pve-manager.git/blob - bin/pveceph
0def860be9d91a5f4cd4fd8a35a50231fd68e592
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 enum
=> ['dumpling', 'emperor', 'firefly'],
90 returns
=> { type
=> 'null' },
94 my $cephver = $param->{version
} || 'dumpling';
96 local $ENV{DEBIAN_FRONTEND
} = 'noninteractive';
98 my $keyurl = "https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc";
100 print "download and import ceph reqpository keys\n";
101 system("wget -q -O- '$keyurl'| apt-key add - 2>&1 >/dev/null") == 0 ||
102 die "unable to download ceph release key\n";
105 my $source = "deb http://ceph.com/debian-$cephver wheezy main\n";
107 PVE
::Tools
::file_set_contents
("/etc/apt/sources.list.d/ceph.list", $source);
109 print "update available package list\n";
110 eval { run_command
(['apt-get', '-q', 'update'], outfunc
=> sub {}, errfunc
=> sub {}); };
112 run_command
(['apt-get', '-q', '--assume-yes', '--no-install-recommends',
113 '-o', 'Dpkg::Options::=--force-confnew',
115 'ceph', 'ceph-common', 'gdisk']);
121 init
=> [ 'PVE::API2::Ceph', 'init', [], { node
=> $nodename } ],
122 lspools
=> [ 'PVE::API2::Ceph', 'lspools', [], { node
=> $nodename }, sub {
125 printf("%-20s %10s %10s %20s\n", "Name", "size", "pg_num", "used");
126 foreach my $p (sort {$a->{pool_name
} cmp $b->{pool_name
}} @$res) {
127 printf("%-20s %10d %10d %20d\n", $p->{pool_name
}, $p->{size
}, $p->{pg_num
}, $p->{bytes_used
});
130 createpool
=> [ 'PVE::API2::Ceph', 'createpool', ['name'], { node
=> $nodename }],
131 destroypool
=> [ 'PVE::API2::Ceph', 'destroypool', ['name'], { node
=> $nodename } ],
132 createosd
=> [ 'PVE::API2::CephOSD', 'createosd', ['dev'], { node
=> $nodename }, $upid_exit],
133 destroyosd
=> [ 'PVE::API2::CephOSD', 'destroyosd', ['osdid'], { node
=> $nodename }, $upid_exit],
134 createmon
=> [ 'PVE::API2::Ceph', 'createmon', [], { node
=> $nodename }, $upid_exit],
135 destroymon
=> [ 'PVE::API2::Ceph', 'destroymon', ['monid'], { node
=> $nodename }, $upid_exit],
136 start
=> [ 'PVE::API2::Ceph', 'start', ['service'], { node
=> $nodename }, $upid_exit],
137 stop
=> [ 'PVE::API2::Ceph', 'stop', ['service'], { node
=> $nodename }, $upid_exit],
138 install
=> [ __PACKAGE__
, 'install', [] ],
139 purge
=> [ __PACKAGE__
, 'purge', [] ],
140 status
=> [ 'PVE::API2::Ceph', 'status', [], { node
=> $nodename }, sub {
142 my $json = JSON-
>new->allow_nonref;
143 print $json->pretty->encode($res) . "\n";
149 PVE
::CLIHandler
::handle_cmd
($cmddef, "pveceph", $cmd, \
@ARGV, undef, $0);
157 pveceph - tool to manage ceph services on pve nodes
165 Tool to manage ceph services on pve nodes.
167 =include pve_copyright