[pve-devel] [PATCH manager 2/5] add ceph flags api call
Dominik Csapak
d.csapak at proxmox.com
Tue Nov 29 15:53:50 CET 2016
here we can set/unset a single ceph flag, like noout
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
PVE/API2/Ceph.pm | 63 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 63 insertions(+)
diff --git a/PVE/API2/Ceph.pm b/PVE/API2/Ceph.pm
index 3dd1439..eaca08d 100644
--- a/PVE/API2/Ceph.pm
+++ b/PVE/API2/Ceph.pm
@@ -535,6 +535,7 @@ __PACKAGE__->register_method ({
{ name => 'config' },
{ name => 'log' },
{ name => 'disks' },
+ { name => 'flags' },
];
return $result;
@@ -1312,6 +1313,68 @@ __PACKAGE__->register_method ({
}});
__PACKAGE__->register_method ({
+ name => 'flags',
+ path => 'flags',
+ method => 'PUT',
+ description => "Set/unset a ceph flag",
+ proxyto => 'node',
+ protected => 1,
+ permissions => {
+ check => ['perm', '/', [ 'Sys.Modify' ]],
+ },
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ flag => {
+ description => 'The ceph flag to set/unset',
+ type => 'string',
+ enum => [ 'full', 'pause', 'noup', 'nodown', 'noout', 'noin', 'nobackfill', 'norebalance', 'norecover', 'noscrub', 'nodeep-scrub', 'notieragent'],
+ },
+ set => {
+ description => 'true if you want to set the flag, false to unset it',
+ type => 'boolean',
+ optional => 1,
+ default => 1,
+ },
+ unset => {
+ description => 'true if you want to unset the flag, false to set it',
+ type => 'boolean',
+ optional => 1,
+ default => 0,
+ }
+ },
+ },
+ returns => { type => 'null' },
+ code => sub {
+ my ($param) = @_;
+
+ PVE::CephTools::check_ceph_inited();
+
+ my $pve_ckeyring_path = PVE::CephTools::get_config('pve_ckeyring_path');
+
+ die "not fully configured - missing '$pve_ckeyring_path'\n"
+ if ! -f $pve_ckeyring_path;
+
+ my $set = $param->{set} // !$param->{unset};
+ my $rados = PVE::RADOS->new();
+
+ if ($set) {
+ $rados->mon_command({
+ prefix => "osd set",
+ key => $param->{flag},
+ });
+ } else {
+ $rados->mon_command({
+ prefix => "osd unset",
+ key => $param->{flag},
+ });
+ }
+
+ return undef;
+ }});
+
+__PACKAGE__->register_method ({
name => 'destroypool',
path => 'pools/{name}',
method => 'DELETE',
--
2.1.4
More information about the pve-devel
mailing list