|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include <rados/librados.h>
|
|
|
|
int main (int argc, const char **argv)
|
|
{
|
|
|
|
rados_t cluster;
|
|
int err;
|
|
err = rados_create(&cluster, "admin");
|
|
|
|
if (err < 0) {
|
|
fprintf(stderr, "%s: Couldn't create the cluster handle! %s\n", argv[0], strerror(-err));
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
err = rados_conf_read_file(cluster, "/etc/ceph/ceph.conf");
|
|
if (err < 0) {
|
|
fprintf(stderr, "%s: cannot read config file: %s\n", argv[0], strerror(-err));
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
err = rados_connect(cluster);
|
|
if (err < 0) {
|
|
fprintf(stderr, "%s: cannot connect to cluster: %s\n", argv[0], strerror(-err));
|
|
exit(EXIT_FAILURE);
|
|
}
|
|
|
|
char *outbuf = NULL;
|
|
size_t outbuf_size = 0;
|
|
char *outs = NULL;
|
|
size_t outs_size = 0;
|
|
|
|
const char * cmd = "{ \"prefix\":\"osd reweight\", \"id\":0, \"weight\": 0.0 }";
|
|
err = rados_mon_command(cluster, &cmd, 1, NULL, 0, &outbuf, &outbuf_size, &outs, &outs_size);
|
|
if (err < 0) {
|
|
fprintf(stderr, "mon_command error: %s\nstatus: %.*s\n", strerror(-err), outs_size, outs);
|
|
} else {
|
|
fprintf(stdout, "cmd successfully exectued\n");
|
|
}
|
|
|
|
cmd = "{ \"prefix\":\"osd reweight\", \"id\":0, \"weight\": 0 }";
|
|
err = rados_mon_command(cluster, &cmd, 1, NULL, 0, &outbuf, &outbuf_size, &outs, &outs_size);
|
|
if (err < 0) {
|
|
fprintf(stderr, "mon_command error: %s\nstatus: %.*s\n", strerror(-err), outs_size, outs);
|
|
} else {
|
|
fprintf(stdout, "cmd successfully exectued\n");
|
|
}
|
|
}
|